Пример #1
0
    def BEnewton(self):
        OOF.Subproblem.Set_Solver(
            subproblem='microstructure:skeleton:mesh:default',
            solver_mode=AdvancedSolverMode(
                time_stepper=AdaptiveDriver(
                    initialstep=0.1,
                    tolerance=1.e-5,
                    minstep=1.e-05,
                    errorscaling=AbsoluteErrorScaling(),
                    stepper=TwoStep(singlestep=BackwardEuler())),
                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)))
        OOF.Mesh.Solve(
            mesh='microstructure:skeleton:mesh',
            endtime=1.0)

        self.assert_(file_utils.fp_file_compare(
                'test.dat',
                os.path.join('mesh_data', 'nldiff.dat'),
                tolerance=1.e-3,
                nlines=16))
        file_utils.remove('test.dat')
        self.assert_(file_utils.fp_file_compare(
                'tempout.dat',
                os.path.join('mesh_data', 'tempout.dat'),
                tolerance=1.e-3,
                nlines=910))
        file_utils.remove('tempout.dat')
Пример #2
0
 def Save(self):
     OOF.Microstructure.New(name="save_test",
                            width=2.5,
                            height=3.5,
                            depth=4.5,
                            width_in_pixels=10,
                            height_in_pixels=10,
                            depth_in_pixels=10)
     OOF.File.Save.Microstructure(filename="ms_save_test",
                                  mode="w",
                                  format="ascii",
                                  microstructure="save_test")
     self.assert_(
         file_utils.fp_file_compare("ms_save_test",
                                    os.path.join("ms_data", "saved_ms"),
                                    1.e-10))
     file_utils.remove("ms_save_test")
     OOF.File.Save.Microstructure(filename="ms_save_test",
                                  mode="w",
                                  format="binary",
                                  microstructure="save_test")
     self.assert_(
         file_utils.fp_file_compare(
             "ms_save_test", os.path.join("ms_data", "saved_ms_binary"),
             1.e-10))
     file_utils.remove("ms_save_test")
Пример #3
0
    def RK4(self):
        # I can't get this to work with any parameter values.
        OOF.Subproblem.Set_Solver(
            subproblem='microstructure:skeleton:mesh:default',
            solver_mode=AdvancedSolverMode(
                time_stepper=AdaptiveDriver(
                    initialstep=0.0001,
                    tolerance=1.e-3,
                    minstep=1.e-05,
                    errorscaling=AbsoluteErrorScaling(),
                    stepper=TwoStep(singlestep=RK4())),
                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)))
        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=1.0)

        self.assert_(
            file_utils.fp_file_compare('nlbulktemp.dat',
                                       os.path.join('mesh_data',
                                                    'nlbulktemp.dat'),
                                       tolerance=1.e-5))
        file_utils.remove('nlbulktemp.dat')
        self.assert_(
            file_utils.fp_file_compare('nlavgtoptemp.dat',
                                       os.path.join('mesh_data',
                                                    'nlavgtoptemp.dat'),
                                       tolerance=1.e-6))
        file_utils.remove('nlavgtoptemp.dat')
Пример #4
0
    def SS22(self):
        # Setting the AdaptiveDriver tolerance to 1.e-7 allows this
        # test to pass with the fp_file_compare tolerance set to
        # 1.e-6, but then the test runs really slowly.  Using
        # tolerances of 1.e-5 and 1.e-4, respectively, lets the test
        # run in a reasonable amount of time.
        OOF.Subproblem.Set_Solver(
            subproblem="microstructure:skeleton:mesh:default",
            solver_mode=AdvancedSolverMode(
                time_stepper=AdaptiveDriver(
                    initialstep=0.1,
                    tolerance=1.0e-5,
                    minstep=1.0e-6,
                    errorscaling=AbsoluteErrorScaling(),
                    stepper=TwoStep(singlestep=SS22(theta1=0.5, theta2=0.5)),
                ),
                nonlinear_solver=Newton(relative_tolerance=1e-08, absolute_tolerance=1.0e-13, maximum_iterations=200),
                symmetric_solver=ConjugateGradient(
                    preconditioner=ILUPreconditioner(), tolerance=1e-13, max_iterations=1000
                ),
            ),
        )
        OOF.Mesh.Solve(mesh="microstructure:skeleton:mesh", endtime=2.0)

        self.assert_(file_utils.fp_file_compare("test.dat", os.path.join("mesh_data", "nldiff.dat"), tolerance=1.0e-4))
        file_utils.remove("test.dat")
        self.assert_(
            file_utils.fp_file_compare("tempout.dat", os.path.join("mesh_data", "tempout.dat"), tolerance=1.0e-4)
        )
        file_utils.remove("tempout.dat")
Пример #5
0
    def SS22(self):
        # Setting the AdaptiveDriver tolerance to 1.e-7 allows this
        # test to pass with the fp_file_compare tolerance set to
        # 1.e-6, but then the test runs really slowly.  Using
        # tolerances of 1.e-5 and 1.e-4, respectively, lets the test
        # run in a reasonable amount of time.
        OOF.Subproblem.Set_Solver(
            subproblem='microstructure:skeleton:mesh:default',
            solver_mode=AdvancedSolverMode(
                time_stepper=AdaptiveDriver(
                    initialstep=0.1,
                    tolerance=1.e-5,
                    minstep=1.e-6,
                    errorscaling=AbsoluteErrorScaling(),
                    stepper=TwoStep(singlestep=SS22(theta1=0.5, theta2=0.5))),
                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)))
        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=2.0)

        self.assert_(
            file_utils.fp_file_compare('test.dat',
                                       os.path.join('mesh_data', 'nldiff.dat'),
                                       tolerance=1.e-4))
        file_utils.remove('test.dat')
        self.assert_(
            file_utils.fp_file_compare('tempout.dat',
                                       os.path.join('mesh_data',
                                                    'tempout.dat'),
                                       tolerance=1.e-4))
        file_utils.remove('tempout.dat')
Пример #6
0
    def RKlinear(self):
        # This test uses a linear solver to generate the reference
        # data for the subsequent nonlinear solvers.
        OOF.Subproblem.Set_Solver(
            subproblem='microstructure:skeleton:mesh:default',
            solver_mode=AdvancedSolverMode(
                time_stepper=AdaptiveDriver(
                    initialstep=0.1,
                    tolerance=1.e-6,
                    minstep=1.e-05,
                    errorscaling=AbsoluteErrorScaling(),
                    stepper=TwoStep(singlestep=RK4())),
                nonlinear_solver=NoNonlinearSolver(),
                symmetric_solver=ConjugateGradient(
                    preconditioner=ILUPreconditioner(),
                    tolerance=1e-13,
                    max_iterations=1000)))
        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=2.0)

        self.assert_(
            file_utils.fp_file_compare('test.dat',
                                       os.path.join('mesh_data', 'nldiff.dat'),
                                       tolerance=1.e-6))
        file_utils.remove('test.dat')
        self.assert_(
            file_utils.fp_file_compare('tempout.dat',
                                       os.path.join('mesh_data',
                                                    'tempout.dat'),
                                       tolerance=1.e-5))
        file_utils.remove('tempout.dat')
