FEM: ccxtools unit tests, simplifictions
This commit is contained in:
@@ -86,23 +86,22 @@ class TestCcxTools(unittest.TestCase):
|
||||
# set up
|
||||
from femexamples.boxanalysis_frequency import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "frequency"
|
||||
base_name = "cube_frequency"
|
||||
res_obj_name = "CCX_Mode1_Results"
|
||||
analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name)
|
||||
|
||||
# test input file writing
|
||||
fea = self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
None,
|
||||
base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
test_end=True,
|
||||
)
|
||||
|
||||
# test result reading
|
||||
self.result_reading_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
None,
|
||||
base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
fea=fea,
|
||||
res_obj_name=res_obj_name,
|
||||
@@ -115,23 +114,22 @@ class TestCcxTools(unittest.TestCase):
|
||||
# set up
|
||||
from femexamples.boxanalysis_static import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "ccxtools static"
|
||||
base_name = "cube_static"
|
||||
res_obj_name = "CCX_Results"
|
||||
analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name)
|
||||
|
||||
# test input file writing
|
||||
fea = self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
None,
|
||||
base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
test_end=True,
|
||||
)
|
||||
|
||||
# test result reading
|
||||
self.result_reading_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
None,
|
||||
base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
fea=fea,
|
||||
res_obj_name=res_obj_name,
|
||||
@@ -141,33 +139,17 @@ class TestCcxTools(unittest.TestCase):
|
||||
def test_static_constraint_force_faceload_hexa20(
|
||||
self
|
||||
):
|
||||
# set up
|
||||
from femexamples.ccx_cantilever_hexa20faceload import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "canti ccx faceload hexa20"
|
||||
base_name = "canti_ccx_faceload_hexa20"
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
)
|
||||
self.input_file_writing_test(None, "canti_ccx_faceload_hexa20")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_static_constraint_contact_shell_shell(
|
||||
self
|
||||
):
|
||||
# set up
|
||||
from femexamples.constraint_contact_shell_shell import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "constraint contact shell shell"
|
||||
base_name = "constraint_contact_shell_shell"
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
)
|
||||
self.input_file_writing_test(None, "constraint_contact_shell_shell")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_static_constraint_contact_solid_solid(
|
||||
@@ -179,97 +161,49 @@ class TestCcxTools(unittest.TestCase):
|
||||
if sys.version_info.major < 3:
|
||||
return
|
||||
|
||||
# set up
|
||||
from femexamples.constraint_contact_solid_solid import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "constraint contact solid solid"
|
||||
base_name = "constraint_contact_solid_solid"
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
)
|
||||
self.input_file_writing_test(None, "constraint_contact_solid_solid")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_static_constraint_sectionprint(
|
||||
self
|
||||
):
|
||||
# set up
|
||||
from femexamples.constraint_section_print import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "constraint sectionprint"
|
||||
base_name = "constraint_sectionprint"
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
)
|
||||
self.input_file_writing_test(None, "constraint_sectionprint")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_static_constraint_tie(
|
||||
self
|
||||
):
|
||||
# set up
|
||||
from femexamples.constraint_tie import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "constraint tie"
|
||||
base_name = "constraint_tie"
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
)
|
||||
self.input_file_writing_test(None, "constraint_tie")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_static_material_multiple(
|
||||
self
|
||||
):
|
||||
# set up
|
||||
from femexamples.material_multiple_twoboxes import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "multiple material"
|
||||
base_name = "mat_multiple"
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
)
|
||||
self.input_file_writing_test(None, "mat_multiple")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_static_material_nonlinar(
|
||||
self
|
||||
):
|
||||
# set up
|
||||
from femexamples.material_nl_platewithhole import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "nonlinear material"
|
||||
base_name = "mat_nonlinear"
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
)
|
||||
self.input_file_writing_test(None, "mat_nonlinear")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_thermomech_bimetall(
|
||||
self
|
||||
):
|
||||
# set up
|
||||
from femexamples.thermomech_bimetall import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "thermomech bimetall"
|
||||
base_name = "thermomech_bimetall"
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
)
|
||||
self.input_file_writing_test(None, "thermomech_bimetall")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_thermomech_flow1D_analysis(
|
||||
@@ -278,23 +212,22 @@ class TestCcxTools(unittest.TestCase):
|
||||
# set up
|
||||
from femexamples.thermomech_flow1d import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "Flow1D"
|
||||
base_name = "Flow1D_thermomech"
|
||||
res_obj_name = "CCX_Time1_0_Results"
|
||||
analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name)
|
||||
|
||||
# test input file writing
|
||||
fea = self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
None,
|
||||
base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
test_end=True,
|
||||
)
|
||||
|
||||
# test result reading
|
||||
self.result_reading_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
None,
|
||||
base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
fea=fea,
|
||||
res_obj_name=res_obj_name,
|
||||
@@ -307,23 +240,22 @@ class TestCcxTools(unittest.TestCase):
|
||||
# set up
|
||||
from femexamples.thermomech_spine import setup
|
||||
setup(self.document, "ccxtools")
|
||||
test_name = "thermomechanical"
|
||||
base_name = "spine_thermomech"
|
||||
res_obj_name = "CCX_Results"
|
||||
analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name)
|
||||
|
||||
# test input file writing
|
||||
fea = self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
None,
|
||||
base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
test_end=True,
|
||||
)
|
||||
|
||||
# test result reading
|
||||
self.result_reading_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
None,
|
||||
base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
fea=fea,
|
||||
res_obj_name=res_obj_name,
|
||||
@@ -341,7 +273,7 @@ class TestCcxTools(unittest.TestCase):
|
||||
"\n--------------- "
|
||||
"Start of FEM ccxtools {} test"
|
||||
"---------------"
|
||||
.format(test_name)
|
||||
.format(base_name)
|
||||
)
|
||||
|
||||
if analysis_dir is None:
|
||||
@@ -358,7 +290,7 @@ class TestCcxTools(unittest.TestCase):
|
||||
"Setting working directory {} failed".format(analysis_dir)
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM inp file prerequisites for {} ...".format(test_name))
|
||||
fcc_print("Checking FEM inp file prerequisites for {} ...".format(base_name))
|
||||
error = fea.check_prerequisites()
|
||||
self.assertFalse(
|
||||
error,
|
||||
@@ -368,7 +300,7 @@ class TestCcxTools(unittest.TestCase):
|
||||
inpfile_given = join(self.test_file_dir, (base_name + ".inp"))
|
||||
inpfile_totest = join(analysis_dir, (self.mesh_name + ".inp"))
|
||||
fcc_print("Checking FEM inp file write...")
|
||||
fcc_print("Writing {} for {}".format(inpfile_totest, test_name))
|
||||
fcc_print("Writing {} for {}".format(inpfile_totest, base_name))
|
||||
error = fea.write_inp_file()
|
||||
self.assertFalse(
|
||||
error,
|
||||
@@ -389,7 +321,7 @@ class TestCcxTools(unittest.TestCase):
|
||||
save_fc_file = join(analysis_dir, base_name + ".FCStd")
|
||||
fcc_print(
|
||||
"Save FreeCAD file for {} to {}..."
|
||||
.format(test_name, save_fc_file)
|
||||
.format(base_name, save_fc_file)
|
||||
)
|
||||
self.document.saveAs(save_fc_file)
|
||||
|
||||
@@ -397,7 +329,7 @@ class TestCcxTools(unittest.TestCase):
|
||||
"\n--------------- "
|
||||
"End of FEM ccxtools {}"
|
||||
"---------------"
|
||||
.format(test_name)
|
||||
.format(base_name)
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
@@ -441,14 +373,14 @@ class TestCcxTools(unittest.TestCase):
|
||||
"Setting inp file name to {} failed".format(inpfile_given)
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM frd file read from {}...".format(test_name))
|
||||
fcc_print("Checking FEM frd file read from {}...".format(base_name))
|
||||
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 {}...".format(test_name))
|
||||
fcc_print("Reading stats from result object for {}...".format(base_name))
|
||||
expected_values = join(
|
||||
self.test_file_dir,
|
||||
base_name + "_expected_values"
|
||||
@@ -466,11 +398,11 @@ class TestCcxTools(unittest.TestCase):
|
||||
save_fc_file = join(analysis_dir, base_name + ".FCStd")
|
||||
fcc_print(
|
||||
"Save FreeCAD file for {} to {}..."
|
||||
.format(test_name, save_fc_file)
|
||||
.format(base_name, save_fc_file)
|
||||
)
|
||||
self.document.saveAs(save_fc_file)
|
||||
|
||||
fcc_print("--------------- End of {} -------------------".format(test_name))
|
||||
fcc_print("--------------- End of {} -------------------".format(base_name))
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user