Beispiel #1
0
    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 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
Beispiel #3
0
    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
Beispiel #4
0
    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
Beispiel #5
0
    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'))
Beispiel #6
0
    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'))
Beispiel #7
0
    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'))
Beispiel #8
0
    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'))
Beispiel #9
0
    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'))
Beispiel #10
0
    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)
Beispiel #11
0
    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))

        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
        count_defmake = testtools.get_defmake_count(fem_vtk_post)
        # because of the analysis itself count -1
        self.assertEqual(len(analysis.Group), count_defmake - 1)
        self.assertEqual(len(doc.Objects), count_defmake)

        fcc_print("doc objects count: {}, method: {}".format(
            len(doc.Objects),
            sys._getframe().f_code.co_name))
Beispiel #12
0
    def test_Flow1D_thermomech_analysis(self):
        fcc_print('--------------- Start of 1D Flow FEM tests ---------------')
        import Draft
        p1 = FreeCAD.Vector(0, 0, 50)
        p2 = FreeCAD.Vector(0, 0, -50)
        p3 = FreeCAD.Vector(0, 0, -4300)
        p4 = FreeCAD.Vector(4950, 0, -4300)
        p5 = FreeCAD.Vector(5000, 0, -4300)
        p6 = FreeCAD.Vector(8535.53, 0, -7835.53)
        p7 = FreeCAD.Vector(8569.88, 0, -7870.88)
        p8 = FreeCAD.Vector(12105.41, 0, -11406.41)
        p9 = FreeCAD.Vector(12140.76, 0, -11441.76)
        p10 = FreeCAD.Vector(13908.53, 0, -13209.53)
        p11 = FreeCAD.Vector(13943.88, 0, -13244.88)
        p12 = FreeCAD.Vector(15046.97, 0, -14347.97)
        p13 = FreeCAD.Vector(15046.97, 0, -7947.97)
        p14 = FreeCAD.Vector(15046.97, 0, -7847.97)
        p15 = FreeCAD.Vector(0, 0, 0)
        p16 = FreeCAD.Vector(0, 0, -2175)
        p17 = FreeCAD.Vector(2475, 0, -4300)
        p18 = FreeCAD.Vector(4975, 0, -4300)
        p19 = FreeCAD.Vector(6767.765, 0, -6067.765)
        p20 = FreeCAD.Vector(8552.705, 0, -7853.205)
        p21 = FreeCAD.Vector(10337.645, 0, -9638.645)
        p22 = FreeCAD.Vector(12123.085, 0, -11424.085)
        p23 = FreeCAD.Vector(13024.645, 0, -12325.645)
        p24 = FreeCAD.Vector(13926.205, 0, -13227.205)
        p25 = FreeCAD.Vector(14495.425, 0, -13796.425)
        p26 = FreeCAD.Vector(15046.97, 0, -11147.97)
        p27 = FreeCAD.Vector(15046.97, 0, -7897.97)
        points = [
            p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,
            p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27
        ]
        line = Draft.makeWire(points, closed=False, face=False, support=None)
        fcc_print('Checking FEM new analysis...')
        analysis = ObjectsFem.makeAnalysis(self.active_doc, 'Analysis')
        self.assertTrue(analysis, "FemTest of new analysis failed")

        fcc_print('Checking FEM new solver...')
        solver_object = ObjectsFem.makeSolverCalculixCcxTools(
            self.active_doc, 'CalculiX')
        solver_object.AnalysisType = 'thermomech'
        solver_object.GeometricalNonlinearity = 'linear'
        solver_object.ThermoMechSteadyState = True
        solver_object.MatrixSolverType = 'default'
        solver_object.IterationsThermoMechMaximum = 2000
        solver_object.IterationsControlParameterTimeUse = False
        self.assertTrue(solver_object, "FemTest of new solver failed")
        analysis.addObject(solver_object)

        fcc_print('Checking FEM new material...')
        material_object = ObjectsFem.makeMaterialFluid(self.active_doc,
                                                       'FluidMaterial')
        mat = material_object.Material
        mat['Name'] = "Water"
        mat['Density'] = "998 kg/m^3"
        mat['SpecificHeat'] = "4.182 J/kg/K"
        mat['DynamicViscosity'] = "1.003e-3 kg/m/s"
        mat['VolumetricThermalExpansionCoefficient'] = "2.07e-4 m/m/K"
        mat['ThermalConductivity'] = "0.591 W/m/K"
        material_object.Material = mat
        self.assertTrue(material_object, "FemTest of new material failed")
        analysis.addObject(material_object)

        fcc_print('Checking FEM Flow1D inlet constraint...')
        Flow1d_inlet = ObjectsFem.makeElementFluid1D(self.active_doc,
                                                     "ElementFluid1D")
        Flow1d_inlet.SectionType = 'Liquid'
        Flow1d_inlet.LiquidSectionType = 'PIPE INLET'
        Flow1d_inlet.InletPressure = 0.1
        Flow1d_inlet.References = [(line, "Edge1")]
        self.assertTrue(Flow1d_inlet,
                        "FemTest of new Flow1D inlet constraint failed")
        analysis.addObject(Flow1d_inlet)

        fcc_print('Checking FEM new Flow1D entrance constraint...')
        Flow1d_entrance = ObjectsFem.makeElementFluid1D(
            self.active_doc, "ElementFluid1D")
        Flow1d_entrance.SectionType = 'Liquid'
        Flow1d_entrance.LiquidSectionType = 'PIPE ENTRANCE'
        Flow1d_entrance.EntrancePipeArea = 31416.00
        Flow1d_entrance.EntranceArea = 25133.00
        Flow1d_entrance.References = [(line, "Edge2")]
        self.assertTrue(Flow1d_entrance,
                        "FemTest of new Flow1D entrance constraint failed")
        analysis.addObject(Flow1d_entrance)

        fcc_print('Checking FEM new Flow1D manning constraint...')
        Flow1d_manning = ObjectsFem.makeElementFluid1D(self.active_doc,
                                                       "ElementFluid1D")
        Flow1d_manning.SectionType = 'Liquid'
        Flow1d_manning.LiquidSectionType = 'PIPE MANNING'
        Flow1d_manning.ManningArea = 31416
        Flow1d_manning.ManningRadius = 50
        Flow1d_manning.ManningCoefficient = 0.002
        Flow1d_manning.References = [(line, "Edge3"), (line, "Edge5")]
        self.assertTrue(Flow1d_manning,
                        "FemTest of new Flow1D manning constraint failed")
        analysis.addObject(Flow1d_manning)

        fcc_print('Checking FEM new Flow1D bend constraint...')
        Flow1d_bend = ObjectsFem.makeElementFluid1D(self.active_doc,
                                                    "ElementFluid1D")
        Flow1d_bend.SectionType = 'Liquid'
        Flow1d_bend.LiquidSectionType = 'PIPE BEND'
        Flow1d_bend.BendPipeArea = 31416
        Flow1d_bend.BendRadiusDiameter = 1.5
        Flow1d_bend.BendAngle = 45
        Flow1d_bend.BendLossCoefficient = 0.4
        Flow1d_bend.References = [(line, "Edge4")]
        self.assertTrue(Flow1d_bend,
                        "FemTest of new Flow1D bend constraint failed")
        analysis.addObject(Flow1d_bend)

        fcc_print('Checking FEM new Flow1D enlargement constraint...')
        Flow1d_enlargement = ObjectsFem.makeElementFluid1D(
            self.active_doc, "ElementFluid1D")
        Flow1d_enlargement.SectionType = 'Liquid'
        Flow1d_enlargement.LiquidSectionType = 'PIPE ENLARGEMENT'
        Flow1d_enlargement.EnlargeArea1 = 31416.00
        Flow1d_enlargement.EnlargeArea2 = 70686.00
        Flow1d_enlargement.References = [(line, "Edge6")]
        self.assertTrue(Flow1d_enlargement,
                        "FemTest of new Flow1D enlargement constraint failed")
        analysis.addObject(Flow1d_enlargement)

        fcc_print('Checking FEM new Flow1D manning constraint...')
        Flow1d_manning1 = ObjectsFem.makeElementFluid1D(
            self.active_doc, "ElementFluid1D")
        Flow1d_manning1.SectionType = 'Liquid'
        Flow1d_manning1.LiquidSectionType = 'PIPE MANNING'
        Flow1d_manning1.ManningArea = 70686.00
        Flow1d_manning1.ManningRadius = 75
        Flow1d_manning1.ManningCoefficient = 0.002
        Flow1d_manning1.References = [(line, "Edge7")]
        self.assertTrue(Flow1d_manning1,
                        "FemTest of new Flow1D manning constraint failed")
        analysis.addObject(Flow1d_manning1)

        fcc_print('Checking FEM new Flow1D contraction constraint...')
        Flow1d_contraction = ObjectsFem.makeElementFluid1D(
            self.active_doc, "ElementFluid1D")
        Flow1d_contraction.SectionType = 'Liquid'
        Flow1d_contraction.LiquidSectionType = 'PIPE CONTRACTION'
        Flow1d_contraction.ContractArea1 = 70686
        Flow1d_contraction.ContractArea2 = 17671
        Flow1d_contraction.References = [(line, "Edge8")]
        self.assertTrue(Flow1d_contraction,
                        "FemTest of new Flow1D contraction constraint failed")
        analysis.addObject(Flow1d_contraction)

        fcc_print('Checking FEM new Flow1D manning constraint...')
        Flow1d_manning2 = ObjectsFem.makeElementFluid1D(
            self.active_doc, "ElementFluid1D")
        Flow1d_manning2.SectionType = 'Liquid'
        Flow1d_manning2.LiquidSectionType = 'PIPE MANNING'
        Flow1d_manning2.ManningArea = 17671.00
        Flow1d_manning2.ManningRadius = 37.5
        Flow1d_manning2.ManningCoefficient = 0.002
        Flow1d_manning2.References = [(line, "Edge11"), (line, "Edge9")]
        self.assertTrue(Flow1d_manning2,
                        "FemTest of new Flow1D manning constraint failed")
        analysis.addObject(Flow1d_manning2)

        fcc_print('Checking FEM new Flow1D gate valve constraint...')
        Flow1d_gate_valve = ObjectsFem.makeElementFluid1D(
            self.active_doc, "ElementFluid1D")
        Flow1d_gate_valve.SectionType = 'Liquid'
        Flow1d_gate_valve.LiquidSectionType = 'PIPE GATE VALVE'
        Flow1d_gate_valve.GateValvePipeArea = 17671
        Flow1d_gate_valve.GateValveClosingCoeff = 0.5
        Flow1d_gate_valve.References = [(line, "Edge10")]
        self.assertTrue(Flow1d_gate_valve,
                        "FemTest of new Flow1D gate valve constraint failed")
        analysis.addObject(Flow1d_gate_valve)

        fcc_print('Checking FEM new Flow1D enlargement constraint...')
        Flow1d_enlargement1 = ObjectsFem.makeElementFluid1D(
            self.active_doc, "ElementFluid1D")
        Flow1d_enlargement1.SectionType = 'Liquid'
        Flow1d_enlargement1.LiquidSectionType = 'PIPE ENLARGEMENT'
        Flow1d_enlargement1.EnlargeArea1 = 17671
        Flow1d_enlargement1.EnlargeArea2 = 1e12
        Flow1d_enlargement1.References = [(line, "Edge12")]
        self.assertTrue(Flow1d_enlargement1,
                        "FemTest of new Flow1D enlargement constraint failed")
        analysis.addObject(Flow1d_enlargement1)

        fcc_print('Checking FEM Flow1D outlet constraint...')
        Flow1d_outlet = ObjectsFem.makeElementFluid1D(self.active_doc,
                                                      "ElementFluid1D")
        Flow1d_outlet.SectionType = 'Liquid'
        Flow1d_outlet.LiquidSectionType = 'PIPE OUTLET'
        Flow1d_outlet.OutletPressure = 0.1
        Flow1d_outlet.References = [(line, "Edge13")]
        self.assertTrue(Flow1d_outlet,
                        "FemTest of new Flow1D inlet constraint failed")
        analysis.addObject(Flow1d_outlet)

        fcc_print('Checking FEM self weight constraint...')
        Flow1d_self_weight = ObjectsFem.makeConstraintSelfWeight(
            self.active_doc, "ConstraintSelfWeight")
        Flow1d_self_weight.Gravity_x = 0.0
        Flow1d_self_weight.Gravity_y = 0.0
        Flow1d_self_weight.Gravity_z = -1.0
        self.assertTrue(Flow1d_outlet,
                        "FemTest of new Flow1D self weight constraint failed")
        analysis.addObject(Flow1d_self_weight)

        fcc_print('Checking FEM new mesh...')
        from .testfiles.ccx.Flow1D_mesh import create_nodes_Flow1D
        from .testfiles.ccx.Flow1D_mesh import create_elements_Flow1D
        mesh = Fem.FemMesh()
        ret = create_nodes_Flow1D(mesh)
        self.assertTrue(ret, "Import of mesh nodes failed")
        ret = create_elements_Flow1D(mesh)
        self.assertTrue(ret, "Import of mesh volumes failed")
        mesh_object = self.active_doc.addObject('Fem::FemMeshObject',
                                                self.mesh_name)
        mesh_object.FemMesh = mesh
        self.assertTrue(mesh, "FemTest of new mesh failed")
        analysis.addObject(mesh_object)

        self.active_doc.recompute()

        Flow1D_thermomech_analysis_dir = self.temp_dir + 'FEM_ccx_Flow1D_thermomech/'
        fea = ccxtools.FemToolsCcx(analysis, test_mode=True)

        fcc_print('Setting up working directory {}'.format(
            Flow1D_thermomech_analysis_dir))
        fea.setup_working_dir(Flow1D_thermomech_analysis_dir)
        self.assertTrue(
            True if fea.working_dir == Flow1D_thermomech_analysis_dir else
            False, "Setting working directory {} failed".format(
                Flow1D_thermomech_analysis_dir))

        fcc_print(
            'Checking FEM inp file prerequisites for thermo-mechanical analysis...'
        )
        error = fea.check_prerequisites()
        self.assertFalse(
            error,
            "ccxtools check_prerequisites returned error message: {}".format(
                error))

        fcc_print('Checking FEM inp file write...')
        fcc_print('Writing {}/{}.inp for thermomech analysis'.format(
            Flow1D_thermomech_analysis_dir, self.mesh_name))
        error = fea.write_inp_file()
        self.assertFalse(error, "Writing failed")

        Flow1D_thermomech_base_name = 'Flow1D_thermomech'
        Flow1D_thermomech_analysis_inp_file = self.test_file_dir + Flow1D_thermomech_base_name + '.inp'
        fcc_print('Comparing {} to {}/{}.inp'.format(
            Flow1D_thermomech_analysis_inp_file,
            Flow1D_thermomech_analysis_dir, self.mesh_name))
        ret = testtools.compare_inp_files(
            Flow1D_thermomech_analysis_inp_file,
            Flow1D_thermomech_analysis_dir + self.mesh_name + '.inp')
        self.assertFalse(
            ret, "ccxtools write_inp_file test failed.\n{}".format(ret))

        fcc_print(
            'Setting up working directory to {} in order to read simulated calculations'
            .format(self.test_file_dir))
        fea.setup_working_dir(self.test_file_dir)
        self.assertTrue(
            True if fea.working_dir == self.test_file_dir else False,
            "Setting working directory {} failed".format(self.test_file_dir))

        fcc_print('Setting base name to read test {}.frd file...'.format(
            'Flow1D_thermomech'))
        fea.set_base_name(Flow1D_thermomech_base_name)
        self.assertTrue(
            True if fea.base_name == Flow1D_thermomech_base_name else False,
            "Setting base name to {} failed".format(
                Flow1D_thermomech_base_name))

        fcc_print('Setting inp file name to read test {}.frd file...'.format(
            'Flow1D_thermomech'))
        fea.set_inp_file_name()
        self.assertTrue(
            True if fea.inp_file_name == Flow1D_thermomech_analysis_inp_file
            else False, "Setting inp file name to {} failed".format(
                Flow1D_thermomech_analysis_inp_file))

        fcc_print(
            'Checking FEM frd file read from Flow1D thermomech analysis...')
        fea.load_results()
        self.assertTrue(
            fea.results_present,
            "Cannot read results from {}.frd frd file".format(fea.base_name))

        fcc_print(
            'Reading stats from result object for Flow1D thermomech analysis...'
        )
        Flow1D_thermomech_expected_values = self.test_file_dir + "Flow1D_thermomech_expected_values"
        stat_types = [
            "U1", "U2", "U3", "Uabs", "Sabs", "MaxPrin", "MidPrin", "MinPrin",
            "MaxShear", "Peeq", "Temp", "MFlow", "NPress"
        ]
        ret = testtools.compare_stats(fea, Flow1D_thermomech_expected_values,
                                      stat_types,
                                      'CalculiX_thermomech_time_1_0_results')
        self.assertFalse(ret, "Invalid results read from .frd file")

        Flow1D_thermomech_save_fc_file = Flow1D_thermomech_analysis_dir + Flow1D_thermomech_base_name + '.fcstd'
        fcc_print('Save FreeCAD file for thermomech analysis to {}...'.format(
            Flow1D_thermomech_save_fc_file))
        self.active_doc.saveAs(Flow1D_thermomech_save_fc_file)

        fcc_print(
            '--------------- End of FEM tests FLow 1D thermomech analysis ---------------'
        )
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", "Box")
    geom_obj.Height = geom_obj.Width = 1000
    geom_obj.Length = 32000
    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""
    elif solvertype == "elmer":
        solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer")
        eq_obj = ObjectsFem.makeEquationElasticity(doc, solver_obj)
        eq_obj.LinearSolverType = "Direct"
    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_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
    mat = material_obj.Material
    mat["Name"] = "CalculiX-Steel"
    mat["YoungsModulus"] = "210000 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 = [(geom_obj, "Face1")]
    analysis.addObject(con_fixed)

    # constraint selfweight
    con_selfweight = ObjectsFem.makeConstraintSelfWeight(
        doc, "ConstraintSelfWeight")
    con_selfweight.Gravity_z = -1.00
    analysis.addObject(con_selfweight)

    # mesh
    from .meshes.mesh_selfweight_cantilever_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