Пример #7
0
    def BEnewton(self):
        OOF.Subproblem.Set_Solver(
            subproblem='microstructure:skeleton:mesh:default',
            solver_mode=AdvancedSolverMode(
                time_stepper=AdaptiveDriver(
                    initialstep=0.1,
                    tolerance=1.e-5,
                    minstep=1.e-05,
                    errorscaling=AbsoluteErrorScaling(),
                    stepper=TwoStep(singlestep=BackwardEuler())),
                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)))
        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=1.0)

        self.assert_(
            file_utils.fp_file_compare('test.dat',
                                       os.path.join('mesh_data', 'nldiff.dat'),
                                       tolerance=1.e-3,
                                       nlines=16))
        file_utils.remove('test.dat')
        self.assert_(
            file_utils.fp_file_compare('tempout.dat',
                                       os.path.join('mesh_data',
                                                    'tempout.dat'),
                                       tolerance=1.e-3,
                                       nlines=910))
        file_utils.remove('tempout.dat')
Пример #8
0
    def RK4(self):
        OOF.Subproblem.Set_Solver(
            subproblem="microstructure:skeleton:mesh:default",
            solver_mode=AdvancedSolverMode(
                time_stepper=AdaptiveDriver(
                    initialstep=0.1,
                    tolerance=1.0e-6,
                    minstep=1.0e-05,
                    errorscaling=AbsoluteErrorScaling(),
                    stepper=TwoStep(singlestep=RK4()),
                ),
                nonlinear_solver=Newton(relative_tolerance=1e-08, absolute_tolerance=1.0e-13, maximum_iterations=200),
                symmetric_solver=ConjugateGradient(
                    preconditioner=ILUPreconditioner(), tolerance=1e-13, max_iterations=1000
                ),
            ),
        )
        OOF.Mesh.Solve(mesh="microstructure:skeleton:mesh", endtime=2.0)

        self.assert_(file_utils.fp_file_compare("test.dat", os.path.join("mesh_data", "nldiff.dat"), tolerance=1.0e-6))
        file_utils.remove("test.dat")
        self.assert_(
            file_utils.fp_file_compare("tempout.dat", os.path.join("mesh_data", "tempout.dat"), tolerance=1.0e-5)
        )
        file_utils.remove("tempout.dat")
Пример #9
0
    def RKlinear(self):
        # This test uses a linear solver to generate the reference
        # data for the subsequent nonlinear solvers.
        OOF.Subproblem.Set_Solver(
            subproblem='microstructure:skeleton:mesh:default',
            solver_mode=AdvancedSolverMode(
                time_stepper=AdaptiveDriver(
                    initialstep=0.1,
                    tolerance=1.e-6,
                    minstep=1.e-05,
                    errorscaling=AbsoluteErrorScaling(),
                    stepper=TwoStep(singlestep=RK4())),
                nonlinear_solver=NoNonlinearSolver(),
                symmetric_solver=ConjugateGradient(
                    preconditioner=ILUPreconditioner(),
                    tolerance=1e-13,
                    max_iterations=1000)))
        OOF.Mesh.Solve(
            mesh='microstructure:skeleton:mesh',
            endtime=2.0)

        self.assert_(file_utils.fp_file_compare(
                'test.dat',
                os.path.join('mesh_data', 'nldiff.dat'),
                tolerance=1.e-6))
        file_utils.remove('test.dat')
        self.assert_(file_utils.fp_file_compare(
                'tempout.dat',
                os.path.join('mesh_data', 'tempout.dat'),
                tolerance=1.e-5))
        file_utils.remove('tempout.dat')
Пример #10
0
    def check(self, tolerance):
        self.assert_(file_utils.fp_file_compare("center.out", os.path.join("mesh_data", "simplecenter.out"), tolerance))
        file_utils.remove("center.out")

        self.assert_(file_utils.fp_file_compare("middle.out", os.path.join("mesh_data", "simplemiddle.out"), tolerance))
        file_utils.remove("middle.out")

        self.assert_(file_utils.fp_file_compare("right.out", os.path.join("mesh_data", "simpleright.out"), tolerance))
        file_utils.remove("right.out")
Пример #11
0
 def check(self):
     self.assert_(
         file_utils.fp_file_compare("riiight.out", os.path.join("mesh_data", "riiight.out"), tolerance=1.0e-4)
     )
     file_utils.remove("riiight.out")
     self.assert_(
         file_utils.fp_file_compare("stress_nl2.out", os.path.join("mesh_data", "stress_nl2.out"), tolerance=1.0e-4)
     )
     file_utils.remove("stress_nl2.out")
Пример #12
0
    def StressFreeStrain(self):
        OOF.Material.Add_property(name="middle", property="Mechanical:Elasticity:Isotropic")
        OOF.Material.Add_property(name="edges", property="Mechanical:Elasticity:Isotropic")
        OOF.Property.Copy(property="Mechanical:StressFreeStrain:Anisotropic:Orthorhombic", new_name="new")
        OOF.Material.Add_property(name="middle", property="Mechanical:StressFreeStrain:Anisotropic:Orthorhombic:new")
        OOF.Property.Parametrize.Mechanical.StressFreeStrain.Anisotropic.Orthorhombic.new(
            epsilon0=OrthorhombicRank2Tensor(xx=0.0, yy=0.0, zz=0.1)
        )
        OOF.Property.Copy(property="Orientation", new_name="new")
        OOF.Material.Add_property(name="middle", property="Orientation:new")
        OOF.Property.Parametrize.Orientation.new(angles=Axis(angle=90, x=0.0, y=1, z=1.0))
        OOF.Subproblem.Field.Define(subproblem="microstructure:skeleton:mesh:default", field=Displacement)
        OOF.Subproblem.Field.Activate(subproblem="microstructure:skeleton:mesh:default", field=Displacement)
        OOF.Mesh.Field.In_Plane(mesh="microstructure:skeleton:mesh", field=Displacement)
        OOF.Subproblem.Equation.Activate(subproblem="microstructure:skeleton:mesh:default", equation=Force_Balance)
        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=ContinuumProfileXTd(function="0", timeDerivative="0", timeDerivative2="0"),
                boundary="left",
            ),
        )
        OOF.Mesh.Boundary_Conditions.New(
            name="bc<2>",
            mesh="microstructure:skeleton:mesh",
            condition=DirichletBC(
                field=Displacement,
                field_component="y",
                equation=Force_Balance,
                eqn_component="y",
                profile=ContinuumProfileXTd(function="0", timeDerivative="0", timeDerivative2="0"),
                boundary="left",
            ),
        )
        OOF.Mesh.Solve(mesh="microstructure:skeleton:mesh", endtime=0.0)
        OOF.File.Save.Mesh(filename="mesh1.dat", mode="w", format="ascii", mesh="microstructure:skeleton:mesh")
        self.assert_(
            file_utils.fp_file_compare("mesh1.dat", os.path.join("aniso_data", "stressfreestrain1.dat"), tolerance)
        )
        OOF.Property.Parametrize.Orientation.new(angles=Axis(angle=0, x=0.0, y=1.0, z=1.0))
        OOF.Mesh.Solve(mesh="microstructure:skeleton:mesh", endtime=0.0)
        OOF.File.Save.Mesh(filename="mesh2.dat", mode="w", format="ascii", mesh="microstructure:skeleton:mesh")
        self.assert_(
            file_utils.fp_file_compare("mesh2.dat", os.path.join("aniso_data", "stressfreestrain2.dat"), tolerance)
        )
        file_utils.remove("mesh1.dat")
        file_utils.remove("mesh2.dat")

        OOF.Property.Delete(property="Orientation:new")
        OOF.Property.Delete(property="Mechanical:StressFreeStrain:Anisotropic:Orthorhombic:new")
