Muscat.Containers.Filters.FilterBase module

CheckIntegrity(GUI: bool = False) str[source]
class ElementsSelection(mesh: Mesh, indices: np.ndarray, elements: ElementContainerLike, meshOffset: int, selectionOffset: int, part: int = 0)[source]

Bases: NamedTuple

Class to store a selection of elements of the same type. This class is immutable.

The public attributes of this class
  • self.mesh: Mesh = The selection mesh

  • self.indices: np.ndarray = The indices of the selected elements locally to elements

  • self.elements: ElementsContainer = The current elements of mesh

  • self.meshOffset: int = Number of elements on the mesh before this ElementsContainer

  • self.selectionOffset: int = Number of elements on the selection before this selection

  • self.elementType: str = Equivalent of self.elements.elementType

  • self.part: int = Part number (non 0 for partitioned meshes)

GetMeshSlice() np.ndarray[source]

Return a slice on a vector of length mesh.GetNumberOfElements()

res = np.empty(elementToBeExtracted, dtype=MuscaFloat)
for selection in filter(mesh):
    res[selection.GetSelectionSlice()] = mesh.elemFields["energy"][selection.GetMeshSlice()]
Returns:

Slice to be used on a vector of size : the number of elements on the mesh

Return type:

slice, nd.ndarray

GetNumpyMask() np.ndarray[source]

Return this selection as a numpy mask This means the array is of size this.elements.GetNumberOfElements() and is false for the selected elements

Returns:

the numpy mask (true for masked elements, e.g. not selected elements)

Return type:

np.ndarray

GetSelectionSlice() slice[source]

Return a slice on a vector of length self.size().

res = np.empty(elementToBeExtracted, dtype=MuscaFloat)
for selection in filter(mesh):
    res[selection.GetSelectionSlice()] = mesh.elemFields["energy"][selection.GetMeshSlice()]
Returns:

Slice to be used on a vector of size : the number of elements extracted by the filter

Return type:

slice

Size() int[source]

Return the size of the selection

Returns:

size of self.indices

Return type:

int

property elementType: ElementType

Return the element type for the current selection

Returns:

_description_

Return type:

ED.ElementType

elements: ElementsContainer | StructuredElementsContainer

Alias for field number 2

indices: ndarray

Alias for field number 1

mesh: Mesh

Alias for field number 0

meshOffset: int

Alias for field number 3

part: int

Alias for field number 5

selectionOffset: int

Alias for field number 4

class FilterBase(zone: Callable[[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], ndarray] | List[Callable[[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], ndarray]] | None = None, eMask: ArrayLike | None = None, nMask: ArrayLike | None = None, eTag: str | List[str] | None = None, nTag: str | List[str] | None = None, eFilter: FilterBase | None = None, nFilter: FilterBase | None = None)[source]

Bases: object

Base class to construct node and element filters

Parameters:
  • zones (Optional[Union[List[ZoneType], ZoneType] ], optional) – a ZoneType or a list of ZoneType (ImplicitGeometry for example), by default None

  • eMask (Optional[ArrayLike], optional) – a boolean vector of the size of the object to filter, by default None

  • nMask (Optional[ArrayLike], optional) – a boolean vector of the size of the object to filter, by default None

  • etags (Optional[Union[List[str], str] ], optional) – An element tag name or a list of element tags to be used, by default None

  • nTags (Optional[Union[List[str], str]], optional) – An nodal tag name of a list of nodal tags names to use, by default None

  • eFilter (Optional[Union[ElementFilter, FilterOperatorBase] ]) – And extra element filter, by default none

  • nFilter (Optional[Union[NodeFilter, FilterOperatorBase] ]) – And extra nodal filter, by default none

AddETag(tagName: str) None[source]

Add a tagname to the list of elementary tags to treat

Parameters:

tagName (str) – the tag name to be added

AddNTag(tagName: str) None[source]

Add a tagname to the list of nodal tags to treat

Parameters:

tagName (str) – the tag name to be added

AddZone(zone: Callable[[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], ndarray]) None[source]

Add a zone to the list of zones to be treated by the filter

Parameters:

zone (ZoneType) – a callable object capable of taking one argument with the points positions, and returning a vector of size pos.shape[0] with negative values for the entities to be selected by the filter

GetNodesIndices(mesh: Mesh) np.ndarray[source]

Get the nodes indices selected by this filter

Parameters:

mesh (Mesh) – mesh to apply the filter

Returns:

The filtered nodes indices

Return type:

Union np.ndarray

IsEquivalent(other: Any) bool[source]

To check if 2 element filter are equivalent

Parameters:

other (Any) – other object to check the equivalency

Returns:

True if the two filters are equal

Return type:

bool

SetETags(tagNames: List[str] | str) None[source]

Set the element tag to use this will erase the previous list

Parameters:

tagNames (List[str]) – the list of string with the elementary tag names

SetNTags(tagNames: List[str] | str) None[source]

Set the nodal tag to use this will erase the previous list

Parameters:

tagNames (List[str]) – the list of string with the nodal tag names

SetZones(zonesList: Callable[[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], ndarray] | List[Callable[[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], ndarray]]) None[source]

Set the zone list to use this will erase the previous list

Parameters:

zonesList (List[ZoneType]) – The list of zones to be used

Intersect1D(first: np.ndarray | None, second: np.ndarray | None) np.ndarray | None[source]

Function to generate an intersection of two vectors (like np.intersect1d) but with the particularity of treat the case where the inputs can be None None represent a non filtered inputs,

Parameters:
  • first (np.ndarray | None) – first vector of indices

  • second (np.ndarray | None) – second vector of indices

Returns:

The intersection of two list

Return type:

Union[np.ndarray,None]