Beispiel #14
0
    def test_5_Flow1D_thermomech_analysis(self):
        fcc_print('--------------- Start of 1D Flow FEM tests ---------------')
        import Draft
        p1 = FreeCAD.Vector(0, 0, 50)
        p2 = FreeCAD.Vector(0, 0, -50)
        p3 = FreeCAD.Vector(0, 0, -4300)
        p4 = FreeCAD.Vector(4950, 0, -4300)
        p5 = FreeCAD.Vector(5000, 0, -4300)
        p6 = FreeCAD.Vector(8535.53, 0, -7835.53)
        p7 = FreeCAD.Vector(8569.88, 0, -7870.88)
        p8 = FreeCAD.Vector(12105.41, 0, -11406.41)
        p9 = FreeCAD.Vector(12140.76, 0, -11441.76)
        p10 = FreeCAD.Vector(13908.53, 0, -13209.53)
        p11 = FreeCAD.Vector(13943.88, 0, -13244.88)
        p12 = FreeCAD.Vector(15046.97, 0, -14347.97)
        p13 = FreeCAD.Vector(15046.97, 0, -7947.97)
        p14 = FreeCAD.Vector(15046.97, 0, -7847.97)
        p15 = FreeCAD.Vector(0, 0, 0)
        p16 = FreeCAD.Vector(0, 0, -2175)
        p17 = FreeCAD.Vector(2475, 0, -4300)
        p18 = FreeCAD.Vector(4975, 0, -4300)
        p19 = FreeCAD.Vector(6767.765, 0, -6067.765)
        p20 = FreeCAD.Vector(8552.705, 0, -7853.205)
        p21 = FreeCAD.Vector(10337.645, 0, -9638.645)
        p22 = FreeCAD.Vector(12123.085, 0, -11424.085)
        p23 = FreeCAD.Vector(13024.645, 0, -12325.645)
        p24 = FreeCAD.Vector(13926.205, 0, -13227.205)
        p25 = FreeCAD.Vector(14495.425, 0, -13796.425)
        p26 = FreeCAD.Vector(15046.97, 0, -11147.97)
        p27 = FreeCAD.Vector(15046.97, 0, -7897.97)
        points = [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27]
        line = Draft.makeWire(points, closed=False, face=False, support=None)
        fcc_print('Checking FEM new analysis...')
        analysis = ObjectsFem.makeAnalysis(self.active_doc, 'Analysis')
        self.assertTrue(analysis, "FemTest of new analysis failed")

        fcc_print('Checking FEM new solver...')
        solver_object = ObjectsFem.makeSolverCalculixCcxTools(self.active_doc, 'CalculiX')
        solver_object.AnalysisType = 'thermomech'
        solver_object.GeometricalNonlinearity = 'linear'
        solver_object.ThermoMechSteadyState = True
        solver_object.MatrixSolverType = 'default'
        solver_object.IterationsThermoMechMaximum = 2000
        solver_object.IterationsControlParameterTimeUse = False
        self.assertTrue(solver_object, "FemTest of new solver failed")
        analysis.addObject(solver_object)

        fcc_print('Checking FEM new material...')
        material_object = ObjectsFem.makeMaterialFluid(self.active_doc, 'FluidMaterial')
        mat = material_object.Material
        mat['Name'] = "Water"
        mat['Density'] = "998 kg/m^3"
        mat['SpecificHeat'] = "4.182 J/kg/K"
        mat['DynamicViscosity'] = "1.003e-3 kg/m/s"
        mat['VolumetricThermalExpansionCoefficient'] = "2.07e-4 m/m/K"
        mat['ThermalConductivity'] = "0.591 W/m/K"
        material_object.Material = mat
        self.assertTrue(material_object, "FemTest of new material failed")
        analysis.addObject(material_object)

        fcc_print('Checking FEM Flow1D inlet constraint...')
        Flow1d_inlet = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_inlet.SectionType = 'Liquid'
        Flow1d_inlet.LiquidSectionType = 'PIPE INLET'
        Flow1d_inlet.InletPressure = 0.1
        Flow1d_inlet.References = [(line, "Edge1")]
        self.assertTrue(Flow1d_inlet, "FemTest of new Flow1D inlet constraint failed")
        analysis.addObject(Flow1d_inlet)

        fcc_print('Checking FEM new Flow1D entrance constraint...')
        Flow1d_entrance = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_entrance.SectionType = 'Liquid'
        Flow1d_entrance.LiquidSectionType = 'PIPE ENTRANCE'
        Flow1d_entrance.EntrancePipeArea = 31416.00
        Flow1d_entrance.EntranceArea = 25133.00
        Flow1d_entrance.References = [(line, "Edge2")]
        self.assertTrue(Flow1d_entrance, "FemTest of new Flow1D entrance constraint failed")
        analysis.addObject(Flow1d_entrance)

        fcc_print('Checking FEM new Flow1D manning constraint...')
        Flow1d_manning = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_manning.SectionType = 'Liquid'
        Flow1d_manning.LiquidSectionType = 'PIPE MANNING'
        Flow1d_manning.ManningArea = 31416
        Flow1d_manning.ManningRadius = 50
        Flow1d_manning.ManningCoefficient = 0.002
        Flow1d_manning.References = [(line, "Edge3"), (line, "Edge5")]
        self.assertTrue(Flow1d_manning, "FemTest of new Flow1D manning constraint failed")
        analysis.addObject(Flow1d_manning)

        fcc_print('Checking FEM new Flow1D bend constraint...')
        Flow1d_bend = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_bend.SectionType = 'Liquid'
        Flow1d_bend.LiquidSectionType = 'PIPE BEND'
        Flow1d_bend.BendPipeArea = 31416
        Flow1d_bend.BendRadiusDiameter = 1.5
        Flow1d_bend.BendAngle = 45
        Flow1d_bend.BendLossCoefficient = 0.4
        Flow1d_bend.References = [(line, "Edge4")]
        self.assertTrue(Flow1d_bend, "FemTest of new Flow1D bend constraint failed")
        analysis.addObject(Flow1d_bend)

        fcc_print('Checking FEM new Flow1D enlargement constraint...')
        Flow1d_enlargement = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_enlargement.SectionType = 'Liquid'
        Flow1d_enlargement.LiquidSectionType = 'PIPE ENLARGEMENT'
        Flow1d_enlargement.EnlargeArea1 = 31416.00
        Flow1d_enlargement.EnlargeArea2 = 70686.00
        Flow1d_enlargement.References = [(line, "Edge6")]
        self.assertTrue(Flow1d_enlargement, "FemTest of new Flow1D enlargement constraint failed")
        analysis.addObject(Flow1d_enlargement)

        fcc_print('Checking FEM new Flow1D manning constraint...')
        Flow1d_manning1 = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_manning1.SectionType = 'Liquid'
        Flow1d_manning1.LiquidSectionType = 'PIPE MANNING'
        Flow1d_manning1.ManningArea = 70686.00
        Flow1d_manning1.ManningRadius = 75
        Flow1d_manning1.ManningCoefficient = 0.002
        Flow1d_manning1.References = [(line, "Edge7")]
        self.assertTrue(Flow1d_manning1, "FemTest of new Flow1D manning constraint failed")
        analysis.addObject(Flow1d_manning1)

        fcc_print('Checking FEM new Flow1D contraction constraint...')
        Flow1d_contraction = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_contraction.SectionType = 'Liquid'
        Flow1d_contraction.LiquidSectionType = 'PIPE CONTRACTION'
        Flow1d_contraction.ContractArea1 = 70686
        Flow1d_contraction.ContractArea2 = 17671
        Flow1d_contraction.References = [(line, "Edge8")]
        self.assertTrue(Flow1d_contraction, "FemTest of new Flow1D contraction constraint failed")
        analysis.addObject(Flow1d_contraction)

        fcc_print('Checking FEM new Flow1D manning constraint...')
        Flow1d_manning2 = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_manning2.SectionType = 'Liquid'
        Flow1d_manning2.LiquidSectionType = 'PIPE MANNING'
        Flow1d_manning2.ManningArea = 17671.00
        Flow1d_manning2.ManningRadius = 37.5
        Flow1d_manning2.ManningCoefficient = 0.002
        Flow1d_manning2.References = [(line, "Edge11"), (line, "Edge9")]
        self.assertTrue(Flow1d_manning2, "FemTest of new Flow1D manning constraint failed")
        analysis.addObject(Flow1d_manning2)

        fcc_print('Checking FEM new Flow1D gate valve constraint...')
        Flow1d_gate_valve = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_gate_valve.SectionType = 'Liquid'
        Flow1d_gate_valve.LiquidSectionType = 'PIPE GATE VALVE'
        Flow1d_gate_valve.GateValvePipeArea = 17671
        Flow1d_gate_valve.GateValveClosingCoeff = 0.5
        Flow1d_gate_valve.References = [(line, "Edge10")]
        self.assertTrue(Flow1d_gate_valve, "FemTest of new Flow1D gate valve constraint failed")
        analysis.addObject(Flow1d_gate_valve)

        fcc_print('Checking FEM new Flow1D enlargement constraint...')
        Flow1d_enlargement1 = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_enlargement1.SectionType = 'Liquid'
        Flow1d_enlargement1.LiquidSectionType = 'PIPE ENLARGEMENT'
        Flow1d_enlargement1.EnlargeArea1 = 17671
        Flow1d_enlargement1.EnlargeArea2 = 1e12
        Flow1d_enlargement1.References = [(line, "Edge12")]
        self.assertTrue(Flow1d_enlargement1, "FemTest of new Flow1D enlargement constraint failed")
        analysis.addObject(Flow1d_enlargement1)

        fcc_print('Checking FEM Flow1D outlet constraint...')
        Flow1d_outlet = ObjectsFem.makeElementFluid1D(self.active_doc, "ElementFluid1D")
        Flow1d_outlet.SectionType = 'Liquid'
        Flow1d_outlet.LiquidSectionType = 'PIPE OUTLET'
        Flow1d_outlet.OutletPressure = 0.1
        Flow1d_outlet.References = [(line, "Edge13")]
        self.assertTrue(Flow1d_outlet, "FemTest of new Flow1D inlet constraint failed")
        analysis.addObject(Flow1d_outlet)

        fcc_print('Checking FEM self weight constraint...')
        Flow1d_self_weight = ObjectsFem.makeConstraintSelfWeight(self.active_doc, "ConstraintSelfWeight")
        Flow1d_self_weight.Gravity_x = 0.0
        Flow1d_self_weight.Gravity_y = 0.0
        Flow1d_self_weight.Gravity_z = -1.0
        self.assertTrue(Flow1d_outlet, "FemTest of new Flow1D self weight constraint failed")
        analysis.addObject(Flow1d_self_weight)

        fcc_print('Checking FEM new mesh...')
        from .testfiles.ccx.Flow1D_mesh import create_nodes_Flow1D
        from .testfiles.ccx.Flow1D_mesh import create_elements_Flow1D
        mesh = Fem.FemMesh()
        ret = create_nodes_Flow1D(mesh)
        self.assertTrue(ret, "Import of mesh nodes failed")
        ret = create_elements_Flow1D(mesh)
        self.assertTrue(ret, "Import of mesh volumes failed")
        mesh_object = self.active_doc.addObject('Fem::FemMeshObject', self.mesh_name)
        mesh_object.FemMesh = mesh
        self.assertTrue(mesh, "FemTest of new mesh failed")
        analysis.addObject(mesh_object)

        self.active_doc.recompute()

        Flow1D_thermomech_analysis_dir = self.temp_dir + 'FEM_ccx_Flow1D_thermomech/'
        fea = ccxtools.FemToolsCcx(analysis, test_mode=True)

        fcc_print('Setting up working directory {}'.format(Flow1D_thermomech_analysis_dir))
        fea.setup_working_dir(Flow1D_thermomech_analysis_dir)
        self.assertTrue(True if fea.working_dir == Flow1D_thermomech_analysis_dir else False,
                        "Setting working directory {} failed".format(Flow1D_thermomech_analysis_dir))

        fcc_print('Checking FEM inp file prerequisites for thermo-mechanical analysis...')
        error = fea.check_prerequisites()
        self.assertFalse(error, "ccxtools check_prerequisites returned error message: {}".format(error))

        fcc_print('Checking FEM inp file write...')
        fcc_print('Writing {}/{}.inp for thermomech analysis'.format(Flow1D_thermomech_analysis_dir, self.mesh_name))
        error = fea.write_inp_file()
        self.assertFalse(error, "Writing failed")

        Flow1D_thermomech_base_name = 'Flow1D_thermomech'
        Flow1D_thermomech_analysis_inp_file = self.test_file_dir + Flow1D_thermomech_base_name + '.inp'
        fcc_print('Comparing {} to {}/{}.inp'.format(Flow1D_thermomech_analysis_inp_file, Flow1D_thermomech_analysis_dir, self.mesh_name))
        ret = testtools.compare_inp_files(Flow1D_thermomech_analysis_inp_file, Flow1D_thermomech_analysis_dir + self.mesh_name + '.inp')
        self.assertFalse(ret, "ccxtools write_inp_file test failed.\n{}".format(ret))

        fcc_print('Setting up working directory to {} in order to read simulated calculations'.format(self.test_file_dir))
        fea.setup_working_dir(self.test_file_dir)
        self.assertTrue(True if fea.working_dir == self.test_file_dir else False,
                        "Setting working directory {} failed".format(self.test_file_dir))

        fcc_print('Setting base name to read test {}.frd file...'.format('Flow1D_thermomech'))
        fea.set_base_name(Flow1D_thermomech_base_name)
        self.assertTrue(True if fea.base_name == Flow1D_thermomech_base_name else False,
                        "Setting base name to {} failed".format(Flow1D_thermomech_base_name))

        fcc_print('Setting inp file name to read test {}.frd file...'.format('Flow1D_thermomech'))
        fea.set_inp_file_name()
        self.assertTrue(True if fea.inp_file_name == Flow1D_thermomech_analysis_inp_file else False,
                        "Setting inp file name to {} failed".format(Flow1D_thermomech_analysis_inp_file))

        fcc_print('Checking FEM frd file read from Flow1D thermomech analysis...')
        fea.load_results()
        self.assertTrue(fea.results_present, "Cannot read results from {}.frd frd file".format(fea.base_name))

        fcc_print('Reading stats from result object for Flow1D thermomech analysis...')
        Flow1D_thermomech_expected_values = self.test_file_dir + "Flow1D_thermomech_expected_values"
        stat_types = ["U1", "U2", "U3", "Uabs", "Sabs", "MaxPrin", "MidPrin", "MinPrin", "MaxShear", "Peeq", "Temp", "MFlow", "NPress"]
        ret = testtools.compare_stats(fea, Flow1D_thermomech_expected_values, stat_types, 'CalculiX_thermomech_time_1_0_results')
        self.assertFalse(ret, "Invalid results read from .frd file")

        Flow1D_thermomech_save_fc_file = Flow1D_thermomech_analysis_dir + Flow1D_thermomech_base_name + '.fcstd'
        fcc_print('Save FreeCAD file for thermomech analysis to {}...'.format(Flow1D_thermomech_save_fc_file))
        self.active_doc.saveAs(Flow1D_thermomech_save_fc_file)

        fcc_print('--------------- End of FEM tests FLow 1D thermomech analysis ---------------')