Пример #13
0
 def check(self):
     self.assert_(file_utils.fp_file_compare(
             'riiight.out',
             os.path.join('mesh_data', 'riiight.out'),
             tolerance=1.e-4))
     file_utils.remove('riiight.out')
     self.assert_(file_utils.fp_file_compare(
             'stress_nl2.out',
             os.path.join('mesh_data', 'stress_nl2.out'),
             tolerance=1.e-4))
     file_utils.remove('stress_nl2.out')
Пример #14
0
    def All2x2x2(self):
        ms = microstructure.getMicrostructure('microstructure')
        skel = skeletoncontext.getSkeleton(ms, "skeleton").getObject()
        # The non-trivial combinations of voxels correspond to voxel
        # signatures between 1 and 255.  Signature 0 has no voxels in
        # it, and would be equivalent to the Trivial test, above.
        sigs = range(1, 256)
        for sig in sigs:
            nvox = self.selectSig(sig)
            sigstr = voxelsetboundary.printSig(sig)
            print "Selected voxels:", sigstr, "(sig=%d)" % sig
            self.assertEqual(nvox, self.selectionSize())

            OOF.PixelGroup.AddSelection(microstructure='microstructure',
                                        group='pixelgroup')
            self.assertEqual(ms.nCategories(), 2)  # triggers categorization

            unselectedCat = ms.category(Point(0, 0, 0))
            selectedCat = 1 - unselectedCat
            print "selectedCat=", selectedCat, "unselectedCat=",\
                unselectedCat

            skel.dumpVSB(selectedCat, "selected.dat")
            skel.dumpVSB(unselectedCat, "unselected.dat")
            # ms.dumpVSBLines(selectedCat, "selected_"+sigstr+".lines")
            # ms.dumpVSBLines(unselectedCat, "unselected_"+sigstr+".lines")

            selectedVol = ms.volumeOfCategory(selectedCat)
            unselectedVol = ms.volumeOfCategory(unselectedCat)
            print "selectedVol=", selectedVol, \
                "unselectedVol=", unselectedVol
            print "Checking connectivity for selected voxels, category",\
                selectedCat
            self.assert_(skel.checkVSB(selectedCat))
            print "Checking connectivity for unselected voxels, category",\
                unselectedCat
            self.assert_(skel.checkVSB(unselectedCat))
            self.assertAlmostEqual(selectedVol, nvox)
            self.assertAlmostEqual(unselectedVol, 64 - nvox)
            # Check that the saved VSB graphs are correct
            sigstr = sigstr.replace('|', '-')
            self.assert_(
                file_utils.fp_file_compare(
                    "selected.dat",
                    os.path.join("vsb_data", "selected_" + sigstr + ".dat"),
                    1.e-9))
            self.assert_(
                file_utils.fp_file_compare(
                    "unselected.dat",
                    os.path.join("vsb_data", "unselected_" + sigstr + ".dat"),
                    1.e-9))
            print "-------"
            file_utils.remove("selected.dat")
            file_utils.remove("unselected.dat")
Пример #15
0
 def check(self):
     self.assert_(file_utils.fp_file_compare(
             'riiight.out',
             os.path.join('mesh_data', 'riiight.out'),
             tolerance=1.e-4))
     file_utils.remove('riiight.out')
     self.assert_(file_utils.fp_file_compare(
             'stress_nl2.out',
             os.path.join('mesh_data', 'stress_nl2.out'),
             tolerance=1.e-4))
     file_utils.remove('stress_nl2.out')
Пример #16
0
 def compareFiles(self, topfile, leftfile):
     self.assert_(
         file_utils.fp_file_compare('temptop.dat',
                                    os.path.join('mesh_data', topfile),
                                    1.e-10))
     self.assert_(
         file_utils.fp_file_compare('templeft.dat',
                                    os.path.join('mesh_data', leftfile),
                                    1.e-10))
     file_utils.remove('temptop.dat')
     file_utils.remove('templeft.dat')
     outputdestination.forgetTextOutputStreams()
Пример #17
0
    def ClippedShape(self):
        # Check that a few carefully selected sets of voxels are
        # clipped properly by a single plane
        sigs = (
            vox000,
            vox111,
            vox000 | vox100,
            vox000 | vox110,
            vox010 | vox100,
            vox000 | vox100 | vox010 | vox111,
        )
        ms = microstructure.getMicrostructure('microstructure')
        skel = skeletoncontext.getSkeleton(ms, "skeleton").getObject()
        for sig in sigs:
            sigstr = voxelsetboundary.printSig(sig)
            print "Selecting voxels", sigstr
            sigstr = sigstr.replace('|', '-')
            nvox = self.selectSig(sig)
            OOF.PixelGroup.AddSelection(microstructure='microstructure',
                                        group='pixelgroup')
            unselectedCat = ms.category(Point(0, 0, 0))
            selectedCat = 1 - unselectedCat
            for i, plane in enumerate(planes):
                # saveClippedVSB writes filename.dat and filename.lines
                skel.saveClippedVSB(selectedCat, plane, 'selected')
                skel.saveClippedVSB(unselectedCat, plane, 'unselected')

                fnamebase = "clipped_%s_p%02d" % (sigstr, i)
                self.assert_(
                    file_utils.fp_file_compare(
                        'selected.dat',
                        os.path.join("vsb_data", 's' + fnamebase + '.dat'),
                        1.e-9))
                self.assert_(
                    file_utils.fp_file_compare(
                        'unselected.dat',
                        os.path.join("vsb_data", 'u' + fnamebase + '.dat'),
                        1.e-9))
                self.assert_(
                    file_utils.fp_file_compare(
                        'selected.lines',
                        os.path.join("vsb_data", 's' + fnamebase + '.lines'),
                        1.e-9))
                self.assert_(
                    file_utils.fp_file_compare(
                        'unselected.lines',
                        os.path.join("vsb_data", 'u' + fnamebase + '.lines'),
                        1.e-9))

                file_utils.remove('selected.dat')
                file_utils.remove('unselected.dat')
                file_utils.remove('selected.lines')
                file_utils.remove('unselected.lines')
Пример #18
0
 def compareFiles(self, topfile, leftfile):
     self.assert_(
         file_utils.fp_file_compare(
             'temptop.dat',
             os.path.join('mesh_data', topfile),
             1.e-10))
     self.assert_(
         file_utils.fp_file_compare(
             'templeft.dat',
             os.path.join('mesh_data', leftfile),
             1.e-10))
     file_utils.remove('temptop.dat')
     file_utils.remove('templeft.dat')
     outputdestination.forgetTextOutputStreams()
