def Static(self): OOF.Mesh.Apply_Field_Initializers_at_Time( mesh='microstructure:skeleton:mesh', time=1) OOF.Mesh.Solve( mesh='microstructure:skeleton:mesh', endtime=1.0) OOF.Mesh.Analyze.Direct_Output( mesh='microstructure:skeleton:mesh', time=latest, data=getOutput('Field:Value',field=Displacement), domain=SinglePoint(point=Point(1,0)), sampling=DiscretePointSampleSet(show_x=True,show_y=True), destination=OutputStream(filename='rotate.out',mode='w')) self.assert_(file_utils.compare_last( 'rotate.out', [1, 0, 1/sqrt(2.)-1, 1/sqrt(2.)])) OOF.Mesh.Analyze.Direct_Output( mesh='microstructure:skeleton:mesh', time=latest, data=getOutput('Field:Value',field=Displacement), domain=SinglePoint(point=Point(0,1)), sampling=DiscretePointSampleSet(show_x=True,show_y=True), destination=OutputStream(filename='rotate.out',mode='w')) self.assert_(file_utils.compare_last( 'rotate.out', [0, 1, -1/sqrt(2.), 1/sqrt(2.)-1])) file_utils.remove('rotate.out')
def Static(self): OOF.Mesh.Apply_Field_Initializers_at_Time( mesh='microstructure:skeleton:mesh', time=1) OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=1.0) OOF.Mesh.Analyze.Direct_Output( mesh='microstructure:skeleton:mesh', time=latest, data=getOutput('Field:Value', field=Displacement), domain=SinglePoint(point=Point(1, 0)), sampling=DiscretePointSampleSet(show_x=True, show_y=True), destination=OutputStream(filename='rotate.out', mode='w')) self.assert_( file_utils.compare_last('rotate.out', [1, 0, 1 / sqrt(2.) - 1, 1 / sqrt(2.)])) OOF.Mesh.Analyze.Direct_Output( mesh='microstructure:skeleton:mesh', time=latest, data=getOutput('Field:Value', field=Displacement), domain=SinglePoint(point=Point(0, 1)), sampling=DiscretePointSampleSet(show_x=True, show_y=True), destination=OutputStream(filename='rotate.out', mode='w')) self.assert_( file_utils.compare_last('rotate.out', [0, 1, -1 / sqrt(2.), 1 / sqrt(2.) - 1])) file_utils.remove('rotate.out')
def Small(self): OOF.Microstructure.New(name='microstructure', width=1.0, height=1.0, width_in_pixels=10, height_in_pixels=10) OOF.Material.New(name='material', material_type='bulk') # Reset the default parameter values for isotropic elasticity. # This shouldn't be necessary if earlier tests clean up after # themselves properly. OOF.Property.Parametrize.Mechanical.Elasticity.Isotropic( cijkl=IsotropicRank4TensorCij(c11=1.0, c12=0.5)) OOF.Material.Add_property(name='material', property='Mechanical:Elasticity:Isotropic') OOF.Material.Assign(material='material', microstructure='microstructure', pixels=all) OOF.Skeleton.New(name='skeleton', microstructure='microstructure', x_elements=1, y_elements=1, skeleton_geometry=QuadSkeleton( left_right_periodicity=False, top_bottom_periodicity=False)) OOF.Mesh.New(name='mesh', skeleton='microstructure:skeleton', element_types=['D2_2', 'T3_3', 'Q4_4']) OOF.Subproblem.Field.Define( subproblem='microstructure:skeleton:mesh:default', field=Displacement) OOF.Subproblem.Field.Activate( subproblem='microstructure:skeleton:mesh:default', field=Displacement) OOF.Subproblem.Equation.Activate( subproblem='microstructure:skeleton:mesh:default', equation=Force_Balance) OOF.Subproblem.Equation.Activate( subproblem='microstructure:skeleton:mesh:default', equation=Plane_Stress) OOF.Mesh.Boundary_Conditions.New( name='bc', mesh='microstructure:skeleton:mesh', condition=DirichletBC(field=Displacement, field_component='x', equation=Force_Balance, eqn_component='x', profile=ConstantProfile(value=0.0), boundary='left')) OOF.Mesh.Boundary_Conditions.New( name='bc<2>', mesh='microstructure:skeleton:mesh', condition=DirichletBC(field=Displacement, field_component='x', equation=Force_Balance, eqn_component='x', profile=ConstantProfile(value=0.1), boundary='right')) OOF.Mesh.Boundary_Conditions.New(name='bc<3>', mesh='microstructure:skeleton:mesh', condition=DirichletBC( field=Displacement, field_component='y', equation=Force_Balance, eqn_component='y', profile=ConstantProfile(value=0), boundary='left')) OOF.Mesh.Boundary_Conditions.New(name='bc<4>', mesh='microstructure:skeleton:mesh', condition=DirichletBC( field=Displacement, field_component='y', equation=Force_Balance, eqn_component='y', profile=ConstantProfile(value=0), boundary='right')) OOF.Mesh.Set_Field_Initializer(mesh='microstructure:skeleton:mesh', field=Displacement, initializer=ConstTwoVectorFieldInit( cx=0.0, cy=0.0)) OOF.Mesh.Set_Field_Initializer(mesh='microstructure:skeleton:mesh', field=Displacement_z, initializer=ConstThreeVectorFieldInit( cx=0.0, cy=0.0, cz=0.0)) OOF.Mesh.Apply_Field_Initializers_at_Time( mesh='microstructure:skeleton:mesh', time=0.0) OOF.Subproblem.Set_Solver( subproblem='microstructure:skeleton:mesh:default', solver_mode=AdvancedSolverMode( time_stepper=StaticDriver(), nonlinear_solver=Newton(relative_tolerance=1e-08, absolute_tolerance=1.e-13, maximum_iterations=200), symmetric_solver=ConjugateGradient( preconditioner=ILUPreconditioner(), tolerance=1e-13, max_iterations=1000), asymmetric_solver=BiConjugateGradient( preconditioner=ILUPreconditioner(), tolerance=1e-13, max_iterations=1000))) OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0) # Check that the average out-of-plane stress is 0.0. OOF.Mesh.Analyze.Average(mesh='microstructure:skeleton:mesh', time=latest, data=getOutput('Flux:Value', flux=Stress), domain=EntireMesh(), sampling=ElementSampleSet(order=automatic), destination=OutputStream(filename='test.dat', mode='w')) self.assert_( file_utils.compare_last('test.dat', (0.0, 0.075, 0.025, 0.0, 0.0, 0.0, 0.0))) file_utils.remove('test.dat') # Check that the out-of-plane displacement derivative at the # nodes is correct. u_zz should be -0.05 and the other # components should be 0.0. from ooflib.engine import mesh from ooflib.SWIG.engine import field msh = mesh.meshes["microstructure:skeleton:mesh"] msh_obj = msh.getObject() dispz = field.getField("Displacement_z") for node in msh_obj.funcnode_iterator(): vals = [dispz.value(msh_obj, node, i) for i in range(3)] self.assert_(vals[0] == 0.0 and vals[1] == 0 and math.fabs(vals[2] + 0.05) < 1.e-13)
def Small(self): OOF.Microstructure.New( name='microstructure', width=1.0, height=1.0, width_in_pixels=10, height_in_pixels=10) OOF.Material.New( name='material', material_type='bulk') # Reset the default parameter values for isotropic elasticity. # This shouldn't be necessary if earlier tests clean up after # themselves properly. OOF.Property.Parametrize.Mechanical.Elasticity.Isotropic( cijkl=IsotropicRank4TensorCij(c11=1.0,c12=0.5)) OOF.Material.Add_property( name='material', property='Mechanical:Elasticity:Isotropic') OOF.Material.Assign( material='material', microstructure='microstructure', pixels=all) OOF.Skeleton.New( name='skeleton', microstructure='microstructure', x_elements=1, y_elements=1, skeleton_geometry=QuadSkeleton( left_right_periodicity=False,top_bottom_periodicity=False)) OOF.Mesh.New( name='mesh', skeleton='microstructure:skeleton', element_types=['D2_2', 'T3_3', 'Q4_4']) OOF.Subproblem.Field.Define( subproblem='microstructure:skeleton:mesh:default', field=Displacement) OOF.Subproblem.Field.Activate( subproblem='microstructure:skeleton:mesh:default', field=Displacement) OOF.Subproblem.Equation.Activate( subproblem='microstructure:skeleton:mesh:default', equation=Force_Balance) OOF.Subproblem.Equation.Activate( subproblem='microstructure:skeleton:mesh:default', equation=Plane_Stress) OOF.Mesh.Boundary_Conditions.New( name='bc', mesh='microstructure:skeleton:mesh', condition=DirichletBC( field=Displacement,field_component='x', equation=Force_Balance,eqn_component='x', profile=ConstantProfile(value=0.0), boundary='left')) OOF.Mesh.Boundary_Conditions.New( name='bc<2>', mesh='microstructure:skeleton:mesh', condition=DirichletBC( field=Displacement,field_component='x', equation=Force_Balance,eqn_component='x', profile=ConstantProfile(value=0.1), boundary='right')) OOF.Mesh.Boundary_Conditions.New( name='bc<3>', mesh='microstructure:skeleton:mesh', condition=DirichletBC( field=Displacement,field_component='y', equation=Force_Balance,eqn_component='y', profile=ConstantProfile(value=0), boundary='left')) OOF.Mesh.Boundary_Conditions.New( name='bc<4>', mesh='microstructure:skeleton:mesh', condition=DirichletBC( field=Displacement,field_component='y', equation=Force_Balance,eqn_component='y', profile=ConstantProfile(value=0), boundary='right')) OOF.Mesh.Set_Field_Initializer( mesh='microstructure:skeleton:mesh', field=Displacement, initializer=ConstTwoVectorFieldInit(cx=0.0,cy=0.0)) OOF.Mesh.Set_Field_Initializer( mesh='microstructure:skeleton:mesh', field=Displacement_z, initializer=ConstThreeVectorFieldInit(cx=0.0,cy=0.0,cz=0.0)) OOF.Mesh.Apply_Field_Initializers_at_Time( mesh='microstructure:skeleton:mesh', time=0.0) OOF.Subproblem.Set_Solver( subproblem='microstructure:skeleton:mesh:default', solver_mode=AdvancedSolverMode( time_stepper=StaticDriver(), nonlinear_solver=Newton( relative_tolerance=1e-08, absolute_tolerance=1.e-13, maximum_iterations=200), symmetric_solver=ConjugateGradient( preconditioner=ILUPreconditioner(), tolerance=1e-13, max_iterations=1000), asymmetric_solver=BiConjugateGradient( preconditioner=ILUPreconditioner(), tolerance=1e-13,max_iterations=1000))) OOF.Mesh.Solve( mesh='microstructure:skeleton:mesh', endtime=0.0) # Check that the average out-of-plane stress is 0.0. OOF.Mesh.Analyze.Average( mesh='microstructure:skeleton:mesh', time=latest, data=getOutput('Flux:Value',flux=Stress), domain=EntireMesh(), sampling=ElementSampleSet(order=automatic), destination=OutputStream(filename='test.dat', mode='w')) self.assert_(file_utils.compare_last( 'test.dat', (0.0, 0.075, 0.025, 0.0, 0.0, 0.0, 0.0))) file_utils.remove('test.dat') # Check that the out-of-plane displacement derivative at the # nodes is correct. u_zz should be -0.05 and the other # components should be 0.0. from ooflib.engine import mesh from ooflib.SWIG.engine import field msh = mesh.meshes["microstructure:skeleton:mesh"] msh_obj = msh.getObject() dispz = field.getField("Displacement_z") for node in msh_obj.funcnode_iterator(): vals = [dispz.value(msh_obj, node, i) for i in range(3)] self.assert_(vals[0] == 0.0 and vals[1] == 0 and math.fabs(vals[2]+0.05) < 1.e-13)