FEM: test modules, use double quotes instead of single ones, all FEM done :-)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@ from .utilstest import fcc_print
|
||||
|
||||
|
||||
class TestFemCommon(unittest.TestCase):
|
||||
fcc_print('import TestFemCommon')
|
||||
fcc_print("import TestFemCommon")
|
||||
|
||||
# ********************************************************************************************
|
||||
def setUp(
|
||||
@@ -74,9 +74,9 @@ class TestFemCommon(unittest.TestCase):
|
||||
ref_eles.append("Edge%d" % (i + 1))
|
||||
cf.References = [(slab, ref_eles)]
|
||||
doc.recompute()
|
||||
expected_reflist = [(slab, ('Edge1', 'Edge2', 'Edge3', 'Edge4'))]
|
||||
expected_reflist = [(slab, ("Edge1", "Edge2", "Edge3", "Edge4"))]
|
||||
assert_err_message = (
|
||||
'Adding reference shapes did not result in expected list {} != {}'
|
||||
"Adding reference shapes did not result in expected list {} != {}"
|
||||
.format(cf.References, expected_reflist)
|
||||
)
|
||||
self.assertEqual(cf.References, expected_reflist, assert_err_message)
|
||||
@@ -89,37 +89,37 @@ class TestFemCommon(unittest.TestCase):
|
||||
pymodules = []
|
||||
|
||||
# collect all Python modules in FEM
|
||||
pymodules += testtools.collect_python_modules('') # FEM main dir
|
||||
pymodules += testtools.collect_python_modules('femexamples')
|
||||
pymodules += testtools.collect_python_modules('feminout')
|
||||
pymodules += testtools.collect_python_modules('femmesh')
|
||||
pymodules += testtools.collect_python_modules('femobjects')
|
||||
pymodules += testtools.collect_python_modules('femresult')
|
||||
pymodules += testtools.collect_python_modules('femtest')
|
||||
pymodules += testtools.collect_python_modules('femtools')
|
||||
pymodules += testtools.collect_python_modules('femsolver')
|
||||
pymodules += testtools.collect_python_modules("") # FEM main dir
|
||||
pymodules += testtools.collect_python_modules("femexamples")
|
||||
pymodules += testtools.collect_python_modules("feminout")
|
||||
pymodules += testtools.collect_python_modules("femmesh")
|
||||
pymodules += testtools.collect_python_modules("femobjects")
|
||||
pymodules += testtools.collect_python_modules("femresult")
|
||||
pymodules += testtools.collect_python_modules("femtest")
|
||||
pymodules += testtools.collect_python_modules("femtools")
|
||||
pymodules += testtools.collect_python_modules("femsolver")
|
||||
# TODO test with join on Windows, the use of os.path.join
|
||||
# in the following code seems to create problems on Windows OS
|
||||
pymodules += testtools.collect_python_modules('femsolver/elmer')
|
||||
pymodules += testtools.collect_python_modules('femsolver/elmer/equations')
|
||||
pymodules += testtools.collect_python_modules('femsolver/z88')
|
||||
pymodules += testtools.collect_python_modules('femsolver/calculix')
|
||||
pymodules += testtools.collect_python_modules("femsolver/elmer")
|
||||
pymodules += testtools.collect_python_modules("femsolver/elmer/equations")
|
||||
pymodules += testtools.collect_python_modules("femsolver/z88")
|
||||
pymodules += testtools.collect_python_modules("femsolver/calculix")
|
||||
if FreeCAD.GuiUp:
|
||||
pymodules += testtools.collect_python_modules('femcommands')
|
||||
pymodules += testtools.collect_python_modules('femguiobjects')
|
||||
pymodules += testtools.collect_python_modules("femcommands")
|
||||
pymodules += testtools.collect_python_modules("femguiobjects")
|
||||
|
||||
# import all collected modules
|
||||
# fcc_print(pymodules)
|
||||
for mod in pymodules:
|
||||
fcc_print('Try importing {0} ...'.format(mod))
|
||||
fcc_print("Try importing {0} ...".format(mod))
|
||||
try:
|
||||
im = __import__('{0}'.format(mod))
|
||||
im = __import__("{0}".format(mod))
|
||||
except ImportError:
|
||||
im = False
|
||||
if not im:
|
||||
# to get an error message what was going wrong
|
||||
__import__('{0}'.format(mod))
|
||||
self.assertTrue(im, 'Problem importing {0}'.format(mod))
|
||||
__import__("{0}".format(mod))
|
||||
self.assertTrue(im, "Problem importing {0}".format(mod))
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
|
||||
@@ -78,7 +78,7 @@ class TestFemImport(unittest.TestCase):
|
||||
# ************************************************************************************************
|
||||
# to be sure this is run on very first of FEM test this is here and not in objects
|
||||
class TestObjectExistance(unittest.TestCase):
|
||||
fcc_print('import TestObjectExistance')
|
||||
fcc_print("import TestObjectExistance")
|
||||
|
||||
# ********************************************************************************************
|
||||
def setUp(
|
||||
|
||||
@@ -31,7 +31,7 @@ from os.path import join
|
||||
|
||||
|
||||
class TestMaterialUnits(unittest.TestCase):
|
||||
fcc_print('import TestMaterialUnits')
|
||||
fcc_print("import TestMaterialUnits")
|
||||
|
||||
# ********************************************************************************************
|
||||
def setUp(
|
||||
@@ -65,11 +65,11 @@ class TestMaterialUnits(unittest.TestCase):
|
||||
known_quantity_parameter = knownquant()
|
||||
from materialtools.cardutils import check_parm_unit as checkparamunit
|
||||
for param in known_quantity_parameter:
|
||||
fcc_print('{}'.format(param))
|
||||
fcc_print("{}".format(param))
|
||||
self.assertTrue(
|
||||
checkparamunit(param),
|
||||
'Unit of quantity material parameter {} '
|
||||
'is not known by FreeCAD unit system.'
|
||||
"Unit of quantity material parameter {} "
|
||||
"is not known by FreeCAD unit system."
|
||||
.format(param)
|
||||
)
|
||||
|
||||
@@ -89,9 +89,9 @@ class TestMaterialUnits(unittest.TestCase):
|
||||
"Material",
|
||||
"StandardMaterial"
|
||||
)
|
||||
fcc_print('{}'.format(builtin_solid_mat_dir))
|
||||
fcc_print("{}".format(builtin_solid_mat_dir))
|
||||
from materialtools.cardutils import add_cards_from_a_dir as addmats
|
||||
materials, cards, icons = addmats({}, {}, {}, builtin_solid_mat_dir, '')
|
||||
materials, cards, icons = addmats({}, {}, {}, builtin_solid_mat_dir, "")
|
||||
|
||||
# get known material quantity parameter
|
||||
from materialtools.cardutils import get_known_material_quantity_parameter as knownquant
|
||||
@@ -100,13 +100,13 @@ class TestMaterialUnits(unittest.TestCase):
|
||||
# check param, value pairs
|
||||
from materialtools.cardutils import check_value_unit as checkvalueunit
|
||||
for mat in materials:
|
||||
fcc_print('{}'.format(mat))
|
||||
fcc_print("{}".format(mat))
|
||||
for param, value in materials[mat].items():
|
||||
if param in known_quantities:
|
||||
# fcc_print(' {} --> {}'.format(param, value))
|
||||
# fcc_print(" {} --> {}".format(param, value))
|
||||
self.assertTrue(
|
||||
checkvalueunit(param, value),
|
||||
'Unit of quantity {} from material parameter {} is wrong.'
|
||||
"Unit of quantity {} from material parameter {} is wrong."
|
||||
.format(value, param)
|
||||
)
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ from os.path import join
|
||||
|
||||
|
||||
class TestMeshCommon(unittest.TestCase):
|
||||
fcc_print('import TestMeshCommon')
|
||||
fcc_print("import TestMeshCommon")
|
||||
|
||||
# ********************************************************************************************
|
||||
def setUp(
|
||||
@@ -161,7 +161,7 @@ class TestMeshCommon(unittest.TestCase):
|
||||
tetra10.addNode(9, 3, 9, 10)
|
||||
tetra10.addVolume([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
|
||||
unv_file = testtools.get_fem_test_tmp_dir() + '/tetra10_mesh.unv'
|
||||
unv_file = testtools.get_fem_test_tmp_dir() + "/tetra10_mesh.unv"
|
||||
tetra10.write(unv_file)
|
||||
newmesh = Fem.read(unv_file)
|
||||
expected = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
|
||||
@@ -189,20 +189,20 @@ class TestMeshCommon(unittest.TestCase):
|
||||
)
|
||||
seg2.addEdge([1, 2])
|
||||
|
||||
inp_file = testtools.get_fem_test_tmp_dir() + '/seg2_mesh.inp'
|
||||
inp_file = testtools.get_fem_test_tmp_dir() + "/seg2_mesh.inp"
|
||||
seg2.writeABAQUS(inp_file, 1, False)
|
||||
|
||||
read_file = open(inp_file, 'r')
|
||||
read_node_line = 'line was not found'
|
||||
read_file = open(inp_file, "r")
|
||||
read_node_line = "line was not found"
|
||||
for ln in read_file:
|
||||
ln = ln.strip()
|
||||
if ln.startswith('2, -5'):
|
||||
if ln.startswith("2, -5"):
|
||||
read_node_line = ln
|
||||
read_file.close()
|
||||
|
||||
# 1234567 12345678901234567890 12345678901234567890
|
||||
expected_win = '2, -5e+018, -1.123456789123e-014, -1.234567890123e-102'
|
||||
expected_lin = '2, -5e+18, -1.123456789123e-14, -1.234567890123e-102'
|
||||
expected_win = "2, -5e+018, -1.123456789123e-014, -1.234567890123e-102"
|
||||
expected_lin = "2, -5e+18, -1.123456789123e-14, -1.234567890123e-102"
|
||||
expected = [expected_lin, expected_win]
|
||||
self.assertTrue(
|
||||
True if read_node_line in expected else False,
|
||||
@@ -222,7 +222,7 @@ class TestMeshCommon(unittest.TestCase):
|
||||
# ************************************************************************************************
|
||||
# ************************************************************************************************
|
||||
class TestMeshEleTetra10(unittest.TestCase):
|
||||
fcc_print('import TestMeshEleTetra10')
|
||||
fcc_print("import TestMeshEleTetra10")
|
||||
|
||||
# ********************************************************************************************
|
||||
def setUp(
|
||||
@@ -240,15 +240,15 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
self.active_doc = FreeCAD.ActiveDocument
|
||||
|
||||
# more inits
|
||||
self.elem = 'tetra10'
|
||||
self.elem = "tetra10"
|
||||
self.base_testfile = join(
|
||||
testtools.get_fem_test_home_dir(),
|
||||
'mesh',
|
||||
(self.elem + '_mesh.')
|
||||
"mesh",
|
||||
(self.elem + "_mesh.")
|
||||
)
|
||||
self.base_outfile = join(
|
||||
testtools.get_fem_test_tmp_dir(),
|
||||
(self.elem + '_mesh.')
|
||||
(self.elem + "_mesh.")
|
||||
)
|
||||
# 10 node tetrahedron --> tetra10
|
||||
femmesh = Fem.FemMesh()
|
||||
@@ -265,8 +265,8 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
femmesh.addVolume([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
self.femmesh = femmesh
|
||||
self.expected_nodes = {
|
||||
'count': 10,
|
||||
'nodes': {
|
||||
"count": 10,
|
||||
"nodes": {
|
||||
1: FreeCAD.Vector(6.0, 12.0, 18.0),
|
||||
2: FreeCAD.Vector(0.0, 0.0, 18.0),
|
||||
3: FreeCAD.Vector(12.0, 0.0, 18.0),
|
||||
@@ -280,16 +280,16 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
}
|
||||
}
|
||||
self.expected_elem = {
|
||||
'volcount': 1,
|
||||
'tetcount': 1,
|
||||
'volumes': [1, (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)]
|
||||
"volcount": 1,
|
||||
"tetcount": 1,
|
||||
"volumes": [1, (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)]
|
||||
}
|
||||
'''
|
||||
fcc_print('\n')
|
||||
"""
|
||||
fcc_print("\n")
|
||||
fcc_print(expected_nodes)
|
||||
fcc_print(expected_elem)
|
||||
fcc_print('\n')
|
||||
'''
|
||||
fcc_print("\n")
|
||||
"""
|
||||
|
||||
def test_00print(
|
||||
self
|
||||
@@ -319,17 +319,17 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
filetyp
|
||||
):
|
||||
|
||||
# '''
|
||||
# """
|
||||
fcc_print([
|
||||
femmesh_testfile.Volumes[0],
|
||||
femmesh_testfile.getElementNodes(femmesh_outfile.Volumes[0])
|
||||
])
|
||||
# '''
|
||||
# """
|
||||
|
||||
# test reading the test mesh
|
||||
self.assertEqual(
|
||||
femmesh_testfile.Nodes,
|
||||
self.expected_nodes['nodes'],
|
||||
self.expected_nodes["nodes"],
|
||||
"Test reading {} mesh to {} file failed. Nodes are different.\n".format(
|
||||
self.elem,
|
||||
filetyp
|
||||
@@ -340,7 +340,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
femmesh_testfile.Volumes[0],
|
||||
femmesh_testfile.getElementNodes(femmesh_outfile.Volumes[0])
|
||||
],
|
||||
self.expected_elem['volumes'],
|
||||
self.expected_elem["volumes"],
|
||||
"Test reading {} mesh to {} file failed. Volumes are different.\n".format(
|
||||
self.elem,
|
||||
filetyp
|
||||
@@ -349,7 +349,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
# test reading the written mesh
|
||||
self.assertEqual(
|
||||
femmesh_outfile.Nodes,
|
||||
self.expected_nodes['nodes'],
|
||||
self.expected_nodes["nodes"],
|
||||
"Test reading {} mesh to {} file failed. Nodes are different.\n".format(
|
||||
self.elem,
|
||||
filetyp
|
||||
@@ -360,7 +360,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
femmesh_outfile.Volumes[0],
|
||||
femmesh_outfile.getElementNodes(femmesh_outfile.Volumes[0])
|
||||
],
|
||||
self.expected_elem['volumes'],
|
||||
self.expected_elem["volumes"],
|
||||
"Test reading {} mesh to {} file failed. Volumes are different.\n".format(
|
||||
self.elem,
|
||||
filetyp
|
||||
@@ -390,13 +390,13 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
):
|
||||
# tetra10 element: creating by Python
|
||||
node_data = {
|
||||
'count': self.femmesh.NodeCount,
|
||||
'nodes': self.femmesh.Nodes
|
||||
"count": self.femmesh.NodeCount,
|
||||
"nodes": self.femmesh.Nodes
|
||||
}
|
||||
elem_data = {
|
||||
'volcount': self.femmesh.VolumeCount,
|
||||
'tetcount': self.femmesh.TetraCount,
|
||||
'volumes': [
|
||||
"volcount": self.femmesh.VolumeCount,
|
||||
"tetcount": self.femmesh.TetraCount,
|
||||
"volumes": [
|
||||
self.femmesh.Volumes[0],
|
||||
self.femmesh.getElementNodes(self.femmesh.Volumes[0])
|
||||
]
|
||||
@@ -411,12 +411,12 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
self.expected_elem,
|
||||
"Elements of Python created " + self.elem + "mesh element are unexpected"
|
||||
)
|
||||
'''
|
||||
"""
|
||||
obj = doc.addObject("Fem::FemMeshObject" , elem)
|
||||
obj.FemMesh = femmesh
|
||||
obj.Placement.Base = (30,50,0)
|
||||
obj.ViewObject.DisplayMode = "Faces, Wireframe & Nodes"
|
||||
'''
|
||||
"""
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_tetra10_inp(
|
||||
@@ -424,7 +424,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
):
|
||||
# tetra10 element: reading from and writing to inp mesh file format
|
||||
|
||||
file_extension = 'inp'
|
||||
file_extension = "inp"
|
||||
outfile, testfile = self.get_file_paths(file_extension)
|
||||
|
||||
self.femmesh.writeABAQUS(outfile, 1, False) # write the mesh
|
||||
@@ -443,7 +443,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
):
|
||||
# tetra10 element: reading from and writing to unv mesh file format
|
||||
|
||||
file_extension = 'unv'
|
||||
file_extension = "unv"
|
||||
outfile, testfile = self.get_file_paths(file_extension)
|
||||
|
||||
self.femmesh.write(outfile) # write the mesh
|
||||
@@ -462,7 +462,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
):
|
||||
# tetra10 element: reading from and writing to unv mesh file format
|
||||
|
||||
file_extension = 'vtk'
|
||||
file_extension = "vtk"
|
||||
outfile, testfile = self.get_file_paths(file_extension)
|
||||
|
||||
if "BUILD_FEM_VTK" in FreeCAD.__cmake__:
|
||||
@@ -476,7 +476,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
file_extension
|
||||
)
|
||||
else:
|
||||
fcc_print('FEM_VTK post processing is disabled.')
|
||||
fcc_print("FEM_VTK post processing is disabled.")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_tetra10_yml(
|
||||
@@ -484,7 +484,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
):
|
||||
# tetra10 element: reading from and writing to yaml/json mesh file format
|
||||
|
||||
file_extension = 'yml'
|
||||
file_extension = "yml"
|
||||
outfile, testfile = self.get_file_paths(file_extension)
|
||||
|
||||
# TODO: implement yaml/json mesh reader writer method calls in C++
|
||||
@@ -510,7 +510,7 @@ class TestMeshEleTetra10(unittest.TestCase):
|
||||
):
|
||||
# tetra10 element: reading from and writing to z88 mesh file format
|
||||
|
||||
file_extension = 'z88'
|
||||
file_extension = "z88"
|
||||
outfile, testfile = self.get_file_paths(file_extension)
|
||||
|
||||
self.femmesh.write(outfile) # write the mesh
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ from os.path import join
|
||||
|
||||
|
||||
class TestResult(unittest.TestCase):
|
||||
fcc_print('import TestResult')
|
||||
fcc_print("import TestResult")
|
||||
|
||||
# ********************************************************************************************
|
||||
def setUp(
|
||||
@@ -65,8 +65,8 @@ class TestResult(unittest.TestCase):
|
||||
# read data from frd file
|
||||
frd_file = join(
|
||||
testtools.get_fem_test_home_dir(),
|
||||
'ccx',
|
||||
'Flow1D_thermomech.frd'
|
||||
"ccx",
|
||||
"Flow1D_thermomech.frd"
|
||||
)
|
||||
from feminout.importCcxFrdResults import read_frd_result as read_frd
|
||||
frd_content = read_frd(frd_file)
|
||||
@@ -75,12 +75,12 @@ class TestResult(unittest.TestCase):
|
||||
frd_content_len = []
|
||||
for key in sorted(frd_content.keys()):
|
||||
frd_content_len.append(len(frd_content[key]))
|
||||
print('read data')
|
||||
print("read data")
|
||||
print(frd_content_len)
|
||||
print(sorted(frd_content.keys()))
|
||||
# print(frd_content)
|
||||
read_mflow = frd_content['Results'][12]['mflow']
|
||||
read_npressure = frd_content['Results'][12]['npressure']
|
||||
read_mflow = frd_content["Results"][12]["mflow"]
|
||||
read_npressure = frd_content["Results"][12]["npressure"]
|
||||
res_len = [
|
||||
len(read_mflow),
|
||||
len(read_npressure)
|
||||
@@ -90,9 +90,9 @@ class TestResult(unittest.TestCase):
|
||||
print(read_npressure)
|
||||
|
||||
# create the expected data
|
||||
print('\nexpected data')
|
||||
print("\nexpected data")
|
||||
efc = {} # expected frd content
|
||||
efc['Nodes'] = {
|
||||
efc["Nodes"] = {
|
||||
2: FreeCAD.Vector(0.0, 0.0, -50.0),
|
||||
3: FreeCAD.Vector(0.0, 0.0, -4300.0),
|
||||
4: FreeCAD.Vector(4950.0, 0.0, -4300.0),
|
||||
@@ -119,13 +119,13 @@ class TestResult(unittest.TestCase):
|
||||
26: FreeCAD.Vector(15047.0, 0.0, -11148.0),
|
||||
27: FreeCAD.Vector(15047.0, 0.0, -7897.97)
|
||||
}
|
||||
efc['Seg2Elem'] = {
|
||||
efc["Seg2Elem"] = {
|
||||
1: (15, 2),
|
||||
13: (13, 27)
|
||||
}
|
||||
efc['Seg3Elem'] = {}
|
||||
''' deleted during reading because of the inout file
|
||||
efc['Seg3Elem'] = {
|
||||
efc["Seg3Elem"] = {}
|
||||
""" deleted during reading because of the inout file
|
||||
efc["Seg3Elem"] = {
|
||||
2: (2, 16, 3),
|
||||
3: (3, 17, 4),
|
||||
4: (4, 18, 5),
|
||||
@@ -138,32 +138,32 @@ class TestResult(unittest.TestCase):
|
||||
11: (11, 25, 12),
|
||||
12: (12, 26, 13)
|
||||
}
|
||||
'''
|
||||
"""
|
||||
# faces
|
||||
efc['Tria3Elem'] = efc['Tria6Elem'] = {}
|
||||
efc['Quad4Elem'] = efc['Quad8Elem'] = {}
|
||||
efc["Tria3Elem"] = efc["Tria6Elem"] = {}
|
||||
efc["Quad4Elem"] = efc["Quad8Elem"] = {}
|
||||
# volumes
|
||||
efc['Tetra4Elem'] = efc['Tetra10Elem'] = {}
|
||||
efc['Hexa8Elem'] = efc['Hexa20Elem'] = {}
|
||||
efc['Penta6Elem'] = efc['Penta15Elem'] = {}
|
||||
efc["Tetra4Elem"] = efc["Tetra10Elem"] = {}
|
||||
efc["Hexa8Elem"] = efc["Hexa20Elem"] = {}
|
||||
efc["Penta6Elem"] = efc["Penta15Elem"] = {}
|
||||
|
||||
efc['Results'] = [
|
||||
{'time': 0.00390625},
|
||||
{'time': 0.0078125},
|
||||
{'time': 0.0136719},
|
||||
{'time': 0.0224609},
|
||||
{'time': 0.0356445},
|
||||
{'time': 0.0554199},
|
||||
{'time': 0.085083},
|
||||
{'time': 0.129578},
|
||||
{'time': 0.19632},
|
||||
{'time': 0.296432},
|
||||
{'time': 0.446602},
|
||||
{'time': 0.671856},
|
||||
efc["Results"] = [
|
||||
{"time": 0.00390625},
|
||||
{"time": 0.0078125},
|
||||
{"time": 0.0136719},
|
||||
{"time": 0.0224609},
|
||||
{"time": 0.0356445},
|
||||
{"time": 0.0554199},
|
||||
{"time": 0.085083},
|
||||
{"time": 0.129578},
|
||||
{"time": 0.19632},
|
||||
{"time": 0.296432},
|
||||
{"time": 0.446602},
|
||||
{"time": 0.671856},
|
||||
{
|
||||
'number': 0,
|
||||
'time': 1.0,
|
||||
'mflow': {
|
||||
"number": 0,
|
||||
"time": 1.0,
|
||||
"mflow": {
|
||||
1: 78.3918, # added during reading because of the inout file
|
||||
2: 78.3918,
|
||||
3: 78.3918,
|
||||
@@ -192,7 +192,7 @@ class TestResult(unittest.TestCase):
|
||||
27: 78.3918,
|
||||
28: 78.3918 # added during reading because of the inout file
|
||||
},
|
||||
'npressure': {
|
||||
"npressure": {
|
||||
1: 0.1, # added during reading because of the inout file
|
||||
2: 0.1,
|
||||
3: 0.134840,
|
||||
@@ -232,8 +232,8 @@ class TestResult(unittest.TestCase):
|
||||
print(expected_frd_content_len)
|
||||
print(sorted(expected_frd_content.keys()))
|
||||
# expected results
|
||||
expected_mflow = expected_frd_content['Results'][12]['mflow']
|
||||
expected_npressure = expected_frd_content['Results'][12]['npressure']
|
||||
expected_mflow = expected_frd_content["Results"][12]["mflow"]
|
||||
expected_npressure = expected_frd_content["Results"][12]["npressure"]
|
||||
expected_res_len = [
|
||||
len(expected_mflow),
|
||||
len(expected_npressure)
|
||||
@@ -249,18 +249,18 @@ class TestResult(unittest.TestCase):
|
||||
"Length's of read frd data values are unexpected"
|
||||
)
|
||||
self.assertEqual(
|
||||
frd_content['Nodes'],
|
||||
expected_frd_content['Nodes'],
|
||||
frd_content["Nodes"],
|
||||
expected_frd_content["Nodes"],
|
||||
"Values of read node data are unexpected"
|
||||
)
|
||||
self.assertEqual(
|
||||
frd_content['Seg2Elem'],
|
||||
expected_frd_content['Seg2Elem'],
|
||||
frd_content["Seg2Elem"],
|
||||
expected_frd_content["Seg2Elem"],
|
||||
"Values of read Seg2 data are unexpected"
|
||||
)
|
||||
self.assertEqual(
|
||||
frd_content['Seg3Elem'],
|
||||
expected_frd_content['Seg3Elem'],
|
||||
frd_content["Seg3Elem"],
|
||||
expected_frd_content["Seg3Elem"],
|
||||
"Values of read Seg3 data are unexpected"
|
||||
)
|
||||
self.assertEqual(
|
||||
@@ -285,7 +285,7 @@ class TestResult(unittest.TestCase):
|
||||
):
|
||||
# node 5 von calculix cantilver 3D example
|
||||
# doc = FreeCAD.open(
|
||||
# FreeCAD.ConfigGet("AppHomePath") + 'data/examples/FemCalculixCantilever3D.FCStd'
|
||||
# FreeCAD.ConfigGet("AppHomePath") + "data/examples/FemCalculixCantilever3D.FCStd"
|
||||
# )
|
||||
# doc.Box_Mesh.FemMesh.Nodes[5]
|
||||
# Vector (0.0, 1000.0, 0.0)
|
||||
@@ -431,7 +431,7 @@ class TestResult(unittest.TestCase):
|
||||
round(res[1], 5),
|
||||
round(res[2], 5)
|
||||
)
|
||||
# fcc_print('Case{}: {}'.format(i + 1 , rhores))
|
||||
# fcc_print("Case{}: {}".format(i + 1 , rhores))
|
||||
self.assertEqual(
|
||||
rhores, case[1],
|
||||
"Calculated rho are not the expected Case{}."
|
||||
|
||||
@@ -34,7 +34,7 @@ from os.path import join
|
||||
|
||||
|
||||
class TestSolverFrameWork(unittest.TestCase):
|
||||
fcc_print('import TestSolverFrameWork')
|
||||
fcc_print("import TestSolverFrameWork")
|
||||
|
||||
# ********************************************************************************************
|
||||
def setUp(
|
||||
@@ -52,9 +52,9 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
self.active_doc = FreeCAD.ActiveDocument
|
||||
|
||||
# more inits
|
||||
self.mesh_name = 'Mesh'
|
||||
self.mesh_name = "Mesh"
|
||||
self.temp_dir = testtools.get_fem_test_tmp_dir()
|
||||
self.test_file_dir = join(testtools.get_fem_test_home_dir(), 'ccx')
|
||||
self.test_file_dir = join(testtools.get_fem_test_home_dir(), "ccx")
|
||||
|
||||
def test_00print(
|
||||
self
|
||||
@@ -69,30 +69,30 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
def test_solver_framework(
|
||||
self
|
||||
):
|
||||
fcc_print('\n--------------- Start of FEM tests solver frame work ---------------')
|
||||
fcc_print("\n--------------- Start of FEM tests solver frame work ---------------")
|
||||
box = self.active_doc.addObject("Part::Box", "Box")
|
||||
fcc_print('Checking FEM new analysis...')
|
||||
fcc_print("Checking FEM new analysis...")
|
||||
analysis = ObjectsFem.makeAnalysis(
|
||||
self.active_doc,
|
||||
'Analysis'
|
||||
"Analysis"
|
||||
)
|
||||
self.assertTrue(analysis, "FemTest of new analysis failed")
|
||||
|
||||
fcc_print('Checking FEM new material...')
|
||||
fcc_print("Checking FEM new material...")
|
||||
material_object = ObjectsFem.makeMaterialSolid(
|
||||
self.active_doc,
|
||||
'MechanicalMaterial'
|
||||
"MechanicalMaterial"
|
||||
)
|
||||
mat = material_object.Material
|
||||
mat['Name'] = "Steel-Generic"
|
||||
mat['YoungsModulus'] = "200000 MPa"
|
||||
mat['PoissonRatio'] = "0.30"
|
||||
mat['Density'] = "7900 kg/m^3"
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
material_object.Material = mat
|
||||
self.assertTrue(material_object, "FemTest of new material failed")
|
||||
analysis.addObject(material_object)
|
||||
|
||||
fcc_print('Checking FEM new fixed constraint...')
|
||||
fcc_print("Checking FEM new fixed constraint...")
|
||||
fixed_constraint = self.active_doc.addObject(
|
||||
"Fem::ConstraintFixed",
|
||||
"FemConstraintFixed"
|
||||
@@ -101,7 +101,7 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
self.assertTrue(fixed_constraint, "FemTest of new fixed constraint failed")
|
||||
analysis.addObject(fixed_constraint)
|
||||
|
||||
fcc_print('Checking FEM new force constraint...')
|
||||
fcc_print("Checking FEM new force constraint...")
|
||||
force_constraint = self.active_doc.addObject(
|
||||
"Fem::ConstraintForce",
|
||||
"FemConstraintForce"
|
||||
@@ -115,7 +115,7 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
self.assertTrue(force_constraint, "FemTest of new force constraint failed")
|
||||
analysis.addObject(force_constraint)
|
||||
|
||||
fcc_print('Checking FEM new pressure constraint...')
|
||||
fcc_print("Checking FEM new pressure constraint...")
|
||||
pressure_constraint = self.active_doc.addObject(
|
||||
"Fem::ConstraintPressure",
|
||||
"FemConstraintPressure"
|
||||
@@ -126,7 +126,7 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
self.assertTrue(pressure_constraint, "FemTest of new pressure constraint failed")
|
||||
analysis.addObject(pressure_constraint)
|
||||
|
||||
fcc_print('Checking FEM new mesh...')
|
||||
fcc_print("Checking FEM new mesh...")
|
||||
from .testfiles.ccx.cube_mesh import create_nodes_cube
|
||||
from .testfiles.ccx.cube_mesh import create_elements_cube
|
||||
mesh = Fem.FemMesh()
|
||||
@@ -135,7 +135,7 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
ret = create_elements_cube(mesh)
|
||||
self.assertTrue(ret, "Import of mesh volumes failed")
|
||||
mesh_object = self.active_doc.addObject(
|
||||
'Fem::FemMeshObject',
|
||||
"Fem::FemMeshObject",
|
||||
self.mesh_name
|
||||
)
|
||||
mesh_object.FemMesh = mesh
|
||||
@@ -146,15 +146,15 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
|
||||
# solver frame work ccx solver
|
||||
# calculix solver object
|
||||
fcc_print('\nChecking FEM CalculiX solver for solver frame work...')
|
||||
fcc_print("\nChecking FEM CalculiX solver for solver frame work...")
|
||||
solver_ccx_object = ObjectsFem.makeSolverCalculix(
|
||||
self.active_doc,
|
||||
'SolverCalculiX'
|
||||
"SolverCalculiX"
|
||||
)
|
||||
solver_ccx_object.AnalysisType = 'static'
|
||||
solver_ccx_object.GeometricalNonlinearity = 'linear'
|
||||
solver_ccx_object.AnalysisType = "static"
|
||||
solver_ccx_object.GeometricalNonlinearity = "linear"
|
||||
solver_ccx_object.ThermoMechSteadyState = False
|
||||
solver_ccx_object.MatrixSolverType = 'default'
|
||||
solver_ccx_object.MatrixSolverType = "default"
|
||||
solver_ccx_object.IterationsControlParameterTimeUse = False
|
||||
solver_ccx_object.EigenmodesCount = 10
|
||||
solver_ccx_object.EigenmodeHighLimit = 1000000.0
|
||||
@@ -162,15 +162,15 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
self.assertTrue(solver_ccx_object, "FemTest of new ccx solver failed")
|
||||
analysis.addObject(solver_ccx_object)
|
||||
|
||||
static_base_name = 'cube_static'
|
||||
static_base_name = "cube_static"
|
||||
solverframework_analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
testtools.get_fem_test_tmp_dir(),
|
||||
'FEM_solverframework'
|
||||
"FEM_solverframework"
|
||||
)
|
||||
|
||||
# write input file
|
||||
fcc_print('Checking FEM ccx solver for solver frame work......')
|
||||
fcc_print('machine_ccx')
|
||||
fcc_print("Checking FEM ccx solver for solver frame work......")
|
||||
fcc_print("machine_ccx")
|
||||
machine_ccx = solver_ccx_object.Proxy.createMachine(
|
||||
solver_ccx_object,
|
||||
solverframework_analysis_dir
|
||||
@@ -181,11 +181,11 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
|
||||
infile_given = join(
|
||||
testtools.get_fem_test_home_dir(),
|
||||
'ccx',
|
||||
(static_base_name + '.inp')
|
||||
"ccx",
|
||||
(static_base_name + ".inp")
|
||||
)
|
||||
inpfile_totest = join(solverframework_analysis_dir, (self.mesh_name + '.inp'))
|
||||
fcc_print('Comparing {} to {}'.format(infile_given, inpfile_totest))
|
||||
inpfile_totest = join(solverframework_analysis_dir, (self.mesh_name + ".inp"))
|
||||
fcc_print("Comparing {} to {}".format(infile_given, inpfile_totest))
|
||||
ret = testtools.compare_inp_files(infile_given, inpfile_totest)
|
||||
self.assertFalse(ret, "ccxtools write_inp_file test failed.\n{}".format(ret))
|
||||
|
||||
@@ -193,7 +193,7 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
# elmer solver object
|
||||
solver_elmer_object = ObjectsFem.makeSolverElmer(
|
||||
self.active_doc,
|
||||
'SolverElmer'
|
||||
"SolverElmer"
|
||||
)
|
||||
self.assertTrue(solver_elmer_object, "FemTest of elmer solver failed")
|
||||
analysis.addObject(solver_elmer_object)
|
||||
@@ -207,7 +207,7 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
# current elmer seems to need it even on simple elasticity analysis
|
||||
mat = material_object.Material
|
||||
# FIXME elmer elasticity needs the dictionary key, otherwise it fails
|
||||
mat['ThermalExpansionCoefficient'] = "0 um/m/K"
|
||||
mat["ThermalExpansionCoefficient"] = "0 um/m/K"
|
||||
material_object.Material = mat
|
||||
|
||||
mesh_gmsh = ObjectsFem.makeMeshGmsh(self.active_doc)
|
||||
@@ -221,7 +221,7 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
|
||||
# solver frame work Elmer solver
|
||||
# write input files
|
||||
fcc_print('\nChecking FEM Elmer solver for solver frame work...')
|
||||
fcc_print("\nChecking FEM Elmer solver for solver frame work...")
|
||||
machine_elmer = solver_elmer_object.Proxy.createMachine(
|
||||
solver_elmer_object,
|
||||
solverframework_analysis_dir,
|
||||
@@ -232,33 +232,33 @@ class TestSolverFrameWork(unittest.TestCase):
|
||||
machine_elmer.join() # wait for the machine to finish.
|
||||
|
||||
# compare startinfo, case and gmsh input files
|
||||
test_file_dir_elmer = join(testtools.get_fem_test_home_dir(), 'elmer')
|
||||
test_file_dir_elmer = join(testtools.get_fem_test_home_dir(), "elmer")
|
||||
|
||||
fcc_print('Test writing STARTINFO file')
|
||||
startinfo_given = join(test_file_dir_elmer, 'ELMERSOLVER_STARTINFO')
|
||||
startinfo_totest = join(solverframework_analysis_dir, 'ELMERSOLVER_STARTINFO')
|
||||
fcc_print('Comparing {} to {}'.format(startinfo_given, startinfo_totest))
|
||||
fcc_print("Test writing STARTINFO file")
|
||||
startinfo_given = join(test_file_dir_elmer, "ELMERSOLVER_STARTINFO")
|
||||
startinfo_totest = join(solverframework_analysis_dir, "ELMERSOLVER_STARTINFO")
|
||||
fcc_print("Comparing {} to {}".format(startinfo_given, startinfo_totest))
|
||||
ret = testtools.compare_files(startinfo_given, startinfo_totest)
|
||||
self.assertFalse(ret, "STARTINFO write file test failed.\n{}".format(ret))
|
||||
|
||||
fcc_print('Test writing case file')
|
||||
casefile_given = join(test_file_dir_elmer, 'case.sif')
|
||||
casefile_totest = join(solverframework_analysis_dir, 'case.sif')
|
||||
fcc_print('Comparing {} to {}'.format(casefile_given, casefile_totest))
|
||||
fcc_print("Test writing case file")
|
||||
casefile_given = join(test_file_dir_elmer, "case.sif")
|
||||
casefile_totest = join(solverframework_analysis_dir, "case.sif")
|
||||
fcc_print("Comparing {} to {}".format(casefile_given, casefile_totest))
|
||||
ret = testtools.compare_files(casefile_given, casefile_totest)
|
||||
self.assertFalse(ret, "case write file test failed.\n{}".format(ret))
|
||||
|
||||
fcc_print('Test writing GMSH geo file')
|
||||
gmshgeofile_given = join(test_file_dir_elmer, 'group_mesh.geo')
|
||||
gmshgeofile_totest = join(solverframework_analysis_dir, 'group_mesh.geo')
|
||||
fcc_print('Comparing {} to {}'.format(gmshgeofile_given, gmshgeofile_totest))
|
||||
fcc_print("Test writing GMSH geo file")
|
||||
gmshgeofile_given = join(test_file_dir_elmer, "group_mesh.geo")
|
||||
gmshgeofile_totest = join(solverframework_analysis_dir, "group_mesh.geo")
|
||||
fcc_print("Comparing {} to {}".format(gmshgeofile_given, gmshgeofile_totest))
|
||||
ret = testtools.compare_files(gmshgeofile_given, gmshgeofile_totest)
|
||||
self.assertFalse(ret, "GMSH geo write file test failed.\n{}".format(ret))
|
||||
|
||||
save_fc_file = solverframework_analysis_dir + static_base_name + '.FCStd'
|
||||
fcc_print('Save FreeCAD file for static2 analysis to {}...'.format(save_fc_file))
|
||||
save_fc_file = solverframework_analysis_dir + static_base_name + ".FCStd"
|
||||
fcc_print("Save FreeCAD file for static2 analysis to {}...".format(save_fc_file))
|
||||
self.active_doc.saveAs(save_fc_file)
|
||||
fcc_print('--------------- End of FEM tests solver frame work ---------------')
|
||||
fcc_print("--------------- End of FEM tests solver frame work ---------------")
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
|
||||
@@ -36,12 +36,12 @@ from os.path import join
|
||||
|
||||
def get_fem_test_home_dir(
|
||||
):
|
||||
return join(FreeCAD.getHomePath(), 'Mod', 'Fem', 'femtest', 'testfiles')
|
||||
return join(FreeCAD.getHomePath(), "Mod", "Fem", "femtest", "testfiles")
|
||||
|
||||
|
||||
def get_fem_test_tmp_dir(
|
||||
):
|
||||
temp_dir = join(tempfile.gettempdir(), 'FEM_unittests')
|
||||
temp_dir = join(tempfile.gettempdir(), "FEM_unittests")
|
||||
if not os.path.exists(temp_dir):
|
||||
os.makedirs(temp_dir)
|
||||
return(temp_dir)
|
||||
@@ -60,22 +60,22 @@ def get_unit_test_tmp_dir(
|
||||
def fcc_print(
|
||||
message
|
||||
):
|
||||
FreeCAD.Console.PrintMessage('{} \n'.format(message))
|
||||
FreeCAD.Console.PrintMessage("{} \n".format(message))
|
||||
|
||||
|
||||
def get_defmake_count(
|
||||
fem_vtk_post=True
|
||||
):
|
||||
'''
|
||||
"""
|
||||
count the def make in module ObjectsFem
|
||||
could also be done in bash with
|
||||
grep -c "def make" src/Mod/Fem/ObjectsFem.py
|
||||
'''
|
||||
name_modfile = join(FreeCAD.getHomePath(), 'Mod', 'Fem', 'ObjectsFem.py')
|
||||
modfile = open(name_modfile, 'r')
|
||||
"""
|
||||
name_modfile = join(FreeCAD.getHomePath(), "Mod", "Fem", "ObjectsFem.py")
|
||||
modfile = open(name_modfile, "r")
|
||||
lines_modefile = modfile.readlines()
|
||||
modfile.close()
|
||||
lines_defmake = [l for l in lines_modefile if l.startswith('def make')]
|
||||
lines_defmake = [l for l in lines_modefile if l.startswith("def make")]
|
||||
if not fem_vtk_post:
|
||||
# FEM VTK post processing is disabled
|
||||
# we are not able to create VTK post objects
|
||||
@@ -88,41 +88,41 @@ def get_defmake_count(
|
||||
|
||||
|
||||
def get_fem_test_defs(
|
||||
inout='out'
|
||||
inout="out"
|
||||
):
|
||||
test_path = join(FreeCAD.getHomePath(), 'Mod', 'Fem', 'femtest')
|
||||
test_path = join(FreeCAD.getHomePath(), "Mod", "Fem", "femtest")
|
||||
collected_test_modules = []
|
||||
collected_test_methods = []
|
||||
for tfile in sorted(os.listdir(test_path)):
|
||||
if tfile.startswith("test") and tfile.endswith(".py"):
|
||||
collected_test_modules.append(join(test_path, tfile))
|
||||
for f in collected_test_modules:
|
||||
tfile = open(f, 'r')
|
||||
tfile = open(f, "r")
|
||||
module_name = os.path.splitext(os.path.basename(f))[0]
|
||||
class_name = ''
|
||||
class_name = ""
|
||||
for ln in tfile:
|
||||
ln = ln.lstrip()
|
||||
ln = ln.rstrip()
|
||||
if ln.startswith('class '):
|
||||
ln = ln.lstrip('class ')
|
||||
ln = ln.split('(')[0]
|
||||
if ln.startswith("class "):
|
||||
ln = ln.lstrip("class ")
|
||||
ln = ln.split("(")[0]
|
||||
class_name = ln
|
||||
if ln.startswith('def test'):
|
||||
ln = ln.lstrip('def ')
|
||||
ln = ln.split('(')[0]
|
||||
if ln.startswith("def test"):
|
||||
ln = ln.lstrip("def ")
|
||||
ln = ln.split("(")[0]
|
||||
collected_test_methods.append(
|
||||
'femtest.{}.{}.{}'.format(module_name, class_name, ln)
|
||||
"femtest.{}.{}.{}".format(module_name, class_name, ln)
|
||||
)
|
||||
tfile.close()
|
||||
print('')
|
||||
print("")
|
||||
for m in collected_test_methods:
|
||||
run_outside_fc = './bin/FreeCADCmd --run-test "{}"'.format(m)
|
||||
run_inside_fc = (
|
||||
'unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName("{}"))'
|
||||
"unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName('{}'))"
|
||||
.format(m)
|
||||
)
|
||||
if inout == 'in':
|
||||
print('\nimport unittest')
|
||||
if inout == "in":
|
||||
print("\nimport unittest")
|
||||
print(run_inside_fc)
|
||||
else:
|
||||
print(run_outside_fc)
|
||||
@@ -132,28 +132,28 @@ def compare_inp_files(
|
||||
file_name1,
|
||||
file_name2
|
||||
):
|
||||
file1 = open(file_name1, 'r')
|
||||
file1 = open(file_name1, "r")
|
||||
f1 = file1.readlines()
|
||||
file1.close()
|
||||
# l.startswith('17671.0,1') is a temporary workaround
|
||||
# l.startswith("17671.0,1") is a temporary workaround
|
||||
# for python3 problem with 1DFlow input
|
||||
# TODO as soon as the 1DFlow result reading is fixed
|
||||
# this should be triggered in the 1DFlow unit test
|
||||
lf1 = [l for l in f1 if not (
|
||||
l.startswith('** written ') or l.startswith('** file ') or l.startswith('17671.0,1')
|
||||
l.startswith("** written ") or l.startswith("** file ") or l.startswith("17671.0,1")
|
||||
)]
|
||||
lf1 = force_unix_line_ends(lf1)
|
||||
file2 = open(file_name2, 'r')
|
||||
file2 = open(file_name2, "r")
|
||||
f2 = file2.readlines()
|
||||
file2.close()
|
||||
# TODO see comment on file1
|
||||
lf2 = [l for l in f2 if not (
|
||||
l.startswith('** written ') or l.startswith('** file ') or l.startswith('17671.0,1')
|
||||
l.startswith("** written ") or l.startswith("** file ") or l.startswith("17671.0,1")
|
||||
)]
|
||||
lf2 = force_unix_line_ends(lf2)
|
||||
import difflib
|
||||
diff = difflib.unified_diff(lf1, lf2, n=0)
|
||||
result = ''
|
||||
result = ""
|
||||
for l in diff:
|
||||
result += l
|
||||
if result:
|
||||
@@ -168,25 +168,25 @@ def compare_files(
|
||||
file_name1,
|
||||
file_name2
|
||||
):
|
||||
file1 = open(file_name1, 'r')
|
||||
file1 = open(file_name1, "r")
|
||||
f1 = file1.readlines()
|
||||
file1.close()
|
||||
# workaround to compare geos of elmer test and temporary file path
|
||||
# (not only names change, path changes with operating system)
|
||||
lf1 = [l for l in f1 if not (
|
||||
l.startswith('Merge "') or l.startswith('Save "') or l.startswith('// ')
|
||||
l.startswith('Merge "') or l.startswith('Save "') or l.startswith("// ")
|
||||
)]
|
||||
lf1 = force_unix_line_ends(lf1)
|
||||
file2 = open(file_name2, 'r')
|
||||
file2 = open(file_name2, "r")
|
||||
f2 = file2.readlines()
|
||||
file2.close()
|
||||
lf2 = [l for l in f2 if not (
|
||||
l.startswith('Merge "') or l.startswith('Save "') or l.startswith('// ')
|
||||
l.startswith('Merge "') or l.startswith('Save "') or l.startswith("// ")
|
||||
)]
|
||||
lf2 = force_unix_line_ends(lf2)
|
||||
import difflib
|
||||
diff = difflib.unified_diff(lf1, lf2, n=0)
|
||||
result = ''
|
||||
result = ""
|
||||
for l in diff:
|
||||
result += l
|
||||
if result:
|
||||
@@ -238,7 +238,7 @@ def compare_stats(
|
||||
return True
|
||||
|
||||
# get stats to compare with, the expected ones
|
||||
sf = open(stat_file, 'r')
|
||||
sf = open(stat_file, "r")
|
||||
sf_content = []
|
||||
for l in sf.readlines():
|
||||
for st in loc_stat_types:
|
||||
@@ -268,7 +268,7 @@ def force_unix_line_ends(
|
||||
new_line_list = []
|
||||
for ln in line_list:
|
||||
if ln.endswith("\r\n"):
|
||||
ln = ln[:-2] + '\n'
|
||||
ln = ln[:-2] + "\n"
|
||||
new_line_list.append(ln)
|
||||
return new_line_list
|
||||
|
||||
@@ -277,20 +277,20 @@ def collect_python_modules(
|
||||
femsubdir=None
|
||||
):
|
||||
if not femsubdir:
|
||||
pydir = join(FreeCAD.ConfigGet("AppHomePath"), 'Mod', 'Fem')
|
||||
pydir = join(FreeCAD.ConfigGet("AppHomePath"), "Mod", "Fem")
|
||||
else:
|
||||
pydir = join(FreeCAD.ConfigGet("AppHomePath"), 'Mod', 'Fem', femsubdir)
|
||||
pydir = join(FreeCAD.ConfigGet("AppHomePath"), "Mod", "Fem", femsubdir)
|
||||
collected_modules = []
|
||||
fcc_print(pydir)
|
||||
for pyfile in sorted(os.listdir(pydir)):
|
||||
if pyfile.endswith(".py") and not pyfile.startswith('Init'):
|
||||
if pyfile.endswith(".py") and not pyfile.startswith("Init"):
|
||||
if not femsubdir:
|
||||
collected_modules.append(
|
||||
os.path.splitext(os.path.basename(pyfile))[0]
|
||||
)
|
||||
else:
|
||||
collected_modules.append(
|
||||
femsubdir.replace('/', '.') + '.' + os.path.splitext(
|
||||
femsubdir.replace("/", ".") + "." + os.path.splitext(
|
||||
os.path.basename(pyfile)
|
||||
)[0]
|
||||
)
|
||||
@@ -315,8 +315,8 @@ def cube_frequency(
|
||||
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(testname))
|
||||
doc = FreeCAD.open(join(
|
||||
get_fem_test_tmp_dir(),
|
||||
'FEM_ccx_frequency',
|
||||
'cube_frequency.FCStd')
|
||||
"FEM_ccx_frequency",
|
||||
"cube_frequency.FCStd")
|
||||
)
|
||||
return doc
|
||||
|
||||
@@ -327,8 +327,8 @@ def cube_static(
|
||||
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(testname))
|
||||
doc = FreeCAD.open(
|
||||
join(get_fem_test_tmp_dir(),
|
||||
'FEM_ccx_static',
|
||||
'cube_static.FCStd')
|
||||
"FEM_ccx_static",
|
||||
"cube_static.FCStd")
|
||||
)
|
||||
return doc
|
||||
|
||||
@@ -339,8 +339,8 @@ def Flow1D_thermomech(
|
||||
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(testname))
|
||||
doc = FreeCAD.open(join(
|
||||
get_fem_test_tmp_dir(),
|
||||
'FEM_ccx_Flow1D_thermomech',
|
||||
'Flow1D_thermomech.FCStd')
|
||||
"FEM_ccx_Flow1D_thermomech",
|
||||
"Flow1D_thermomech.FCStd")
|
||||
)
|
||||
return doc
|
||||
|
||||
@@ -351,8 +351,8 @@ def multimat(
|
||||
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(testname))
|
||||
doc = FreeCAD.open(join(
|
||||
get_fem_test_tmp_dir(),
|
||||
'FEM_ccx_multimat',
|
||||
'multimat.FCStd')
|
||||
"FEM_ccx_multimat",
|
||||
"multimat.FCStd")
|
||||
)
|
||||
return doc
|
||||
|
||||
@@ -363,7 +363,7 @@ def spine_thermomech(
|
||||
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName(testname))
|
||||
doc = FreeCAD.open(join(
|
||||
get_fem_test_tmp_dir(),
|
||||
'FEM_ccx_thermomech',
|
||||
'spine_thermomech.FCStd')
|
||||
"FEM_ccx_thermomech",
|
||||
"spine_thermomech.FCStd")
|
||||
)
|
||||
return doc
|
||||
|
||||
Reference in New Issue
Block a user