Пример #19
0
 def ThermalConductivity(self):
     OOF.Material.Add_property(name="edges", property="Thermal:Conductivity:Isotropic")
     OOF.Property.Copy(property="Thermal:Conductivity:Anisotropic:Orthorhombic", new_name="new")
     OOF.Property.Parametrize.Thermal.Conductivity.Anisotropic.Orthorhombic.new(
         kappa=OrthorhombicRank2Tensor(xx=1.0, yy=1.0, zz=10.0)
     )
     OOF.Material.Add_property(name="middle", property="Thermal:Conductivity:Anisotropic:Orthorhombic:new")
     OOF.Property.Copy(property="Orientation", new_name="new")
     OOF.Property.Parametrize.Orientation.new(angles=Axis(angle=90, x=0.0, y=1.0, z=1.0))
     OOF.Material.Add_property(name="middle", property="Orientation:new")
     OOF.Subproblem.Field.Define(subproblem="microstructure:skeleton:mesh:default", field=Temperature)
     OOF.Subproblem.Field.Activate(subproblem="microstructure:skeleton:mesh:default", field=Temperature)
     OOF.Mesh.Field.In_Plane(mesh="microstructure:skeleton:mesh", field=Temperature)
     OOF.Subproblem.Equation.Activate(subproblem="microstructure:skeleton:mesh:default", equation=Heat_Eqn)
     OOF.Mesh.Boundary_Conditions.New(
         name="bc",
         mesh="microstructure:skeleton:mesh",
         condition=DirichletBC(
             field=Temperature,
             field_component="",
             equation=Heat_Eqn,
             eqn_component="",
             profile=ContinuumProfileXTd(function="1.0", timeDerivative="0", timeDerivative2="0"),
             boundary="bottomleft",
         ),
     )
     OOF.Mesh.Boundary_Conditions.New(
         name="bc",
         mesh="microstructure:skeleton:mesh",
         condition=DirichletBC(
             field=Temperature,
             field_component="",
             equation=Heat_Eqn,
             eqn_component="",
             profile=ContinuumProfileXTd(function="0.0", timeDerivative="0", timeDerivative2="0"),
             boundary="topright",
         ),
     )
     OOF.Mesh.Solve(mesh="microstructure:skeleton:mesh", endtime=0.0)
     OOF.File.Save.Mesh(filename="mesh.dat", mode="w", format="ascii", mesh="microstructure:skeleton:mesh")
     self.assert_(file_utils.fp_file_compare("mesh.dat", os.path.join("aniso_data", "heatcond1.dat"), tolerance))
     file_utils.remove("mesh.dat")
     OOF.Property.Parametrize.Orientation.new(angles=Axis(angle=0, x=0.0, y=1.0, z=1.0))
     OOF.Mesh.Solve(mesh="microstructure:skeleton:mesh", endtime=0.0)
     OOF.File.Save.Mesh(filename="mesh.dat", mode="w", format="ascii", mesh="microstructure:skeleton:mesh")
     self.assert_(file_utils.fp_file_compare("mesh.dat", os.path.join("aniso_data", "heatcond2.dat"), tolerance))
     file_utils.remove("mesh.dat")
     OOF.Property.Delete(property="Thermal:Conductivity:Anisotropic:Orthorhombic:new")
     OOF.Property.Delete(property="Orientation:new")
Пример #20
0
 def TwoSeparateNamed(self):
     # Two outputs sent to separate files.
     self.scheduleNamedVectorField('vtest.dat', 0.1)
     self.scheduleNamedTensorFluxNormal('ttest.dat', 0.1)
     self.solve()
     self.assert_(file_utils.fp_file_compare(
             'vtest.dat',
             os.path.join('mesh_data', 'vectorfieldoutput.dat'),
             1.e-8))
     self.assert_(file_utils.fp_file_compare(
             'ttest.dat',
             os.path.join('mesh_data', 'tensorfluxoutput.dat'),
             1.e-8))
     self.rewind()
     file_utils.remove('vtest.dat')
     file_utils.remove('ttest.dat')
Пример #21
0
 def Save_Pinned(self):
     OOF.Graphics_1.Toolbox.Pin_Nodes.Pin(
         skeleton='bluegreen:skeleton',
         point=Point(-15.7509, 25.046, 0.586289),
         view=View(cameraPosition=Coord(-15.8018, 25.0947, 0.579851),
                   focalPoint=Coord(5, 5, 5),
                   up=Coord(0.143933, -0.0681609, -0.987237),
                   angle=30,
                   clipPlanes=[],
                   invertClip=0,
                   size_x=690,
                   size_y=618))
     OOF.Graphics_1.Toolbox.Pin_Nodes.Pin(
         skeleton='bluegreen:skeleton',
         point=Point(-15.7517, 25.0469, 0.593985),
         view=View(cameraPosition=Coord(-15.8018, 25.0947, 0.579851),
                   focalPoint=Coord(5, 5, 5),
                   up=Coord(0.143933, -0.0681609, -0.987237),
                   angle=30,
                   clipPlanes=[],
                   invertClip=0,
                   size_x=690,
                   size_y=618))
     OOF.File.Save.Skeleton(filename='pinnedskel.dat',
                            mode='w',
                            format='ascii',
                            skeleton='bluegreen:skeleton')
     self.assert_(
         file_utils.fp_file_compare(
             "pinnedskel.dat", os.path.join("skeleton_data", "pintest"),
             1.e-9))
     file_utils.remove("pinnedskel.dat")
Пример #22
0
 def QuasiStatic(self):
     OOF.Mesh.Scheduled_Output.New(
         mesh='microstructure:skeleton:mesh',
         name='LRcorner',
         output=BulkAnalysis(
             output_type='Aggregate',
             data=getOutput('Field:Value',field=Displacement),
             operation=DirectOutput(),
             domain=SinglePoint(point=Point(1,0)),
             sampling=DiscretePointSampleSet(show_x=False,show_y=False)))
     OOF.Mesh.Scheduled_Output.Schedule.Set(
         mesh='microstructure:skeleton:mesh',
         output='LRcorner',
         scheduletype=AbsoluteOutputSchedule(),
         schedule=Periodic(delay=0.0,interval=0.1))
     OOF.Mesh.Scheduled_Output.Destination.Set(
         mesh='microstructure:skeleton:mesh',
         output='LRcorner',
         destination=OutputStream(filename='rotate.out',mode='w'))
     OOF.Mesh.Apply_Field_Initializers_at_Time(
         mesh='microstructure:skeleton:mesh', time=0)
     OOF.Mesh.Solve(
         mesh='microstructure:skeleton:mesh', endtime=1.0)
     self.assert_(file_utils.fp_file_compare(
         'rotate.out',
         os.path.join('mesh_data', 'rotatingsquare1.out'),
         tolerance=1.e-8))
     file_utils.remove('rotate.out')
Пример #23
0
 def TwoSeparateNamed(self):
     # Two outputs sent to separate files.
     self.scheduleNamedVectorField('vtest.dat', 0.1)
     self.scheduleNamedTensorFluxNormal('ttest.dat', 0.1)
     self.solve()
     self.assert_(
         file_utils.fp_file_compare(
             'vtest.dat', os.path.join('mesh_data',
                                       'vectorfieldoutput.dat'), 1.e-8))
     self.assert_(
         file_utils.fp_file_compare(
             'ttest.dat', os.path.join('mesh_data', 'tensorfluxoutput.dat'),
             1.e-8))
     self.rewind()
     file_utils.remove('vtest.dat')
     file_utils.remove('ttest.dat')
Пример #24
0
 def QuasiStatic(self):
     OOF.Mesh.Scheduled_Output.New(
         mesh='microstructure:skeleton:mesh',
         name='LRcorner',
         output=BulkAnalysis(output_type='Aggregate',
                             data=getOutput('Field:Value',
                                            field=Displacement),
                             operation=DirectOutput(),
                             domain=SinglePoint(point=Point(1, 0)),
                             sampling=DiscretePointSampleSet(show_x=False,
                                                             show_y=False)))
     OOF.Mesh.Scheduled_Output.Schedule.Set(
         mesh='microstructure:skeleton:mesh',
         output='LRcorner',
         scheduletype=AbsoluteOutputSchedule(),
         schedule=Periodic(delay=0.0, interval=0.1))
     OOF.Mesh.Scheduled_Output.Destination.Set(
         mesh='microstructure:skeleton:mesh',
         output='LRcorner',
         destination=OutputStream(filename='rotate.out', mode='w'))
     OOF.Mesh.Apply_Field_Initializers_at_Time(
         mesh='microstructure:skeleton:mesh', time=0)
     OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=1.0)
     self.assert_(
         file_utils.fp_file_compare('rotate.out',
                                    os.path.join('mesh_data',
                                                 'rotatingsquare1.out'),
                                    tolerance=1.e-8))
     file_utils.remove('rotate.out')
