You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importmeshiodefconvert_med_to_xdmf(
med_file,
cell_file="mesh_domains.xdmf",
facet_file="mesh_boundaries.xdmf",
cell_type="tetra",
facet_type="triangle",
):
"""Converts a MED mesh to XDMF Args: med_file (str): the name of the MED file cell_file (str, optional): the name of the file containing the volume markers. Defaults to "mesh_domains.xdmf". facet_file (str, optional): the name of the file containing the surface markers.. Defaults to "mesh_boundaries.xdmf". cell_type (str, optional): The topology of the cells. Defaults to "tetra". facet_type (str, optional): The topology of the facets. Defaults to "triangle". Returns: dict, dict: the correspondance dict, the cell types """msh=meshio.read(med_file)
correspondance_dict=msh.cell_tagscell_data_types=msh.cell_data_dict["cell_tags"].keys()
formesh_blockinmsh.cells:
ifmesh_block.type==cell_type:
meshio.write_points_cells(
cell_file,
msh.points,
[mesh_block],
cell_data={"f": [-1*msh.cell_data_dict["cell_tags"][cell_type]]},
)
elifmesh_block.type==facet_type:
meshio.write_points_cells(
facet_file,
msh.points,
[mesh_block],
cell_data={"f": [-1*msh.cell_data_dict["cell_tags"][facet_type]]},
)
returncorrespondance_dict, cell_data_types
Should we consider adding it to the festim codebase (maybe in helpers)?
We would make meshio an optional dependency only required if you want to run this function:
defconvert_med_to_xdmf(...):
importmeshio
The text was updated successfully, but these errors were encountered:
This snippet is used in a lot of places:
Should we consider adding it to the festim codebase (maybe in helpers)?
We would make meshio an optional dependency only required if you want to run this function:
The text was updated successfully, but these errors were encountered: