test pickling also non-empty mesh

This commit is contained in:
Matthias Hochsteger 2021-06-14 10:09:19 +02:00
parent b83d73e919
commit 167df9feb9

View File

@ -87,19 +87,23 @@ def test_pickle_geom2d():
def test_pickle_mesh():
import netgen.csg as csg
geo = csg.CSGeometry()
geo1 = csg.CSGeometry()
geo2 = csg.CSGeometry()
brick = csg.OrthoBrick(csg.Pnt(-3,-3,-3), csg.Pnt(3,3,3))
mesh = geo.GenerateMesh(maxh=0.2)
assert geo == mesh.GetGeometry()
dump = pickle.dumps([geo,mesh])
geo2, mesh2 = pickle.loads(dump)
assert geo2 == mesh2.GetGeometry()
mesh.Save("msh1.vol.gz")
mesh2.Save("msh2.vol.gz")
import filecmp, os
assert filecmp.cmp("msh1.vol.gz", "msh2.vol.gz")
os.remove("msh1.vol.gz")
os.remove("msh2.vol.gz")
geo2.Add(brick)
for geo in [geo1, geo2]:
mesh = geo.GenerateMesh(maxh=2)
assert geo == mesh.GetGeometry()
dump = pickle.dumps([geo,mesh])
geo2, mesh2 = pickle.loads(dump)
assert geo2 == mesh2.GetGeometry()
mesh.Save("msh1.vol.gz")
mesh2.Save("msh2.vol.gz")
import filecmp, os
assert filecmp.cmp("msh1.vol.gz", "msh2.vol.gz")
os.remove("msh1.vol.gz")
os.remove("msh2.vol.gz")
if __name__ == "__main__":
test_pickle_mesh()