import dolfinx
import meshio
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
# This line needs to get cell data from what ever the markers have been called in the vtk file.
# Expore this by printing mesh.cell_data
# cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
if prune_z:
points = mesh.points[:,:2]
else:
points = mesh.points
out_mesh = meshio.Mesh(points=points, cells={cell_type: cells})
#, cell_data={"name_to_read":[cell_data]})
return out_mesh
domain = meshio.read("testrve.xdmf")
import numpy as np
from mpi4py import MPI
from dolfinx.cpp.mesh import CellType
from dolfinx.io import (XDMFFile)
from dolfinx import mesh, fem, plot, io
from dolfinx.fem import FunctionSpace
V = dolfinx.fem.FunctionSpace(domain, ("CG", 2))
I am using the gmshModel API to create my mesh file. I am using the docker image of the Jupyter notebook for using FeniCSx. I was using the create_mesh function provided on this forum, but I think that is no longer required since I am directly using an xdmf file.
Yes, that worked. However now there is another issue, I get a RuntimeError: Cannot recognise cell type. Unknown value: mixed. I believe this has to do with the .xdmf file. I have pasted what I see in Notepad++ when I open the .xdmf file.
import dolfinx
from dolfinx.io import (XDMFFile)
import numpy as np
from mpi4py import MPI
from dolfinx.cpp.mesh import CellType
from dolfinx import mesh, fem, plot, io
from dolfinx.fem import FunctionSpace
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
# This line needs to get cell data from what ever the markers have been called in the vtk file.
# Expore this by printing mesh.cell_data
# cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
if prune_z:
points = mesh.points[:,:2]
else:
points = mesh.points
out_mesh = meshio.Mesh(points=points, cells={cell_type: cells})
#, cell_data={"name_to_read":[cell_data]})
return out_mesh
with XDMFFile(MPI.COMM_WORLD, "testrve.xdmf", "r") as xdmf:
domain = xdmf.read_mesh(name="Grid")
print(domain)
V = dolfinx.fem.FunctionSpace(domain, ("CG", 1))