Beispiel #15
0
def setup(doc=None, solvertype="ccxtools"):
    # setup model

    if doc is None:
        doc = init_doc()

    p1 = FreeCAD.Vector(0, 0, 50)
    p2 = FreeCAD.Vector(0, 0, -50)
    p3 = FreeCAD.Vector(0, 0, -4300)
    p4 = FreeCAD.Vector(4950, 0, -4300)
    p5 = FreeCAD.Vector(5000, 0, -4300)
    p6 = FreeCAD.Vector(8535.53, 0, -7835.53)
    p7 = FreeCAD.Vector(8569.88, 0, -7870.88)
    p8 = FreeCAD.Vector(12105.41, 0, -11406.41)
    p9 = FreeCAD.Vector(12140.76, 0, -11441.76)
    p10 = FreeCAD.Vector(13908.53, 0, -13209.53)
    p11 = FreeCAD.Vector(13943.88, 0, -13244.88)
    p12 = FreeCAD.Vector(15046.97, 0, -14347.97)
    p13 = FreeCAD.Vector(15046.97, 0, -7947.97)
    p14 = FreeCAD.Vector(15046.97, 0, -7847.97)
    p15 = FreeCAD.Vector(0, 0, 0)
    p16 = FreeCAD.Vector(0, 0, -2175)
    p17 = FreeCAD.Vector(2475, 0, -4300)
    p18 = FreeCAD.Vector(4975, 0, -4300)
    p19 = FreeCAD.Vector(6767.765, 0, -6067.765)
    p20 = FreeCAD.Vector(8552.705, 0, -7853.205)
    p21 = FreeCAD.Vector(10337.645, 0, -9638.645)
    p22 = FreeCAD.Vector(12123.085, 0, -11424.085)
    p23 = FreeCAD.Vector(13024.645, 0, -12325.645)
    p24 = FreeCAD.Vector(13926.205, 0, -13227.205)
    p25 = FreeCAD.Vector(14495.425, 0, -13796.425)
    p26 = FreeCAD.Vector(15046.97, 0, -11147.97)
    p27 = FreeCAD.Vector(15046.97, 0, -7897.97)
    points = [
        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16,
        p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27
    ]
    from Draft import makeWire
    line = makeWire(points, closed=False, face=False, support=None)
    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")  # CalculiX
        )[0]
        solver_object.WorkingDir = u""
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_object.AnalysisType = "thermomech"
        solver_object.GeometricalNonlinearity = "linear"
        solver_object.ThermoMechSteadyState = True
        solver_object.MatrixSolverType = "default"
        solver_object.IterationsThermoMechMaximum = 2000
        solver_object.IterationsControlParameterTimeUse = False

    # material
    material_object = analysis.addObject(
        ObjectsFem.makeMaterialFluid(doc, "FluidMaterial"))[0]
    mat = material_object.Material
    mat["Name"] = "Water"
    mat["Density"] = "998 kg/m^3"
    mat["SpecificHeat"] = "4.182 J/kg/K"
    mat["DynamicViscosity"] = "1.003e-3 kg/m/s"
    mat["VolumetricThermalExpansionCoefficient"] = "2.07e-4 m/m/K"
    mat["ThermalConductivity"] = "0.591 W/m/K"
    material_object.Material = mat

    inlet = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    inlet.SectionType = "Liquid"
    inlet.LiquidSectionType = "PIPE INLET"
    inlet.InletPressure = 0.1
    inlet.References = [(line, "Edge1")]

    entrance = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    entrance.SectionType = "Liquid"
    entrance.LiquidSectionType = "PIPE ENTRANCE"
    entrance.EntrancePipeArea = 31416.00
    entrance.EntranceArea = 25133.00
    entrance.References = [(line, "Edge2")]

    manning1 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    manning1.SectionType = "Liquid"
    manning1.LiquidSectionType = "PIPE MANNING"
    manning1.ManningArea = 31416
    manning1.ManningRadius = 50
    manning1.ManningCoefficient = 0.002
    manning1.References = [(line, "Edge3"), (line, "Edge5")]

    bend = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    bend.SectionType = "Liquid"
    bend.LiquidSectionType = "PIPE BEND"
    bend.BendPipeArea = 31416
    bend.BendRadiusDiameter = 1.5
    bend.BendAngle = 45
    bend.BendLossCoefficient = 0.4
    bend.References = [(line, "Edge4")]

    enlargement1 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    enlargement1.SectionType = "Liquid"
    enlargement1.LiquidSectionType = "PIPE ENLARGEMENT"
    enlargement1.EnlargeArea1 = 31416.00
    enlargement1.EnlargeArea2 = 70686.00
    enlargement1.References = [(line, "Edge6")]

    manning2 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    manning2.SectionType = "Liquid"
    manning2.LiquidSectionType = "PIPE MANNING"
    manning2.ManningArea = 70686.00
    manning2.ManningRadius = 75
    manning2.ManningCoefficient = 0.002
    manning2.References = [(line, "Edge7")]

    contraction = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    contraction.SectionType = "Liquid"
    contraction.LiquidSectionType = "PIPE CONTRACTION"
    contraction.ContractArea1 = 70686
    contraction.ContractArea2 = 17671
    contraction.References = [(line, "Edge8")]

    manning3 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    manning3.SectionType = "Liquid"
    manning3.LiquidSectionType = "PIPE MANNING"
    manning3.ManningArea = 17671.00
    manning3.ManningRadius = 37.5
    manning3.ManningCoefficient = 0.002
    manning3.References = [(line, "Edge11"), (line, "Edge9")]

    gate_valve = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    gate_valve.SectionType = "Liquid"
    gate_valve.LiquidSectionType = "PIPE GATE VALVE"
    gate_valve.GateValvePipeArea = 17671
    gate_valve.GateValveClosingCoeff = 0.5
    gate_valve.References = [(line, "Edge10")]

    enlargement2 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    enlargement2.SectionType = "Liquid"
    enlargement2.LiquidSectionType = "PIPE ENLARGEMENT"
    enlargement2.EnlargeArea1 = 17671
    enlargement2.EnlargeArea2 = 1e12
    enlargement2.References = [(line, "Edge12")]

    outlet = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    outlet.SectionType = "Liquid"
    outlet.LiquidSectionType = "PIPE OUTLET"
    outlet.OutletPressure = 0.1
    outlet.References = [(line, "Edge13")]

    self_weight = analysis.addObject(
        ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight"))[0]
    self_weight.Gravity_x = 0.0
    self_weight.Gravity_y = 0.0
    self_weight.Gravity_z = -1.0

    # mesh
    from .meshes.mesh_thermomech_flow1d_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(
        doc.addObject("Fem::FemMeshObject", mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh

    doc.recompute()
    return doc
Beispiel #16
0
    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

        # FemAnalysis
        analysis = ObjectsFem.makeAnalysis(doc)
        self.assertTrue(is_derived_from(analysis, "App::DocumentObject"))
        self.assertTrue(is_derived_from(analysis, "Fem::FemAnalysis"))

        # ConstraintBearing
        constraint_bearing = ObjectsFem.makeConstraintBearing(doc)
        self.assertTrue(
            is_derived_from(constraint_bearing, "App::DocumentObject"))
        self.assertTrue(is_derived_from(constraint_bearing, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_bearing, "Fem::ConstraintBearing"))

        # ConstraintBodyHeatSource
        constraint_body_heat_source = ObjectsFem.makeConstraintBodyHeatSource(
            doc)
        self.assertTrue(
            is_derived_from(constraint_body_heat_source,
                            "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_body_heat_source,
                            "Fem::ConstraintPython"))
        self.assertTrue(
            is_derived_from(constraint_body_heat_source,
                            "Fem::ConstraintBodyHeatSource"))

        # ConstraintContact
        constraint_contact = ObjectsFem.makeConstraintContact(doc)
        self.assertTrue(
            is_derived_from(constraint_contact, "App::DocumentObject"))
        self.assertTrue(is_derived_from(constraint_contact, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_contact, "Fem::ConstraintContact"))

        # ConstraintDisplacement
        constraint_dicplacement = ObjectsFem.makeConstraintDisplacement(doc)
        self.assertTrue(
            is_derived_from(constraint_dicplacement, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_dicplacement, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_dicplacement,
                            "Fem::ConstraintDisplacement"))

        # ConstraintElectrostaticPotential
        constraint_electorstatic_potential = ObjectsFem.makeConstraintElectrostaticPotential(
            doc)
        self.assertTrue(
            is_derived_from(constraint_electorstatic_potential,
                            "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_electorstatic_potential,
                            "Fem::ConstraintPython"))
        self.assertTrue(
            is_derived_from(constraint_electorstatic_potential,
                            "Fem::ConstraintElectrostaticPotential"))

        # ConstraintFixed
        constraint_fixed = ObjectsFem.makeConstraintFixed(doc)
        self.assertTrue(
            is_derived_from(constraint_fixed, "App::DocumentObject"))
        self.assertTrue(is_derived_from(constraint_fixed, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_fixed, "Fem::ConstraintFixed"))

        # ConstraintFlowVelocity
        constraint_flow_velocity = ObjectsFem.makeConstraintFlowVelocity(doc)
        self.assertTrue(
            is_derived_from(constraint_flow_velocity, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_flow_velocity, "Fem::ConstraintPython"))
        self.assertTrue(
            is_derived_from(constraint_flow_velocity,
                            "Fem::ConstraintFlowVelocity"))

        # ConstraintFluidBoundary
        constraint_fluid_boundary = ObjectsFem.makeConstraintFluidBoundary(doc)
        self.assertTrue(
            is_derived_from(constraint_fluid_boundary, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_fluid_boundary, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_fluid_boundary,
                            "Fem::ConstraintFluidBoundary"))

        # ConstraintForce
        constraint_force = ObjectsFem.makeConstraintForce(doc)
        self.assertTrue(
            is_derived_from(constraint_force, "App::DocumentObject"))
        self.assertTrue(is_derived_from(constraint_force, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_force, "Fem::ConstraintForce"))

        # ConstraintGear
        constraint_gear = ObjectsFem.makeConstraintGear(doc)
        self.assertTrue(is_derived_from(constraint_gear,
                                        "App::DocumentObject"))
        self.assertTrue(is_derived_from(constraint_gear, "Fem::Constraint"))
        self.assertTrue(is_derived_from(constraint_gear,
                                        "Fem::ConstraintGear"))

        # ConstraintHeatflux
        constraint_heat_flux = ObjectsFem.makeConstraintHeatflux(doc)
        self.assertTrue(
            is_derived_from(constraint_heat_flux, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_heat_flux, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_heat_flux, "Fem::ConstraintHeatflux"))

        # ConstraintInitialFlowVelocity
        constraint_initial_flow_velocity = ObjectsFem.makeConstraintInitialFlowVelocity(
            doc)
        self.assertTrue(
            is_derived_from(constraint_initial_flow_velocity,
                            "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_initial_flow_velocity,
                            "Fem::ConstraintPython"))
        self.assertTrue(
            is_derived_from(constraint_initial_flow_velocity,
                            "Fem::ConstraintInitialFlowVelocity"))

        # ConstraintInitialTemperature
        constraint_initial_temperature = ObjectsFem.makeConstraintInitialTemperature(
            doc)
        self.assertTrue(
            is_derived_from(constraint_initial_temperature,
                            "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_initial_temperature, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_initial_temperature,
                            "Fem::ConstraintInitialTemperature"))

        # ConstraintPlaneRotation
        constraint_plane_rotation = ObjectsFem.makeConstraintPlaneRotation(doc)
        self.assertTrue(
            is_derived_from(constraint_plane_rotation, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_plane_rotation, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_plane_rotation,
                            "Fem::ConstraintPlaneRotation"))

        # ConstraintPressure
        constraint_pressure = ObjectsFem.makeConstraintPressure(doc)
        self.assertTrue(
            is_derived_from(constraint_pressure, "App::DocumentObject"))
        self.assertTrue(is_derived_from(constraint_pressure,
                                        "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_pressure, "Fem::ConstraintPressure"))

        # ConstraintPulley
        constraint_pulley = ObjectsFem.makeConstraintPulley(doc)
        self.assertTrue(
            is_derived_from(constraint_pulley, "App::DocumentObject"))
        self.assertTrue(is_derived_from(constraint_pulley, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_pulley, "Fem::ConstraintPulley"))

        # ConstraintSelfWeight
        constraint_self_weight = ObjectsFem.makeConstraintSelfWeight(doc)
        self.assertTrue(
            is_derived_from(constraint_self_weight, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_self_weight, "Fem::ConstraintPython"))
        self.assertTrue(
            is_derived_from(constraint_self_weight,
                            "Fem::ConstraintSelfWeight"))

        # ConstraintTemperature
        constraint_temperature = ObjectsFem.makeConstraintTemperature(doc)
        self.assertTrue(
            is_derived_from(constraint_temperature, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_temperature, "Fem::Constraint"))
        self.assertTrue(
            is_derived_from(constraint_temperature,
                            "Fem::ConstraintTemperature"))

        # ConstraintTransform
        constraint_transform = ObjectsFem.makeConstraintTransform(doc)
        self.assertTrue(
            is_derived_from(constraint_transform, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(constraint_transform, "Fem::ConstraintTransform"))

        # FemElementFluid1D
        fluid1d = ObjectsFem.makeElementFluid1D(doc)
        self.assertTrue(is_derived_from(fluid1d, "App::DocumentObject"))
        self.assertTrue(is_derived_from(fluid1d, "Fem::FeaturePython"))
        self.assertTrue(is_derived_from(fluid1d, "Fem::FemElementFluid1D"))

        # FemElementGeometry1D
        geometry1d = ObjectsFem.makeElementGeometry1D(doc)
        self.assertTrue(is_derived_from(geometry1d, "App::DocumentObject"))
        self.assertTrue(is_derived_from(geometry1d, "Fem::FeaturePython"))
        self.assertTrue(
            is_derived_from(geometry1d, "Fem::FemElementGeometry1D"))

        # FemElementGeometry2D
        geometry2d = ObjectsFem.makeElementGeometry2D(doc)
        self.assertTrue(is_derived_from(geometry2d, "App::DocumentObject"))
        self.assertTrue(is_derived_from(geometry2d, "Fem::FeaturePython"))
        self.assertTrue(
            is_derived_from(geometry2d, "Fem::FemElementGeometry2D"))

        # FemElementRotation1D
        rotation1d = ObjectsFem.makeElementRotation1D(doc)
        self.assertTrue(is_derived_from(rotation1d, "App::DocumentObject"))
        self.assertTrue(is_derived_from(rotation1d, "Fem::FeaturePython"))
        self.assertTrue(
            is_derived_from(rotation1d, "Fem::FemElementRotation1D"))

        # Material Fluid
        material_fluid = ObjectsFem.makeMaterialFluid(doc)
        self.assertTrue(is_derived_from(material_fluid, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(material_fluid, "App::MaterialObjectPython"))
        self.assertTrue(is_derived_from(material_fluid, "Fem::Material"))

        # Material Solid
        material_solid = ObjectsFem.makeMaterialSolid(doc)
        self.assertTrue(is_derived_from(material_solid, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(material_solid, "App::MaterialObjectPython"))
        self.assertTrue(is_derived_from(material_solid, "Fem::Material"))

        # MaterialMechanicalNonlinear
        material_nonlinear = ObjectsFem.makeMaterialMechanicalNonlinear(
            doc, material_solid)
        self.assertTrue(
            is_derived_from(material_nonlinear, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(material_nonlinear, "Fem::FeaturePython"))
        self.assertTrue(
            is_derived_from(material_nonlinear,
                            "Fem::MaterialMechanicalNonlinear"))

        # MaterialReinforced
        material_reinforced = ObjectsFem.makeMaterialReinforced(doc)
        self.assertTrue(
            is_derived_from(material_reinforced, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(material_reinforced, "App::MaterialObjectPython"))
        self.assertTrue(
            is_derived_from(material_reinforced, "Fem::MaterialReinforced"))

        # FemMeshGmsh
        mesh_gmsh = ObjectsFem.makeMeshGmsh(doc)
        self.assertTrue(is_derived_from(mesh_gmsh, "App::DocumentObject"))
        self.assertTrue(is_derived_from(mesh_gmsh, "Fem::FemMeshObjectPython"))
        self.assertTrue(is_derived_from(mesh_gmsh, "Fem::FemMeshGmsh"))

        # FemMeshBoundaryLayer
        mesh_boundarylayer = ObjectsFem.makeMeshBoundaryLayer(doc, mesh_gmsh)
        self.assertTrue(
            is_derived_from(mesh_boundarylayer, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(mesh_boundarylayer, "Fem::FeaturePython"))
        self.assertTrue(
            is_derived_from(mesh_boundarylayer, "Fem::FemMeshBoundaryLayer"))

        # FemMeshGroup
        mesh_group = ObjectsFem.makeMeshGroup(doc, mesh_gmsh)
        self.assertTrue(is_derived_from(mesh_group, "App::DocumentObject"))
        self.assertTrue(is_derived_from(mesh_group, "Fem::FeaturePython"))
        self.assertTrue(is_derived_from(mesh_group, "Fem::FemMeshGroup"))

        # FemMeshRegion
        mesh_region = ObjectsFem.makeMeshRegion(doc, mesh_gmsh)
        self.assertTrue(is_derived_from(mesh_region, "App::DocumentObject"))
        self.assertTrue(is_derived_from(mesh_region, "Fem::FeaturePython"))
        self.assertTrue(is_derived_from(mesh_region, "Fem::FemMeshRegion"))

        # FemMeshShapeNetgenObject
        mesh_netgen = ObjectsFem.makeMeshNetgen(doc)
        self.assertTrue(is_derived_from(mesh_netgen, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(mesh_netgen, "Fem::FemMeshShapeNetgenObject"))

        # FemMeshResult
        mesh_result = ObjectsFem.makeMeshResult(doc)
        self.assertTrue(is_derived_from(mesh_result, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(mesh_result, "Fem::FemMeshObjectPython"))
        self.assertTrue(is_derived_from(mesh_result, "Fem::FemMeshResult"))

        # FemResultMechanical
        result_mechanical = ObjectsFem.makeResultMechanical(doc)
        self.assertTrue(
            is_derived_from(result_mechanical, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(result_mechanical, "Fem::FemResultObjectPython"))
        self.assertTrue(
            is_derived_from(result_mechanical, "Fem::FemResultMechanical"))

        # FemSolverCalculixCcxTools
        solver_ccxtools = ObjectsFem.makeSolverCalculixCcxTools(doc)
        self.assertTrue(is_derived_from(solver_ccxtools,
                                        "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(solver_ccxtools, "Fem::FemSolverObject"))
        self.assertTrue(
            is_derived_from(solver_ccxtools, "Fem::FemSolverObjectPython"))
        self.assertTrue(
            is_derived_from(solver_ccxtools, "Fem::FemSolverCalculixCcxTools"))

        # FemSolverObjectCalculix
        solver_calculix = ObjectsFem.makeSolverCalculix(doc)
        self.assertTrue(is_derived_from(solver_calculix,
                                        "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(solver_calculix, "Fem::FemSolverObject"))
        self.assertTrue(
            is_derived_from(solver_calculix, "Fem::FemSolverObjectPython"))
        self.assertTrue(
            is_derived_from(solver_calculix, "Fem::FemSolverObjectCalculix"))

        # FemSolverObjectElmer
        solver_elmer = ObjectsFem.makeSolverElmer(doc)
        self.assertTrue(is_derived_from(solver_elmer, "App::DocumentObject"))
        self.assertTrue(is_derived_from(solver_elmer, "Fem::FemSolverObject"))
        self.assertTrue(
            is_derived_from(solver_elmer, "Fem::FemSolverObjectPython"))
        self.assertTrue(
            is_derived_from(solver_elmer, "Fem::FemSolverObjectElmer"))

        # FemSolverObjectZ88
        solver_z88 = ObjectsFem.makeSolverZ88(doc)
        self.assertTrue(is_derived_from(solver_z88, "App::DocumentObject"))
        self.assertTrue(is_derived_from(solver_z88, "Fem::FemSolverObject"))
        self.assertTrue(
            is_derived_from(solver_z88, "Fem::FemSolverObjectPython"))
        self.assertTrue(is_derived_from(solver_z88, "Fem::FemSolverObjectZ88"))

        # FemEquationElmerElasticity
        equation_elasticity = ObjectsFem.makeEquationElasticity(
            doc, solver_elmer)
        self.assertTrue(
            is_derived_from(equation_elasticity, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(equation_elasticity, "App::FeaturePython"))
        self.assertTrue(
            is_derived_from(equation_elasticity,
                            "Fem::FemEquationElmerElasticity"))

        # FemEquationElmerElectrostatic
        equation_electrostatic = ObjectsFem.makeEquationElectrostatic(
            doc, solver_elmer)
        self.assertTrue(
            is_derived_from(equation_electrostatic, "App::DocumentObject"))
        self.assertTrue(
            is_derived_from(equation_electrostatic, "App::FeaturePython"))
        self.assertTrue(
            is_derived_from(equation_electrostatic,
                            "Fem::FemEquationElmerElectrostatic"))

        # FemEquationElmerFlow
        equation_flow = ObjectsFem.makeEquationFlow(doc, solver_elmer)
        self.assertTrue(is_derived_from(equation_flow, "App::DocumentObject"))
        self.assertTrue(is_derived_from(equation_flow, "App::FeaturePython"))
        self.assertTrue(
            is_derived_from(equation_flow, "Fem::FemEquationElmerFlow"))

        # FemEquationElmerFluxsolver
        equation_flux = ObjectsFem.makeEquationFluxsolver(doc, solver_elmer)
        self.assertTrue(is_derived_from(equation_flux, "App::DocumentObject"))
        self.assertTrue(is_derived_from(equation_flux, "App::FeaturePython"))
        self.assertTrue(
            is_derived_from(equation_flux, "Fem::FemEquationElmerFluxsolver"))

        # FemEquationElmerHeat
        equation_heat = ObjectsFem.makeEquationHeat(doc, solver_elmer)
        self.assertTrue(is_derived_from(equation_heat, "App::DocumentObject"))
        self.assertTrue(is_derived_from(equation_heat, "App::FeaturePython"))
        self.assertTrue(
            is_derived_from(equation_heat, "Fem::FemEquationElmerHeat"))

        fcc_print("doc objects count: {}, method: {}".format(
            len(doc.Objects),
            sys._getframe().f_code.co_name))
        # TODO: vtk post objs, thus 5 obj less than test_femobjects_make
        self.assertEqual(len(doc.Objects), testtools.get_defmake_count(False))
Beispiel #17
0
    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'))
Beispiel #18
0
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
    p1 = vec(0, 0, 50)
    p2 = vec(0, 0, -50)
    p3 = vec(0, 0, -4300)
    p4 = vec(4950, 0, -4300)
    p5 = vec(5000, 0, -4300)
    p6 = vec(8535.53, 0, -7835.53)
    p7 = vec(8569.88, 0, -7870.88)
    p8 = vec(12105.41, 0, -11406.41)
    p9 = vec(12140.76, 0, -11441.76)
    p10 = vec(13908.53, 0, -13209.53)
    p11 = vec(13943.88, 0, -13244.88)
    p12 = vec(15046.97, 0, -14347.97)
    p13 = vec(15046.97, 0, -7947.97)
    p14 = vec(15046.97, 0, -7847.97)
    p15 = vec(0, 0, 0)
    p16 = vec(0, 0, -2175)
    p17 = vec(2475, 0, -4300)
    p18 = vec(4975, 0, -4300)
    p19 = vec(6767.765, 0, -6067.765)
    p20 = vec(8552.705, 0, -7853.205)
    p21 = vec(10337.645, 0, -9638.645)
    p22 = vec(12123.085, 0, -11424.085)
    p23 = vec(13024.645, 0, -12325.645)
    p24 = vec(13926.205, 0, -13227.205)
    p25 = vec(14495.425, 0, -13796.425)
    p26 = vec(15046.97, 0, -11147.97)
    p27 = vec(15046.97, 0, -7897.97)
    points = [
        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
        p11, p12, p13, p14, p15, p16, p17, p18, p19, p20,
        p21, p22, p23, p24, p25, p26, p27
    ]
    geom_obj = makeWire(
        points,
        closed=False,
        face=False,
        support=None
    )
    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 = analysis.addObject(
            ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
        )[0]
    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 = "thermomech"
        solver_obj.GeometricalNonlinearity = "linear"
        solver_obj.ThermoMechSteadyState = True
        solver_obj.MatrixSolverType = "default"
        solver_obj.IterationsThermoMechMaximum = 2000
        solver_obj.IterationsControlParameterTimeUse = False
    analysis.addObject(solver_obj)

    # material
    material_obj = ObjectsFem.makeMaterialFluid(doc, "FluidMaterial")
    mat = material_obj.Material
    mat["Name"] = "Water"
    mat["Density"] = "998 kg/m^3"
    mat["SpecificHeat"] = "4.182 J/kg/K"
    mat["DynamicViscosity"] = "1.003e-3 kg/m/s"
    mat["VolumetricThermalExpansionCoefficient"] = "2.07e-4 m/m/K"
    mat["ThermalConductivity"] = "0.591 W/m/K"
    material_obj.Material = mat
    analysis.addObject(material_obj)

    inlet = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    inlet.SectionType = "Liquid"
    inlet.LiquidSectionType = "PIPE INLET"
    inlet.InletPressure = 0.1
    inlet.References = [(geom_obj, "Edge1")]
    analysis.addObject(inlet)

    entrance = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    entrance.SectionType = "Liquid"
    entrance.LiquidSectionType = "PIPE ENTRANCE"
    entrance.EntrancePipeArea = 31416.00
    entrance.EntranceArea = 25133.00
    entrance.References = [(geom_obj, "Edge2")]
    analysis.addObject(entrance)

    manning1 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    manning1.SectionType = "Liquid"
    manning1.LiquidSectionType = "PIPE MANNING"
    manning1.ManningArea = 31416
    manning1.ManningRadius = 50
    manning1.ManningCoefficient = 0.002
    manning1.References = [(geom_obj, "Edge3"), (geom_obj, "Edge5")]
    analysis.addObject(manning1)

    bend = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    bend.SectionType = "Liquid"
    bend.LiquidSectionType = "PIPE BEND"
    bend.BendPipeArea = 31416
    bend.BendRadiusDiameter = 1.5
    bend.BendAngle = 45
    bend.BendLossCoefficient = 0.4
    bend.References = [(geom_obj, "Edge4")]
    analysis.addObject(bend)

    enlargement1 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    enlargement1.SectionType = "Liquid"
    enlargement1.LiquidSectionType = "PIPE ENLARGEMENT"
    enlargement1.EnlargeArea1 = 31416.00
    enlargement1.EnlargeArea2 = 70686.00
    enlargement1.References = [(geom_obj, "Edge6")]
    analysis.addObject(enlargement1)

    manning2 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    manning2.SectionType = "Liquid"
    manning2.LiquidSectionType = "PIPE MANNING"
    manning2.ManningArea = 70686.00
    manning2.ManningRadius = 75
    manning2.ManningCoefficient = 0.002
    manning2.References = [(geom_obj, "Edge7")]
    analysis.addObject(manning2)

    contraction = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    contraction.SectionType = "Liquid"
    contraction.LiquidSectionType = "PIPE CONTRACTION"
    contraction.ContractArea1 = 70686
    contraction.ContractArea2 = 17671
    contraction.References = [(geom_obj, "Edge8")]
    analysis.addObject(contraction)

    manning3 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    manning3.SectionType = "Liquid"
    manning3.LiquidSectionType = "PIPE MANNING"
    manning3.ManningArea = 17671.00
    manning3.ManningRadius = 37.5
    manning3.ManningCoefficient = 0.002
    manning3.References = [(geom_obj, "Edge11"), (geom_obj, "Edge9")]
    analysis.addObject(manning3)

    gate_valve = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    gate_valve.SectionType = "Liquid"
    gate_valve.LiquidSectionType = "PIPE GATE VALVE"
    gate_valve.GateValvePipeArea = 17671
    gate_valve.GateValveClosingCoeff = 0.5
    gate_valve.References = [(geom_obj, "Edge10")]
    analysis.addObject(gate_valve)

    enlargement2 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    enlargement2.SectionType = "Liquid"
    enlargement2.LiquidSectionType = "PIPE ENLARGEMENT"
    enlargement2.EnlargeArea1 = 17671
    enlargement2.EnlargeArea2 = 1e12
    enlargement2.References = [(geom_obj, "Edge12")]
    analysis.addObject(enlargement2)

    outlet = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
    outlet.SectionType = "Liquid"
    outlet.LiquidSectionType = "PIPE OUTLET"
    outlet.OutletPressure = 0.1
    outlet.References = [(geom_obj, "Edge13")]
    analysis.addObject(outlet)

    # self_weight_constraint
    self_weight = ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight")
    self_weight.Gravity_x = 0.0
    self_weight.Gravity_y = 0.0
    self_weight.Gravity_z = -1.0
    analysis.addObject(self_weight)

    # mesh
    from .meshes.mesh_thermomech_flow1d_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

    doc.recompute()
    return doc
Beispiel #19
0
    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"))
        self.assertTrue(
            ObjectsFem.makeMaterialReinforced(doc).isDerivedFrom(
                "App::MaterialObjectPython"))
        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"))

        fcc_print("doc objects count: {}, method: {}".format(
            len(doc.Objects),
            sys._getframe().f_code.co_name))
        # TODO: vtk post objs, thus 5 obj less than test_femobjects_make
        self.assertEqual(len(doc.Objects), testtools.get_defmake_count(False))
Beispiel #20
0
    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)))
Beispiel #21
0
def setup(doc=None, solvertype="ccxtools"):
    # setup self weight cantilever base model

    if doc is None:
        doc = init_doc()

    # geometry object
    # name is important because the other method in this module use obj name
    geom_obj = doc.addObject("Part::Box", "Box")
    geom_obj.Height = geom_obj.Width = 1000
    geom_obj.Length = 32000
    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""
    elif solvertype == "elmer":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverElmer(doc, "SolverElmer")
        )[0]
        eq_obj = ObjectsFem.makeEquationElasticity(doc, solver_object)
        eq_obj.LinearSolverType = "Direct"
    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

    # material
    material_object = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
    )[0]
    mat = material_object.Material
    mat["Name"] = "CalculiX-Steel"
    mat["YoungsModulus"] = "210000 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 = [(geom_obj, "Face1")]

    # selfweight_constraint
    selfweight = doc.Analysis.addObject(
        ObjectsFem.makeConstraintSelfWeight(doc)
    )[0]
    selfweight.Gravity_z = -1.00

    # mesh
    from .meshes.mesh_selfweight_cantilever_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, mesh_name)
    )[0]
    femmesh_obj.FemMesh = fem_mesh
    femmesh_obj.Part = geom_obj
    femmesh_obj.SecondOrderLinear = False

    doc.recompute()
    return doc