cashocs.io.mesh.MeshConverter#

class cashocs.io.mesh.MeshConverter(comm: MPI.Comm | None)[source]#

Bases: object

Converter from Gmsh to XDMF.

Initializes the mesh converter.

Parameters:

comm (MPI.Comm | None) – The MPI.Comm used for parallelization. If this is None, COMM_WORLD is used.

Methods Summary

check_for_physical_names(inputfile, ...)

Checks and extracts physical tags if they are given as strings.

check_mode(mode)

Cheks, whether the supplied mode is sensible.

convert(inputfile[, outputfile, mode, quiet])

Converts a Gmsh .msh file to a .xdmf mesh file.

write_boundaries(topological_dimension, ...)

Writes out a xdmf file with meshio corresponding to the boundaries.

write_mesh(topological_dimension, ...)

Writes out a xdmf file with the mesh and corresponding subdomains.

Methods Documentation

check_for_physical_names(inputfile: str, topological_dimension: int, ostring: str) None[source]#

Checks and extracts physical tags if they are given as strings.

Parameters:
  • inputfile (str) – Path to the input file.

  • topological_dimension (int) – The dimension of the mesh.

  • ostring (str) – The output string, containing the name and path to the output file, without extension.

Return type:

None

check_mode(mode: str) None[source]#

Cheks, whether the supplied mode is sensible.

Parameters:

mode (str) – The mode that should be used for the conversion.

Returns:

Raises an exception if the supplied mode is not supported.

Return type:

None

convert(inputfile: str, outputfile: str | None = None, mode: str = 'physical', quiet: bool = False) None[source]#

Converts a Gmsh .msh file to a .xdmf mesh file.

Parameters:
  • inputfile (str) – Gmsh file to be converted.

  • outputfile (str | None, optional) – Path to the target output. Defaults to None.

  • mode (str, optional) – The mode used to define the subdomains and boundaries. This can be either “physical” or “geometrical”. Defaults to “physical”.

  • quiet (bool, optional) – A boolean flag which indicates whether the method should produce output to stdout. Defaults to False.

Return type:

None

write_boundaries(topological_dimension: int, cell_data_dict: dict, points: ndarray, cells_dict: dict, ostring: str, mode: str) None[source]#

Writes out a xdmf file with meshio corresponding to the boundaries.

Parameters:
  • topological_dimension (int) – The topological dimension of the mesh.

  • cell_data_dict (dict) – The cell_data_dict of the mesh.

  • points (ndarray) – The array of points.

  • cells_dict (dict) – The cells_dict of the mesh.

  • ostring (str) – The output string, containing the name and path to the output file, without extension.

  • mode (str) – The mode which is used to define the subdomains and boundaries. Should be one of ‘physical’ (the default), ‘geometrical’, or ‘none’.

Return type:

None

write_mesh(topological_dimension: int, cell_data_dict: dict, points: ndarray, cells_dict: dict, ostring: str, mode: str) None[source]#

Writes out a xdmf file with the mesh and corresponding subdomains.

Parameters:
  • topological_dimension (int) – The topological dimension of the mesh.

  • cell_data_dict (dict) – The cell_data_dict of the mesh.

  • points (ndarray) – The array of points.

  • cells_dict (dict) – The cells_dict of the mesh.

  • ostring (str) – The output string, containing the name and path to the output file, without extension.

  • mode (str) – The mode which is used to define the subdomains and boundaries. Should be one of ‘physical’ (the default), ‘geometrical’, or ‘none’.

Return type:

None