Muscat.Containers.MeshGraphTools module

CheckIntegrity(GUI: bool = False)[source]
CheckIntegrity_ComputeElementToElementGraph(GUI: bool = False)[source]
CheckIntegrity_ComputeMeshLaplacianEigenmaps(GUI: bool = False)[source]
CheckIntegrity_ComputeNodalAveragedStretchMetric(GUI: bool = False)[source]
CheckIntegrity_ComputeNodeToNodeGraph(GUI: bool = False)[source]
CheckIntegrity_FloaterMesh3DParametrization(GUI: bool = False)[source]
CheckIntegrity_FloaterMesh3DParametrizationStarDomain(GUI: bool = False)[source]
CheckIntegrity_FloaterMeshParametrization(GUI: bool = False)[source]
CheckIntegrity_InitializeGraphPointsFromMeshElements(GUI: bool = False)[source]
CheckIntegrity_InitializeGraphPointsFromMeshPoints(GUI: bool = False)[source]
CheckIntegrity_PartitionMesh_Metis(GUI: bool = False)[source]
ComputeElementToElementGraph(inMesh: Mesh, dimensionality: int | None = None, connectivityDimension: int | None = None)[source]

Creates a networkx graph from the element connectivity on an Mesh in the following sense.

An element is linked to another in the graph if they share:
  • a face if connectivityDimension = 2

  • an edge if connectivityDimension = 1

  • a vertex if connectivityDimension = 0

(if connectivityDimension is initialized to None, it will be set to dimensionality - 1)

Parameters:
  • inMesh (Mesh) – input mesh

  • dimensionality (int) – dimension of the elements considered to initialize the graph

  • connectivityDimension (int) – dimension of the connectivity

Returns:

Element to element graph

Return type:

networkx.Graph

ComputeMeshLaplacianEigenmaps(inMesh: Mesh, dimensionality: int | None = None, nEigenmaps: int = 10, distFunc: Callable | None = None, normalizedLaplacian: bool = False)[source]

Computes the Laplacian engenmaps of a mesh

Parameters:
  • mesh (Mesh) – input mesh

  • dimensionality (int) – dimension of the elements considered to initalize the graph

  • nEigenmaps (int) – number of computed eigenmaps (less or equal to the number of nodes of mesh)

  • distFunc (func) – function applied to the length of the edges of the mesh, and attached of the corresponding edge of the graph of the mesh

  • normalizedLaplacian (bool) – if “True”, the normalized Laplacian matrix is taken

Returns:

  • ndarray(nEigenmaps) – eigenvalues

  • ndarray(numberOfNodes, nEigenmaps) – Laplacian eigenmaps

ComputeNodalAveragedStretchMetric(originMesh: Mesh, parametrizedMesh: Mesh)[source]

Computes a nodal-averaged stretch metric between an inital triangle mesh and its parametrization, as defined in [1].

Parameters:
  • originMesh (Mesh) – Renumbered triangular mesh to parametrize

  • parametrizedMesh (int) – Parametrization of originMesh

Returns:

texture stretch metric

Return type:

np.ndarray, of size(nNodes)

Notes

mesh mush be a renumbered Mesh of triangles (either in a 2D or 3D ambiant space), with a line boundary (no closed surface in 3D)

References

[1] S. Yoshizawa, A. Belyaev, H.-P. Seidel. A fast and simple stretch-minimizing mesh parameterization, 2004. URL, http://www2.riken.jp/brict/Yoshizawa/Papers/smi04ybs.pdf

ComputeNodeToNodeGraph(inMesh: Mesh, dimensionality: int | None = None, distFunc: Callable | None = None)[source]

Creates a networkx graph from the node connectivity on an Mesh through edges

Parameters:
  • inMesh (Mesh) – input mesh

  • dimensionality (int) – dimension of the elements considered to initialize the graph

  • distFunc (Callable) – function applied to the length of the edges of the mesh, and attached of the corresponding edge of the graph of the mesh

Returns:

Node to node graph

Return type:

networkx.Graph

ComputeStretchMetric(originMesh: Mesh, parametrizedMesh: Mesh)[source]

Computes the texture stretch metric between an inital triangle mesh and its parametrization, as defined in [1].

Parameters:
  • originMesh (Mesh) – Renumbered triangular mesh to parametrize

  • parametrizedMesh (int) – Parametrization of originMesh

Returns:

  • np.ndarray, of size(nTriangles) – texture stretch metric

  • np.ndarray, of size(nTriangles) – areas of the triangles of the mesh

Notes

mesh mush be a renumbered Mesh of triangles (either in a 2D or 3D ambiant space), with a line boundary (no closed surface in 3D)