Пример #25
0
    def check(self, tolerance):
        self.assert_(
            file_utils.fp_file_compare(
                'center.out', os.path.join('mesh_data', 'simplecenter.out'),
                tolerance))
        file_utils.remove('center.out')

        self.assert_(
            file_utils.fp_file_compare(
                'middle.out', os.path.join('mesh_data', 'simplemiddle.out'),
                tolerance))
        file_utils.remove('middle.out')

        self.assert_(
            file_utils.fp_file_compare(
                'right.out', os.path.join('mesh_data', 'simpleright.out'),
                tolerance))
        file_utils.remove('right.out')
Пример #26
0
 def NamedTensorFlux(self):
     self.scheduleNamedTensorFluxNormal('test.dat', 0.1)
     self.solve()
     self.assert_(
         file_utils.fp_file_compare(
             'test.dat', os.path.join('mesh_data', 'tensorfluxoutput.dat'),
             1.e-8))
     self.rewind()
     file_utils.remove('test.dat')
Пример #27
0
 def NamedVectorField(self):
     self.scheduleNamedVectorField('test.dat', 0.1)
     self.solve()
     self.assert_(
         file_utils.fp_file_compare(
             'test.dat', os.path.join('mesh_data', 'vectorfieldoutput.dat'),
             1.e-8))
     self.rewind()
     file_utils.remove('test.dat')
Пример #28
0
 def NamedVectorField(self):
     self.scheduleNamedVectorField('test.dat', 0.1)
     self.solve()
     self.assert_(file_utils.fp_file_compare(
             'test.dat',
             os.path.join('mesh_data', 'vectorfieldoutput.dat'),
             1.e-8))
     self.rewind()
     file_utils.remove('test.dat')
Пример #29
0
 def NamedTensorFlux(self):
     self.scheduleNamedTensorFluxNormal('test.dat', 0.1)
     self.solve()
     self.assert_(file_utils.fp_file_compare(
             'test.dat',
             os.path.join('mesh_data', 'tensorfluxoutput.dat'),
             1.e-8))
     self.rewind()
     file_utils.remove('test.dat')
Пример #30
0
 def compare(self, filename):
     OOF.File.Save.Mesh(filename=filename,
                        mode='w',
                        format='ascii',
                        mesh='microstructure:skeleton:mesh')
     self.assert_(
         file_utils.fp_file_compare(filename,
                                    os.path.join('mesh_data', filename),
                                    1.e-6))
     file_utils.remove(filename)
Пример #31
0
 def TwoTogetherAsync(self):
     # Two outputs sent to one file.
     self.scheduleUnnamedVectorField('test.dat', 0.1)
     self.scheduleUnnamedTensorFluxNormal('test.dat', 0.2)
     self.solve()
     self.assert_(file_utils.fp_file_compare(
             'test.dat',
             os.path.join('mesh_data', 'asyncoutput.dat'),
             1.e-8))
     self.rewind()
     file_utils.remove('test.dat')
Пример #32
0
 def Adaptive_Pts(self):
     self.adaptive()
     self.topleftOutput(interval=0.1, filename='test.dat')
     self.shearTopPoints()
     OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=1.0)
     self.assert_(
         file_utils.fp_file_compare(
             'test.dat', os.path.join('mesh_data', 'td_dirichlet.dat'),
             1.e-10))
     file_utils.remove('test.dat')
     outputdestination.forgetTextOutputStreams()
Пример #33
0
 def TwoTogetherAsync(self):
     # Two outputs sent to one file.
     self.scheduleUnnamedVectorField('test.dat', 0.1)
     self.scheduleUnnamedTensorFluxNormal('test.dat', 0.2)
     self.solve()
     self.assert_(
         file_utils.fp_file_compare(
             'test.dat', os.path.join('mesh_data', 'asyncoutput.dat'),
             1.e-8))
     self.rewind()
     file_utils.remove('test.dat')
Пример #34
0
 def solveAndCheck(self, filename):
     OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
     OOF.File.Save.Mesh(filename='solved',
                        mode='w',
                        format='ascii',
                        mesh='microstructure:skeleton:mesh')
     self.assert_(
         file_utils.fp_file_compare('solved',
                                    os.path.join('bc_data', filename),
                                    1.e-10))
     file_utils.remove("solved")
Пример #35
0
 def PropSave(self):
     OOF.Property.Copy(property="Color", new_name="bloo")
     OOF.Property.Parametrize.Color.bloo(
         color=RGBColor(red=0.1,green=0.1,blue=0.9))
     OOF.File.Save.Property(filename="prop_save_test",
                            mode="w", format="ascii",
                            property="Color:bloo")
     self.assert_(file_utils.fp_file_compare(
         "prop_save_test",
         os.path.join("matprop_data", "propsave"), 1.e-9))
     file_utils.remove("prop_save_test")
     OOF.Property.Delete(property="Color:bloo")
Пример #36
0
 def Adaptive_Pts(self):
     self.adaptive()
     self.topleftOutput(interval=0.1, filename='test.dat')
     self.shearTopPoints()
     OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=1.0)
     self.assert_(
         file_utils.fp_file_compare(
             'test.dat',
             os.path.join('mesh_data', 'td_dirichlet.dat'),
             1.e-10))
     file_utils.remove('test.dat')
     outputdestination.forgetTextOutputStreams()
Пример #37
0
 def Save_Pinned(self):
     OOF.Skeleton.PinNodes.Pin(skeleton='bluegreen:skeleton',
                               node=Coord(0, 10, 2.5))
     OOF.Skeleton.PinNodes.AddPin(skeleton='bluegreen:skeleton',
                                  node=Coord(0, 10, 5))
     OOF.File.Save.Skeleton(filename='pinnedskel.dat',
                            mode='w',
                            format='ascii',
                            skeleton='bluegreen:skeleton')
     self.assert_(
         file_utils.fp_file_compare(
             "pinnedskel.dat", os.path.join("skeleton_data", "pintest"),
             1.e-9))
     file_utils.remove("pinnedskel.dat")
Пример #38
0
 def MatSave(self):
     OOF.Material.New(name="save")
     OOF.Property.Copy(property="Color", new_name="check")
     OOF.Property.Parametrize.Color.check(
         color=RGBColor(red=0.2,green=0.3,blue=0.4))
     OOF.Material.Add_property(name="save",
                               property="Color:check")
     OOF.File.Save.Materials(filename="mat_save_test",
                             mode="w", format="ascii",
                             materials=["save"])
     self.assert_(file_utils.fp_file_compare(
         "mat_save_test",
         os.path.join("matprop_data","matsave"), 1.e-9))
     file_utils.remove("mat_save_test")
     OOF.Material.Delete(name="save")
     OOF.Property.Delete(property="Color:check")
