BasicTools.Containers.ConstantRectilinearMesh module
- class BasicTools.Containers.ConstantRectilinearMesh.ConstantRectilinearElementContainer(_ConstantRectilinearElementContainer__dimensions: ArrayLike)[source]
Bases:
BaseOutputObjectElement container of a topologically regular array of elements. This class can hold regular element in 2D and 3D. Pixels and Voxel. The grid is defined by the dimensions (number of nodes in each direction)
- GetConnectivityForElement(index: int) np.ndarray[source]
Get the connectivity matrix for one element please see documentation for GetConnectivityForElements
- Parameters:
index (int) – element index
- Returns:
connectivity matrix
- Return type:
np.ndarray
- GetConnectivityForElements(indices: ArrayLike) np.ndarray[source]
Return the connectivity for the element listed in the indices array. If the connectivity is used many times, a simple call of self.connectivity will generate the connectivity for all the elements and keep it for later use.
- Parameters:
indices (ArrayLike) – the indices of the elements to generate the connectivity
- Returns:
the connectivity of the selected elements size = (len(indices), 4 or 8 )
- Return type:
np.ndarray
- GetDimensionality() int[source]
Return the dimensionality (2 for 2D, 3 for 3D) of this container
- Returns:
the dimensionality of this containers
- Return type:
int
- GetMultiIndexOfElement(index: int) np.ndarray[source]
Return the multi-index ijk for an element please see documentation for GetMultiIndexOfElements
- Parameters:
index (int) – the index of the element
- Returns:
ij or ijk for the element
- Return type:
np.ndarray
- GetMultiIndexOfElements(indices: ArrayLike) np.ndarray[source]
Return the multi-index ijk for element with indices
- Parameters:
indices (ArrayLike) – the indices of the elements to treat
- Returns:
an array with the ijk indices for every element in indices size (nb element, 2 (ij) or 3 (ijk) )
- Return type:
np.ndarray
- GetNumberOfElements() int[source]
Return the number of element in this container
- Returns:
the number of elements
- Return type:
int
- GetNumberOfNodesPerElement() int[source]
Return the number of node per element
- Returns:
number of nodes
- Return type:
int
- GetTag(tagName: str) Tag[source]
Return the Tag by the name if the tag does not exist a new tag is created
- Parameters:
tagName (str) – The name of the tag
- Returns:
an instance of type Tag
- Return type:
- IsFrozen()
- SetDimensions(data: ArrayLike)[source]
Set the number of points for the grid in each dimension
- Parameters:
data (ArrayLike) – the number of points in each dimension for this grid
- UnFrozen()
- property connectivity: np.ndarray
Generate and retrieve the connectivity of the elements
- Returns:
Connectivity of the elements size (self.GetNumberOfElements(), 4 or 8)
- Return type:
np.ndarray
- class BasicTools.Containers.ConstantRectilinearMesh.ConstantRectilinearMesh(dim=3)[source]
Bases:
MeshBaseTopologically and geometrically regular array of data. This class can hold regular data in 2D and 3D. The positions of the nodes is generated using the origin, spacing and dimension of the mesh
- ComputeGlobalOffset() None[source]
Recompute the Global Offset, This is necessary for some operations. Recommendation : Call it after changing the topology
- GetClosestPointToPos(pos: ArrayLike, MultiIndex: bool = False) np.ndarray[source]
Get the index of the closes point to pos
- Parameters:
pos (ArrayLike) – Position of the probe
MultiIndex (bool, optional) – if MultiIndex is True the, the multi-index is returned, by default False
- Returns:
the index of the closest node to pos
- Return type:
np.ndarray
- GetDimensionality() int[source]
Get the dimensionality of the mesh 2 for 2D or 3 for 3D
- Returns:
The dimensionality of the mesh
- Return type:
int
- GetDimensions() np.ndarray[source]
Return the number of nodes in each direction
- Returns:
the number of nodes in each direction
- Return type:
np.ndarray
- GetElementAtPos(pos: ArrayLike, MultiIndex: bool = False) np.ndarray[source]
Get the index of the closes element to pos
- Parameters:
pos (ArrayLike) – Position of the probe
MultiIndex (bool, optional) – if MultiIndex is True the, the multi-index is returned, by default False
- Returns:
the index of the closest element to pos
- Return type:
np.ndarray
- GetElementShapeFunctionsAtPos(el: int, pos: ArrayLike) np.ndarray[source]
Get the shape function values at position pos
- Parameters:
el (int) – the id of the element to evaluate the shape function
pos (ArrayLike) – Real space coordinate of the position to evaluate the shape functions
- Returns:
the values of the shape function at pos
- Return type:
np.ndarray
- GetElementsInTag(tagname: str, useOriginalId: bool = False) np.ndarray[source]
return a list with the ids of the elements in a tag (only for the structElements)
- Parameters:
tagname (str) – the name of the tag
useOriginalId (bool, optional) – if True return the original ids, by default False
- Returns:
the id or the original ids
- Return type:
np.ndarray
- GetElementsInTagBulk(tagname: str) np.ndarray[source]
return the element in the tag of name tagname
- Parameters:
tagname (str) – the name of the tag
- Returns:
the ids of the elements
- Return type:
np.ndarray
- GetElementsOriginalIDs(dim: int | None = None) np.ndarray[source]
return a single list with all the originalid concatenated
- Parameters:
dim (int, optional) – if dim != none generate the original ids only for the element of dimensionality dim, by default None
- Returns:
the original ids
- Return type:
np.ndarray
- GetMonoIndexOfElement(indices: int) np.ndarray[source]
Return the mono index for the element with multi index indices
- Parameters:
indices (int) – the multi index of the element
- Returns:
the mono index
- Return type:
np.ndarray
- GetMonoIndexOfElements(indices: ArrayLike) np.ndarray[source]
return the mono index for the elements with multi index indices
- Parameters:
indices (ArrayLike) – the ij or ijk indices of the elements
- Returns:
the mono index for the element
- Return type:
np.ndarray
- GetMonoIndexOfNode(indices: ArrayLike) np.ndarray[source]
return the mono index for the nodes with multi index indices
- Parameters:
indices (ArrayLike) – the ij or ijk indices of the nodes
- Returns:
the mono index for the nodes
- Return type:
np.ndarray
- GetMultiIndexOfElement(index: int) np.ndarray[source]
Please see ConstantRectilinearElementContainer.GetMultiIndexOfElement Documentation
- Parameters:
index (int) – the index of the element
- Returns:
ij or ijk for the element
- Return type:
np.ndarray
- GetMultiIndexOfElements(indices: ArrayLike) np.ndarray[source]
Please see ConstantRectilinearElementContainer.GetMultiIndexOfElements Documentation
- Parameters:
indices (ArrayLike) – indices
- Returns:
MultiInndex
- Return type:
np.ndarray
- GetMultiIndexOfNode(index: int) np.ndarray[source]
Return the multi-index ijk for a node Please see GetMultiIndexOfNodes.ConstantRectilinearMesh
- Parameters:
index (int) – the index of the node
- Returns:
ij or ijk for the node
- Return type:
np.ndarray
- GetMultiIndexOfNodes(indices: ArrayLike) np.ndarray[source]
Return the multi-index ijk for nodes with indices
- Parameters:
indices (ArrayLike) – the indices of the nodes to treat
- Returns:
an array with the ijk indices for every point in indices size (nb points, 2 (ij) or 3 (ijk) )
- Return type:
np.ndarray
- GetNamesOfElemTagsBulk() List[str][source]
Return a list of the tag names of the element of dimensionality == dim
- Returns:
The names of the tags
- Return type:
List[str]
- GetNodalIndicesOfBorder(border: int = 0) np.ndarray[source]
Return the ids of the nodes in the border (first layer if border is 0) the id of the second line of nodes (second layer if border is 1) …
- Parameters:
border (int, optional) – the layer number to extract, by default 0
- Returns:
the ids of the nodes in the layer = border
- Return type:
np.ndarray
- GetNumberOfElements(dim: int | None = None) int64[source]
Compute and return the total number of elements in the mesh
- Parameters:
dim (int, optional) – the user can filter by the dimensionality, by default None
- Returns:
number of element in the mesh
- Return type:
PBasicIndexType
- GetNumberOfNodes() int64[source]
Return the number of nodes in the mes
- Returns:
The number of nodes in the mesh
- Return type:
PBasicIndexType
- GetOrigin() np.ndarray[source]
Return the origin. the coordinate of the first node of the mesh
- Returns:
the coordinate position of the first point
- Return type:
np.ndarray
- GetPointsDimensionality() int[source]
Get the point dimensionality of the mesh 2 for 2D or 3 for 3D
- Returns:
The dimensionality of the mesh
- Return type:
int
- GetPosOfNode(indices: ArrayLike) np.ndarray[source]
Return the position of the nodes with indices
- Parameters:
indices (ArrayLike) – Nodes to treat
- Returns:
Position of the nodes
- Return type:
np.ndarray
- GetPosOfNodes()[source]
position for all nodes in the mesh.
- Returns:
A 2-dimensional array, the first axis corresponds to the node index, the second axis corresponds to space dimension index.
- Return type:
numpy.array
- GetSpacing() np.ndarray[source]
Return the spacing. The length of the elements in each direction
- Returns:
size in each direction
- Return type:
np.ndarray
- GetValueAtPos(field: ArrayLike, pos: ArrayLike) float64[source]
Evaluate a point field (field defined at nodes) at the position pos
- Parameters:
field (ArrayLike) – the values at every node of the mesh
pos (ArrayLike) – the position of the probe
- Returns:
the value of the field at pos
- Return type:
PBasicFloatType
- GetdV() float64[source]
Get the volume of one element.
- Returns:
The volume of one element (this is the product of the spacing)
- Return type:
PBasicFloatType
- IsFrozen()
- SetDimensions(data: ArrayLike) None[source]
Set the number of nodes and element in each direction
- Parameters:
data (ArrayLike) – Number of node in each direction
- SetOrigin(data: ArrayLike) None[source]
Set the origin of this mesh.
- Parameters:
data (ArrayLike) – the coordinates of the first point in this mesh
- SetSpacing(data: ArrayLike) None[source]
Set the spacing. The length of the element in each direction
- Parameters:
data (ArrayLike) – size in each coordinate
- UnFrozen()
- property boundingMax: np.ndarray
The bounding box maximum of the mesh
- Returns:
the coordinates of the higher corner of the bounding box
- Return type:
np.ndarray
- property boundingMin: np.ndarray
the bounding box minimum of the mesh
- Returns:
the coordinate of the lower corner of the bounding box
- Return type:
np.ndarray