Skip to content

Commit

Permalink
FEM: ccx tools unit tests, rename some methods and change base name r…
Browse files Browse the repository at this point in the history
…etrieving
  • Loading branch information
berndhahnebach committed Jul 6, 2020
1 parent ac5f856 commit 2d9459d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 48 deletions.
6 changes: 6 additions & 0 deletions src/Mod/Fem/femtest/app/support_utils.py
Expand Up @@ -26,6 +26,7 @@
__url__ = "http://www.freecadweb.org"

import os
import sys
import tempfile
import unittest

Expand Down Expand Up @@ -70,6 +71,11 @@ def fcc_print(
FreeCAD.Console.PrintMessage("{} \n".format(message))


def get_namefromdef(strdel="", stradd=""):
# https://code.activestate.com/recipes/66062-determining-current-function-name/
return (sys._getframe(1).f_code.co_name).replace(strdel, stradd)


def get_defmake_count(
fem_vtk_post=True
):
Expand Down
47 changes: 24 additions & 23 deletions src/Mod/Fem/femtest/app/test_ccxtools.py
Expand Up @@ -34,6 +34,7 @@

from . import support_utils as testtools
from .support_utils import fcc_print
from .support_utils import get_namefromdef
from femtools import ccxtools


Expand Down Expand Up @@ -80,13 +81,13 @@ def test_00print(
))

# ********************************************************************************************
def test_freq_analysis(
def test_box_frequency(
self
):
# set up
from femexamples.boxanalysis_frequency import setup
setup(self.document, "ccxtools")
base_name = "cube_frequency"
base_name = get_namefromdef("test_box", "cube")
res_obj_name = "CCX_Mode1_Results"
analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name)

Expand All @@ -108,13 +109,13 @@ def test_freq_analysis(
)

# ********************************************************************************************
def test_static_analysis(
def test_box_static(
self
):
# set up
from femexamples.boxanalysis_static import setup
setup(self.document, "ccxtools")
base_name = "cube_static"
base_name = get_namefromdef("test_box", "cube")
res_obj_name = "CCX_Results"
analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name)

Expand All @@ -136,23 +137,23 @@ def test_static_analysis(
)

