FEM: unit tests, add tetra10 vtk mesh read and write test

This commit is contained in:
Bernd Hahnebach
2018-12-14 21:27:47 +01:00
parent 3e247b32dc
commit fffd4d49c4
3 changed files with 60 additions and 0 deletions

View File

@@ -168,6 +168,7 @@ SET(FemTestsMesh_SRCS
femtest/testfiles/mesh/__init__.py
femtest/testfiles/mesh/tetra10_mesh.inp
femtest/testfiles/mesh/tetra10_mesh.unv
femtest/testfiles/mesh/tetra10_mesh.vtk
femtest/testfiles/mesh/tetra10_mesh.z88
)

View File

@@ -0,0 +1,15 @@
# vtk DataFile Version 4.0
vtk output
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 10 float
6 12 18 0 0 18 12 0 18
6 6 0 3 6 18 6 0 18
9 6 18 6 9 9 3 3 9
9 3 9
CELLS 1 11
10 0 1 2 3 4 5 6 7 8 9
CELL_TYPES 1
24

View File

@@ -305,6 +305,50 @@ class TestMeshEleTetra10(unittest.TestCase):
"Test writing " + self.elem + " mesh to " + filetyp + " file failed. Volumes are different.\n"
)
def test_tetra10_vkt(self):
# tetra10 element: reading from and writing to unv mesh file format
filetyp = 'vtk'
outfile = self.base_outfile + filetyp
testfile = self.base_testfile + filetyp
# fcc_print(outfile)
# fcc_print(testfile)
self.femmesh.write(outfile) # write the mesh
femmesh_outfile = Fem.read(outfile) # read the mesh from written mesh
femmesh_testfile = Fem.read(testfile) # read the mesh from test mesh
# reading the test mesh
self.assertEqual(
femmesh_testfile.Nodes,
self.expected_nodes['nodes'],
"Test writing " + self.elem + " mesh to " + filetyp + " file failed. Nodes are different.\n"
)
self.assertEqual(
[femmesh_testfile.Volumes[0], femmesh_testfile.getElementNodes(femmesh_outfile.Volumes[0])],
self.expected_elem['volumes'],
"Test writing " + self.elem + " mesh to " + filetyp + " file failed. Volumes are different.\n"
)
# reading the written mesh
self.assertEqual(
femmesh_outfile.Nodes,
self.expected_nodes['nodes'],
"Test writing " + self.elem + " mesh to " + filetyp + " file failed. Nodes are different.\n"
)
self.assertEqual(
[femmesh_outfile.Volumes[0], femmesh_outfile.getElementNodes(femmesh_outfile.Volumes[0])],
self.expected_elem['volumes'],
"Test writing " + self.elem + " mesh to " + filetyp + " file failed. Volumes are different.\n"
)
# both
self.assertEqual(
femmesh_outfile.Nodes,
femmesh_testfile.Nodes,
"Test writing " + self.elem + " mesh to " + filetyp + " file failed. Nodes are different.\n"
)
self.assertEqual(
femmesh_outfile.Volumes,
femmesh_testfile.Volumes,
"Test writing " + self.elem + " mesh to " + filetyp + " file failed. Volumes are different.\n"
)
def test_tetra10_z88(self):
# tetra10 element: reading from and writing to z88 mesh file format
filetyp = 'z88'