Пример #39
0
 def Save(self):
     OOF.Skeleton.New(
         name="savetest",
         microstructure="skeltest",
         x_elements=4,
         y_elements=4,
         z_elements=4,
         skeleton_geometry=TetraSkeleton(arrangement='moderate'))
     OOF.File.Save.Skeleton(filename="skeleton_save",
                            mode="w",
                            format="ascii",
                            skeleton="skeltest:savetest")
     self.assert_(
         file_utils.fp_file_compare(
             "skeleton_save", os.path.join("skeleton_data", "savetest"),
             1.e-9))
     file_utils.remove("skeleton_save")
Пример #40
0
 def Save(self):
     OOF.Microstructure.New(name='microstructure',
                            width=1.0,
                            height=1.0,
                            depth=1.0,
                            width_in_pixels=3,
                            height_in_pixels=3,
                            depth_in_pixels=3)
     OOF.Graphics_1.Layer.New(
         category='Microstructure',
         what='microstructure',
         how=MicrostructureMaterialDisplay(
             no_material=Gray(value=0.4444444444444444),
             no_color=RGBColor(red=0.00000, green=0.00000, blue=1.00000),
             filter=AllVoxels()))
     # Select the eight voxels at the corners of the microstructure.
     for x in (0, 2):
         for y in (0, 2):
             for z in (0, 2):
                 OOF.VoxelSelection.Select(source='microstructure',
                                           method=PointSelector(
                                               point=iPoint(x, y, z),
                                               operator=AddSelection()))
     OOF.PixelGroup.New(name='pixelgroup', microstructure='microstructure')
     OOF.PixelGroup.AddSelection(microstructure='microstructure',
                                 group='pixelgroup')
     # Save ascii
     OOF.File.Save.Microstructure(filename='micro.dat',
                                  mode='w',
                                  format='ascii',
                                  microstructure='microstructure')
     self.assert_(
         file_utils.fp_file_compare(
             "micro.dat", os.path.join("ms_data", "pixgrp_save_ascii"),
             1.e-9))
     file_utils.remove("micro.dat")
     # Save binary
     OOF.File.Save.Microstructure(filename='micro.dat',
                                  mode='w',
                                  format='binary',
                                  microstructure='microstructure')
     self.assert_(
         file_utils.binary_file_compare(
             "micro.dat", os.path.join("ms_data", "pixgrp_save_binary")))
     os.remove("micro.dat")
Пример #41
0
 def stressFreeStrainTest(self):
     OOF.Mesh.Apply_Field_Initializers(
         mesh='microstructure:skeleton:mesh')
     OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
     OOF.Mesh.Analyze.Direct_Output(
         mesh='microstructure:skeleton:mesh',
         time=latest, 
         data=getOutput('Field:Value',field=Displacement),
         domain=EntireMesh(),
         sampling=GridSampleSet(
             x_points=10,y_points=10,show_x=True,show_y=True),
         destination=OutputStream(filename='pyprop.out',mode='w'))
     outputdestination.forgetTextOutputStreams()
     self.assert_(file_utils.fp_file_compare(
             'pyprop.out',
             os.path.join('mesh_data', 'pystressfreestrain.out'),
             1.e-6))
     file_utils.remove('pyprop.out')
Пример #42
0
 def stressFreeStrainTest(self):
     OOF.Mesh.Apply_Field_Initializers(
         mesh='microstructure:skeleton:mesh')
     OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
     OOF.Mesh.Analyze.Direct_Output(
         mesh='microstructure:skeleton:mesh',
         time=latest, 
         data=getOutput('Field:Value',field=Displacement),
         domain=EntireMesh(),
         sampling=GridSampleSet(
             x_points=10,y_points=10,show_x=True,show_y=True),
         destination=OutputStream(filename='pyprop.out',mode='w'))
     outputdestination.forgetTextOutputStreams()
     self.assert_(file_utils.fp_file_compare(
             'pyprop.out',
             os.path.join('mesh_data', 'pystressfreestrain.out'),
             1.e-6))
     file_utils.remove('pyprop.out')
Пример #43
0
 def AbaqusFormat(self):
     OOF.File.LoadStartUp.Data(
         filename=reference_file('mesh_data', 'solveable'))
     OOF.File.Save.Mesh(filename='solveable.abq', mode='w', format='abaqus',
                        mesh='solve_test:skeleton:mesh')
     # Use fp_file_compare because it can ignore dates in files,
     # and the abaqus output contains the date in the header.
     self.assert_(
         file_utils.fp_file_compare(
             'solveable.abq',
             os.path.join('mesh_data', 'solveable.abq'),
             tolerance=1.e-8, ignoretime=True))
     file_utils.remove('solveable.abq')
     OOF.Material.Delete(name='mortar')
     OOF.Material.Delete(name='bricks')
     OOF.Property.Delete(property='Color:bloo')
     OOF.Property.Delete(property='Color:wred')
     OOF.Property.Delete(property='Mechanical:Elasticity:Isotropic:soft')
     OOF.Property.Delete(property='Mechanical:Elasticity:Isotropic:stiff')
Пример #44
0
 def MatDeleteSave(self):
     OOF.Microstructure.New(
         name='microstructure',
         width=1.0, height=1.0, depth=1.0,
         width_in_pixels=10, height_in_pixels=10, depth_in_pixels=10)
     OOF.Material.New(
         name='material0',
         material_type='bulk')
     OOF.Material.Assign(
         material='material0',
         microstructure='microstructure',
         pixels=every)
     OOF.Material.Delete(name='material0')
     OOF.File.Save.Microstructure(
         filename='microtest.dat',
         mode='w', format='ascii',
         microstructure='microstructure')
     self.assert_(file_utils.fp_file_compare(
         "microtest.dat",
         os.path.join("matprop_data", "deletematerial.dat"), 1.e-9))
     file_utils.remove("microtest.dat")
