From 41e56ef9d032bf825cdc9f2d05a6c2ed01e0aa30 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Sun, 16 Dec 2018 11:30:46 +0100 Subject: [PATCH] FEM: unit tests, add FEM_VTK check and reactivate vtk mesh test --- src/Mod/Fem/femtest/testmesh.py | 77 +++++++++++++++++---------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/src/Mod/Fem/femtest/testmesh.py b/src/Mod/Fem/femtest/testmesh.py index b9043290e8..c86d5c2107 100644 --- a/src/Mod/Fem/femtest/testmesh.py +++ b/src/Mod/Fem/femtest/testmesh.py @@ -304,7 +304,6 @@ 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' @@ -312,43 +311,45 @@ class TestMeshEleTetra10(unittest.TestCase): 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" - ) - ''' + if "BUILD_FEM_VTK" in FreeCAD.__cmake__: + 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" + ) + else: + fcc_print('FEM_VTK post processing is disabled.') def test_tetra10_z88(self): # tetra10 element: reading from and writing to z88 mesh file format