References

[1] P.V. Sander, J. Snyder, S.J. Gortler, H. Hoppe. Texture mapping progressive meshes, 2001. URL: https://hhoppe.com/tmpm.pdf

Create3DMeshForCheckIntegrity()[source]
CreateMeshForCheckIntegrity()[source]
FloaterMesh3DParametrization(inMesh: Mesh, boundaryTag: str, inPlace: bool = True, fixedInteriorPoints=None, fixedBoundaryPoints=None)[source]

STILL LARGELY EXPERIMENTAL

Only for linear tetrahedral meshes

Computes a 3D mesh parametrization by cutting a 3D mesh using a plane and applying the 2D mesh parametrization to the boundaries of the half-meshes on disks, projecting the meshes on two half-spheres, and then morphing the interior points.

Parameters:
  • inMesh (Mesh) – Renumbered triangular mesh to parametrize

  • boundaryTag (str) – element tag for the surface triangles of half of the boundary of inMesh (whichever one)

  • inPlace (bool) – if “True”, inMesh is modified if “False”, inMesh is let unmodified, and a new mesh is produced

  • boundaryOrientation (str) – if “direct, the boundary of the parametrisation is constructed in the direct trigonometric order if “indirect”, the boundary of the parametrisation is constructed in the indirect trigonometric order

  • fixedInteriorPoints (dict) –

    with two keys: “skinIds1”, and “skinIds2”, and dict as value:

    with one key, and corresponding value, a list: [ndarray(n), ndarray(n,2)], with n the number of interior points to be fixed; the first ndarray is the index of the considered interior point, the second ndarray is the corresponding prescribed positions if key is “mean”, the interior points are displaced by the mean of the prescribed positions if key is “value”, the interior points are displaced by the value of the prescribed positions

  • fixedBoundaryPoints (list) – list of lists: [ndarray(2), ndarray(2)], helping definining a point in inMesh; the first ndarray is the component of a point on the boundary, and the second array is the value of corresponding component. Tested for triangular meshes in the 3D space.

Returns:

  • Mesh – parametrization of the 3D mesh

  • ndarray(1) of ints – renumbering of the nodes of the returned parametrized mesh, with respect to inMesh

  • dict – containing 4 keys: “minEdge” and “maxEdge”, with values floats containing the minimal and maximal edged length of the parametrized mesh; and “paramMesh1” and “paramMesh2”, containing the 2D mesh parametrization (disks) of each half-boundary on inMesh

Notes

inMesh must have its skin partitionned in two, with boundaryTag being a element tag for surface triangles of one element of this partition

FloaterMesh3DParametrizationStarDomain(inMesh: Mesh, boundaryTag: str, shape: Dict | None = None)[source]

Floater algorithm for 3D Mesh (Star Domain) Naive implementation only for linear tetrahedral meshes and 3D star domains

Parameters:
  • inMesh (Mesh) – input mesh of a 3D star domain

  • boundaryTag (str) – elementtag for the boundary of the mesh

  • shape (dict) – with key “type”:str, “center”:None or ndarray(3) of floats , “dimension”:ndarray(3) of floats if shape == “None”, the boundary of inMesh is mapped into a ball of radius 1, centered at the origin if “type”=”cuboid”, inMesh is mapped into a cuboid if “type”=”ellipsoid”, inMesh is mapped into a ellipsoid “center” defined the center of symmetry of the obtained parametrized mesh “dimension” defined the diameter of the obtained parametrized mesh along each direction

Returns:

  • Mesh – parametrization of mesh

  • ndarray(1) of ints – renumbering of the nodes of the returned parametrized mesh, with respect to inMesh

  • dict – containing two keys: “minEdge” and “maxEdge”, with values floats containing the minimal and maximal edged length of the parametrized mesh

Notes

mesh mush be a Mesh of linear tetrahedrons, with an elementSet defining the boundary (the skin)

FloaterMeshParametrization(inMesh, nBoundary: int, outShape: str = 'circle', boundaryOrientation: str = 'direct', curvAbsBoundary: bool = True, fixedInteriorPoints: dict | None = None, fixedBoundaryPoints: list | None = None)[source]

STILL LARGELY EXPERIMENTAL

Only for linear triangular meshes

Computes the Mesh Parametrization algorithm [1] proposed by Floater, in the case of target parametrization fitted to the unit 2D circle (R=1) or square (L=1). Adapted for ML need: the outShape’s boundary is sampled following the curvilinear abscissa along the boundary on inMesh (only for outShape = “circle” for the moment)

