Muscat.Containers.Filters.FilterTools module

CheckIntegrity(GUI: bool = False) str[source]
CheckIntegrityElementFilterToImplicitField(GUI: False)[source]
CheckIntegrityGetComplementaryFilter(GUI=False) str[source]
CheckIntegrityGetFrozenFilter(GUI=False) str[source]
CheckIntegrityGetListOfPartialElementFilter(GUI=False) str[source]
CheckIntegrityReadElementFilter(GUI=False) str[source]
CheckIntegrity_FilterToETag(GUI=False) str[source]
CheckIntegrity_ListOfElementFiltersFromETagList(GUI=False) str[source]
CheckIntegrity_ListOfElementFiltersFromMask(GUI: bool = False) str[source]
CheckIntegrity_VerifyExclusiveFilters(GUI=False) str[source]
ElementFilterToImplicitField(elementFilter: FilterBase | FilterOperatorBase, mesh: Mesh, pseudoDistance: int = 2) ndarray[source]

Function to generate an iso zero level-set on the mesh to represent the shape of the filter. This discretized iso zero on the mesh cant always hold a ‘perfect’ representation of the filter, so a modified iso zero is created. An additional parameter pseudo-distance can be increased to create a pseudo distance. This field is created using the connectivity and not the real distances.

Parameters:
  • elementFilter (ElementFilter) – the element filter to process

  • mesh (Mesh) – the mesh to work on

  • pseudoDistance (int, optional) – the number of element to propagate the pseudo-distance, by default 2

Returns:

a field over the nodes with negative values inside the domain defined by the filter

Return type:

np.ndarray

FilterToETag(mesh: Mesh, elementFilter: ElementFilter | FilterOperatorBase, tagname: str, append: bool = False) None[source]

Create an Element tag with the name tagname using the elementFilter The tag is added the mesh.

Parameters:
  • mesh (Mesh) – Mesh to work on

  • elementFilter (Union[ElementFilter,FilterOP]) – The element filter to use to select the elements

  • tagname (str) – the name of tag to create

  • append (bool, default False) – if False, and the tag already exist an error is raised if True, the selection is added

  • exists (if the tag already) –

  • raised. (an exception is) –

GetComplementaryFilter(filter: FilterBase | FilterOperatorBase) ComplementaryFilter[source]

Create a filter with the complementary part. if filter is already a ComplementaryFilter the original filter (filter.filters[0]) is returned

Parameters:

filter (FilterLike) – the filter to invert

Returns:

The filter of the Complementary part of filter

Return type:

ComplementaryFilter

GetFrozenFilter(filter: FilterBase | FilterOperatorBase, mesh: Mesh, onElements: bool = True, onNodes: bool = False, withError: bool = False) FrozenFilter[source]

Generate a frozen filter. This is a filter with pre-evaluated ids. This class is useful when a repeated use of a filter is needed over the same mesh.

Parameters:
  • filter (FilterLike) – the filter to evaluate

  • mesh (Mesh) – the mesh to work on

  • onElements (bool, optional) – if True the filter will be evaluated over the elements, by default True

  • onNodes (bool, optional) – if True the filter will be evaluated over the nodes, by default False

  • withError (bool, optional) – if True a exception is raised if the filter has zero elements and zero nodes , by default False

Returns:

a FrozenFilter instance pre-evaluated using the incoming filter and the incoming mesh if the incoming filter is already a GetFrozenFilter over the mesh, the filter is returned (no re-evaluation)

Return type:

FrozenFilter

Raises:

RuntimeError – If the user tries to freeze a frozen filter on a different mesh

GetListOfPartialElementFilter(elementFilter: FilterBase | FilterOperatorBase, nbPartitions: int | int64, meshToFrozen=None, onElements: bool = True, onNodes: bool = False) List[PartialFilter] | List[FrozenFilter][source]

Generate a list of PartialElementFilter for a number of partitions

Parameters:
  • elementFilter (FilterLike) – _description_

  • nbPartitions (int) – Number of partitions

  • meshToFrozen (Mesh, optional) – if not None the filters are frozen (evaluated at the moment of creation), no more modification is allowed, by default None

Returns:

a list of partialElementFilter or frozen filter. the union of all the element of the list matches the original elementFilter

Return type:

List[PartialElementFilter]

ListOfElementFiltersFromETagList(tagList: List[str | List[str]]) List[ElementFilter][source]

Function to construct a list of filters from a list of tags (or a list of tags)

Parameters:
  • tagList (List[Union[str,List[str]]]) – A list containing a string or a list of strings. Example (“tag1”,(“tag2”,”tag3”)) -> list with 2 ElementFilters

  • mesh (Optional[Mesh], optional) – Mesh to pass to the filters

Returns:

List of ElementFilter with the associated tags as filters

Return type:

List[ElementFilter]

ListOfElementFiltersFromMask(maskVector: _SupportsArray[dtype] | _NestedSequence[_SupportsArray[dtype]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) List[ElementFilter][source]

Function to construct a list of filter from a element mask vector

Parameters:

maskVector (ArrayLike) – A element size vector of ints to determine to which filter each elements belongs to. The number of filters is calculated using np.unique

Returns:

List of ElementFilter with the associated tags as filters

Return type:

List[ElementFilter]

ReadElementFilter(string: str) ElementFilter[source]

Function to read from a string all the parameter of a ElementFiler

Parameters:

string (str) –

a string in the form of key(names) & key(options) && …

possible keywords are:
  • eTags -> Tags(bulk1,bulk2)

  • nTags -> nTags(points1,points2)

  • Dim -> Dim(3,2)

  • Exprs -> Exprs(x-1,y+3, x**2 +y**2 - 5)

  • nTagsOn -> to select the nTags Treatment

  • ExprsOn -> to select the Exprs Treatment

Example

ReadElementFilter("Tags(Inside) & Dim(2) & nTags(Toto,Tata) & Exprs(x-1, y+3, x**2 + y**2 - 5)")

Please read the documentation of ElementFilter

Returns:

An initialized instance of an ElementFilter.

Return type:

ElementFilter

VerifyExclusiveFilters(listOfFilters: List[FilterBase | FilterOperatorBase], mesh: Mesh) bool[source]
Function to check if a list of ElementFilter is exclusive.

(each element is present at the most in one filter)

Parameters:
  • listOfFilters (List[FilterLike]) – The list of filters to check

  • mesh (Mesh) – Mesh to evaluate the filters

Returns:

True if the filters are exclusive

Return type:

bool