Skip to content

Commit

Permalink
FEM: unit test objects, add some prints and obj count tests
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Jan 29, 2020
1 parent a31435b commit 899854a
Showing 1 changed file with 48 additions and 12 deletions.
60 changes: 48 additions & 12 deletions src/Mod/Fem/femtest/app/test_object.py
Expand Up @@ -22,6 +22,7 @@
# * *
# ***************************************************************************/

import sys

import FreeCAD
import ObjectsFem
Expand Down Expand Up @@ -119,10 +120,6 @@ def test_femobjects_make(
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()

Expand All @@ -131,11 +128,18 @@ def test_femobjects_make(
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),
testtools.get_defmake_count(fem_vtk_post) - 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)
)
# TODO if the equations and gmsh mesh children are added to the analysis,
# they show up twice on Tree (on solver resp. gmsh mesh obj and on analysis)
# https://forum.freecadweb.org/viewtopic.php?t=25283

# ********************************************************************************************
def tearDown(
Expand Down Expand Up @@ -164,6 +168,15 @@ def setUp(
FreeCAD.setActiveDocument(self.doc_name)
self.active_doc = FreeCAD.ActiveDocument

def test_00print(
self
):
fcc_print("\n{0}\n{1} run FEM TestObjectType tests {2}\n{0}".format(
100 * "*",
10 * "*",
60 * "*"
))

# ********************************************************************************************
def test_femobjects_type(
self
Expand Down Expand Up @@ -348,9 +361,14 @@ def test_femobjects_type(
"Fem::FemEquationElmerHeat",
type_of_obj(ObjectsFem.makeEquationHeat(doc, solverelmer))
)
# is = 44 tests (just copy in empty file to test)
# TODO: vtk post objs
# TODO: use different type for fluid and solid material

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))
# TODO: use different type for material fluid and material solid

# ********************************************************************************************
def test_femobjects_isoftype(
Expand Down Expand Up @@ -538,7 +556,13 @@ def test_femobjects_isoftype(
ObjectsFem.makeEquationHeat(doc, solverelmer),
"Fem::FemEquationElmerHeat"
))
# is = 44 tests (just copy in empty file to test)

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))

# ********************************************************************************************
def test_femobjects_derivedfromfem(
Expand Down Expand Up @@ -1214,6 +1238,12 @@ def test_femobjects_derivedfromfem(
"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))
# TODO constraint transform is not derived from "Fem::Constraint" ?!?

# ********************************************************************************************
Expand Down Expand Up @@ -1445,7 +1475,13 @@ def test_femobjects_derivedfromstd(
solverelmer
).isDerivedFrom("App::FeaturePython")
)
# is = 44 tests (just copy in empty file to test)

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))

# ********************************************************************************************
def tearDown(
Expand Down

0 comments on commit 899854a

Please sign in to comment.