Muscat.Containers.ElementsContainers module¶
- class AllElements[source]¶
Bases:
object
Class to store a list of element containers. This class is mostly a re-implementation of dict but with ordered elementType. This class is sorted by elementTypes in lexicographic order, so the retrieving order is stable, and independent on the order of filling.
- AddContainer(value: ED.ElementsContainer | StructuredElementsContainer) None [source]¶
add an ElementsContainer
- Parameters:
value (ElementsContainer) – the ElementsContainer to be added
- GetElementsOfType(typename: ElementType | str) ElementsContainer [source]¶
return an ElementContainer by name, if the container does not exist a new is inserted and returned
- Parameters:
typename (str) – the name of the elements to retrieve
- Returns:
the container
- Return type:
- GetTagsNames() List[str] [source]¶
return a list with all the tags names in this container
- Returns:
the list of the tag names
- Return type:
List[str]
- Index(elementType: ElementType | str) int [source]¶
Get the position of the container of type elementType inside the storage
- IsFrozen()¶
- MergeElements(other: AllElements, nodesOffset: int = 0) None [source]¶
Merge the elements for a AllElements into this (self)
- Parameters:
other (AllElements) – the element to merge into this
nodesOffset (int, optional) – an node offset to use to shift the connectivity of the elements, by default 0
- UnFrozen()¶
- View() AllElements [source]¶
return a copy of this object recursively, numpy arrays are view to the original ones but with the flags.writeable = False
- Returns:
a view of AllElements
- Return type:
- items() Generator[Tuple[ElementType, ElementsContainer | StructuredElementsContainer], None, None] [source]¶
List of (elementType, ElementsContainer)
- Returns:
_description_
- Return type:
List[Tuple]
- ElementContainerLike¶
Meta type for the element type names
alias of
Union
[ElementsContainer
,StructuredElementsContainer
]
- class ElementsContainer(elementType: ElementType | str)[source]¶
Bases:
object
Class to hold a list of elements of the same type
elementType : a string from Muscat.Containers.ElementsDescription
connectivity : the connectivity matrix starting form 0
tags : an instance of the Tags class
originalIds : the id or number from the previous mesh/file
The user can use this data to find the mapping from the initial mesh/file to the current mesh (self).
self.cpt : an internal counter to do efficient add of elements one by one
The user is responsible to call self.Tighten() to compact the connectivity matrix after the population ( calls AddNewElement(…) or allocate(…))
- AddNewElement(connectivity: ArrayLike, originalId: int) int [source]¶
append a single element to the connectivity
- Parameters:
connectivity (ArrayLike) – connectivity of the added element
originalId (int) – the original id of the added element
- Returns:
the total number of elements in the container
- Return type:
int
- AddNewElements(connectivity: ArrayLike, originalIds: ArrayLike | None = None) int [source]¶
Append a new elements to the connectivity
- Parameters:
conn (ArrayLike) – connectivity of the added elements
originalIds (ArrayLike, optional) – the original id of the added element, by default -1 is used
- Returns:
the total number of elements in the container
- Return type:
int
- Allocate(nbElements: int | int64) None [source]¶
Allocate the storage for nbElements
the user is responsible of filling the connectivity and the originalIds with valid values
- Parameters:
nbElements (int, MuscatIndex) – Number of element to Allocate
- GetNodesIndexFor(ids: int | ArrayLike) np.ndarray [source]¶
return the nodes used by the list of elements
- input:
ids :
- Parameters:
ids (Union[int,ArrayLike]) – the id or a list of ids of elements to treat (always a local id list)
- Returns:
the ids of the nodes used by the elements ids
- Return type:
np.ndarray
- GetNumberOfElements() int64 [source]¶
return the number of elements in this container
- Returns:
Number of elements
- Return type:
int
- GetNumberOfNodesPerElement() int [source]¶
return the number of nodes per element for the elements in this container
- Returns:
the number of nodes per element for the elements in this container
- Return type:
int
- GetTag(tagName: str) Tag [source]¶
return the tag by name. If the tag does not exist a new tag is created
- Parameters:
tagName (str) – the name of the tag to retrieve
- Returns:
a tag with the name tagName
- Return type:
- IsFrozen()¶
- Merge(other: ElementsContainer | StructuredElementsContainer, offset: int64 | None = None) None [source]¶
Merge the elements from the other container into this.
Warning!!! Non elimination of double elements is done
if an offset is supplied the connectivity of the other container is shifted by the value of the offset during the merge. Useful for after merging the nodes from the other mesh.
- Reserve(nbElements: int | int64) None [source]¶
Reserve the storage for nbElements
The user is responsible to call self.Tighten() to compact the connectivity and the originalIds. matrix after the population
- Parameters:
nbElements (int) – Number of element to reserve
- UnFrozen()¶
- View() ElementsContainer [source]¶
return a copy of this object recursively, numpy arrays are view to the original ones but with the flags.writeable = False
- Returns:
a view of ElementsContainer
- Return type:
- class StructuredElementsContainer(elementType: ElementType | str)[source]¶
Bases:
object
Element 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)
- AddNewElement(connectivity: ArrayLike, originalId: int) NoReturn [source]¶
Not possible for a StructuredElementContainer
- AddNewElements(connectivity: ArrayLike, originalIds: ArrayLike | None = None) NoReturn [source]¶
Not possible for a StructuredElementContainer
- 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 | int) 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
- GetNodesIndexFor(ids: int | ArrayLike) np.ndarray [source]¶
return the nodes used by the list of elements
- input:
ids :
- Parameters:
ids (Union[int,ArrayLike]) – the id or a list of ids of elements to treat (always a local id list)
- Returns:
the ids of the nodes used by the elements ids
- Return type:
np.ndarray
- GetNumberOfElements() int64 [source]¶
Return the number of element in this container
- Returns:
the number of elements
- Return type:
int
- GetNumberOfNodesPerElement() int64 [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()¶
- Merge(other: ElementsContainer, offset: int | None = None) NoReturn [source]¶
Not possible for a StructuredElementContainer
- SetDimensions(data: ArrayLike) None [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()¶
- View() StructuredElementsContainer [source]¶
return a copy of this object recursively, numpy arrays are view to the original ones but with the flags.writeable = False
- Returns:
a view of StructuredElementsContainer
- Return type:
- 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
- property cpt¶