Пример #45
0
    def Elasticity(self):
        OOF.Property.Parametrize.Mechanical.Elasticity.Isotropic(
            cijkl=IsotropicRank4TensorCij(c11=1.0, c12=0.5))
        OOF.Material.Add_property(name='edges',
                                  property='Mechanical:Elasticity:Isotropic')
        OOF.Property.Copy(
            property='Mechanical:Elasticity:Anisotropic:Orthorhombic',
            new_name='new')
        OOF.Property.Parametrize.Mechanical.Elasticity.Anisotropic.Orthorhombic.new(
            cijkl=OrthorhombicRank4TensorCij(c11=1,
                                             c12=0.5,
                                             c13=0.5,
                                             c22=1,
                                             c23=0.5,
                                             c33=10,
                                             c44=0.25,
                                             c55=0.25,
                                             c66=0.25))
        OOF.Property.Copy(property='Orientation', new_name='new')
        OOF.Property.Parametrize.Orientation.new(
            angles=Axis(angle=90, x=0.0, y=1.0, z=1.0))
        OOF.Material.Add_property(name='middle', property='Orientation:new')
        OOF.Material.Add_property(
            name='middle',
            property='Mechanical:Elasticity:Anisotropic:Orthorhombic:new')
        OOF.Subproblem.Field.Define(
            subproblem='microstructure:skeleton:mesh:default',
            field=Displacement)
        OOF.Subproblem.Field.Activate(
            subproblem='microstructure:skeleton:mesh:default',
            field=Displacement)
        OOF.Mesh.Field.In_Plane(mesh='microstructure:skeleton:mesh',
                                field=Displacement)
        OOF.Subproblem.Equation.Activate(
            subproblem='microstructure:skeleton:mesh:default',
            equation=Force_Balance)
        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='y',
                                  equation=Force_Balance,
                                  eqn_component='y',
                                  profile=ConstantProfile(value=0.0),
                                  boundary='left'))
        OOF.Mesh.Boundary_Conditions.New(
            name='bc<3>',
            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.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
        OOF.File.Save.Mesh(filename='mesh.dat',
                           mode='w',
                           format='ascii',
                           mesh='microstructure:skeleton:mesh')
        self.assert_(
            file_utils.fp_file_compare(
                'mesh.dat', os.path.join('aniso_data', 'elasticity1.dat'),
                tolerance))
        file_utils.remove('mesh.dat')

        OOF.Property.Parametrize.Orientation.new(
            angles=Axis(angle=0, x=0.0, y=1.0, z=1.0))
        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
        OOF.File.Save.Mesh(filename='mesh.dat',
                           mode='w',
                           format='ascii',
                           mesh='microstructure:skeleton:mesh')
        self.assert_(
            file_utils.fp_file_compare(
                'mesh.dat', os.path.join('aniso_data', 'elasticity2.dat'),
                tolerance))
        file_utils.remove('mesh.dat')

        OOF.Property.Delete(
            property='Mechanical:Elasticity:Anisotropic:Orthorhombic:new')
        OOF.Property.Delete(property='Orientation:new')
Пример #46
0
 def ThermalConductivity(self):
     OOF.Material.Add_property(name='edges',
                               property='Thermal:Conductivity:Isotropic')
     OOF.Property.Copy(
         property='Thermal:Conductivity:Anisotropic:Orthorhombic',
         new_name='new')
     OOF.Property.Parametrize.Thermal.Conductivity.Anisotropic.Orthorhombic.new(
         kappa=OrthorhombicRank2Tensor(xx=1.0, yy=1.0, zz=10.0))
     OOF.Material.Add_property(
         name='middle',
         property='Thermal:Conductivity:Anisotropic:Orthorhombic:new')
     OOF.Property.Copy(property='Orientation', new_name='new')
     OOF.Property.Parametrize.Orientation.new(
         angles=Axis(angle=90, x=0.0, y=1.0, z=1.0))
     OOF.Material.Add_property(name='middle', property='Orientation:new')
     OOF.Subproblem.Field.Define(
         subproblem='microstructure:skeleton:mesh:default',
         field=Temperature)
     OOF.Subproblem.Field.Activate(
         subproblem='microstructure:skeleton:mesh:default',
         field=Temperature)
     OOF.Mesh.Field.In_Plane(mesh='microstructure:skeleton:mesh',
                             field=Temperature)
     OOF.Subproblem.Equation.Activate(
         subproblem='microstructure:skeleton:mesh:default',
         equation=Heat_Eqn)
     OOF.Mesh.Boundary_Conditions.New(name='bc',
                                      mesh='microstructure:skeleton:mesh',
                                      condition=DirichletBC(
                                          field=Temperature,
                                          field_component='',
                                          equation=Heat_Eqn,
                                          eqn_component='',
                                          profile=ContinuumProfileXTd(
                                              function='1.0',
                                              timeDerivative='0',
                                              timeDerivative2='0'),
                                          boundary='bottomleft'))
     OOF.Mesh.Boundary_Conditions.New(name='bc',
                                      mesh='microstructure:skeleton:mesh',
                                      condition=DirichletBC(
                                          field=Temperature,
                                          field_component='',
                                          equation=Heat_Eqn,
                                          eqn_component='',
                                          profile=ContinuumProfileXTd(
                                              function='0.0',
                                              timeDerivative='0',
                                              timeDerivative2='0'),
                                          boundary='topright'))
     OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
     OOF.File.Save.Mesh(filename='mesh.dat',
                        mode='w',
                        format='ascii',
                        mesh='microstructure:skeleton:mesh')
     self.assert_(
         file_utils.fp_file_compare(
             'mesh.dat', os.path.join('aniso_data', 'heatcond1.dat'),
             tolerance))
     file_utils.remove('mesh.dat')
     OOF.Property.Parametrize.Orientation.new(
         angles=Axis(angle=0, x=0.0, y=1.0, z=1.0))
     OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
     OOF.File.Save.Mesh(filename='mesh.dat',
                        mode='w',
                        format='ascii',
                        mesh='microstructure:skeleton:mesh')
     self.assert_(
         file_utils.fp_file_compare(
             'mesh.dat', os.path.join('aniso_data', 'heatcond2.dat'),
             tolerance))
     file_utils.remove('mesh.dat')
     OOF.Property.Delete(
         property='Thermal:Conductivity:Anisotropic:Orthorhombic:new')
     OOF.Property.Delete(property='Orientation:new')
Пример #47
0
 def check(self, tolerance):
     self.assert_(
         file_utils.fp_file_compare(
             'temptop.out', os.path.join('mesh_data', 'temptop.out'),
             tolerance))
     file_utils.remove('temptop.out')
Пример #48
0
 def check(self, tolerance):
     self.assert_(file_utils.fp_file_compare("temptop.out", os.path.join("mesh_data", "temptop.out"), tolerance))
     file_utils.remove("temptop.out")
Пример #49
0
    def StressFreeStrain(self):
        OOF.Material.Add_property(name='middle',
                                  property='Mechanical:Elasticity:Isotropic')
        OOF.Material.Add_property(name='edges',
                                  property='Mechanical:Elasticity:Isotropic')
        OOF.Property.Copy(
            property='Mechanical:StressFreeStrain:Anisotropic:Orthorhombic',
            new_name='new')
        OOF.Material.Add_property(
            name='middle',
            property='Mechanical:StressFreeStrain:Anisotropic:Orthorhombic:new'
        )
        OOF.Property.Parametrize.Mechanical.StressFreeStrain.Anisotropic.Orthorhombic.new(
            epsilon0=OrthorhombicRank2Tensor(xx=0.0, yy=0.0, zz=0.1))
        OOF.Property.Copy(property='Orientation', new_name='new')
        OOF.Material.Add_property(name='middle', property='Orientation:new')
        OOF.Property.Parametrize.Orientation.new(
            angles=Axis(angle=90, x=0.0, y=1, z=1.0))
        OOF.Subproblem.Field.Define(
            subproblem='microstructure:skeleton:mesh:default',
            field=Displacement)
        OOF.Subproblem.Field.Activate(
            subproblem='microstructure:skeleton:mesh:default',
            field=Displacement)
        OOF.Mesh.Field.In_Plane(mesh='microstructure:skeleton:mesh',
                                field=Displacement)
        OOF.Subproblem.Equation.Activate(
            subproblem='microstructure:skeleton:mesh:default',
            equation=Force_Balance)
        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=ContinuumProfileXTd(
                                                 function='0',
                                                 timeDerivative='0',
                                                 timeDerivative2='0'),
                                             boundary='left'))
        OOF.Mesh.Boundary_Conditions.New(name='bc<2>',
                                         mesh='microstructure:skeleton:mesh',
                                         condition=DirichletBC(
                                             field=Displacement,
                                             field_component='y',
                                             equation=Force_Balance,
                                             eqn_component='y',
                                             profile=ContinuumProfileXTd(
                                                 function='0',
                                                 timeDerivative='0',
                                                 timeDerivative2='0'),
                                             boundary='left'))
        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
        OOF.File.Save.Mesh(filename='mesh1.dat',
                           mode='w',
                           format='ascii',
                           mesh='microstructure:skeleton:mesh')
        self.assert_(
            file_utils.fp_file_compare(
                'mesh1.dat', os.path.join('aniso_data',
                                          'stressfreestrain1.dat'), tolerance))
        OOF.Property.Parametrize.Orientation.new(
            angles=Axis(angle=0, x=0.0, y=1.0, z=1.0))
        OOF.Mesh.Solve(mesh='microstructure:skeleton:mesh', endtime=0.0)
        OOF.File.Save.Mesh(filename='mesh2.dat',
                           mode='w',
                           format='ascii',
                           mesh='microstructure:skeleton:mesh')
        self.assert_(
            file_utils.fp_file_compare(
                'mesh2.dat', os.path.join('aniso_data',
                                          'stressfreestrain2.dat'), tolerance))
        file_utils.remove('mesh1.dat')
        file_utils.remove('mesh2.dat')

        OOF.Property.Delete(property='Orientation:new')
        OOF.Property.Delete(
            property='Mechanical:StressFreeStrain:Anisotropic:Orthorhombic:new'
        )