Parameters:
  • inMesh (Mesh) – Renumbered triangular mesh to parametrize

  • nBoundary (int) – number nodes on the line boundary

  • outShape (str) – if “circle”, the boundary of inMesh is mapped into the unit circle if “square”, the boundary of inMesh is mapped into the unit square

  • boundaryOrientation (str) – if “direct, the boundary of the parametrisation is constructed in the direct trigonometric order if “indirect”, the boundary of the parametrisation is constructed in the indirect trigonometric order

  • curvAbsBoundary (bool) – only if fixedInteriorPoints = None if True, the point density on the boundary of outShape is the same as the point density on the boundary of inMesh if False, the point density on the boundary is uniform

  • fixedInteriorPoints (dict) – with one key, and corresponding value, a list: [ndarray(n), ndarray(n,2)], with n the number of interior points to be fixed; the first ndarray is the index of the considered interior point, the second ndarray is the corresponding prescribed positions if key is “mean”, the interior points are displaced by the mean of the prescribed positions if key is “value”, the interior points are displaced by the value of the prescribed positions

  • fixedBoundaryPoints (list) – list of lists: [ndarray(2), ndarray(2)], helping definining a point in inMesh; the first ndarray is the component of a point on the boundary, and the second array is the value of corresponding component. Tested for triangular meshes in the 3D space.

Returns:

  • Mesh – parametrization of mesh

  • dict – containing 3 keys: “minEdge”, “maxEdge” and “weights”, with values floats containing the minimal and maximal edged length of the parametrized mesh, and the weights (lambda) in the Floater algorithm

Notes

mesh mush be a renumbered Mesh of triangles (either in a 2D or 3D ambiant space), with a line boundary (no closed surface in 3D). outShape = “circle” is more robust in the sense that is inMesh has a 2D square-like, for triangles may ended up flat with outShape = “square”

References

[1] M. S. Floater. Parametrization and smooth approximation of surface triangulations, 1997. URL: https://www.sciencedirect.com/science/article/abs/pii/S0167839696000313

InitializeGraphPointsFromMeshElements(inMesh: Mesh, dimensionality=None)[source]

Initializes a networkx graph with nodes consistent with the number of elements of an Mesh. This enables further edge addition compatible with a chosen global numbering of the elements of the Mesh.

Parameters:
  • inMesh (Mesh) – input mesh

  • dimensionality (int) – dimension of the elements considered to initialize the graph

Returns:

initialized graph

Return type:

networkx.Graph

InitializeGraphPointsFromMeshPoints(inMesh: Mesh)[source]

Initializes a networkx graph with nodes consistent with the number of nodes of an Mesh. This enables further edge addition compatible with the connectivity of the elements of the Mesh.

Parameters:

inMesh (Mesh) – input mesh

Returns:

initialized graph

Return type:

networkx.Graph

PartitionMesh(inmesh: Mesh, nbSubdomains: int, driver: str = 'asyn_fluidc')[source]

Generates a partition vector providing labels ordered for each element of the input mesh based on a third party graph partitioning solver.

Options are:
  • “Metis” (pymetis must be installed)

  • “lukes_partitioning” from networkx.algorithms.community.lukes_partitioning (slow)

  • “asyn_fluidc” from networkx.algorithms.community.asyn_fluidc

Parameters:
  • inmesh (Mesh) – the mesh to compute the partition on

  • nbSubdomains (int) – Number of subdomain, must be > 1

  • driver (str, optional) – library to use for the partition, for the moment only Metis is available, default “asyn_fluidc” of networkx

RenumberMeshForParametrization(inMesh: Mesh, inPlace=True, boundaryOrientation='direct', fixedBoundaryPoints=None, startingPointRankOnBoundary=None)[source]

Only for linear triangle meshes Renumber the node IDs, such that the points on the boundary are placed at the end of the numbering. Serves as a preliminary step for mesh parametrization.

Parameters:
  • inMesh (Mesh) – input triangular to be renumbered

  • inPlace (bool) – if “True”, inMesh is modified if “False”, inMesh is let unmodified, and a new mesh is produced

  • boundaryOrientation (str) – if “direct, the boundary of the parametrization is constructed in the direct trigonometric order if “indirect”, the boundary of the parametrization is constructed in the indirect trigonometric order

  • fixedBoundaryPoints (list) – list containing lists of two np.ndarray. Each 2-member list is used to identify one point on the boundary: the first array contains the specified components, and the second the

  • startingPointRankOnBoundary (int) – node id (in the complete mesh) of the point on the boundary where the mapping starts

Returns:

  • Mesh – renumbered mesh

  • ndarray(1) of ints – renumbering of the nodes of the returned renumbered mesh, with respect to inMesh

  • int – number of node of the boundary of inMesh

check_list_matching(list1, list2)[source]