magnet._absaggmodels.AgglomerationModel#
- class magnet._absaggmodels.AgglomerationModel#
Bases:
ABC
Abstract base class for mesh agglomeration models.
- agglomerate()#
Agglomerate a mesh.
- agglomerate_dataset()#
Agglomerate a dataset of meshes.
- bisect()#
Bisect a mesh.
- bisection_Nref()#
Bisect a mesh recursively a set number of times.
- bisection_mult_factor()#
Bisect a mesh until the agglomerated elements are small enough.
Constructor
- __init__()#
Methods
agglomerate
(mesh[, mode, nref, mult_factor])Agglomerate a mesh.
agglomerate_dataset
(dataset, **kwargs)Agglomerate all meshes in a dataset.
bisect
(mesh)Bisect the mesh once.
bisection_Nref
(mesh, Nref[, warm_start])Bisect the mesh recursively a set number of times.
bisection_mult_factor
(mesh, mult_factor[, ...])Bisect a mesh until the agglomerated elements are small enough.
bisection_segregated
(mesh, mult_factor[, subset])Bisect heterogeneous mesh until elements are small enough.
coarsen
(mesh, subset[, mode, nref, mult_factor])Coarsen a subregion of the mesh.
multilevel_bisection
(mesh[, refiner, ...])- agglomerate(mesh: AggMesh, mode: str = 'Nref', nref: int = 7, mult_factor: float = 0.4, **kwargs) AggMesh #
Agglomerate a mesh.
Create a new mesh starting from mesh by agglomerating elements using this model.
- Parameters:
mesh (AggMesh) – Input mesh to be agglomerated.
mode ({'Nref, 'mult_factor'}, optional) – Agglomeration mode. ‘Nref’ : bisect the mesh recursively a set number of times. ‘mult_factor’ : bisect the mesh until the agglomerated elements are small enough. ‘segregated’ : same as ‘mult_factor’, but bisect heterogeneous parts of the mesh independently.
param (int, optional) – Number of refinements for mode ‘Nref’, ignored otherwise (default is 7).
mult_factor (float, optional.) – Multiplicative factor for mode ‘mult_factor’, ignored otherwise (default is 0.4).
- Returns:
The agglomerated mesh.
- Return type:
Notes
The adjacency matrix of the the agglomerated mesh is not computed (since it is expensive and in most cases a mesh will be agglomerated only once), so it is equal to None.
See also
- agglomerate_dataset(dataset: AggMeshDataset, **kwargs) AggMeshDataset #
Agglomerate all meshes in a dataset.
Constructs a new dataset by agglomerating the meshes in a dataset.
- Parameters:
dataset (AggMeshDataset) – The dataset to be agglomerated.
**kwargs (dict[str, Any], optional) – Additional keyword arguments to pass to ‘agglomerate’.
- Returns:
The agglomerated dataset.
- Return type:
- bisect(mesh: Mesh) List[ndarray[int]] #
Bisect the mesh once.
- Parameters:
mesh (Mesh) – The mesh to be bisected.
- Returns:
A list of 2 arrays containing the indices of the elements belonging to each of the 2 agglomerated elements.
- Return type:
Classlist
- bisection_Nref(mesh: Mesh, Nref: int, warm_start: List[ndarray[int]] | None = None) List[ndarray[int]] #
Bisect the mesh recursively a set number of times.
The agglomearated mesh will have (at most) 2^`Nref` agglomerated elements.
- Parameters:
mesh (Mesh) – Mesh to be bisected.
Nref (int) – Number of times to recursively bisect the mesh.
- Returns:
A list of arrays, each containing the indices of the elements corresponding to one of the agglomerated elements.
- Return type:
Classlist
- bisection_mult_factor(mesh: Mesh, mult_factor: float, warm_start: List[ndarray[int]] | None = None) List[ndarray[int]] #
Bisect a mesh until the agglomerated elements are small enough.
The mesh is bisected until all elements have a diameter that is less than the diameter of the entire mesh mutliplied by mult_factor. The number of agglomearated elements is thus variable.
- Parameters:
mesh (Mesh) – Mesh to be bisected.
mult_factor (float) – ratio between the the desired agglomerted elemnts diameter and that of the entire mesh. Must be between 0 and 1.
- Returns:
A list of arrays, each containing the indices of the elements corresponding to one of the agglomerated elements.
- Return type:
Classlist
Notes
The implementation is iterative rather than recursive because for very small mult_factor the number of recursive calls grows fast and can quickly fill the RAM.
- bisection_segregated(mesh: Mesh, mult_factor: float, subset: ndarray | None = None) List[ndarray[int]] #
Bisect heterogeneous mesh until elements are small enough.
Heterogeneous parts of the mesh are bisected separately; the physical groups identifying different parts should be integer numbers. The mesh is bisected until all elements have a diameter that is less than the diameter of the entire mesh mutliplied by mult_factor. The number of agglomearated elements is thus variable.
- Parameters:
mesh (Mesh) – Mesh to be bisected.
mult_factor (float) – ratio between the the desired agglomerted elements diameter and that of the entire mesh. Must be between 0 and 1.
- Returns:
A list of arrays, each containing the indices of the elements corresponding to one of the agglomerated elements.
- Return type:
Classlist
See also
- coarsen(mesh: AggMesh, subset: ndarray, mode: str = 'Nref', nref: int = 7, mult_factor: float = 0.4) AggMesh #
Coarsen a subregion of the mesh.
Inherited Methods
__init__
()