The MeshParser class#
What it does#
Based on the gmsh API, the MeshParser class is used to parse the data extracted from the .msh file provided by the user. Unless you know what you are doing, do not access and modify this class.
Documentation#
- class watlab.meshParser.MeshParser(msh_mesh)#
- This class aims at extracting the information of .msh files to be
compatible with the Watlab philosophy. Mainly, the GMSH API is used to extract the data. HydroFlow requires mainly informations on cells centers, nodes, regions… In HydroFlow, this class should not be used directly by the users?
It must be initialized by giving a path to a .msh.
- Parameters:
msh_mesh (string) – a mesh file containg a mesh from GMSH
- __sort_elements_by_tag(tags, elements)#
Sorts the parsed elements by tag.
- Parameters:
tags (nDArray) – a n x 1 array
elements (nDArray) – a n x dim array
- Returns:
tags and elem, sorted by tags
- Return type:
nDArray
- extract_cells()#
Extracts the cells from the GMSH mesh
- Raises:
Exception – There is no cells in the provided mesh
- Returns:
cells and tags_cells
- Return type:
nDArray
- extract_cells_barycenters()#
Extracts the cells barycenters from the GMSH mesh
- Returns:
barycenters = all the barycenters of each cell of the domain
- Return type:
nDArray
- extract_cells_by_physical_group(dim) dict #
- Extracts the cells for each entity of a physical group and
stacks them all in a dictionnary where the key is the physical group.
- Parameters:
dim (int) – a specific dimension 0,1,2
- Returns:
a dictionnary corresponding to the cells of a specific dimension
- Return type:
dict
- extract_edges()#
Extracts the edges’ interfaces from the GMSH mesh and returns the tag of the edge
- Raises:
Exception – Orientations of cells cannot be different than -1 or 1
- Returns:
edgeNode = the nodes composing each edge oriented positively edgeCells = an array of the left and right cells tags tags = an array of the unsorted edges tags edgeTags = an array of the sorted edges tags
- Return type:
nDArray
- extract_nodes()#
Extracts the nodes from the GMSH mesh
- Returns:
nodes and tags
- Return type:
nDArray
- extract_physical_groups(dim) dict #
Extracts physical groups of dimension dim with their names.
- Parameters:
dim (int) – a specific dimension 0,1,2
- Returns:
groups = a dictionnary corresponding to the entities of a physical group for a specific dimension
- Return type:
dict