Muscat.Containers.MeshInspectionTools module¶
- ComputeElementToElementConnectivity(inmesh: Mesh, dimensionality: int | None = None, connectivityDimension: int | None = None, maxNumConnections: int = 200) Tuple[ndarray, ndarray] [source]¶
Generates the elements to element connectivity of 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)
Also provides the array of number of connection per cell.
- Parameters:
inmesh (Mesh) – the input mesh
dimensionality (int, optional) – dimensionality filter, by default inmesh.GetPointsDimensionality()
connectivityDimension (int, optional) – type of connectivity, by default dimensionality - 1
maxNumConnections (int, optional) – the number of potential connection to a single node, normally 200 is more than enough, by default 200
- Returns:
numpy.ndarray, (nb elements, max nb connections) item, the connections for each element -> element numpy.array, the number of connections per elements
- Return type:
Tuple
- ComputeMeshDensityAtNodes(mesh: Mesh) ndarray [source]¶
Function to compute the mesh size at each point This is done using the length of the bars of each element and averaging the data at nodes. All the element are treated, even the lower dimensionality element (not the 0D elements of course). This means the triangles in the surface can affect the values of the nodes on the surface No weighting is done.
- Parameters:
mesh (Mesh) – The input mesh
- Returns:
a numpy array (node field) with average of the mesh size at each point
- Return type:
np.ndarray
- ComputeMeshMinMaxLengthScale(mesh) Tuple[float64, float64] [source]¶
Compute a estimation of the minimal and maximal length scale of the elements for this we compute the centroid of the element and compute the min and max distance between the centroid and each node of the mesh. Then return a tuple with (2*min,2*max) of all the distances on the mesh
- Parameters:
mesh (Mesh) – The input mesh
- Returns:
tuple with (2*min_dist,2*max_dist) for all the elements in the mesh
- Return type:
Tuple[MuscatFloat,MuscatFloat]
- ComputeNodeToElementConnectivity(inmesh: Mesh, maxNumConnections: int = 200) Tuple[ndarray, ndarray] [source]¶
Compute the node to connectivity connection for every point
- Parameters:
inmesh (Mesh) – the mesh
maxNumConnections (int, optional) – the number of potential connection to a single node, normally 200 is more than enough, by default 200
- Returns:
numpy.ndarray, (nb point, max nb connections) item, the connectivity for each node -> element numpy.array, the number of connections per point
- Return type:
Tuple
- ComputeNodeToNodeConnectivity(inmesh: Mesh, maxNumConnections=200) Tuple[ndarray, ndarray] [source]¶
Compute the node to node connection for every node in the mesh
- Parameters:
inmesh (Mesh) – the mesh
maxNumConnections (int, optional) – the number of potential connection to a single node, normally 200 is more than enough, by default 200
- Returns:
numpy.ndarray, (nb point, max nb connections) item, the connectivity for each node -> node numpy.array, the number of connections per point
- Return type:
Tuple
- ComputeNormalsAtElements(mesh: Mesh, ef: ElementFilter | None = None) ndarray [source]¶
Compute an unique normal per element using the first 3 nodes (for 2D element in 3D) or the first 2 nodes (for 1D elements in 2D)
- Parameters:
mesh (Mesh) – Mesh to work on
ef (ElementFilter, optional) – Element Filter to select element to work on, by default None
- Returns:
- A numpy array of size (mesh.GetNumberOfElements(), mesh.GetPointsDimensionality()), with the normal (in 3D or 2D) for the
selected elements
- Return type:
np.ndarray
- EnsureUniquenessElements(mesh: Mesh) None [source]¶
Ensure that every element if present only once on the mesh
- Parameters:
mesh (Mesh) – input mesh
- Raises:
Exception – if 2 element (event if the connectivity is permuted) a exception is raised
- ExtractElementByTags(inmesh: Mesh, tagsToKeep: List[str], allNodes: bool = False, dimensionalityFilter: int | None = None, cleanLonelyNodes: bool = True) Mesh [source]¶
Extract element by tags. create a new Mesh with element present in the tags
- Parameters:
inmesh (Mesh) – the input mesh
tagsToKeep (List[str]) – List of Tag name to extract element can contain tag name for nodes tags
allNodes (bool, optional) – if tagsToKeep point to a node tags then this option controls if all the nodes of the element must be in the tag to select the element , by default False
dimensionalityFilter (int, optional) – keep all the element of dimensionality dimensionalityFilter, by default None
cleanLonelyNodes (bool, optional) – true to apply a after the extraction, by default True
- Returns:
a new Mesh with the extracted elements (the tags are updated)
- Return type:
- ExtractElementsByElementFilter(inmesh: Mesh, elementFilter: ElementFilter, copy: bool = True) Mesh [source]¶
Create a new mesh with the selected element by elementFilter For the moment this function make a copy of nodes
- Parameters:
inmesh (Mesh) – the input mesh
elementFilter (ElementFilter) – the ElementFilter to select the element to extract
copy (bool) – if true this function will try to make reuse as mush as possible the memory of the input mesh. Warning!!! Making modification of one of the two meshes will potentially invalidate the other mesh
- Returns:
the mesh with the extracted elements
- Return type:
- ExtractElementsByMask(inElementContainer: ElementsContainer, mask: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ElementsContainer [source]¶
Create a new ElementContainer with the element selected by the mask
- Parameters:
inelems (ElementsContainer) – _description_
mask (ArrayLike) – a vector of bool (a boolean mask) or a vector with the indices to extract
- Returns:
a new container with the extracted elements (the tags are updated)
- Return type:
- GetDataOverALine(startPoint: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], stopPoint: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], nbPoints: int, mesh: Mesh, fields: List, method: str | None = None) Mesh [source]¶
Compute the values of a mesh/field over a line startPoint and stopPoint are used to construct a line with nbPoints points. the data in mesh.nodeFields, mesh.elemFields and fields are evaluated at every point of the line
- Parameters:
startPoint (ArrayLike) – Start point. this is passed to the CreateUniformMeshOfBars function
stopPoint (ArrayLike) – Stop point. this is passed to the CreateUniformMeshOfBars function
nbPoints (int) – this argument is passed to the CreateUniformMeshOfBars function
mesh (Mesh) – the mesh to extract mesh.nodeFields, mesh.elemFields
fields (List) – a list containing only FEFields
method (Optional[str], optional) – this argument is passed to the GetFieldTransferOp function, by default None
- Returns:
a unstructured mesh with nodeFields populated with the data nodeFields with contain a dictionary for every field name and the numpy vector with the values at the points. If two or more fields have the same name only one is recovered, the priority order staring with the hightest priority are : fields, elemFields and nodeFields
- Return type:
- Raises:
Exception – In the case an IPField is present in the ‘fields’ argument
- GetElementsFractionInside(field: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], mesh: Mesh, ef: ElementFilter | None = None) ndarray [source]¶
Compute the volume fraction for each element in ids, based in the level-set field field. Function valid for simplices (bars, triangles, tetrahedrons)
- Parameters:
field (ArrayLike) – the levelset field
mesh (Mesh) – the support mesh of the point field field
ef (Optional[ElementFilter], optional) – Element Filter to select elements, by default None
- Returns:
a numpy array of size number of element selected by the element filter
- Return type:
np.ndarray
- GetElementsFractionInsideLegacy(field: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], points: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], name: ElementType, elements: ElementsContainer, ids: ndarray) ndarray [source]¶
Compute the volume fraction for each element in ids, based in the level-set field field. Function valid for simplices (bars, triangles, tetrahedrons)
- Parameters:
field (ArrayLike) – the levelset field
points (ArrayLike) – the points of the mesh
name (ED.ElementType) – the element name
elements (ElementsContainer) – the element data
ids (np.ndarray) – the ids to treat
- Returns:
the volume fraction for each element in ids
- Return type:
np.ndarray
- GetMeasure(inmesh: Mesh, elementFilter: ElementFilter | None = None)[source]¶
Compute the measure of the mesh (volume in 3D, surface in 2D, …) Only elements of the higher dimensionality are taken into account if no element filter is supplied
Attention: if the element filter contain dimensionality mixed elements the result is the sum of the measure (volume + surface for example)
- Parameters:
inmesh (Mesh) – the mesh to use for the computation
elementFilter (ElementFilter) – element to take into account in the computation of the measure, if none all the element of the higher dimensionality are used.
- Returns:
the volume if the mesh contains 3D elements the surface if the mesh contains 2D elements and no 3D elements the length if the mesh contains 1D elements and no 3D elements nor 2D elements
- Return type:
MuscatFloat
- GetVolume(inmesh: Mesh) float64 [source]¶
Compute the volume of the mesh Only element of the bigger dimensionality are taken into account if no elements on mesh we return zero.
for a more general function see: GetMeasure
- Parameters:
inmesh (Mesh) – the mesh to use for the computation
- Returns:
the volume if the mesh contains 3D elements the surface if the mesh contains 2D elements and no 3D elements the length if the mesh contains 1D elements and no 3D elements nor 2D elements
- Return type:
MuscatFloat
- GetVolumePerElement(inmesh: Mesh, elementFilter: ElementFilter | None = None) ndarray [source]¶
Compute the volume (surface for 2D element and length for 1D elements) for each element selected by the elementFilter
- Parameters:
inmesh (Mesh) – the mesh to extract elements
elementFilter (Optional[ElementFilter], optional) – filter to select some elements, if None the volume of all the element are computed
- Returns:
a numpy array of size number of “element selected by the elementFilter” with the volume
- Return type:
np.ndarray