-
This commit is contained in:
parent
8fa62bba38
commit
c7111dc9cc
33
playground/meshConvert.py
Normal file
33
playground/meshConvert.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user