# ********************************************************************************************
def test_static_constraint_force_faceload_hexa20(
def test_ccxcantilever_hexa20(
self
):
from femexamples.ccx_cantilever_hexa20faceload import setup
setup(self.document, "ccxtools")
self.input_file_writing_test(None, "canti_ccx_faceload_hexa20")
self.input_file_writing_test(None, get_namefromdef("test_ccxcantilever", "canti_ccx_faceload"))

# ********************************************************************************************
def test_static_constraint_contact_shell_shell(
def test_constraint_contact_shell_shell(
self
):
from femexamples.constraint_contact_shell_shell import setup
setup(self.document, "ccxtools")
self.input_file_writing_test(None, "constraint_contact_shell_shell")
self.input_file_writing_test(None, get_namefromdef("test_"))

# ********************************************************************************************
def test_static_constraint_contact_solid_solid(
def test_constraint_contact_solid_solid(
self
):
# does not pass on travis, but on my local system it does, Bernd
Expand All @@ -163,56 +164,56 @@ def test_static_constraint_contact_solid_solid(

from femexamples.constraint_contact_solid_solid import setup
setup(self.document, "ccxtools")
self.input_file_writing_test(None, "constraint_contact_solid_solid")
self.input_file_writing_test(None, get_namefromdef("test_"))

# ********************************************************************************************
def test_static_constraint_sectionprint(
def test_constraint_sectionprint(
self
):
from femexamples.constraint_section_print import setup
setup(self.document, "ccxtools")
self.input_file_writing_test(None, "constraint_sectionprint")
self.input_file_writing_test(None, get_namefromdef("test_"))

# ********************************************************************************************
def test_static_constraint_tie(
def test_constraint_tie(
self
):
from femexamples.constraint_tie import setup
setup(self.document, "ccxtools")
self.input_file_writing_test(None, "constraint_tie")
self.input_file_writing_test(None, get_namefromdef("test_"))

# ********************************************************************************************
def test_static_material_multiple(
def test_material_multiple(
self
):
from femexamples.material_multiple_twoboxes import setup
setup(self.document, "ccxtools")
self.input_file_writing_test(None, "mat_multiple")
self.input_file_writing_test(None, get_namefromdef("test_material", "mat"))

# ********************************************************************************************
def test_static_material_nonlinar(
def test_material_nonlinear(
self
):
from femexamples.material_nl_platewithhole import setup
setup(self.document, "ccxtools")
self.input_file_writing_test(None, "mat_nonlinear")
self.input_file_writing_test(None, get_namefromdef("test_material", "mat"))

# ********************************************************************************************
def test_thermomech_bimetall(
self
):
from femexamples.thermomech_bimetall import setup
setup(self.document, "ccxtools")
self.input_file_writing_test(None, "thermomech_bimetall")
self.input_file_writing_test(None, get_namefromdef("test_"))

# ********************************************************************************************
def test_thermomech_flow1D_analysis(
def test_thermomech_flow1D(
self
):
# set up
from femexamples.thermomech_flow1d import setup
setup(self.document, "ccxtools")
base_name = "Flow1D_thermomech"
base_name = get_namefromdef("test_thermomech_flow1D", "Flow1D_thermomech")
res_obj_name = "CCX_Time1_0_Results"
analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name)

Expand All @@ -234,13 +235,13 @@ def test_thermomech_flow1D_analysis(
)

# ********************************************************************************************
def test_thermomech_spine_analysis(
def test_thermomech_spine(
self
):
# set up
from femexamples.thermomech_spine import setup
setup(self.document, "ccxtools")
base_name = "spine_thermomech"
base_name = get_namefromdef("test_thermomech_spine", "spine_thermomech")
res_obj_name = "CCX_Results"
analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name)

Expand Down
50 changes: 25 additions & 25 deletions src/Mod/Fem/femtest/test_commands.sh
Expand Up @@ -37,18 +37,18 @@ make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_solver_elmer.TestSolverElmer


# methods
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_freq_analysis
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_static_analysis
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_force_faceload_hexa20
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_contact_shell_shell
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_contact_solid_solid
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_sectionprint
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_tie
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_static_material_multiple
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_static_material_nonlinar
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_box_frequency
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_box_static
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_ccxcantilever_faceload_hexa20
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_constraint_contact_shell_shell
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_constraint_contact_solid_solid
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_constraint_sectionprint
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_constraint_tie
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_material_multiple
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_material_nonlinear
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_thermomech_bimetall
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_thermomech_flow1D_analysis
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_thermomech_spine_analysis
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_thermomech_flow1D
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_ccxtools.TestCcxTools.test_thermomech_spine
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_common.TestFemCommon.test_adding_refshaps
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_common.TestFemCommon.test_pyimport_all_FEM_modules
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_femimport.TestFemImport.test_import_fem
Expand Down Expand Up @@ -83,55 +83,55 @@ make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_result.TestResult.test_rho
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_result.TestResult.test_disp_abs
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_solver_calculix.TestSolverCalculix.test_solver_calculix
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_solver_elmer.TestSolverElmer.test_solver_elmer
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_solver_elmer.TestSolverElmer.test_elmer_ccxcanti_nodeload
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_solver_elmer.TestSolverElmer.test_elmer_ccxcanti_faceload
make -j 4 && ./bin/FreeCADCmd -t femtest.app.test_solver_elmer.TestSolverElmer.test_elmer_ccxcanti_nodeload


# methods in FreeCAD

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_freq_analysis'
'femtest.app.test_ccxtools.TestCcxTools.test_box_frequency'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_static_analysis'
'femtest.app.test_ccxtools.TestCcxTools.test_box_static'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_force_faceload_hexa20'
'femtest.app.test_ccxtools.TestCcxTools.test_ccxcantilever_faceload_hexa20'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_contact_shell_shell'
'femtest.app.test_ccxtools.TestCcxTools.test_constraint_contact_shell_shell'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_contact_solid_solid'
'femtest.app.test_ccxtools.TestCcxTools.test_constraint_contact_solid_solid'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_sectionprint'
'femtest.app.test_ccxtools.TestCcxTools.test_constraint_sectionprint'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_static_constraint_tie'
'femtest.app.test_ccxtools.TestCcxTools.test_constraint_tie'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_static_material_multiple'
'femtest.app.test_ccxtools.TestCcxTools.test_material_multiple'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_static_material_nonlinar'
'femtest.app.test_ccxtools.TestCcxTools.test_material_nonlinear'
))

import unittest
Expand All @@ -141,12 +141,12 @@ unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_thermomech_flow1D_analysis'
'femtest.app.test_ccxtools.TestCcxTools.test_thermomech_flow1D'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_ccxtools.TestCcxTools.test_thermomech_spine_analysis'
'femtest.app.test_ccxtools.TestCcxTools.test_thermomech_spine'
))

import unittest
Expand Down Expand Up @@ -321,10 +321,10 @@ unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_solver_elmer.TestSolverElmer.test_elmer_ccxcanti_nodeload'
'femtest.app.test_solver_elmer.TestSolverElmer.test_elmer_ccxcanti_faceload'
))

import unittest
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(
'femtest.app.test_solver_elmer.TestSolverElmer.test_elmer_ccxcanti_faceload'
'femtest.app.test_solver_elmer.TestSolverElmer.test_elmer_ccxcanti_nodeload'
))

0 comments on commit 2d9459d

Please sign in to comment.