-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMonopole2Conv.py
More file actions
36 lines (25 loc) · 873 Bytes
/
Monopole2Conv.py
File metadata and controls
36 lines (25 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import meshio
msh = meshio.read("Monopole2.msh")
for cell in msh.cells:
if cell.type == "tetra":
tetra_cells = cell.data
for key in msh.cell_data_dict["gmsh:physical"].keys():
if key == "tetra":
tetra_data = msh.cell_data_dict["gmsh:physical"][key]
tetra_mesh = meshio.Mesh(points=msh.points, cells={"tetra": tetra_cells},
cell_data={"VolumeRegions":[tetra_data]})
meshio.write("mesh.xdmf", tetra_mesh)
from dolfin import *
from vtkplotter.dolfin import datadir, plot
mesh = Mesh()
with XDMFFile("mesh.xdmf") as infile:
infile.read(mesh)
mvc = MeshValueCollection("size_t", mesh, 3)
with XDMFFile("mesh.xdmf") as infile:
infile.read(mvc, "VolumeRegions")
cf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
info(mesh)
# Volume domains
File("VolSubDomains.pvd").write(cf)
File("Mesh.pvd").write(mesh)
plot(mesh)