Пример #50
0
 def Save(self):
     # Before saving, define some fields and bcs.
     OOF.Mesh.Rename(mesh="meshtest:skeleton:fe_test", name="save_test")
     OOF.Mesh.Field.Define(mesh="meshtest:skeleton:save_test",
                           field=Temperature)
     OOF.Mesh.Field.Define(mesh="meshtest:skeleton:save_test",
                           field=Displacement)
     OOF.Mesh.Set_Field_Initializer(
         mesh="meshtest:skeleton:save_test",
         field=Temperature,
         initializer=ConstScalarFieldInit(value=0.0))
     OOF.Mesh.Set_Field_Initializer(
         mesh="meshtest:skeleton:save_test",
         field=Temperature_z,
         initializer=ConstScalarFieldInit(value=0.0))
     OOF.Mesh.Field.Activate(mesh="meshtest:skeleton:save_test",
                             field=Temperature)
     OOF.Mesh.Equation.Activate(mesh="meshtest:skeleton:save_test",
                                equation=Heat_Eqn)
     OOF.Mesh.Equation.Activate(mesh="meshtest:skeleton:save_test",
                                equation=Plane_Heat_Flux)
     OOF.Mesh.Equation.Activate(mesh="meshtest:skeleton:save_test",
                                equation=Force_Balance)
     OOF.Mesh.Boundary_Conditions.New(
         name="high", mesh="meshtest:skeleton:save_test",
         condition=DirichletBC(field=Temperature,
                               field_component="",
                               equation=Heat_Eqn,
                               eqn_component="",
                               profile=ConstantProfile(value=1.0),
                               boundary="top"))
     OOF.Mesh.Boundary_Conditions.New(
         name="low", mesh="meshtest:skeleton:save_test",
         condition=DirichletBC(field=Temperature,
                               field_component="",
                               equation=Heat_Eqn,
                               eqn_component="",
                               profile=ConstantProfile(value=0.0),
                               boundary="bottom"))
     OOF.Mesh.Boundary_Conditions.New(
         name="floatdisp", mesh="meshtest:skeleton:save_test",
         condition=FloatBC(
             field=Displacement, field_component='x',
             equation=Force_Balance,eqn_component='x',
             profile=ConstantProfile(value=0.0),
             boundary='top'))
     OOF.Mesh.Boundary_Conditions.New(
         name="floattemp", mesh="meshtest:skeleton:save_test",
         condition=FloatBC(
             field=Temperature, field_component='x',
             equation=Heat_Eqn,eqn_component='x',
             profile=ConstantProfile(value=0.0),
             boundary='left'))
     OOF.Subproblem.Set_Solver(
         subproblem='meshtest:skeleton:save_test:default',
         solver_mode=BasicSolverMode(
             time_stepper=BasicAdaptiveDriver(
                 tolerance=0.0001,minstep=1.0e-05),
             matrix_method=BasicIterative(
                 tolerance=1e-13,max_iterations=1000)))
     OOF.Mesh.Boundary_Conditions.Set_BC_Initializer(
         mesh='meshtest:skeleton:save_test',
         bc='floatdisp',
         initializer=FloatBCInitMin_td(value=0.2, time_derivative=0.1))
     OOF.Mesh.Boundary_Conditions.Set_BC_Initializer(
         mesh='meshtest:skeleton:save_test',
         bc='floattemp',
         initializer=FloatBCInitMin(value=0.3))
     OOF.File.Save.Mesh(filename="mesh_save_test",
                        mode="w", format="ascii",
                        mesh="meshtest:skeleton:save_test")
     self.assert_(
         file_utils.fp_file_compare(
             "mesh_save_test",
             os.path.join("mesh_data", "saved_mesh"),
             1.e-10))
     os.remove("mesh_save_test")
Пример #51
0
    def Elasticity(self):
        OOF.Property.Parametrize.Mechanical.Elasticity.Isotropic(cijkl=IsotropicRank4TensorCij(c11=1.0, c12=0.5))
        OOF.Material.Add_property(name="edges", property="Mechanical:Elasticity:Isotropic")
        OOF.Property.Copy(property="Mechanical:Elasticity:Anisotropic:Orthorhombic", new_name="new")
        OOF.Property.Parametrize.Mechanical.Elasticity.Anisotropic.Orthorhombic.new(
            cijkl=OrthorhombicRank4TensorCij(
                c11=1, c12=0.5, c13=0.5, c22=1, c23=0.5, c33=10, c44=0.25, c55=0.25, c66=0.25
            )
        )
        OOF.Property.Copy(property="Orientation", new_name="new")
        OOF.Property.Parametrize.Orientation.new(angles=Axis(angle=90, x=0.0, y=1.0, z=1.0))
        OOF.Material.Add_property(name="middle", property="Orientation:new")
        OOF.Material.Add_property(name="middle", property="Mechanical:Elasticity:Anisotropic:Orthorhombic:new")
        OOF.Subproblem.Field.Define(subproblem="microstructure:skeleton:mesh:default", field=Displacement)
        OOF.Subproblem.Field.Activate(subproblem="microstructure:skeleton:mesh:default", field=Displacement)
        OOF.Mesh.Field.In_Plane(mesh="microstructure:skeleton:mesh", field=Displacement)
        OOF.Subproblem.Equation.Activate(subproblem="microstructure:skeleton:mesh:default", equation=Force_Balance)
        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="y",
                equation=Force_Balance,
                eqn_component="y",
                profile=ConstantProfile(value=0.0),
                boundary="left",
            ),
        )
        OOF.Mesh.Boundary_Conditions.New(
            name="bc<3>",
            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.Solve(mesh="microstructure:skeleton:mesh", endtime=0.0)
        OOF.File.Save.Mesh(filename="mesh.dat", mode="w", format="ascii", mesh="microstructure:skeleton:mesh")
        self.assert_(file_utils.fp_file_compare("mesh.dat", os.path.join("aniso_data", "elasticity1.dat"), tolerance))
        file_utils.remove("mesh.dat")

        OOF.Property.Parametrize.Orientation.new(angles=Axis(angle=0, x=0.0, y=1.0, z=1.0))
        OOF.Mesh.Solve(mesh="microstructure:skeleton:mesh", endtime=0.0)
        OOF.File.Save.Mesh(filename="mesh.dat", mode="w", format="ascii", mesh="microstructure:skeleton:mesh")
        self.assert_(file_utils.fp_file_compare("mesh.dat", os.path.join("aniso_data", "elasticity2.dat"), tolerance))
        file_utils.remove("mesh.dat")

        OOF.Property.Delete(property="Mechanical:Elasticity:Anisotropic:Orthorhombic:new")
        OOF.Property.Delete(property="Orientation:new")