From c7111dc9ccaa64605c9f960c7dcca56542ff6a6f Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Fri, 14 Jan 2022 09:26:18 +0500 Subject: [PATCH] - --- playground/meshConvert.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 playground/meshConvert.py diff --git a/playground/meshConvert.py b/playground/meshConvert.py new file mode 100644 index 0000000..d595cf8 --- /dev/null +++ b/playground/meshConvert.py @@ -0,0 +1,33 @@ +from netgen.meshing import Mesh as netgenMesh +from meshio import Mesh as meshioMesh + +meshfile = "mesh.mesh" + +mesh = netgenMesh() +mesh.Load(meshfile) + +topology3d = { + 4: "tetra" +} + +pointsNew = [] +cellsNew = {} + +for point in mesh.Points(): + pointsNew.append(list(point.p)) + +for cell in mesh.Elements3D(): + cellTopo = topology3d[len(cell.points)] + cellNew = [] + + for pointId in cell.points: + cellNew.append(pointId.nr) + + if cellsNew.get(cellTopo): + cellsNew[cellTopo].append(cellNew) + + else: + cellsNew[cellTopo] = [ cellNew ] + +cellsMeshio = [ cell for cell in cellsNew.items() ] +meshNew = meshioMesh(pointsNew, cellsMeshio) \ No newline at end of file