def test_femobjects_make(self): doc = self.active_doc analysis = ObjectsFem.makeAnalysis(doc) analysis.addObject(ObjectsFem.makeConstraintBearing(doc)) analysis.addObject(ObjectsFem.makeConstraintBodyHeatSource(doc)) analysis.addObject(ObjectsFem.makeConstraintContact(doc)) analysis.addObject(ObjectsFem.makeConstraintDisplacement(doc)) analysis.addObject( ObjectsFem.makeConstraintElectrostaticPotential(doc)) analysis.addObject(ObjectsFem.makeConstraintFixed(doc)) analysis.addObject(ObjectsFem.makeConstraintFlowVelocity(doc)) analysis.addObject(ObjectsFem.makeConstraintFluidBoundary(doc)) analysis.addObject(ObjectsFem.makeConstraintForce(doc)) analysis.addObject(ObjectsFem.makeConstraintGear(doc)) analysis.addObject(ObjectsFem.makeConstraintHeatflux(doc)) analysis.addObject(ObjectsFem.makeConstraintInitialFlowVelocity(doc)) analysis.addObject(ObjectsFem.makeConstraintInitialTemperature(doc)) analysis.addObject(ObjectsFem.makeConstraintPlaneRotation(doc)) analysis.addObject(ObjectsFem.makeConstraintPressure(doc)) analysis.addObject(ObjectsFem.makeConstraintPulley(doc)) analysis.addObject(ObjectsFem.makeConstraintSelfWeight(doc)) analysis.addObject(ObjectsFem.makeConstraintTemperature(doc)) analysis.addObject(ObjectsFem.makeConstraintTransform(doc)) analysis.addObject(ObjectsFem.makeElementFluid1D(doc)) analysis.addObject(ObjectsFem.makeElementGeometry1D(doc)) analysis.addObject(ObjectsFem.makeElementGeometry2D(doc)) analysis.addObject(ObjectsFem.makeElementRotation1D(doc)) analysis.addObject(ObjectsFem.makeMaterialFluid(doc)) mat = analysis.addObject(ObjectsFem.makeMaterialSolid(doc))[0] analysis.addObject(ObjectsFem.makeMaterialMechanicalNonlinear( doc, mat)) msh = analysis.addObject(ObjectsFem.makeMeshGmsh(doc))[0] analysis.addObject(ObjectsFem.makeMeshBoundaryLayer(doc, msh)) analysis.addObject(ObjectsFem.makeMeshGroup(doc, msh)) analysis.addObject(ObjectsFem.makeMeshRegion(doc, msh)) analysis.addObject(ObjectsFem.makeMeshNetgen(doc)) analysis.addObject(ObjectsFem.makeMeshResult(doc)) analysis.addObject(ObjectsFem.makeResultMechanical(doc)) analysis.addObject(ObjectsFem.makeSolverCalculixCcxTools(doc)) analysis.addObject(ObjectsFem.makeSolverCalculix(doc)) sol = analysis.addObject(ObjectsFem.makeSolverElmer(doc))[0] analysis.addObject(ObjectsFem.makeSolverZ88(doc)) analysis.addObject(ObjectsFem.makeEquationElasticity(doc, sol)) analysis.addObject(ObjectsFem.makeEquationElectrostatic(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFlow(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFluxsolver(doc, sol)) analysis.addObject(ObjectsFem.makeEquationHeat(doc, sol)) # TODO the equations show up twice on Tree (on solver and on analysis), if they are added to the analysis group doc.recompute() self.assertEqual(len(analysis.Group), testtools.get_defmake_count() - 1) # because of the analysis itself count -1
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # setup CalculiX cantilever, apply 9 MN on the 4 nodes of the front end face doc = setup_cantileverbase(doc, solvertype) analysis = doc.Analysis geom_obj = doc.Box # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [(geom_obj, "Vertex5"), (geom_obj, "Vertex6"), (geom_obj, "Vertex7"), (geom_obj, "Vertex8")] con_force.Force = 9000000.0 con_force.Direction = (doc.Box, ["Edge5"]) con_force.Reversed = True analysis.addObject(con_force) doc.recompute() return doc
def test_femobjects_make(self): doc = self.active_doc analysis = ObjectsFem.makeAnalysis(doc) analysis.addObject(ObjectsFem.makeConstraintBearing(doc)) analysis.addObject(ObjectsFem.makeConstraintBodyHeatSource(doc)) analysis.addObject(ObjectsFem.makeConstraintContact(doc)) analysis.addObject(ObjectsFem.makeConstraintDisplacement(doc)) analysis.addObject(ObjectsFem.makeConstraintElectrostaticPotential(doc)) analysis.addObject(ObjectsFem.makeConstraintFixed(doc)) analysis.addObject(ObjectsFem.makeConstraintFlowVelocity(doc)) analysis.addObject(ObjectsFem.makeConstraintFluidBoundary(doc)) analysis.addObject(ObjectsFem.makeConstraintForce(doc)) analysis.addObject(ObjectsFem.makeConstraintGear(doc)) analysis.addObject(ObjectsFem.makeConstraintHeatflux(doc)) analysis.addObject(ObjectsFem.makeConstraintInitialFlowVelocity(doc)) analysis.addObject(ObjectsFem.makeConstraintInitialTemperature(doc)) analysis.addObject(ObjectsFem.makeConstraintPlaneRotation(doc)) analysis.addObject(ObjectsFem.makeConstraintPressure(doc)) analysis.addObject(ObjectsFem.makeConstraintPulley(doc)) analysis.addObject(ObjectsFem.makeConstraintSelfWeight(doc)) analysis.addObject(ObjectsFem.makeConstraintTemperature(doc)) analysis.addObject(ObjectsFem.makeConstraintTransform(doc)) analysis.addObject(ObjectsFem.makeElementFluid1D(doc)) analysis.addObject(ObjectsFem.makeElementGeometry1D(doc)) analysis.addObject(ObjectsFem.makeElementGeometry2D(doc)) analysis.addObject(ObjectsFem.makeElementRotation1D(doc)) analysis.addObject(ObjectsFem.makeMaterialFluid(doc)) mat = analysis.addObject(ObjectsFem.makeMaterialSolid(doc))[0] analysis.addObject(ObjectsFem.makeMaterialMechanicalNonlinear(doc, mat)) msh = analysis.addObject(ObjectsFem.makeMeshGmsh(doc))[0] analysis.addObject(ObjectsFem.makeMeshBoundaryLayer(doc, msh)) analysis.addObject(ObjectsFem.makeMeshGroup(doc, msh)) analysis.addObject(ObjectsFem.makeMeshRegion(doc, msh)) analysis.addObject(ObjectsFem.makeMeshNetgen(doc)) analysis.addObject(ObjectsFem.makeMeshResult(doc)) analysis.addObject(ObjectsFem.makeResultMechanical(doc)) analysis.addObject(ObjectsFem.makeSolverCalculixCcxTools(doc)) analysis.addObject(ObjectsFem.makeSolverCalculix(doc)) sol = analysis.addObject(ObjectsFem.makeSolverElmer(doc))[0] analysis.addObject(ObjectsFem.makeSolverZ88(doc)) analysis.addObject(ObjectsFem.makeEquationElasticity(doc, sol)) analysis.addObject(ObjectsFem.makeEquationElectrostatic(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFlow(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFluxsolver(doc, sol)) analysis.addObject(ObjectsFem.makeEquationHeat(doc, sol)) # is = 43 (just copy in empty file to test, or run unit test case, it is printed) # TODO if the equations and gmsh mesh childs are added to the analysis, # they show up twice on Tree (on solver resp. gemsh mesh obj and on analysis) # https://forum.freecadweb.org/viewtopic.php?t=25283 doc.recompute() self.assertEqual(len(analysis.Group), testtools.get_defmake_count() - 1) # because of the analysis itself count -1
def setup(doc=None, solvertype="ccxtools"): # setup box static, add a fixed, force and a pressure constraint doc = setup_base(doc, solvertype) geom_obj = doc.Box analysis = doc.Analysis # solver if solvertype == "calculix": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0] elif solvertype == "ccxtools": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0] solver_object.WorkingDir = u"" elif solvertype == "elmer": solver_object = analysis.addObject( ObjectsFem.makeSolverElmer(doc, "SolverElmer"))[0] ObjectsFem.makeEquationElasticity(doc, solver_object) elif solvertype == "z88": analysis.addObject(ObjectsFem.makeSolverZ88(doc, "SolverZ88")) else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_object.SplitInputWriter = False solver_object.AnalysisType = "static" solver_object.GeometricalNonlinearity = "linear" solver_object.ThermoMechSteadyState = False solver_object.MatrixSolverType = "default" solver_object.IterationsControlParameterTimeUse = False # fixed_constraint fixed_constraint = analysis.addObject( ObjectsFem.makeConstraintFixed(doc, name="FemConstraintFixed"))[0] fixed_constraint.References = [(geom_obj, "Face1")] # force_constraint force_constraint = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="FemConstraintForce"))[0] force_constraint.References = [(geom_obj, "Face6")] force_constraint.Force = 40000.0 force_constraint.Direction = (geom_obj, ["Edge5"]) force_constraint.Reversed = True # pressure_constraint pressure_constraint = analysis.addObject( ObjectsFem.makeConstraintPressure(doc, name="FemConstraintPressure"))[0] pressure_constraint.References = [(geom_obj, "Face2")] pressure_constraint.Pressure = 1000.0 pressure_constraint.Reversed = False doc.recompute() return doc
def test_femobjects_make(self): doc = self.active_doc analysis = ObjectsFem.makeAnalysis(doc) analysis.addObject(ObjectsFem.makeConstraintBearing(doc)) analysis.addObject(ObjectsFem.makeConstraintBodyHeatSource(doc)) analysis.addObject(ObjectsFem.makeConstraintContact(doc)) analysis.addObject(ObjectsFem.makeConstraintDisplacement(doc)) analysis.addObject(ObjectsFem.makeConstraintElectrostaticPotential(doc)) analysis.addObject(ObjectsFem.makeConstraintFixed(doc)) analysis.addObject(ObjectsFem.makeConstraintFlowVelocity(doc)) analysis.addObject(ObjectsFem.makeConstraintFluidBoundary(doc)) analysis.addObject(ObjectsFem.makeConstraintForce(doc)) analysis.addObject(ObjectsFem.makeConstraintGear(doc)) analysis.addObject(ObjectsFem.makeConstraintHeatflux(doc)) analysis.addObject(ObjectsFem.makeConstraintInitialFlowVelocity(doc)) analysis.addObject(ObjectsFem.makeConstraintInitialTemperature(doc)) analysis.addObject(ObjectsFem.makeConstraintPlaneRotation(doc)) analysis.addObject(ObjectsFem.makeConstraintPressure(doc)) analysis.addObject(ObjectsFem.makeConstraintPulley(doc)) analysis.addObject(ObjectsFem.makeConstraintSelfWeight(doc)) analysis.addObject(ObjectsFem.makeConstraintTemperature(doc)) analysis.addObject(ObjectsFem.makeConstraintTransform(doc)) analysis.addObject(ObjectsFem.makeElementFluid1D(doc)) analysis.addObject(ObjectsFem.makeElementGeometry1D(doc)) analysis.addObject(ObjectsFem.makeElementGeometry2D(doc)) analysis.addObject(ObjectsFem.makeElementRotation1D(doc)) analysis.addObject(ObjectsFem.makeMaterialFluid(doc)) mat = analysis.addObject(ObjectsFem.makeMaterialSolid(doc))[0] analysis.addObject(ObjectsFem.makeMaterialMechanicalNonlinear(doc, mat)) msh = analysis.addObject(ObjectsFem.makeMeshGmsh(doc))[0] analysis.addObject(ObjectsFem.makeMeshBoundaryLayer(doc, msh)) analysis.addObject(ObjectsFem.makeMeshGroup(doc, msh)) analysis.addObject(ObjectsFem.makeMeshRegion(doc, msh)) analysis.addObject(ObjectsFem.makeMeshNetgen(doc)) analysis.addObject(ObjectsFem.makeMeshResult(doc)) analysis.addObject(ObjectsFem.makeResultMechanical(doc)) analysis.addObject(ObjectsFem.makeSolverCalculixCcxTools(doc)) analysis.addObject(ObjectsFem.makeSolverCalculix(doc)) sol = analysis.addObject(ObjectsFem.makeSolverElmer(doc))[0] analysis.addObject(ObjectsFem.makeSolverZ88(doc)) analysis.addObject(ObjectsFem.makeEquationElasticity(doc, sol)) analysis.addObject(ObjectsFem.makeEquationElectrostatic(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFlow(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFluxsolver(doc, sol)) analysis.addObject(ObjectsFem.makeEquationHeat(doc, sol)) # TODO the equations show up twice on Tree (on solver and on analysis), if they are added to the analysis group doc.recompute() self.assertEqual(len(analysis.Group), testtools.get_defmake_count() - 1) # because of the analysis itself count -1
def setup_static(doc=None, solver="ccxtools"): # setup box static, add a fixed, force and a pressure constraint doc = setup_base(doc, solver) box_obj = doc.Box analysis = doc.Analysis # solver # TODO How to pass multiple solver for one analysis in one doc if solver == "calculix": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") )[0] elif solver == "ccxtools": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools") )[0] solver_object.WorkingDir = u"" elif solver == "elmer": analysis.addObject(ObjectsFem.makeSolverElmer(doc, "SolverElmer")) elif solver == "z88": analysis.addObject(ObjectsFem.makeSolverZ88(doc, "SolverZ88")) if solver == "calculix" or solver == "ccxtools": solver_object.AnalysisType = "static" solver_object.GeometricalNonlinearity = "linear" solver_object.ThermoMechSteadyState = False solver_object.MatrixSolverType = "default" solver_object.IterationsControlParameterTimeUse = False # fixed_constraint fixed_constraint = analysis.addObject( ObjectsFem.makeConstraintFixed(doc, name="FemConstraintFixed") )[0] fixed_constraint.References = [(box_obj, "Face1")] # force_constraint force_constraint = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="FemConstraintForce") )[0] force_constraint.References = [(box_obj, "Face6")] force_constraint.Force = 40000.0 force_constraint.Direction = (box_obj, ["Edge5"]) force_constraint.Reversed = True # pressure_constraint pressure_constraint = analysis.addObject( ObjectsFem.makeConstraintPressure(doc, name="FemConstraintPressure") )[0] pressure_constraint.References = [(box_obj, "Face2")] pressure_constraint.Pressure = 1000.0 pressure_constraint.Reversed = False doc.recompute() return doc
def test_femobjects_isoftype(self): doc = self.active_doc from femtools.femutils import is_of_type self.assertTrue(is_of_type(ObjectsFem.makeAnalysis(doc), 'Fem::FemAnalysis')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintBearing(doc), 'Fem::ConstraintBearing')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintBodyHeatSource(doc), 'Fem::ConstraintBodyHeatSource')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintContact(doc), 'Fem::ConstraintContact')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintDisplacement(doc), 'Fem::ConstraintDisplacement')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintElectrostaticPotential(doc), 'Fem::ConstraintElectrostaticPotential')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintFixed(doc), 'Fem::ConstraintFixed')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintFlowVelocity(doc), 'Fem::ConstraintFlowVelocity')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintFluidBoundary(doc), 'Fem::ConstraintFluidBoundary')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintForce(doc), 'Fem::ConstraintForce')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintGear(doc), 'Fem::ConstraintGear')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintHeatflux(doc), 'Fem::ConstraintHeatflux')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintInitialFlowVelocity(doc), 'Fem::ConstraintInitialFlowVelocity')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintInitialTemperature(doc), 'Fem::ConstraintInitialTemperature')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintPlaneRotation(doc), 'Fem::ConstraintPlaneRotation')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintPressure(doc), 'Fem::ConstraintPressure')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintPulley(doc), 'Fem::ConstraintPulley')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintSelfWeight(doc), 'Fem::ConstraintSelfWeight')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintTemperature(doc), 'Fem::ConstraintTemperature')) self.assertTrue(is_of_type(ObjectsFem.makeConstraintTransform(doc), 'Fem::ConstraintTransform')) self.assertTrue(is_of_type(ObjectsFem.makeElementFluid1D(doc), 'Fem::FemElementFluid1D')) self.assertTrue(is_of_type(ObjectsFem.makeElementGeometry1D(doc), 'Fem::FemElementGeometry1D')) self.assertTrue(is_of_type(ObjectsFem.makeElementGeometry2D(doc), 'Fem::FemElementGeometry2D')) self.assertTrue(is_of_type(ObjectsFem.makeElementRotation1D(doc), 'Fem::FemElementRotation1D')) materialsolid = ObjectsFem.makeMaterialSolid(doc) self.assertTrue(is_of_type(ObjectsFem.makeMaterialFluid(doc), 'Fem::Material')) self.assertTrue(is_of_type(materialsolid, 'Fem::Material')) self.assertTrue(is_of_type(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'Fem::MaterialMechanicalNonlinear')) mesh = ObjectsFem.makeMeshGmsh(doc) self.assertTrue(is_of_type(mesh, 'Fem::FemMeshGmsh')) self.assertTrue(is_of_type(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'Fem::FemMeshBoundaryLayer')) self.assertTrue(is_of_type(ObjectsFem.makeMeshGroup(doc, mesh), 'Fem::FemMeshGroup')) self.assertTrue(is_of_type(ObjectsFem.makeMeshRegion(doc, mesh), 'Fem::FemMeshRegion')) self.assertTrue(is_of_type(ObjectsFem.makeMeshNetgen(doc), 'Fem::FemMeshShapeNetgenObject')) self.assertTrue(is_of_type(ObjectsFem.makeMeshResult(doc), 'Fem::FemMeshResult')) self.assertTrue(is_of_type(ObjectsFem.makeResultMechanical(doc), 'Fem::FemResultMechanical')) solverelmer = ObjectsFem.makeSolverElmer(doc) self.assertTrue(is_of_type(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverCalculixCcxTools')) self.assertTrue(is_of_type(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObjectCalculix')) self.assertTrue(is_of_type(solverelmer, 'Fem::FemSolverObjectElmer')) self.assertTrue(is_of_type(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObjectZ88')) self.assertTrue(is_of_type(ObjectsFem.makeEquationElasticity(doc, solverelmer), 'Fem::FemEquationElmerElasticity')) self.assertTrue(is_of_type(ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'Fem::FemEquationElmerElectrostatic')) self.assertTrue(is_of_type(ObjectsFem.makeEquationFlow(doc, solverelmer), 'Fem::FemEquationElmerFlow')) self.assertTrue(is_of_type(ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'Fem::FemEquationElmerFluxsolver')) self.assertTrue(is_of_type(ObjectsFem.makeEquationHeat(doc, solverelmer), 'Fem::FemEquationElmerHeat'))
def test_femobjects_derivedfromstd(self): # only the last True type is used doc = self.active_doc self.assertTrue(ObjectsFem.makeAnalysis(doc).isDerivedFrom('Fem::FemAnalysis')) self.assertTrue(ObjectsFem.makeConstraintBearing(doc).isDerivedFrom('Fem::ConstraintBearing')) self.assertTrue(ObjectsFem.makeConstraintBodyHeatSource(doc).isDerivedFrom('Fem::ConstraintPython')) self.assertTrue(ObjectsFem.makeConstraintContact(doc).isDerivedFrom('Fem::ConstraintContact')) self.assertTrue(ObjectsFem.makeConstraintDisplacement(doc).isDerivedFrom('Fem::ConstraintDisplacement')) self.assertTrue(ObjectsFem.makeConstraintElectrostaticPotential(doc).isDerivedFrom('Fem::ConstraintPython')) self.assertTrue(ObjectsFem.makeConstraintFixed(doc).isDerivedFrom('Fem::ConstraintFixed')) self.assertTrue(ObjectsFem.makeConstraintFlowVelocity(doc).isDerivedFrom('Fem::ConstraintPython')) self.assertTrue(ObjectsFem.makeConstraintFluidBoundary(doc).isDerivedFrom('Fem::ConstraintFluidBoundary')) self.assertTrue(ObjectsFem.makeConstraintForce(doc).isDerivedFrom('Fem::ConstraintForce')) self.assertTrue(ObjectsFem.makeConstraintGear(doc).isDerivedFrom('Fem::ConstraintGear')) self.assertTrue(ObjectsFem.makeConstraintHeatflux(doc).isDerivedFrom('Fem::ConstraintHeatflux')) self.assertTrue(ObjectsFem.makeConstraintInitialFlowVelocity(doc).isDerivedFrom('Fem::ConstraintPython')) self.assertTrue(ObjectsFem.makeConstraintInitialTemperature(doc).isDerivedFrom('Fem::ConstraintInitialTemperature')) self.assertTrue(ObjectsFem.makeConstraintPlaneRotation(doc).isDerivedFrom('Fem::ConstraintPlaneRotation')) self.assertTrue(ObjectsFem.makeConstraintPressure(doc).isDerivedFrom('Fem::ConstraintPressure')) self.assertTrue(ObjectsFem.makeConstraintPulley(doc).isDerivedFrom('Fem::ConstraintPulley')) self.assertTrue(ObjectsFem.makeConstraintSelfWeight(doc).isDerivedFrom('Fem::ConstraintPython')) self.assertTrue(ObjectsFem.makeConstraintTemperature(doc).isDerivedFrom('Fem::ConstraintTemperature')) self.assertTrue(ObjectsFem.makeConstraintTransform(doc).isDerivedFrom('Fem::ConstraintTransform')) self.assertTrue(ObjectsFem.makeElementFluid1D(doc).isDerivedFrom('Fem::FeaturePython')) self.assertTrue(ObjectsFem.makeElementGeometry1D(doc).isDerivedFrom('Fem::FeaturePython')) self.assertTrue(ObjectsFem.makeElementGeometry2D(doc).isDerivedFrom('Fem::FeaturePython')) self.assertTrue(ObjectsFem.makeElementRotation1D(doc).isDerivedFrom('Fem::FeaturePython')) materialsolid = ObjectsFem.makeMaterialSolid(doc) self.assertTrue(ObjectsFem.makeMaterialFluid(doc).isDerivedFrom('App::MaterialObjectPython')) self.assertTrue(materialsolid.isDerivedFrom('App::MaterialObjectPython')) self.assertTrue(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid).isDerivedFrom('Fem::FeaturePython')) mesh = ObjectsFem.makeMeshGmsh(doc) self.assertTrue(mesh.isDerivedFrom('Fem::FemMeshObjectPython')) self.assertTrue(ObjectsFem.makeMeshBoundaryLayer(doc, mesh).isDerivedFrom('Fem::FeaturePython')) self.assertTrue(ObjectsFem.makeMeshGroup(doc, mesh).isDerivedFrom('Fem::FeaturePython')) self.assertTrue(ObjectsFem.makeMeshRegion(doc, mesh).isDerivedFrom('Fem::FeaturePython')) self.assertTrue(ObjectsFem.makeMeshNetgen(doc).isDerivedFrom('Fem::FemMeshShapeNetgenObject')) self.assertTrue(ObjectsFem.makeMeshResult(doc).isDerivedFrom('Fem::FemMeshObjectPython')) self.assertTrue(ObjectsFem.makeResultMechanical(doc).isDerivedFrom('Fem::FemResultObjectPython')) solverelmer = ObjectsFem.makeSolverElmer(doc) self.assertTrue(ObjectsFem.makeSolverCalculixCcxTools(doc).isDerivedFrom('Fem::FemSolverObjectPython')) self.assertTrue(ObjectsFem.makeSolverCalculix(doc).isDerivedFrom('Fem::FemSolverObjectPython')) self.assertTrue(solverelmer.isDerivedFrom('Fem::FemSolverObjectPython')) self.assertTrue(ObjectsFem.makeSolverZ88(doc).isDerivedFrom('Fem::FemSolverObjectPython')) self.assertTrue(ObjectsFem.makeEquationElasticity(doc, solverelmer).isDerivedFrom('App::FeaturePython')) self.assertTrue(ObjectsFem.makeEquationElectrostatic(doc, solverelmer).isDerivedFrom('App::FeaturePython')) self.assertTrue(ObjectsFem.makeEquationFlow(doc, solverelmer).isDerivedFrom('App::FeaturePython')) self.assertTrue(ObjectsFem.makeEquationFluxsolver(doc, solverelmer).isDerivedFrom('App::FeaturePython')) self.assertTrue(ObjectsFem.makeEquationHeat(doc, solverelmer).isDerivedFrom('App::FeaturePython'))
def setup_cantilevernodeload(doc=None, solver='ccxtools'): # setup CalculiX cantilever, apply 9 MN on the 4 nodes of the front end face doc = setup_cantileverbase(doc, solver) # force_constraint force_constraint = doc.Analysis.addObject(ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0] force_constraint.References = [(doc.Box, "Vertex5"), (doc.Box, "Vertex6"), (doc.Box, "Vertex7"), (doc.Box, "Vertex8")] # should be possible in one tuple too force_constraint.Force = 9000000.0 force_constraint.Direction = (doc.Box, ["Edge5"]) force_constraint.Reversed = True doc.recompute() return doc
def setup_cantileverfaceload(doc=None, solver='ccxtools'): # setup CalculiX cantilever, apply 9 MN on surface of front end face doc = setup_cantileverbase(doc, solver) # force_constraint force_constraint = doc.Analysis.addObject(ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0] force_constraint.References = [(doc.Box, "Face2")] force_constraint.Force = 9000000.0 force_constraint.Direction = (doc.Box, ["Edge5"]) force_constraint.Reversed = True doc.recompute() return doc
def setup_cantileverfaceload(doc=None, solvertype="ccxtools"): # setup CalculiX cantilever, apply 9 MN on surface of front end face doc = setup_cantileverbase(doc, solvertype) # force_constraint force_constraint = doc.Analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0] force_constraint.References = [(doc.Box, "Face2")] force_constraint.Force = 9000000.0 force_constraint.Direction = (doc.Box, ["Edge5"]) force_constraint.Reversed = True doc.recompute() return doc
def setup_cantilevernodeload(doc=None, solvertype="ccxtools"): # setup CalculiX cantilever, apply 9 MN on the 4 nodes of the front end face doc = setup_cantileverbase(doc, solvertype) # force_constraint force_constraint = doc.Analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0] # should be possible in one tuple too force_constraint.References = [(doc.Box, "Vertex5"), (doc.Box, "Vertex6"), (doc.Box, "Vertex7"), (doc.Box, "Vertex8")] force_constraint.Force = 9000000.0 force_constraint.Direction = (doc.Box, ["Edge5"]) force_constraint.Reversed = True doc.recompute() return doc
def create_constraints(self, force_quant=100.0): force_constraint = ObjectsFem.makeConstraintForce(self.doc, "FemForceConstraint") force_references = [] for face in self.force_faces: force_references.append((self.doc.Geometry, face)) # print "FORCE-REFERENCES : ", force_references force_constraint.References = force_references force_constraint.Force = force_quant force_constraint.Direction = (self.doc.Geometry, self.force_dir) fixed_constraint = ObjectsFem.makeConstraintFixed(self.doc, "FemFixedConstraint") fixed_references = [] for face in self.fixed_faces: fixed_references.append((self.doc.Geometry, face)) fixed_constraint.References = fixed_references self.analysis.addObject(force_constraint) self.analysis.addObject(fixed_constraint)
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information()))) # geometric objects bottom_flange = doc.addObject("Part::Plane", "Bottom_Flange") bottom_flange.Length = 10000 bottom_flange.Width = 150 top_flange = doc.addObject("Part::Plane", "Top_Flange") top_flange.Length = 10000 top_flange.Width = 150 top_flange.Placement.Base = (0, 0, 278.6) web = doc.addObject("Part::Plane", "Top_Flange") web.Length = 10000 web.Width = 278.6 web.Placement = FreeCAD.Placement( FreeCAD.Vector(0, 75, 0), FreeCAD.Rotation(0, 0, 90), FreeCAD.Vector(0, 0, 0), ) geom_obj = doc.addObject("Part::MultiFuse", "Fusion") geom_obj.Shapes = [bottom_flange, top_flange, web] doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype) ) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "buckling" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False solver_obj.BucklingFactors = 1 analysis.addObject(solver_obj) # shell thicknesses thickness_flanges = ObjectsFem.makeElementGeometry2D(doc, 10.7, 'Thickness_Flanges') thickness_flanges.References = [(geom_obj, ("Face1", "Face2", "Face3", "Face4"))] analysis.addObject(thickness_flanges) thickness_web = ObjectsFem.makeElementGeometry2D(doc, 7.1, 'Thickness_Web') thickness_web.References = [(geom_obj, "Face5")] analysis.addObject(thickness_web) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "Steel") mat = material_obj.Material mat["Name"] = "CalculiX-Steel" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # constraints displacement con_disp_x = ObjectsFem.makeConstraintDisplacement(doc, "ConstraintDisplacement_X") con_disp_x.References = [(geom_obj, "Vertex2")] con_disp_x.xFix = True con_disp_x.xFree = False analysis.addObject(con_disp_x) con_disp_yz = ObjectsFem.makeConstraintDisplacement(doc, "ConstraintDisplacement_YZ") con_disp_yz.References = [(geom_obj, ("Edge15", "Edge16"))] con_disp_yz.yFix = True con_disp_yz.yFree = False con_disp_yz.zFix = True con_disp_yz.zFree = False analysis.addObject(con_disp_yz) # constraints force con_force_in_x = ObjectsFem.makeConstraintForce(doc, "Force_in_X") con_force_in_x.References = [(geom_obj, ("Edge3", "Edge7", "Edge8", "Edge12"))] con_force_in_x.Force = 155350 con_force_in_x.Reversed = False con_force_in_x.Direction = (geom_obj, ["Edge4"]) analysis.addObject(con_force_in_x) con_force_rev_x = ObjectsFem.makeConstraintForce(doc, "Force_rev_X") con_force_rev_x.References = [(geom_obj, ("Edge1", "Edge5", "Edge10", "Edge14"))] con_force_rev_x.Force = 155350 con_force_rev_x.Reversed = True con_force_rev_x.Direction = (geom_obj, ["Edge4"]) analysis.addObject(con_force_rev_x) # mesh from .meshes.mesh_buckling_ibeam_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False femmesh_obj.CharacteristicLengthMax = "50.0 mm" femmesh_obj.ElementDimension = "2D" doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # geometric object plate = doc.addObject("Part::Plane", "Plate") plate.Width = 10 plate.Length = 10 force_pt1 = doc.addObject("Part::Vertex", "ForcePT1") force_pt1.X = 10 force_pt1.Y = 2 force_pt2 = doc.addObject("Part::Vertex", "ForcePT2") force_pt2.X = 10 force_pt2.Y = 4 force_pt3 = doc.addObject("Part::Vertex", "ForcePT3") force_pt3.X = 10 force_pt3.Y = 6 force_pt4 = doc.addObject("Part::Vertex", "ForcePT4") force_pt4.X = 10 force_pt4.Y = 8 doc.recompute() # all geom boolean fragment geom_obj = SplitFeatures.makeBooleanFragments(name='ThePointPlate') geom_obj.Objects = [plate, force_pt1, force_pt2, force_pt3, force_pt4] doc.recompute() if FreeCAD.GuiUp: plate.ViewObject.hide() force_pt1.ViewObject.hide() force_pt2.ViewObject.hide() force_pt3.ViewObject.hide() force_pt4.ViewObject.hide() doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.PointSize = 10 geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" elif solvertype == "elmer": solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer") ObjectsFem.makeEquationElasticity(doc, solver_obj) elif solvertype == "mystran": solver_obj = ObjectsFem.makeSolverMystran(doc, "SolverMystran") elif solvertype == "z88": solver_obj = ObjectsFem.makeSolverZ88(doc, "SolverZ88") else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # shell thickness thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 0.3, 'Thickness') analysis.addObject(thickness_obj) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial") mat = material_obj.Material mat["Name"] = "CalculiX-Steel" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(geom_obj, "Edge1")] analysis.addObject(con_fixed) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [ (geom_obj, "Vertex7"), (geom_obj, "Vertex1"), (geom_obj, "Vertex2"), (geom_obj, "Vertex3"), (geom_obj, "Vertex4"), (geom_obj, "Vertex8"), ] con_force.Force = 600 # 600 N on six nodes == 100 N/Node con_force.Reversed = False con_force.Direction = (geom_obj, ["Edge2"]) analysis.addObject(con_force) # mesh from .meshes.mesh_plate_mystran_quad4 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False femmesh_obj.CharacteristicLengthMax = "1.0 mm" femmesh_obj.ElementDimension = "2D" femmesh_obj.ElementOrder = "1st" doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # geometric objects # name is important because the other method in this module use obj name box_obj1 = doc.addObject("Part::Box", "Box1") box_obj1.Height = 10 box_obj1.Width = 10 box_obj1.Length = 20 box_obj2 = doc.addObject("Part::Box", "Box2") box_obj2.Height = 10 box_obj2.Width = 10 box_obj2.Length = 20 box_obj2.Placement.Base = (20, 0, 0) box_obj3 = doc.addObject("Part::Box", "Box3") box_obj3.Height = 10 box_obj3.Width = 10 box_obj3.Length = 20 box_obj3.Placement.Base = (40, 0, 0) box_obj4 = doc.addObject("Part::Box", "Box4") box_obj4.Height = 10 box_obj4.Width = 10 box_obj4.Length = 20 box_obj4.Placement.Base = (60, 0, 0) box_obj5 = doc.addObject("Part::Box", "Box5") box_obj5.Height = 10 box_obj5.Width = 10 box_obj5.Length = 20 box_obj5.Placement.Base = (80, 0, 0) # make a CompSolid out of the boxes, to be able to remesh with GUI j = BOPTools.SplitFeatures.makeBooleanFragments(name="BooleanFragments") j.Objects = [box_obj1, box_obj2, box_obj3, box_obj4, box_obj5] j.Mode = "CompSolid" j.Proxy.execute(j) j.purgeTouched() doc.recompute() if FreeCAD.GuiUp: for obj in j.ViewObject.Proxy.claimChildren(): obj.ViewObject.hide() geom_obj = doc.addObject("Part::Feature", "CompSolid") geom_obj.Shape = j.Shape.CompSolids[0] if FreeCAD.GuiUp: j.ViewObject.hide() doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # material material_obj1 = ObjectsFem.makeMaterialSolid(doc, "FemMaterial1") material_obj1.References = [(doc.Box3, "Solid1")] mat = material_obj1.Material mat["Name"] = "Concrete-Generic" mat["YoungsModulus"] = "32000 MPa" mat["PoissonRatio"] = "0.17" material_obj1.Material = mat analysis.addObject(material_obj1) material_obj2 = ObjectsFem.makeMaterialSolid(doc, "FemMaterial2") material_obj2.References = [(doc.Box2, "Solid1"), (doc.Box4, "Solid1")] mat = material_obj2.Material mat["Name"] = "PLA" mat["YoungsModulus"] = "3640 MPa" mat["PoissonRatio"] = "0.36" material_obj2.Material = mat analysis.addObject(material_obj2) material_obj3 = ObjectsFem.makeMaterialSolid(doc, "FemMaterial3") material_obj3.References = [] mat = material_obj3.Material mat["Name"] = "Steel-Generic" mat["YoungsModulus"] = "200000 MPa" mat["PoissonRatio"] = "0.30" material_obj3.Material = mat analysis.addObject(material_obj3) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(doc.Box1, "Face1"), (doc.Box5, "Face2")] analysis.addObject(con_fixed) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [(doc.Box1, "Face6"), (doc.Box2, "Face6"), (doc.Box3, "Face6"), (doc.Box4, "Face6"), (doc.Box5, "Face6")] con_force.Force = 10000.00 con_force.Direction = (doc.Box1, ["Edge1"]) con_force.Reversed = True analysis.addObject(con_force) # mesh from .meshes.mesh_multibodybeam_tetra10 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # setup box static, add a fixed, force and a pressure constraint doc = setup_boxanalysisbase(doc, solvertype) geom_obj = doc.Box analysis = doc.Analysis # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" elif solvertype == "elmer": solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer") ObjectsFem.makeEquationElasticity(doc, solver_obj) else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "FemConstraintFixed") con_fixed.References = [(geom_obj, "Face1")] analysis.addObject(con_fixed) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "FemConstraintForce") con_force.References = [(geom_obj, "Face6")] con_force.Force = 40000.0 con_force.Direction = (geom_obj, ["Edge5"]) con_force.Reversed = True analysis.addObject(con_force) # constraint pressure con_pressure = ObjectsFem.makeConstraintPressure( doc, name="FemConstraintPressure") con_pressure.References = [(geom_obj, "Face2")] con_pressure.Pressure = 1000.0 con_pressure.Reversed = False analysis.addObject(con_pressure) doc.recompute() return doc
def test_femobjects_derivedfromfem(self): # try to add all possible True types from inheritance chain see https://forum.freecadweb.org/viewtopic.php?f=10&t=32625 doc = self.active_doc from femtools.femutils import is_derived_from materialsolid = ObjectsFem.makeMaterialSolid(doc) mesh = ObjectsFem.makeMeshGmsh(doc) solverelmer = ObjectsFem.makeSolverElmer(doc) self.assertTrue(is_derived_from(ObjectsFem.makeAnalysis(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeAnalysis(doc), 'Fem::FemAnalysis')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintBearing(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintBearing(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintBearing(doc), 'Fem::ConstraintBearing')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintBodyHeatSource(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintBodyHeatSource(doc), 'Fem::ConstraintPython')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintBodyHeatSource(doc), 'Fem::ConstraintBodyHeatSource')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintContact(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintContact(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintContact(doc), 'Fem::ConstraintContact')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintDisplacement(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintDisplacement(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintDisplacement(doc), 'Fem::ConstraintDisplacement')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintElectrostaticPotential(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintElectrostaticPotential(doc), 'Fem::ConstraintPython')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintElectrostaticPotential(doc), 'Fem::ConstraintElectrostaticPotential')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFixed(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFixed(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFixed(doc), 'Fem::ConstraintFixed')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFlowVelocity(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFlowVelocity(doc), 'Fem::ConstraintPython')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFlowVelocity(doc), 'Fem::ConstraintFlowVelocity')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFluidBoundary(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFluidBoundary(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintFluidBoundary(doc), 'Fem::ConstraintFluidBoundary')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintForce(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintForce(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintForce(doc), 'Fem::ConstraintForce')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintGear(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintGear(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintGear(doc), 'Fem::ConstraintGear')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintHeatflux(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintHeatflux(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintHeatflux(doc), 'Fem::ConstraintHeatflux')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintInitialFlowVelocity(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintInitialFlowVelocity(doc), 'Fem::ConstraintPython')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintInitialFlowVelocity(doc), 'Fem::ConstraintInitialFlowVelocity')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintInitialTemperature(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintInitialTemperature(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintInitialTemperature(doc), 'Fem::ConstraintInitialTemperature')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPlaneRotation(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPlaneRotation(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPlaneRotation(doc), 'Fem::ConstraintPlaneRotation')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPressure(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPressure(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPressure(doc), 'Fem::ConstraintPressure')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPulley(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPulley(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintPulley(doc), 'Fem::ConstraintPulley')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintSelfWeight(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintSelfWeight(doc), 'Fem::ConstraintPython')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintSelfWeight(doc), 'Fem::ConstraintSelfWeight')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTemperature(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTemperature(doc), 'Fem::Constraint')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTemperature(doc), 'Fem::ConstraintTemperature')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTransform(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeConstraintTransform(doc), 'Fem::ConstraintTransform')) self.assertTrue(is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'Fem::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'Fem::FemElementFluid1D')) self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'Fem::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'Fem::FemElementGeometry1D')) self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'Fem::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'Fem::FemElementGeometry2D')) self.assertTrue(is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'Fem::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'Fem::FemElementRotation1D')) self.assertTrue(is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'App::MaterialObjectPython')) self.assertTrue(is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'Fem::Material')) self.assertTrue(is_derived_from(materialsolid, 'App::DocumentObject')) self.assertTrue(is_derived_from(materialsolid, 'App::MaterialObjectPython')) self.assertTrue(is_derived_from(materialsolid, 'Fem::Material')) self.assertTrue(is_derived_from(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'Fem::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'Fem::MaterialMechanicalNonlinear')) self.assertTrue(is_derived_from(mesh, 'App::DocumentObject')) self.assertTrue(is_derived_from(mesh, 'Fem::FemMeshObjectPython')) self.assertTrue(is_derived_from(mesh, 'Fem::FemMeshGmsh')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'Fem::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'Fem::FemMeshBoundaryLayer')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'Fem::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'Fem::FemMeshGroup')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'Fem::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'Fem::FemMeshRegion')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshNetgen(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshNetgen(doc), 'Fem::FemMeshShapeNetgenObject')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshResult(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshResult(doc), 'Fem::FemMeshObjectPython')) self.assertTrue(is_derived_from(ObjectsFem.makeMeshResult(doc), 'Fem::FemMeshResult')) self.assertTrue(is_derived_from(ObjectsFem.makeResultMechanical(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeResultMechanical(doc), 'Fem::FemResultObjectPython')) self.assertTrue(is_derived_from(ObjectsFem.makeResultMechanical(doc), 'Fem::FemResultMechanical')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverObject')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverObjectPython')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverCalculixCcxTools')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObject')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObjectPython')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObjectCalculix')) self.assertTrue(is_derived_from(solverelmer, 'App::DocumentObject')) self.assertTrue(is_derived_from(solverelmer, 'Fem::FemSolverObject')) self.assertTrue(is_derived_from(solverelmer, 'Fem::FemSolverObjectPython')) self.assertTrue(is_derived_from(solverelmer, 'Fem::FemSolverObjectElmer')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverZ88(doc), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObject')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObjectPython')) self.assertTrue(is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObjectZ88')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationElasticity(doc, solverelmer), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationElasticity(doc, solverelmer), 'App::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationElasticity(doc, solverelmer), 'Fem::FemEquationElmerElasticity')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'App::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'Fem::FemEquationElmerElectrostatic')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'App::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'Fem::FemEquationElmerFlow')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'App::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'Fem::FemEquationElmerFluxsolver')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'App::DocumentObject')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'App::FeaturePython')) self.assertTrue(is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'Fem::FemEquationElmerHeat'))
def test_femobjects_type(self): doc = self.active_doc from femtools.femutils import type_of_obj self.assertEqual("Fem::FemAnalysis", type_of_obj(ObjectsFem.makeAnalysis(doc))) self.assertEqual("Fem::ConstraintBearing", type_of_obj(ObjectsFem.makeConstraintBearing(doc))) self.assertEqual( "Fem::ConstraintBodyHeatSource", type_of_obj(ObjectsFem.makeConstraintBodyHeatSource(doc))) self.assertEqual("Fem::ConstraintContact", type_of_obj(ObjectsFem.makeConstraintContact(doc))) self.assertEqual( "Fem::ConstraintDisplacement", type_of_obj(ObjectsFem.makeConstraintDisplacement(doc))) self.assertEqual( "Fem::ConstraintElectrostaticPotential", type_of_obj(ObjectsFem.makeConstraintElectrostaticPotential(doc))) self.assertEqual("Fem::ConstraintFixed", type_of_obj(ObjectsFem.makeConstraintFixed(doc))) self.assertEqual( "Fem::ConstraintFlowVelocity", type_of_obj(ObjectsFem.makeConstraintFlowVelocity(doc))) self.assertEqual( "Fem::ConstraintFluidBoundary", type_of_obj(ObjectsFem.makeConstraintFluidBoundary(doc))) self.assertEqual("Fem::ConstraintForce", type_of_obj(ObjectsFem.makeConstraintForce(doc))) self.assertEqual("Fem::ConstraintGear", type_of_obj(ObjectsFem.makeConstraintGear(doc))) self.assertEqual("Fem::ConstraintHeatflux", type_of_obj(ObjectsFem.makeConstraintHeatflux(doc))) self.assertEqual( "Fem::ConstraintInitialFlowVelocity", type_of_obj(ObjectsFem.makeConstraintInitialFlowVelocity(doc))) self.assertEqual( "Fem::ConstraintInitialTemperature", type_of_obj(ObjectsFem.makeConstraintInitialTemperature(doc))) self.assertEqual( "Fem::ConstraintPlaneRotation", type_of_obj(ObjectsFem.makeConstraintPlaneRotation(doc))) self.assertEqual("Fem::ConstraintPressure", type_of_obj(ObjectsFem.makeConstraintPressure(doc))) self.assertEqual("Fem::ConstraintPulley", type_of_obj(ObjectsFem.makeConstraintPulley(doc))) self.assertEqual("Fem::ConstraintSelfWeight", type_of_obj(ObjectsFem.makeConstraintSelfWeight(doc))) self.assertEqual( "Fem::ConstraintTemperature", type_of_obj(ObjectsFem.makeConstraintTemperature(doc))) self.assertEqual("Fem::ConstraintTransform", type_of_obj(ObjectsFem.makeConstraintTransform(doc))) self.assertEqual("Fem::FemElementFluid1D", type_of_obj(ObjectsFem.makeElementFluid1D(doc))) self.assertEqual("Fem::FemElementGeometry1D", type_of_obj(ObjectsFem.makeElementGeometry1D(doc))) self.assertEqual("Fem::FemElementGeometry2D", type_of_obj(ObjectsFem.makeElementGeometry2D(doc))) self.assertEqual("Fem::FemElementRotation1D", type_of_obj(ObjectsFem.makeElementRotation1D(doc))) materialsolid = ObjectsFem.makeMaterialSolid(doc) self.assertEqual("Fem::Material", type_of_obj(ObjectsFem.makeMaterialFluid(doc))) self.assertEqual("Fem::Material", type_of_obj(materialsolid)) self.assertEqual( "Fem::MaterialMechanicalNonlinear", type_of_obj( ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid))) self.assertEqual("Fem::MaterialReinforced", type_of_obj(ObjectsFem.makeMaterialReinforced(doc))) mesh = ObjectsFem.makeMeshGmsh(doc) self.assertEqual("Fem::FemMeshGmsh", type_of_obj(mesh)) self.assertEqual( "Fem::FemMeshBoundaryLayer", type_of_obj(ObjectsFem.makeMeshBoundaryLayer(doc, mesh))) self.assertEqual("Fem::FemMeshGroup", type_of_obj(ObjectsFem.makeMeshGroup(doc, mesh))) self.assertEqual("Fem::FemMeshRegion", type_of_obj(ObjectsFem.makeMeshRegion(doc, mesh))) self.assertEqual("Fem::FemMeshShapeNetgenObject", type_of_obj(ObjectsFem.makeMeshNetgen(doc))) self.assertEqual("Fem::FemMeshResult", type_of_obj(ObjectsFem.makeMeshResult(doc))) self.assertEqual("Fem::FemResultMechanical", type_of_obj(ObjectsFem.makeResultMechanical(doc))) solverelmer = ObjectsFem.makeSolverElmer(doc) self.assertEqual( "Fem::FemSolverCalculixCcxTools", type_of_obj(ObjectsFem.makeSolverCalculixCcxTools(doc))) self.assertEqual("Fem::FemSolverObjectCalculix", type_of_obj(ObjectsFem.makeSolverCalculix(doc))) self.assertEqual("Fem::FemSolverObjectElmer", type_of_obj(solverelmer)) self.assertEqual("Fem::FemSolverObjectZ88", type_of_obj(ObjectsFem.makeSolverZ88(doc))) self.assertEqual( "Fem::FemEquationElmerElasticity", type_of_obj(ObjectsFem.makeEquationElasticity(doc, solverelmer))) self.assertEqual( "Fem::FemEquationElmerElectrostatic", type_of_obj(ObjectsFem.makeEquationElectrostatic(doc, solverelmer))) self.assertEqual( "Fem::FemEquationElmerFlow", type_of_obj(ObjectsFem.makeEquationFlow(doc, solverelmer))) self.assertEqual( "Fem::FemEquationElmerFluxsolver", type_of_obj(ObjectsFem.makeEquationFluxsolver(doc, solverelmer))) self.assertEqual( "Fem::FemEquationElmerHeat", type_of_obj(ObjectsFem.makeEquationHeat(doc, solverelmer)))
def setup(doc=None, solvertype="ccxtools"): # setup reinfoced wall in 2D if doc is None: doc = init_doc() # part from FreeCAD import Vector as vec import Part from Part import makeLine as ln v1 = vec(0, -2000, 0) v2 = vec(500, -2000, 0) v3 = vec(500, 0, 0) v4 = vec(3500, 0, 0) v5 = vec(3500, -2000, 0) v6 = vec(4000, -2000, 0) v7 = vec(4000, 2000, 0) v8 = vec(0, 2000, 0) l1 = ln(v1, v2) l2 = ln(v2, v3) l3 = ln(v3, v4) l4 = ln(v4, v5) l5 = ln(v5, v6) l6 = ln(v6, v7) l7 = ln(v7, v8) l8 = ln(v8, v1) rcwall = doc.addObject("Part::Feature", "FIB_Wall") rcwall.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8])) doc.recompute() if FreeCAD.GuiUp: import FreeCADGui FreeCADGui.ActiveDocument.activeView().viewAxonometric() FreeCADGui.SendMsgToActiveView("ViewFit") # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0] elif solvertype == "ccxtools": solver = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0] solver.WorkingDir = u"" if solvertype == "calculix" or solvertype == "ccxtools": solver.AnalysisType = "static" solver.GeometricalNonlinearity = "linear" solver.ThermoMechSteadyState = False solver.MatrixSolverType = "default" solver.IterationsControlParameterTimeUse = False # shell thickness thickness = analysis.addObject( ObjectsFem.makeElementGeometry2D(doc, 0, "ShellThickness"))[0] thickness.Thickness = 150.0 # material matrixprop = {} matrixprop["Name"] = "Concrete-EN-C35/45" matrixprop["YoungsModulus"] = "32000 MPa" matrixprop["PoissonRatio"] = "0.17" matrixprop["CompressiveStrength"] = "15.75 MPa" # make some hint on the possible angle units in material system matrixprop["AngleOfFriction"] = "30 deg" matrixprop["Density"] = "2500 kg/m^3" reinfoprop = {} reinfoprop["Name"] = "Reinforcement-FIB-B500" reinfoprop["YieldStrength"] = "315 MPa" # not an official FreeCAD material property reinfoprop["ReinforcementRatio"] = "0.0" material_reinforced = analysis.addObject( ObjectsFem.makeMaterialReinforced(doc, "MaterialReinforced"))[0] material_reinforced.Material = matrixprop material_reinforced.Reinforcement = reinfoprop # fixed_constraint fixed_constraint = analysis.addObject( ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed"))[0] fixed_constraint.References = [(rcwall, "Edge1"), (rcwall, "Edge5")] # force constraint force_constraint = doc.Analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0] force_constraint.References = [(rcwall, "Edge7")] force_constraint.Force = 1000000.0 force_constraint.Direction = (rcwall, ["Edge8"]) force_constraint.Reversed = False # displacement_constraint displacement_constraint = doc.Analysis.addObject( ObjectsFem.makeConstraintDisplacement( doc, name="ConstraintDisplacmentPrescribed"))[0] displacement_constraint.References = [(rcwall, "Face1")] displacement_constraint.zFix = True # mesh from .meshes.mesh_rc_wall_2d_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( doc.addObject("Fem::FemMeshObject", mesh_name))[0] femmesh_obj.FemMesh = fem_mesh doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # geometric object geom_obj = doc.addObject("Part::Plane", "Plate") geom_obj.Width = 6000 geom_obj.Length = 8000 doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "buckling" solver_obj.BucklingFactors = 10 solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False solver_obj.BucklingFactors = 1 analysis.addObject(solver_obj) # shell thickness thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 50, 'Thickness') analysis.addObject(thickness_obj) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "Steel") mat = material_obj.Material mat["Name"] = "CalculiX-Steel" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # constraints displacement con_disp_x = ObjectsFem.makeConstraintDisplacement( doc, "ConstraintDisplacement_X") con_disp_x.References = [(geom_obj, "Edge1")] con_disp_x.xFix = True con_disp_x.xFree = False analysis.addObject(con_disp_x) con_disp_y = ObjectsFem.makeConstraintDisplacement( doc, "ConstraintDisplacement_Y") con_disp_y.References = [(geom_obj, "Vertex1")] con_disp_y.yFix = True con_disp_y.yFree = False analysis.addObject(con_disp_y) con_disp_z = ObjectsFem.makeConstraintDisplacement( doc, "ConstraintDisplacement_Z") con_disp_z.References = [ (geom_obj, "Edge1"), (geom_obj, "Edge2"), (geom_obj, "Edge3"), (geom_obj, "Edge4"), ] con_disp_z.zFix = True con_disp_z.zFree = False analysis.addObject(con_disp_z) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [(geom_obj, "Edge3")] con_force.Force = 17162160 # 17'162.16 N con_force.Reversed = True con_force.Direction = (geom_obj, ["Edge2"]) analysis.addObject(con_force) # mesh from .meshes.mesh_buckling_plate_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False femmesh_obj.CharacteristicLengthMax = "300.0 mm" femmesh_obj.ElementDimension = "2D" doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): if doc is None: doc = init_doc() # geometry object # name is important because the other method in this module use obj name l1 = Part.makeLine((-142.5, -142.5, 0), (142.5, -142.5, 0)) l2 = Part.makeLine((142.5, -142.5, 0), (142.5, 142.5, 0)) l3 = Part.makeLine((142.5, 142.5, 0), (-142.5, 142.5, 0)) l4 = Part.makeLine((-142.5, 142.5, 0), (-142.5, -142.5, 0)) wire = Part.Wire([l1, l2, l3, l4]) shape = wire.extrude(Vector(0, 0, 1000)) geom_obj = doc.addObject('Part::Feature', 'SquareTube') geom_obj.Shape = shape points_forces = [] points_forces.append(Part.Vertex(-142.5, 142.5, 0.0)) points_forces.append(Part.Vertex(-142.5, -142.5, 0.0)) points_forces.append(Part.Vertex(-142.5, 95.0, 0.0)) points_forces.append(Part.Vertex(-142.5, 47.5, 0.0)) points_forces.append(Part.Vertex(-142.5, 0.0, 0.0)) points_forces.append(Part.Vertex(-142.5, -47.5, 0.0)) points_forces.append(Part.Vertex(-142.5, -95.0, 0.0)) points_forces.append(Part.Vertex(142.5, -142.5, 0.0)) points_forces.append(Part.Vertex(-95.0, -142.5, 0.0)) points_forces.append(Part.Vertex(-47.5, -142.5, 0.0)) points_forces.append(Part.Vertex(0.0, -142.5, 0.0)) points_forces.append(Part.Vertex(47.5, -142.5, 0.0)) points_forces.append(Part.Vertex(95.0, -142.5, 0.0)) points_forces.append(Part.Vertex(142.5, 142.5, 0.0)) points_forces.append(Part.Vertex(142.5, -95.0, 0.0)) points_forces.append(Part.Vertex(142.5, -47.5, 0.0)) points_forces.append(Part.Vertex(142.5, 0.0, 0.0)) points_forces.append(Part.Vertex(142.5, 47.5, 0.0)) points_forces.append(Part.Vertex(142.5, 95.0, 0.0)) points_forces.append(Part.Vertex(95.0, 142.5, 0.0)) points_forces.append(Part.Vertex(47.5, 142.5, 0.0)) points_forces.append(Part.Vertex(0.0, 142.5, 0.0)) points_forces.append(Part.Vertex(-47.5, 142.5, 0.0)) points_forces.append(Part.Vertex(-95.0, 142.5, 0.0)) points_forces.append(Part.Vertex(-142.5, 118.75, 0.0)) points_forces.append(Part.Vertex(-142.5, -118.75, 0.0)) points_forces.append(Part.Vertex(-142.5, 71.25, 0.0)) points_forces.append(Part.Vertex(-142.5, 23.75, 0.0)) points_forces.append(Part.Vertex(-142.5, -23.75, 0.0)) points_forces.append(Part.Vertex(-142.5, -71.25, 0.0)) points_forces.append(Part.Vertex(118.75, -142.5, 0.0)) points_forces.append(Part.Vertex(-71.25, -142.5, 0.0)) points_forces.append(Part.Vertex(-118.75, -142.5, 0.0)) points_forces.append(Part.Vertex(-23.75, -142.5, 0.0)) points_forces.append(Part.Vertex(23.75, -142.5, 0.0)) points_forces.append(Part.Vertex(71.25, -142.5, 0.0)) points_forces.append(Part.Vertex(142.5, 118.75, 0.0)) points_forces.append(Part.Vertex(142.5, -71.25, 0.0)) points_forces.append(Part.Vertex(142.5, -118.75, 0.0)) points_forces.append(Part.Vertex(142.5, -23.75, 0.0)) points_forces.append(Part.Vertex(142.5, 23.75, 0.0)) points_forces.append(Part.Vertex(142.5, 71.25, 0.0)) points_forces.append(Part.Vertex(71.25, 142.5, 0.0)) points_forces.append(Part.Vertex(118.75, 142.5, 0.0)) points_forces.append(Part.Vertex(23.75, 142.5, 0.0)) points_forces.append(Part.Vertex(-23.75, 142.5, 0.0)) points_forces.append(Part.Vertex(-71.25, 142.5, 0.0)) points_forces.append(Part.Vertex(-118.75, 142.5, 0.0)) points_fixes = [] points_fixes.append(Part.Vertex(-142.5, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 95.0, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 47.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 0.0, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -47.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -95.0, 1000.0)) points_fixes.append(Part.Vertex(142.5, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-95.0, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-47.5, -142.5, 1000.0)) points_fixes.append(Part.Vertex(0.0, -142.5, 1000.0)) points_fixes.append(Part.Vertex(47.5, -142.5, 1000.0)) points_fixes.append(Part.Vertex(95.0, -142.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, 142.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, -95.0, 1000.0)) points_fixes.append(Part.Vertex(142.5, -47.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, 0.0, 1000.0)) points_fixes.append(Part.Vertex(142.5, 47.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, 95.0, 1000.0)) points_fixes.append(Part.Vertex(95.0, 142.5, 1000.0)) points_fixes.append(Part.Vertex(47.5, 142.5, 1000.0)) points_fixes.append(Part.Vertex(0.0, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-47.5, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-95.0, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 118.75, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -118.75, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 71.25, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 23.75, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -23.75, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -71.25, 1000.0)) points_fixes.append(Part.Vertex(118.75, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-71.25, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-118.75, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-23.75, -142.5, 1000.0)) points_fixes.append(Part.Vertex(23.75, -142.5, 1000.0)) points_fixes.append(Part.Vertex(71.25, -142.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, 118.75, 1000.0)) points_fixes.append(Part.Vertex(142.5, -71.25, 1000.0)) points_fixes.append(Part.Vertex(142.5, -118.75, 1000.0)) points_fixes.append(Part.Vertex(142.5, -23.75, 1000.0)) points_fixes.append(Part.Vertex(142.5, 23.75, 1000.0)) points_fixes.append(Part.Vertex(142.5, 71.25, 1000.0)) points_fixes.append(Part.Vertex(71.25, 142.5, 1000.0)) points_fixes.append(Part.Vertex(118.75, 142.5, 1000.0)) points_fixes.append(Part.Vertex(23.75, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-23.75, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-71.25, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-118.75, 142.5, 1000.0)) forces_obj = doc.addObject('Part::Feature', 'Forces') forces_obj.Shape = Part.makeCompound(points_forces) fixes_obj = doc.addObject('Part::Feature', 'Fixes') fixes_obj.Shape = Part.makeCompound(points_fixes) doc.recompute() if FreeCAD.GuiUp: forces_obj.ViewObject.PointColor = (1.0, 0.0, 0.0, 0.0) forces_obj.ViewObject.PointSize = 10.0 fixes_obj.ViewObject.PointColor = (1.0, 0.0, 0.0, 0.0) fixes_obj.ViewObject.PointSize = 10.0 geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0] elif solvertype == "ccxtools": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0] solver_object.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_object.SplitInputWriter = False solver_object.AnalysisType = "static" solver_object.GeometricalNonlinearity = "linear" solver_object.ThermoMechSteadyState = False solver_object.MatrixSolverType = "default" solver_object.IterationsControlParameterTimeUse = False # shell thickness thickness = analysis.addObject( ObjectsFem.makeElementGeometry2D(doc, 0, "ShellThickness"))[0] thickness.Thickness = 15.0 # material material_object = analysis.addObject( ObjectsFem.makeMaterialSolid(doc, "FemMaterial"))[0] mat = material_object.Material mat["Name"] = "Steel-Generic" mat["YoungsModulus"] = "200000 MPa" mat["PoissonRatio"] = "0.30" mat["Density"] = "7900 kg/m^3" material_object.Material = mat # fixed_constraint fixed_constraint = analysis.addObject( ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed"))[0] fixed_constraint.References = [(doc.Fixes, 'Vertex6'), (doc.Fixes, 'Vertex15'), (doc.Fixes, 'Vertex5'), (doc.Fixes, 'Vertex29'), (doc.Fixes, 'Vertex42'), (doc.Fixes, 'Vertex30'), (doc.Fixes, 'Vertex9'), (doc.Fixes, 'Vertex31'), (doc.Fixes, 'Vertex33'), (doc.Fixes, 'Vertex32'), (doc.Fixes, 'Vertex3'), (doc.Fixes, 'Vertex34'), (doc.Fixes, 'Vertex46'), (doc.Fixes, 'Vertex1'), (doc.Fixes, 'Vertex36'), (doc.Fixes, 'Vertex11'), (doc.Fixes, 'Vertex38'), (doc.Fixes, 'Vertex12'), (doc.Fixes, 'Vertex39'), (doc.Fixes, 'Vertex13'), (doc.Fixes, 'Vertex40'), (doc.Fixes, 'Vertex16'), (doc.Fixes, 'Vertex35'), (doc.Fixes, 'Vertex14'), (doc.Fixes, 'Vertex47'), (doc.Fixes, 'Vertex20'), (doc.Fixes, 'Vertex37'), (doc.Fixes, 'Vertex18'), (doc.Fixes, 'Vertex41'), (doc.Fixes, 'Vertex17'), (doc.Fixes, 'Vertex10'), (doc.Fixes, 'Vertex26'), (doc.Fixes, 'Vertex43'), (doc.Fixes, 'Vertex21'), (doc.Fixes, 'Vertex44'), (doc.Fixes, 'Vertex19'), (doc.Fixes, 'Vertex4'), (doc.Fixes, 'Vertex28'), (doc.Fixes, 'Vertex48'), (doc.Fixes, 'Vertex22'), (doc.Fixes, 'Vertex8'), (doc.Fixes, 'Vertex23'), (doc.Fixes, 'Vertex7'), (doc.Fixes, 'Vertex24'), (doc.Fixes, 'Vertex45'), (doc.Fixes, 'Vertex27'), (doc.Fixes, 'Vertex2'), (doc.Fixes, 'Vertex25')] # force_constraint1 force_constraint1 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce1"))[0] force_constraint1.References = [(forces_obj, 'Vertex1'), (forces_obj, 'Vertex14')] force_constraint1.Force = 5555.56 force_constraint1.Direction = (doc.SquareTube, ["Edge9"]) force_constraint1.Reversed = False # force_constraint2 force_constraint2 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce2"))[0] force_constraint2.References = [(forces_obj, 'Vertex2'), (forces_obj, 'Vertex8')] force_constraint2.Force = 5555.56 force_constraint2.Direction = (doc.SquareTube, ["Edge3"]) force_constraint2.Reversed = False # force_constraint3 force_constraint3 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce3"))[0] force_constraint3.References = [ (forces_obj, 'Vertex20'), (forces_obj, 'Vertex21'), (forces_obj, 'Vertex22'), (forces_obj, 'Vertex23'), (forces_obj, 'Vertex24'), ] force_constraint3.Force = 27777.78 force_constraint3.Direction = (doc.SquareTube, ["Edge9"]) force_constraint3.Reversed = False # force_constraint4 force_constraint4 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce4"))[0] force_constraint4.References = [ (forces_obj, 'Vertex9'), (forces_obj, 'Vertex10'), (forces_obj, 'Vertex11'), (forces_obj, 'Vertex12'), (forces_obj, 'Vertex13'), ] force_constraint4.Force = 27777.78 force_constraint4.Direction = (doc.SquareTube, ["Edge3"]) force_constraint4.Reversed = False # force_constraint5 force_constraint5 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce5"))[0] force_constraint5.References = [ (forces_obj, 'Vertex43'), (forces_obj, 'Vertex44'), (forces_obj, 'Vertex45'), (forces_obj, 'Vertex46'), (forces_obj, 'Vertex47'), (forces_obj, 'Vertex48'), ] force_constraint5.Force = 66666.67 force_constraint5.Direction = (doc.SquareTube, ["Edge9"]) force_constraint5.Reversed = False # force_constraint6 force_constraint6 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce6"))[0] force_constraint6.References = [ (forces_obj, 'Vertex31'), (forces_obj, 'Vertex32'), (forces_obj, 'Vertex33'), (forces_obj, 'Vertex34'), (forces_obj, 'Vertex35'), (forces_obj, 'Vertex36'), ] force_constraint6.Force = 66666.67 force_constraint6.Direction = (doc.SquareTube, ["Edge3"]) force_constraint6.Reversed = False # force_constraint7 force_constraint7 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce7"))[0] force_constraint7.References = [(forces_obj, 'Vertex1'), (forces_obj, 'Vertex2')] force_constraint7.Force = 5555.56 force_constraint7.Direction = (doc.SquareTube, ["Edge11"]) force_constraint7.Reversed = False # force_constraint8 force_constraint8 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce8"))[0] force_constraint8.References = [(forces_obj, 'Vertex8'), (forces_obj, 'Vertex14')] force_constraint8.Force = 5555.56 force_constraint8.Direction = (doc.SquareTube, ["Edge6"]) force_constraint8.Reversed = False # force_constraint9 force_constraint9 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce9"))[0] force_constraint9.References = [ (forces_obj, 'Vertex3'), (forces_obj, 'Vertex4'), (forces_obj, 'Vertex5'), (forces_obj, 'Vertex6'), (forces_obj, 'Vertex7'), ] force_constraint9.Force = 27777.78 force_constraint9.Direction = (doc.SquareTube, ["Edge11"]) force_constraint9.Reversed = False # force_constraint10 force_constraint10 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce10"))[0] force_constraint10.References = [ (forces_obj, 'Vertex15'), (forces_obj, 'Vertex16'), (forces_obj, 'Vertex17'), (forces_obj, 'Vertex18'), (forces_obj, 'Vertex19'), ] force_constraint10.Force = 27777.78 force_constraint10.Direction = (doc.SquareTube, ["Edge6"]) force_constraint10.Reversed = False # force_constraint11 force_constraint11 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce11"))[0] force_constraint11.References = [ (forces_obj, 'Vertex25'), (forces_obj, 'Vertex26'), (forces_obj, 'Vertex27'), (forces_obj, 'Vertex28'), (forces_obj, 'Vertex29'), (forces_obj, 'Vertex30'), ] force_constraint11.Force = 66666.67 force_constraint11.Direction = (doc.SquareTube, ["Edge11"]) force_constraint11.Reversed = False # force_constraint12 force_constraint12 = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce12"))[0] force_constraint12.References = [ (forces_obj, 'Vertex37'), (forces_obj, 'Vertex38'), (forces_obj, 'Vertex39'), (forces_obj, 'Vertex40'), (forces_obj, 'Vertex41'), (forces_obj, 'Vertex42'), ] force_constraint12.Force = 66666.67 force_constraint12.Direction = (doc.SquareTube, ["Edge6"]) force_constraint12.Reversed = False # mesh from .meshes.mesh_square_pipe_end_twisted_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # geometric object # name is important because the other method in this module use obj name l1 = Part.makeLine((-142.5, -142.5, 0), (142.5, -142.5, 0)) l2 = Part.makeLine((142.5, -142.5, 0), (142.5, 142.5, 0)) l3 = Part.makeLine((142.5, 142.5, 0), (-142.5, 142.5, 0)) l4 = Part.makeLine((-142.5, 142.5, 0), (-142.5, -142.5, 0)) wire = Part.Wire([l1, l2, l3, l4]) shape = wire.extrude(Vector(0, 0, 1000)) geom_obj = doc.addObject('Part::Feature', 'SquareTube') geom_obj.Shape = shape points_forces = [] points_forces.append(Part.Vertex(-142.5, 142.5, 0.0)) points_forces.append(Part.Vertex(-142.5, -142.5, 0.0)) points_forces.append(Part.Vertex(-142.5, 95.0, 0.0)) points_forces.append(Part.Vertex(-142.5, 47.5, 0.0)) points_forces.append(Part.Vertex(-142.5, 0.0, 0.0)) points_forces.append(Part.Vertex(-142.5, -47.5, 0.0)) points_forces.append(Part.Vertex(-142.5, -95.0, 0.0)) points_forces.append(Part.Vertex(142.5, -142.5, 0.0)) points_forces.append(Part.Vertex(-95.0, -142.5, 0.0)) points_forces.append(Part.Vertex(-47.5, -142.5, 0.0)) points_forces.append(Part.Vertex(0.0, -142.5, 0.0)) points_forces.append(Part.Vertex(47.5, -142.5, 0.0)) points_forces.append(Part.Vertex(95.0, -142.5, 0.0)) points_forces.append(Part.Vertex(142.5, 142.5, 0.0)) points_forces.append(Part.Vertex(142.5, -95.0, 0.0)) points_forces.append(Part.Vertex(142.5, -47.5, 0.0)) points_forces.append(Part.Vertex(142.5, 0.0, 0.0)) points_forces.append(Part.Vertex(142.5, 47.5, 0.0)) points_forces.append(Part.Vertex(142.5, 95.0, 0.0)) points_forces.append(Part.Vertex(95.0, 142.5, 0.0)) points_forces.append(Part.Vertex(47.5, 142.5, 0.0)) points_forces.append(Part.Vertex(0.0, 142.5, 0.0)) points_forces.append(Part.Vertex(-47.5, 142.5, 0.0)) points_forces.append(Part.Vertex(-95.0, 142.5, 0.0)) points_forces.append(Part.Vertex(-142.5, 118.75, 0.0)) points_forces.append(Part.Vertex(-142.5, -118.75, 0.0)) points_forces.append(Part.Vertex(-142.5, 71.25, 0.0)) points_forces.append(Part.Vertex(-142.5, 23.75, 0.0)) points_forces.append(Part.Vertex(-142.5, -23.75, 0.0)) points_forces.append(Part.Vertex(-142.5, -71.25, 0.0)) points_forces.append(Part.Vertex(118.75, -142.5, 0.0)) points_forces.append(Part.Vertex(-71.25, -142.5, 0.0)) points_forces.append(Part.Vertex(-118.75, -142.5, 0.0)) points_forces.append(Part.Vertex(-23.75, -142.5, 0.0)) points_forces.append(Part.Vertex(23.75, -142.5, 0.0)) points_forces.append(Part.Vertex(71.25, -142.5, 0.0)) points_forces.append(Part.Vertex(142.5, 118.75, 0.0)) points_forces.append(Part.Vertex(142.5, -71.25, 0.0)) points_forces.append(Part.Vertex(142.5, -118.75, 0.0)) points_forces.append(Part.Vertex(142.5, -23.75, 0.0)) points_forces.append(Part.Vertex(142.5, 23.75, 0.0)) points_forces.append(Part.Vertex(142.5, 71.25, 0.0)) points_forces.append(Part.Vertex(71.25, 142.5, 0.0)) points_forces.append(Part.Vertex(118.75, 142.5, 0.0)) points_forces.append(Part.Vertex(23.75, 142.5, 0.0)) points_forces.append(Part.Vertex(-23.75, 142.5, 0.0)) points_forces.append(Part.Vertex(-71.25, 142.5, 0.0)) points_forces.append(Part.Vertex(-118.75, 142.5, 0.0)) points_fixes = [] points_fixes.append(Part.Vertex(-142.5, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 95.0, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 47.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 0.0, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -47.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -95.0, 1000.0)) points_fixes.append(Part.Vertex(142.5, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-95.0, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-47.5, -142.5, 1000.0)) points_fixes.append(Part.Vertex(0.0, -142.5, 1000.0)) points_fixes.append(Part.Vertex(47.5, -142.5, 1000.0)) points_fixes.append(Part.Vertex(95.0, -142.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, 142.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, -95.0, 1000.0)) points_fixes.append(Part.Vertex(142.5, -47.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, 0.0, 1000.0)) points_fixes.append(Part.Vertex(142.5, 47.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, 95.0, 1000.0)) points_fixes.append(Part.Vertex(95.0, 142.5, 1000.0)) points_fixes.append(Part.Vertex(47.5, 142.5, 1000.0)) points_fixes.append(Part.Vertex(0.0, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-47.5, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-95.0, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 118.75, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -118.75, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 71.25, 1000.0)) points_fixes.append(Part.Vertex(-142.5, 23.75, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -23.75, 1000.0)) points_fixes.append(Part.Vertex(-142.5, -71.25, 1000.0)) points_fixes.append(Part.Vertex(118.75, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-71.25, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-118.75, -142.5, 1000.0)) points_fixes.append(Part.Vertex(-23.75, -142.5, 1000.0)) points_fixes.append(Part.Vertex(23.75, -142.5, 1000.0)) points_fixes.append(Part.Vertex(71.25, -142.5, 1000.0)) points_fixes.append(Part.Vertex(142.5, 118.75, 1000.0)) points_fixes.append(Part.Vertex(142.5, -71.25, 1000.0)) points_fixes.append(Part.Vertex(142.5, -118.75, 1000.0)) points_fixes.append(Part.Vertex(142.5, -23.75, 1000.0)) points_fixes.append(Part.Vertex(142.5, 23.75, 1000.0)) points_fixes.append(Part.Vertex(142.5, 71.25, 1000.0)) points_fixes.append(Part.Vertex(71.25, 142.5, 1000.0)) points_fixes.append(Part.Vertex(118.75, 142.5, 1000.0)) points_fixes.append(Part.Vertex(23.75, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-23.75, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-71.25, 142.5, 1000.0)) points_fixes.append(Part.Vertex(-118.75, 142.5, 1000.0)) geoforces_obj = doc.addObject('Part::Feature', 'Forces') geoforces_obj.Shape = Part.makeCompound(points_forces) geofixes_obj = doc.addObject('Part::Feature', 'Fixes') geofixes_obj.Shape = Part.makeCompound(points_fixes) doc.recompute() if FreeCAD.GuiUp: geoforces_obj.ViewObject.PointColor = (1.0, 0.0, 0.0, 0.0) geoforces_obj.ViewObject.PointSize = 10.0 geofixes_obj.ViewObject.PointColor = (1.0, 0.0, 0.0, 0.0) geofixes_obj.ViewObject.PointSize = 10.0 geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # shell thickness thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 15.0, "ShellThickness") analysis.addObject(thickness_obj) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial") mat = material_obj.Material mat["Name"] = "Steel-Generic" mat["YoungsModulus"] = "200000 MPa" mat["PoissonRatio"] = "0.30" mat["Density"] = "7900 kg/m^3" material_obj.Material = mat analysis.addObject(material_obj) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(geofixes_obj, 'Vertex6'), (geofixes_obj, 'Vertex15'), (geofixes_obj, 'Vertex5'), (geofixes_obj, 'Vertex29'), (geofixes_obj, 'Vertex42'), (geofixes_obj, 'Vertex30'), (geofixes_obj, 'Vertex9'), (geofixes_obj, 'Vertex31'), (geofixes_obj, 'Vertex33'), (geofixes_obj, 'Vertex32'), (geofixes_obj, 'Vertex3'), (geofixes_obj, 'Vertex34'), (geofixes_obj, 'Vertex46'), (geofixes_obj, 'Vertex1'), (geofixes_obj, 'Vertex36'), (geofixes_obj, 'Vertex11'), (geofixes_obj, 'Vertex38'), (geofixes_obj, 'Vertex12'), (geofixes_obj, 'Vertex39'), (geofixes_obj, 'Vertex13'), (geofixes_obj, 'Vertex40'), (geofixes_obj, 'Vertex16'), (geofixes_obj, 'Vertex35'), (geofixes_obj, 'Vertex14'), (geofixes_obj, 'Vertex47'), (geofixes_obj, 'Vertex20'), (geofixes_obj, 'Vertex37'), (geofixes_obj, 'Vertex18'), (geofixes_obj, 'Vertex41'), (geofixes_obj, 'Vertex17'), (geofixes_obj, 'Vertex10'), (geofixes_obj, 'Vertex26'), (geofixes_obj, 'Vertex43'), (geofixes_obj, 'Vertex21'), (geofixes_obj, 'Vertex44'), (geofixes_obj, 'Vertex19'), (geofixes_obj, 'Vertex4'), (geofixes_obj, 'Vertex28'), (geofixes_obj, 'Vertex48'), (geofixes_obj, 'Vertex22'), (geofixes_obj, 'Vertex8'), (geofixes_obj, 'Vertex23'), (geofixes_obj, 'Vertex7'), (geofixes_obj, 'Vertex24'), (geofixes_obj, 'Vertex45'), (geofixes_obj, 'Vertex27'), (geofixes_obj, 'Vertex2'), (geofixes_obj, 'Vertex25')] analysis.addObject(con_fixed) # con_force1 con_force1 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce1") con_force1.References = [(geoforces_obj, 'Vertex1'), (geoforces_obj, 'Vertex14')] con_force1.Force = 5555.56 con_force1.Direction = (geom_obj, ["Edge9"]) con_force1.Reversed = False analysis.addObject(con_force1) # con_force2 con_force2 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce2") con_force2.References = [(geoforces_obj, 'Vertex2'), (geoforces_obj, 'Vertex8')] con_force2.Force = 5555.56 con_force2.Direction = (geom_obj, ["Edge3"]) con_force2.Reversed = False analysis.addObject(con_force2) # con_force3 con_force3 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce3") con_force3.References = [ (geoforces_obj, 'Vertex20'), (geoforces_obj, 'Vertex21'), (geoforces_obj, 'Vertex22'), (geoforces_obj, 'Vertex23'), (geoforces_obj, 'Vertex24'), ] con_force3.Force = 27777.78 con_force3.Direction = (geom_obj, ["Edge9"]) con_force3.Reversed = False analysis.addObject(con_force3) # con_force4 con_force4 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce4") con_force4.References = [ (geoforces_obj, 'Vertex9'), (geoforces_obj, 'Vertex10'), (geoforces_obj, 'Vertex11'), (geoforces_obj, 'Vertex12'), (geoforces_obj, 'Vertex13'), ] con_force4.Force = 27777.78 con_force4.Direction = (geom_obj, ["Edge3"]) con_force4.Reversed = False analysis.addObject(con_force4) # con_force5 con_force5 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce5") con_force5.References = [ (geoforces_obj, 'Vertex43'), (geoforces_obj, 'Vertex44'), (geoforces_obj, 'Vertex45'), (geoforces_obj, 'Vertex46'), (geoforces_obj, 'Vertex47'), (geoforces_obj, 'Vertex48'), ] con_force5.Force = 66666.67 con_force5.Direction = (geom_obj, ["Edge9"]) con_force5.Reversed = False analysis.addObject(con_force5) # con_force6 con_force6 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce6") con_force6.References = [ (geoforces_obj, 'Vertex31'), (geoforces_obj, 'Vertex32'), (geoforces_obj, 'Vertex33'), (geoforces_obj, 'Vertex34'), (geoforces_obj, 'Vertex35'), (geoforces_obj, 'Vertex36'), ] con_force6.Force = 66666.67 con_force6.Direction = (geom_obj, ["Edge3"]) con_force6.Reversed = False analysis.addObject(con_force6) # con_force7 con_force7 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce7") con_force7.References = [(geoforces_obj, 'Vertex1'), (geoforces_obj, 'Vertex2')] con_force7.Force = 5555.56 con_force7.Direction = (geom_obj, ["Edge11"]) con_force7.Reversed = False analysis.addObject(con_force7) # con_force8 con_force8 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce8") con_force8.References = [(geoforces_obj, 'Vertex8'), (geoforces_obj, 'Vertex14')] con_force8.Force = 5555.56 con_force8.Direction = (geom_obj, ["Edge6"]) con_force8.Reversed = False analysis.addObject(con_force8) # con_force9 con_force9 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce9") con_force9.References = [ (geoforces_obj, 'Vertex3'), (geoforces_obj, 'Vertex4'), (geoforces_obj, 'Vertex5'), (geoforces_obj, 'Vertex6'), (geoforces_obj, 'Vertex7'), ] con_force9.Force = 27777.78 con_force9.Direction = (geom_obj, ["Edge11"]) con_force9.Reversed = False analysis.addObject(con_force9) # con_force10 con_force10 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce10") con_force10.References = [ (geoforces_obj, 'Vertex15'), (geoforces_obj, 'Vertex16'), (geoforces_obj, 'Vertex17'), (geoforces_obj, 'Vertex18'), (geoforces_obj, 'Vertex19'), ] con_force10.Force = 27777.78 con_force10.Direction = (geom_obj, ["Edge6"]) con_force10.Reversed = False analysis.addObject(con_force10) # con_force11 con_force11 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce11") con_force11.References = [ (geoforces_obj, 'Vertex25'), (geoforces_obj, 'Vertex26'), (geoforces_obj, 'Vertex27'), (geoforces_obj, 'Vertex28'), (geoforces_obj, 'Vertex29'), (geoforces_obj, 'Vertex30'), ] con_force11.Force = 66666.67 con_force11.Direction = (geom_obj, ["Edge11"]) con_force11.Reversed = False analysis.addObject(con_force11) # con_force12 con_force12 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce12") con_force12.References = [ (geoforces_obj, 'Vertex37'), (geoforces_obj, 'Vertex38'), (geoforces_obj, 'Vertex39'), (geoforces_obj, 'Vertex40'), (geoforces_obj, 'Vertex41'), (geoforces_obj, 'Vertex42'), ] con_force12.Force = 66666.67 con_force12.Direction = (geom_obj, ["Edge6"]) con_force12.Reversed = False analysis.addObject(con_force12) # mesh from .meshes.mesh_square_pipe_end_twisted_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False doc.recompute() return doc
def setup_cantilever_base_edge(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # geometric objects # load line load_line = doc.addObject("Part::Line", "LoadLine") load_line.X1 = 0 load_line.Y1 = 0 load_line.Z1 = 1000 load_line.X2 = 0 load_line.Y2 = 0 load_line.Z2 = 0 # cantilever line geom_obj = doc.addObject("Part::Line", "CantileverLine") geom_obj.X1 = 0 geom_obj.Y1 = 500 geom_obj.Z1 = 500 geom_obj.X2 = 8000 geom_obj.Y2 = 500 geom_obj.Z2 = 500 doc.recompute() if FreeCAD.GuiUp: load_line.ViewObject.Visibility = False geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" elif solvertype == "mystran": solver_obj = ObjectsFem.makeSolverMystran(doc, "SolverMystran") else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False solver_obj.SplitInputWriter = False analysis.addObject(solver_obj) # beam section beamsection_obj = ObjectsFem.makeElementGeometry1D( doc, sectiontype="Rectangular", width=1000.0, height=1000.0, name="BeamCrossSection") analysis.addObject(beamsection_obj) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial") mat = material_obj.Material mat["Name"] = "Calculix-Steel" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(geom_obj, "Vertex1")] analysis.addObject(con_fixed) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [(geom_obj, "Vertex2")] con_force.Force = 9000000.0 # 9'000'000 N = 9 MN con_force.Direction = (load_line, ["Edge1"]) con_force.Reversed = False analysis.addObject(con_force) # mesh from .meshes.mesh_canticcx_seg3 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False femmesh_obj.ElementDimension = "1D" femmesh_obj.CharacteristicLengthMax = "1750.0 mm" femmesh_obj.CharacteristicLengthMin = "1750.0 mm" doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # setup model if doc is None: doc = init_doc() # parts # cones cut cone_outer_sh = Part.makeCone(1100, 1235, 1005, Vector(0, 0, 0), Vector(0, 0, 1), 359) cone_inner_sh = Part.makeCone(1050, 1185, 1005, Vector(0, 0, 0), Vector(0, 0, 1), 359) cone_cut_sh = cone_outer_sh.cut(cone_inner_sh) cone_cut_obj = doc.addObject("Part::Feature", "Cone_Cut") cone_cut_obj.Shape = cone_cut_sh # lines line_fix_sh = Part.Edge(Part.LineSegment(Vector(0, -1235, 1005), Vector(0, -1185, 1005))) line_fix_obj = doc.addObject("Part::Feature", "Line_Fix") line_fix_obj.Shape = line_fix_sh line_force_sh = Part.Edge(Part.LineSegment(Vector(0, 1185, 1005), Vector(0, 1235, 1005))) line_force_obj = doc.addObject("Part::Feature", "Line_Force") line_force_obj.Shape = line_force_sh geom_all_obj = BOPTools.SplitFeatures.makeBooleanFragments(name='BooleanFragments') geom_all_obj.Objects = [cone_cut_obj, line_fix_obj, line_force_obj] if FreeCAD.GuiUp: cone_cut_obj.ViewObject.hide() line_fix_obj.ViewObject.hide() line_force_obj.ViewObject.hide() doc.recompute() if FreeCAD.GuiUp: import FreeCADGui FreeCADGui.ActiveDocument.activeView().viewAxonometric() FreeCADGui.SendMsgToActiveView("ViewFit") # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") )[0] elif solvertype == "ccxtools": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools") )[0] solver_object.WorkingDir = u"" if solvertype == "calculix" or solvertype == "ccxtools": solver_object.AnalysisType = "static" solver_object.GeometricalNonlinearity = "linear" solver_object.ThermoMechSteadyState = False solver_object.MatrixSolverType = "default" solver_object.IterationsControlParameterTimeUse = False solver_object.SplitInputWriter = False # material material_obj = analysis.addObject( ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial") )[0] mat = material_obj.Material mat["Name"] = "Calculix-Steel" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # constraint fixed con_fixed = analysis.addObject( ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") )[0] con_fixed.References = [(geom_all_obj, "Edge1")] # constraint force con_force = doc.Analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce") )[0] con_force.References = [(geom_all_obj, "Edge2")] con_force.Force = 10000.0 # 10000 N = 10 kN con_force.Direction = (geom_all_obj, ["Edge2"]) con_force.Reversed = False # constraint tie con_tie = doc.Analysis.addObject( ObjectsFem.makeConstraintTie(doc, name="ConstraintTie") )[0] con_tie.References = [ (geom_all_obj, "Face5"), (geom_all_obj, "Face7"), ] con_tie.Tolerance = 25.0 # mesh from .meshes.mesh_constraint_tie_tetra10 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( doc.addObject("Fem::FemMeshObject", mesh_name) )[0] femmesh_obj.FemMesh = fem_mesh doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information()))) # geometric object v1 = vec(0, -2000, 0) v2 = vec(500, -2000, 0) v3 = vec(500, 0, 0) v4 = vec(3500, 0, 0) v5 = vec(3500, -2000, 0) v6 = vec(4000, -2000, 0) v7 = vec(4000, 2000, 0) v8 = vec(0, 2000, 0) l1 = ln(v1, v2) l2 = ln(v2, v3) l3 = ln(v3, v4) l4 = ln(v4, v5) l5 = ln(v5, v6) l6 = ln(v6, v7) l7 = ln(v7, v8) l8 = ln(v8, v1) geom_obj = doc.addObject("Part::Feature", "FIB_Wall") geom_obj.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8])) doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype) ) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # shell thickness thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 150.0, "ShellThickness") analysis.addObject(thickness_obj) # material matrixprop = {} matrixprop["Name"] = "Concrete-EN-C35/45" matrixprop["YoungsModulus"] = "32000 MPa" matrixprop["PoissonRatio"] = "0.17" matrixprop["CompressiveStrength"] = "15.75 MPa" # make some hint on the possible angle units in material system matrixprop["AngleOfFriction"] = "30 deg" reinfoprop = {} reinfoprop["Name"] = "Reinforcement-FIB-B500" reinfoprop["YieldStrength"] = "315 MPa" # not an official FreeCAD material property reinfoprop["ReinforcementRatio"] = "0.0" material_reinforced = ObjectsFem.makeMaterialReinforced(doc, "MaterialReinforced") material_reinforced.Material = matrixprop material_reinforced.Reinforcement = reinfoprop analysis.addObject(material_reinforced) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(geom_obj, "Edge1"), (geom_obj, "Edge5")] analysis.addObject(con_fixed) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [(geom_obj, "Edge7")] con_force.Force = 1000000.0 con_force.Direction = (geom_obj, ["Edge8"]) con_force.Reversed = False analysis.addObject(con_force) # constraint displacement con_disp = ObjectsFem.makeConstraintDisplacement(doc, "ConstraintDisplacmentPrescribed") con_disp.References = [(geom_obj, "Face1")] con_disp.zFree = False con_disp.zFix = True analysis.addObject(con_disp) # mesh from .meshes.mesh_rc_wall_2d_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False doc.recompute() return doc
def test_femobjects_derivedfromfem(self): # try to add all possible True types from inheritance chain see # https://forum.freecadweb.org/viewtopic.php?f=10&t=32625 doc = self.active_doc from femtools.femutils import is_derived_from materialsolid = ObjectsFem.makeMaterialSolid(doc) mesh = ObjectsFem.makeMeshGmsh(doc) solverelmer = ObjectsFem.makeSolverElmer(doc) # FemAnalysis self.assertTrue( is_derived_from(ObjectsFem.makeAnalysis(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeAnalysis(doc), 'Fem::FemAnalysis')) # ConstraintBearing self.assertTrue( is_derived_from(ObjectsFem.makeConstraintBearing(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintBearing(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintBearing(doc), 'Fem::ConstraintBearing')) # ConstraintBodyHeatSource self.assertTrue( is_derived_from(ObjectsFem.makeConstraintBodyHeatSource(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintBodyHeatSource(doc), 'Fem::ConstraintPython')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintBodyHeatSource(doc), 'Fem::ConstraintBodyHeatSource')) # ConstraintContact self.assertTrue( is_derived_from(ObjectsFem.makeConstraintContact(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintContact(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintContact(doc), 'Fem::ConstraintContact')) # ConstraintDisplacement self.assertTrue( is_derived_from(ObjectsFem.makeConstraintDisplacement(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintDisplacement(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintDisplacement(doc), 'Fem::ConstraintDisplacement')) # ConstraintElectrostaticPotential self.assertTrue( is_derived_from( ObjectsFem.makeConstraintElectrostaticPotential(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from( ObjectsFem.makeConstraintElectrostaticPotential(doc), 'Fem::ConstraintPython')) self.assertTrue( is_derived_from( ObjectsFem.makeConstraintElectrostaticPotential(doc), 'Fem::ConstraintElectrostaticPotential')) # ConstraintFixed self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFixed(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFixed(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFixed(doc), 'Fem::ConstraintFixed')) # ConstraintFlowVelocity self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFlowVelocity(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFlowVelocity(doc), 'Fem::ConstraintPython')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFlowVelocity(doc), 'Fem::ConstraintFlowVelocity')) # ConstraintFluidBoundary self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFluidBoundary(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFluidBoundary(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintFluidBoundary(doc), 'Fem::ConstraintFluidBoundary')) # ConstraintForce self.assertTrue( is_derived_from(ObjectsFem.makeConstraintForce(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintForce(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintForce(doc), 'Fem::ConstraintForce')) # ConstraintGear self.assertTrue( is_derived_from(ObjectsFem.makeConstraintGear(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintGear(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintGear(doc), 'Fem::ConstraintGear')) # ConstraintHeatflux self.assertTrue( is_derived_from(ObjectsFem.makeConstraintHeatflux(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintHeatflux(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintHeatflux(doc), 'Fem::ConstraintHeatflux')) # ConstraintInitialFlowVelocity self.assertTrue( is_derived_from(ObjectsFem.makeConstraintInitialFlowVelocity(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintInitialFlowVelocity(doc), 'Fem::ConstraintPython')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintInitialFlowVelocity(doc), 'Fem::ConstraintInitialFlowVelocity')) # ConstraintInitialTemperature self.assertTrue( is_derived_from(ObjectsFem.makeConstraintInitialTemperature(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintInitialTemperature(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintInitialTemperature(doc), 'Fem::ConstraintInitialTemperature')) # ConstraintPlaneRotation self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPlaneRotation(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPlaneRotation(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPlaneRotation(doc), 'Fem::ConstraintPlaneRotation')) # ConstraintPressure self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPressure(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPressure(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPressure(doc), 'Fem::ConstraintPressure')) # ConstraintPulley self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPulley(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPulley(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintPulley(doc), 'Fem::ConstraintPulley')) # ConstraintSelfWeight self.assertTrue( is_derived_from(ObjectsFem.makeConstraintSelfWeight(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintSelfWeight(doc), 'Fem::ConstraintPython')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintSelfWeight(doc), 'Fem::ConstraintSelfWeight')) # ConstraintTemperature self.assertTrue( is_derived_from(ObjectsFem.makeConstraintTemperature(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintTemperature(doc), 'Fem::Constraint')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintTemperature(doc), 'Fem::ConstraintTemperature')) # ConstraintTransform self.assertTrue( is_derived_from(ObjectsFem.makeConstraintTransform(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeConstraintTransform(doc), 'Fem::ConstraintTransform')) # FemElementFluid1D self.assertTrue( is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'Fem::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeElementFluid1D(doc), 'Fem::FemElementFluid1D')) # FemElementGeometry1D self.assertTrue( is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'Fem::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeElementGeometry1D(doc), 'Fem::FemElementGeometry1D')) # FemElementGeometry2D self.assertTrue( is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'Fem::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeElementGeometry2D(doc), 'Fem::FemElementGeometry2D')) # FemElementRotation1D self.assertTrue( is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'Fem::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeElementRotation1D(doc), 'Fem::FemElementRotation1D')) # Material self.assertTrue( is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'App::MaterialObjectPython')) self.assertTrue( is_derived_from(ObjectsFem.makeMaterialFluid(doc), 'Fem::Material')) # Material self.assertTrue(is_derived_from(materialsolid, 'App::DocumentObject')) self.assertTrue( is_derived_from(materialsolid, 'App::MaterialObjectPython')) self.assertTrue(is_derived_from(materialsolid, 'Fem::Material')) # MaterialMechanicalNonlinear self.assertTrue( is_derived_from( ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'App::DocumentObject')) self.assertTrue( is_derived_from( ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'Fem::FeaturePython')) self.assertTrue( is_derived_from( ObjectsFem.makeMaterialMechanicalNonlinear(doc, materialsolid), 'Fem::MaterialMechanicalNonlinear')) # MaterialReinforced self.assertTrue( is_derived_from(ObjectsFem.makeMaterialReinforced(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeMaterialReinforced(doc), 'App::MaterialObjectPython')) self.assertTrue( is_derived_from(ObjectsFem.makeMaterialReinforced(doc), 'Fem::MaterialReinforced')) # FemMeshGmsh self.assertTrue(is_derived_from(mesh, 'App::DocumentObject')) self.assertTrue(is_derived_from(mesh, 'Fem::FemMeshObjectPython')) self.assertTrue(is_derived_from(mesh, 'Fem::FemMeshGmsh')) # FemMeshBoundaryLayer self.assertTrue( is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'Fem::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshBoundaryLayer(doc, mesh), 'Fem::FemMeshBoundaryLayer')) # FemMeshGroup self.assertTrue( is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'Fem::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshGroup(doc, mesh), 'Fem::FemMeshGroup')) # FemMeshRegion self.assertTrue( is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'Fem::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshRegion(doc, mesh), 'Fem::FemMeshRegion')) # FemMeshShapeNetgenObject self.assertTrue( is_derived_from(ObjectsFem.makeMeshNetgen(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshNetgen(doc), 'Fem::FemMeshShapeNetgenObject')) # FemMeshResult self.assertTrue( is_derived_from(ObjectsFem.makeMeshResult(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshResult(doc), 'Fem::FemMeshObjectPython')) self.assertTrue( is_derived_from(ObjectsFem.makeMeshResult(doc), 'Fem::FemMeshResult')) # FemResultMechanical self.assertTrue( is_derived_from(ObjectsFem.makeResultMechanical(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeResultMechanical(doc), 'Fem::FemResultObjectPython')) self.assertTrue( is_derived_from(ObjectsFem.makeResultMechanical(doc), 'Fem::FemResultMechanical')) # FemSolverCalculixCcxTools self.assertTrue( is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverObject')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverObjectPython')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverCalculixCcxTools(doc), 'Fem::FemSolverCalculixCcxTools')) # FemSolverObjectCalculix self.assertTrue( is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObject')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObjectPython')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverCalculix(doc), 'Fem::FemSolverObjectCalculix')) # FemSolverObjectElmer self.assertTrue(is_derived_from(solverelmer, 'App::DocumentObject')) self.assertTrue(is_derived_from(solverelmer, 'Fem::FemSolverObject')) self.assertTrue( is_derived_from(solverelmer, 'Fem::FemSolverObjectPython')) self.assertTrue( is_derived_from(solverelmer, 'Fem::FemSolverObjectElmer')) # FemSolverObjectZ88 self.assertTrue( is_derived_from(ObjectsFem.makeSolverZ88(doc), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObject')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObjectPython')) self.assertTrue( is_derived_from(ObjectsFem.makeSolverZ88(doc), 'Fem::FemSolverObjectZ88')) # FemEquationElmerElasticity self.assertTrue( is_derived_from( ObjectsFem.makeEquationElasticity(doc, solverelmer), 'App::DocumentObject')) self.assertTrue( is_derived_from( ObjectsFem.makeEquationElasticity(doc, solverelmer), 'App::FeaturePython')) self.assertTrue( is_derived_from( ObjectsFem.makeEquationElasticity(doc, solverelmer), 'Fem::FemEquationElmerElasticity')) # FemEquationElmerElectrostatic self.assertTrue( is_derived_from( ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'App::DocumentObject')) self.assertTrue( is_derived_from( ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'App::FeaturePython')) self.assertTrue( is_derived_from( ObjectsFem.makeEquationElectrostatic(doc, solverelmer), 'Fem::FemEquationElmerElectrostatic')) # FemEquationElmerFlow self.assertTrue( is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'App::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeEquationFlow(doc, solverelmer), 'Fem::FemEquationElmerFlow')) # FemEquationElmerFluxsolver self.assertTrue( is_derived_from( ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'App::DocumentObject')) self.assertTrue( is_derived_from( ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'App::FeaturePython')) self.assertTrue( is_derived_from( ObjectsFem.makeEquationFluxsolver(doc, solverelmer), 'Fem::FemEquationElmerFluxsolver')) # FemEquationElmerHeat self.assertTrue( is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'App::DocumentObject')) self.assertTrue( is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'App::FeaturePython')) self.assertTrue( is_derived_from(ObjectsFem.makeEquationHeat(doc, solverelmer), 'Fem::FemEquationElmerHeat'))
def setup(doc=None, solvertype="ccxtools"): if doc is None: doc = init_doc() # geometry object # name is important because the other method in this module use obj name # parts face_obj1 = doc.addObject('Part::Plane', 'Face1') face_obj1.Width = 10 face_obj1.Length = 20 face_obj2 = doc.addObject('Part::Plane', 'Face2') face_obj2.Width = 10 face_obj2.Length = 20 face_obj2.Placement.Base = (20, 0, 0) face_obj3 = doc.addObject('Part::Plane', 'Face3') face_obj3.Width = 10 face_obj3.Length = 20 face_obj3.Placement.Base = (40, 0, 0) face_obj4 = doc.addObject('Part::Plane', 'Face4') face_obj4.Width = 10 face_obj4.Length = 20 face_obj4.Placement.Base = (60, 0, 0) face_obj5 = doc.addObject('Part::Plane', 'Face5') face_obj5.Width = 10 face_obj5.Length = 20 face_obj5.Placement.Base = (80, 0, 0) doc.recompute() # make a Shell out of the facees, to be able to remesh with GUI geom_obj = doc.addObject("Part::MultiFuse", "Fusion") geom_obj.Shapes = [face_obj1, face_obj2, face_obj3, face_obj4, face_obj5] if FreeCAD.GuiUp: face_obj1.ViewObject.hide() face_obj2.ViewObject.hide() face_obj3.ViewObject.hide() face_obj4.ViewObject.hide() face_obj5.ViewObject.hide() doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0] elif solvertype == "ccxtools": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0] solver_object.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_object.SplitInputWriter = False solver_object.AnalysisType = "static" solver_object.GeometricalNonlinearity = "linear" solver_object.ThermoMechSteadyState = False solver_object.MatrixSolverType = "default" solver_object.IterationsControlParameterTimeUse = False # shell thickness analysis.addObject( ObjectsFem.makeElementGeometry2D(doc, 10, 'ShellThickness')) # materials # material1 material_object1 = analysis.addObject( ObjectsFem.makeMaterialSolid(doc, 'FemMaterial1'))[0] material_object1.References = [(doc.Face3, "Face1")] mat = material_object1.Material mat['Name'] = "Concrete-Generic" mat['YoungsModulus'] = "32000 MPa" mat['PoissonRatio'] = "0.17" mat['Density'] = "0 kg/m^3" material_object1.Material = mat # material2 material_object2 = analysis.addObject( ObjectsFem.makeMaterialSolid(doc, 'FemMaterial2'))[0] material_object2.References = [(doc.Face2, "Face1"), (doc.Face4, "Face1")] mat = material_object2.Material mat['Name'] = "PLA" mat['YoungsModulus'] = "3640 MPa" mat['PoissonRatio'] = "0.36" mat['Density'] = "0 kg/m^3" material_object2.Material = mat # material3 material_object3 = analysis.addObject( ObjectsFem.makeMaterialSolid(doc, 'FemMaterial3'))[0] material_object3.References = [] mat = material_object3.Material mat['Name'] = "Steel-Generic" mat['YoungsModulus'] = "200000 MPa" mat['PoissonRatio'] = "0.30" mat['Density'] = "7900 kg/m^3" material_object3.Material = mat # fixed_constraint fixed_constraint = analysis.addObject( ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed"))[0] fixed_constraint.References = [(doc.Face1, "Edge1"), (doc.Face5, "Edge3")] # force_constraint force_constraint = analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0] force_constraint.References = [(doc.Face1, "Edge4"), (doc.Face2, "Edge4"), (doc.Face3, "Edge4"), (doc.Face4, "Edge4"), (doc.Face5, "Edge4")] force_constraint.Force = 10000.00 force_constraint.Direction = (doc.Face1, ["Edge1"]) force_constraint.Reversed = True # mesh from .meshes.mesh_multibodybeam_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False doc.recompute() return doc
def test_femobjects_make(self): doc = self.active_doc analysis = ObjectsFem.makeAnalysis(doc) analysis.addObject(ObjectsFem.makeConstraintBearing(doc)) analysis.addObject(ObjectsFem.makeConstraintBodyHeatSource(doc)) analysis.addObject(ObjectsFem.makeConstraintContact(doc)) analysis.addObject(ObjectsFem.makeConstraintDisplacement(doc)) analysis.addObject( ObjectsFem.makeConstraintElectrostaticPotential(doc)) analysis.addObject(ObjectsFem.makeConstraintFixed(doc)) analysis.addObject(ObjectsFem.makeConstraintFlowVelocity(doc)) analysis.addObject(ObjectsFem.makeConstraintFluidBoundary(doc)) analysis.addObject(ObjectsFem.makeConstraintForce(doc)) analysis.addObject(ObjectsFem.makeConstraintGear(doc)) analysis.addObject(ObjectsFem.makeConstraintHeatflux(doc)) analysis.addObject(ObjectsFem.makeConstraintInitialFlowVelocity(doc)) analysis.addObject(ObjectsFem.makeConstraintInitialTemperature(doc)) analysis.addObject(ObjectsFem.makeConstraintPlaneRotation(doc)) analysis.addObject(ObjectsFem.makeConstraintPressure(doc)) analysis.addObject(ObjectsFem.makeConstraintPulley(doc)) analysis.addObject(ObjectsFem.makeConstraintSelfWeight(doc)) analysis.addObject(ObjectsFem.makeConstraintTemperature(doc)) analysis.addObject(ObjectsFem.makeConstraintTransform(doc)) analysis.addObject(ObjectsFem.makeElementFluid1D(doc)) analysis.addObject(ObjectsFem.makeElementGeometry1D(doc)) analysis.addObject(ObjectsFem.makeElementGeometry2D(doc)) analysis.addObject(ObjectsFem.makeElementRotation1D(doc)) analysis.addObject(ObjectsFem.makeMaterialFluid(doc)) mat = analysis.addObject(ObjectsFem.makeMaterialSolid(doc))[0] analysis.addObject(ObjectsFem.makeMaterialMechanicalNonlinear( doc, mat)) analysis.addObject(ObjectsFem.makeMaterialReinforced(doc)) msh = analysis.addObject(ObjectsFem.makeMeshGmsh(doc))[0] analysis.addObject(ObjectsFem.makeMeshBoundaryLayer(doc, msh)) analysis.addObject(ObjectsFem.makeMeshGroup(doc, msh)) analysis.addObject(ObjectsFem.makeMeshRegion(doc, msh)) analysis.addObject(ObjectsFem.makeMeshNetgen(doc)) analysis.addObject(ObjectsFem.makeMeshResult(doc)) res = analysis.addObject(ObjectsFem.makeResultMechanical(doc))[0] if "BUILD_FEM_VTK" in FreeCAD.__cmake__: vres = analysis.addObject(ObjectsFem.makePostVtkResult(doc, res))[0] analysis.addObject( ObjectsFem.makePostVtkFilterClipRegion(doc, vres)) analysis.addObject( ObjectsFem.makePostVtkFilterClipScalar(doc, vres)) analysis.addObject( ObjectsFem.makePostVtkFilterCutFunction(doc, vres)) analysis.addObject(ObjectsFem.makePostVtkFilterWarp(doc, vres)) analysis.addObject(ObjectsFem.makeSolverCalculixCcxTools(doc)) analysis.addObject(ObjectsFem.makeSolverCalculix(doc)) sol = analysis.addObject(ObjectsFem.makeSolverElmer(doc))[0] analysis.addObject(ObjectsFem.makeSolverZ88(doc)) analysis.addObject(ObjectsFem.makeEquationElasticity(doc, sol)) analysis.addObject(ObjectsFem.makeEquationElectrostatic(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFlow(doc, sol)) analysis.addObject(ObjectsFem.makeEquationFluxsolver(doc, sol)) analysis.addObject(ObjectsFem.makeEquationHeat(doc, sol)) # is = 48 (just copy in empty file to test, or run unit test case, it is printed) # TODO if the equations and gmsh mesh childs are added to the analysis, # they show up twice on Tree (on solver resp. gemsh mesh obj and on analysis) # https://forum.freecadweb.org/viewtopic.php?t=25283 doc.recompute() # if FEM VTK post processing is disabled, we are not able to create VTK post objects if "BUILD_FEM_VTK" in FreeCAD.__cmake__: fem_vtk_post = True else: fem_vtk_post = False # because of the analysis itself count -1 self.assertEqual(len(analysis.Group), testtools.get_defmake_count(fem_vtk_post) - 1)
def setup(doc=None, solvertype="ccxtools"): # setup model if doc is None: doc = init_doc() # parts # TODO turn circle of upper tube to have the line on the other side # make a boolean fragment of them to be sure there is a mesh point on remesh # but as long as we do not remesh it works without the boolean fragment too # tubes tube_radius = 25 tube_length = 500 sh_lower_circle = Part.Wire(Part.makeCircle(tube_radius)) sh_lower_tube = sh_lower_circle.extrude(FreeCAD.Vector(0, 0, tube_length)) sh_lower_tube.reverse() lower_tube = doc.addObject("Part::Feature", "Lower_tube") lower_tube.Shape = sh_lower_tube sh_upper_circle = Part.Wire(Part.makeCircle(tube_radius)) sh_upper_tube = sh_upper_circle.extrude(FreeCAD.Vector(0, 0, tube_length)) sh_upper_tube.reverse() upper_tube = doc.addObject("Part::Feature", "Upper_tube") upper_tube.Shape = sh_upper_tube upper_tube.Placement = FreeCAD.Placement( FreeCAD.Vector(-25, 51, 475), FreeCAD.Rotation(90, 0, 90), FreeCAD.Vector(0, 0, 0), ) # point for load v_force_pt = FreeCAD.Vector(0, 76, 475) sh_force_point = Part.Vertex(v_force_pt) force_point = doc.addObject("Part::Feature", "Load_place_point") force_point.Shape = sh_force_point if FreeCAD.GuiUp: force_point.ViewObject.PointSize = 10.0 force_point.ViewObject.PointColor = (1.0, 0.0, 0.0) BooleanFrag = BOPTools.SplitFeatures.makeBooleanFragments( name='BooleanFragments') BooleanFrag.Objects = [upper_tube, force_point] if FreeCAD.GuiUp: upper_tube.ViewObject.hide() compound = doc.addObject("Part::Compound", "Compound") compound.Links = [BooleanFrag, lower_tube] # line for load direction sh_load_line = Part.makeLine(v_force_pt, FreeCAD.Vector(0, 150, 475)) load_line = doc.addObject("Part::Feature", "Load_direction_line") load_line.Shape = sh_load_line if FreeCAD.GuiUp: load_line.ViewObject.LineWidth = 5.0 load_line.ViewObject.LineColor = (1.0, 0.0, 0.0) doc.recompute() if FreeCAD.GuiUp: import FreeCADGui FreeCADGui.ActiveDocument.activeView().viewAxonometric() FreeCADGui.SendMsgToActiveView("ViewFit") # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0] elif solvertype == "ccxtools": solver_object = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0] solver_object.WorkingDir = u"" if solvertype == "calculix" or solvertype == "ccxtools": solver_object.AnalysisType = "static" solver_object.BeamShellResultOutput3D = True solver_object.GeometricalNonlinearity = "linear" # really? # TODO iterations parameter !!! solver_object.ThermoMechSteadyState = False solver_object.MatrixSolverType = "default" solver_object.IterationsControlParameterTimeUse = False solver_object.SplitInputWriter = False # shell thickness analysis.addObject( ObjectsFem.makeElementGeometry2D(doc, 0.5, 'ShellThickness')) # material material_obj = analysis.addObject( ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial"))[0] mat = material_obj.Material mat["Name"] = "AlCuMgPb" mat["YoungsModulus"] = "72000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # fixed_constraint fixed_constraint = analysis.addObject( ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed"))[0] fixed_constraint.References = [ (lower_tube, "Edge2"), (upper_tube, "Edge3"), ] # force_constraint force_constraint = doc.Analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0] # TODO use point of tube boolean fragment force_constraint.References = [(force_point, "Vertex1")] force_constraint.Force = 5000.0 force_constraint.Direction = (load_line, ["Edge1"]) force_constraint.Reversed = True # contact constraint contact_constraint = doc.Analysis.addObject( ObjectsFem.makeConstraintContact(doc, name="ConstraintContact"))[0] contact_constraint.References = [ (lower_tube, "Face1"), (upper_tube, "Face1"), ] contact_constraint.Friction = 0.0 # contact_constrsh_aint.Slope = "1000000.0 kg/(mm*s^2)" # contact stiffness contact_constraint.Slope = 1000000.0 # should be 1000000.0 kg/(mm*s^2) # mesh from .meshes.mesh_contact_tube_tube_tria3 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( doc.addObject("Fem::FemMeshObject", mesh_name))[0] femmesh_obj.FemMesh = fem_mesh doc.recompute() return doc
def setup_rcwall2d(doc=None, solver='ccxtools'): # setup reinfoced wall in 2D if doc is None: doc = init_doc() # part from FreeCAD import Vector as vec import Part from Part import makeLine as ln v1 = vec(0, -2000, 0) v2 = vec(500, -2000, 0) v3 = vec(500, 0, 0) v4 = vec(3500, 0, 0) v5 = vec(3500, -2000, 0) v6 = vec(4000, -2000, 0) v7 = vec(4000, 2000, 0) v8 = vec(0, 2000, 0) l1 = ln(v1, v2) l2 = ln(v2, v3) l3 = ln(v3, v4) l4 = ln(v4, v5) l5 = ln(v5, v6) l6 = ln(v6, v7) l7 = ln(v7, v8) l8 = ln(v8, v1) rcwall = doc.addObject("Part::Feature", "FIB_Wall") rcwall.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8])) # analysis analysis = ObjectsFem.makeAnalysis(doc, 'Analysis') solver # TODO How to pass multiple solver for one analysis in one doc if solver is None: pass # no solver is added elif solver is 'calculix': solver = analysis.addObject( ObjectsFem.makeSolverCalculix(doc, 'SolverCalculiX'))[0] solver.AnalysisType = 'static' solver.GeometricalNonlinearity = 'linear' solver.ThermoMechSteadyState = False solver.MatrixSolverType = 'default' solver.IterationsControlParameterTimeUse = False elif solver is 'ccxtools': solver = analysis.addObject( ObjectsFem.makeSolverCalculixCcxTools(doc, 'CalculiXccxTools'))[0] solver.AnalysisType = 'static' solver.GeometricalNonlinearity = 'linear' solver.ThermoMechSteadyState = False solver.MatrixSolverType = 'default' solver.IterationsControlParameterTimeUse = False solver.WorkingDir = u'' # shell thickness thickness = analysis.addObject( ObjectsFem.makeElementGeometry2D(doc, 0, 'ShellThickness'))[0] thickness.Thickness = 150.0 # material matrixprop = {} matrixprop['Name'] = "Concrete-EN-C35/45" matrixprop['YoungsModulus'] = "32000 MPa" matrixprop['PoissonRatio'] = "0.17" matrixprop['CompressiveStrength'] = "15.75 MPa" # make some hint on the possible angle units in material system matrixprop['AngleOfFriction'] = "30 deg" matrixprop['Density'] = '2500 kg/m^3' reinfoprop = {} reinfoprop['Name'] = "Reinforcement-FIB-B500" reinfoprop['YieldStrength'] = "315 MPa" # not an official FreeCAD material property reinfoprop['ReinforcementRatio'] = "0.0" material_reinforced = analysis.addObject( ObjectsFem.makeMaterialReinforced(doc, 'MaterialReinforced'))[0] material_reinforced.Material = matrixprop material_reinforced.Reinforcement = reinfoprop # fixed_constraint fixed_constraint = analysis.addObject( ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed"))[0] fixed_constraint.References = [(rcwall, "Edge1"), (rcwall, "Edge5")] # force constraint force_constraint = doc.Analysis.addObject( ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0] force_constraint.References = [(rcwall, "Edge7")] force_constraint.Force = 1000000.0 force_constraint.Direction = (rcwall, ["Edge8"]) force_constraint.Reversed = False # displacement_constraint displacement_constraint = doc.Analysis.addObject( ObjectsFem.makeConstraintDisplacement( doc, name="ConstraintDisplacmentPrescribed"))[0] displacement_constraint.References = [(rcwall, "Face1")] displacement_constraint.zFix = True # mesh from femexamples.meshes.mesh_rc_wall_2d_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: print('ERROR on creating nodes') control = create_elements(fem_mesh) if not control: print('ERROR on creating elements') femmesh_obj = analysis.addObject( doc.addObject('Fem::FemMeshObject', mesh_name))[0] femmesh_obj.FemMesh = fem_mesh doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # geometric object # name is important because the other method in this module use obj name l1 = Part.makeLine((-142.5, -142.5, 0), (142.5, -142.5, 0)) l2 = Part.makeLine((142.5, -142.5, 0), (142.5, 142.5, 0)) l3 = Part.makeLine((142.5, 142.5, 0), (-142.5, 142.5, 0)) l4 = Part.makeLine((-142.5, 142.5, 0), (-142.5, -142.5, 0)) wire = Part.Wire([l1, l2, l3, l4]) shape = wire.extrude(Vector(0, 0, 1000)) geom_obj = doc.addObject('Part::Feature', 'SquareTube') geom_obj.Shape = shape doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # shell thickness thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 15.0, "ShellThickness") analysis.addObject(thickness_obj) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial") mat = material_obj.Material mat["Name"] = "Steel-Generic" mat["YoungsModulus"] = "200000 MPa" mat["PoissonRatio"] = "0.30" mat["Density"] = "7900 kg/m^3" material_obj.Material = mat analysis.addObject(material_obj) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(doc.SquareTube, "Edge4"), (doc.SquareTube, "Edge7"), (doc.SquareTube, "Edge10"), (doc.SquareTube, "Edge12")] analysis.addObject(con_fixed) # con_force1 con_force1 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce1") con_force1.References = [(geom_obj, "Edge9")] con_force1.Force = 100000.00 con_force1.Direction = (geom_obj, ["Edge9"]) con_force1.Reversed = True analysis.addObject(con_force1) # con_force2 con_force2 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce2") con_force2.References = [(geom_obj, "Edge3")] con_force2.Force = 100000.00 con_force2.Direction = (geom_obj, ["Edge3"]) con_force2.Reversed = True analysis.addObject(con_force2) # con_force3 con_force3 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce3") con_force3.References = [(geom_obj, "Edge11")] con_force3.Force = 100000.00 con_force3.Direction = (geom_obj, ["Edge11"]) con_force3.Reversed = True analysis.addObject(con_force3) # con_force4 con_force4 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce4") con_force4.References = [(geom_obj, "Edge6")] con_force4.Force = 100000.00 con_force4.Direction = (geom_obj, ["Edge6"]) con_force4.Reversed = True analysis.addObject(con_force4) # mesh from .meshes.mesh_square_pipe_end_twisted_tria6 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # geometric object geom_obj = doc.addObject("Part::Box", "Beam") geom_obj.Length = 1 geom_obj.Width = 1.5 geom_obj.Height = 8 doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver, if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "buckling" solver_obj.BucklingFactors = 10 solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial") mat = material_obj.Material mat["Name"] = "CalculiX-Steel" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(geom_obj, "Face5")] analysis.addObject(con_fixed) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [(geom_obj, "Face6")] con_force.Force = 21 con_force.Reversed = True analysis.addObject(con_force) # mesh from .meshes.mesh_flexural_buckling import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj doc.recompute() return doc
material_object = ObjectsFem.makeMaterialSolid(doc, "SolidMaterial") mat = material_object.Material mat['Name'] = "Steel-Generic" mat['YoungsModulus'] = "210000 MPa" mat['PoissonRatio'] = "0.30" mat['Density'] = "7900 kg/m^3" material_object.Material = mat analysis_object.addObject(material_object) # fixed_constraint fixed_constraint = ObjectsFem.makeConstraintFixed(doc, "FemConstraintFixed") fixed_constraint.References = [(doc.Box, "Face1")] analysis_object.addObject(fixed_constraint) # force_constraint force_constraint = ObjectsFem.makeConstraintForce(doc, "FemConstraintForce") force_constraint.References = [(doc.Box, "Face2")] force_constraint.Force = 9000000.0 force_constraint.Direction = (doc.Box, ["Edge5"]) force_constraint.Reversed = True analysis_object.addObject(force_constraint) # gmsh femmesh_obj = ObjectsFem.makeMeshGmsh(doc, box_obj.Name + "_Mesh") femmesh_obj.Part = doc.Box doc.recompute() from femmesh.gmshtools import GmshTools as gt gmsh_mesh = gt(femmesh_obj) error = gmsh_mesh.create_mesh()