Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::geometry::AbstractAgglomerationModel< MeshType > Class Template Referenceabstract

Defines an abstract interface for mesh agglomeration strategies. More...

#include <abs_agg_model.hpp>

Inheritance diagram for vulpes::geometry::AbstractAgglomerationModel< MeshType >:
[legend]
Collaboration diagram for vulpes::geometry::AbstractAgglomerationModel< MeshType >:
[legend]

Public Types

using float_t = double
using index_t = int64_t
using IndVec = std::vector<index_t>
using MapType = datastructure::CrsMap<index_t, index_t>
using ParamType = std::variant<index_t, float_t>
using IndexTrackerType = datastructure::IndexTracker<index_t>

Public Member Functions

virtual std::vector< MeshType > agglomerate (const MeshType &mesh, MethodType method_type, ParamType params, bool return_hierarchy=true, const std::string &segregated_tag="", const IndVec &subset={})=0
 Agglomerates a mesh according to a selected strategy.
virtual void directKWay (const MeshType &mesh, std::size_t n_groups, IndexTrackerType &indicator, const std::vector< bool > &agglomerate)=0
 Performs a direct k-way partition on the (sub)mesh.
std::vector< IndVec > multFactor (const MeshType &mesh, const float_t target_h, IndexTrackerType &indicator, const std::vector< bool > &agglomerate)
 Partitions the mesh based on a multiplicative factor strategy.
std::vector< IndVec > bisectNRef (const MeshType &mesh, const index_t n_refs, IndexTrackerType &indicator, const std::vector< bool > &agglomerate)
 Applies recursive bisection n_refs times.

Static Public Attributes

static constexpr index_t dim = MeshType::self_dim

Protected Member Functions

std::vector< IndVec > invokeMethod (const MeshType &mesh, MethodType method_type, ParamType params, const std::string &segregation_tag, const IndVec &subset)
 Dispatches to the correct agglomeration method to compute cell labels.
virtual IndVec bisectSubGraph (const MeshType &mesh, const IndVec &subgraph)=0
 Backend implementation of a single bisection operation.
void connectedComponents (const IndVec &subset, IndexTrackerType &indicator, index_t &max_id)
 Splits a set of cells into its connected components.
void groupToBisection (const IndVec &subset, const IndVec &classes, IndexTrackerType &indicator, index_t new_id)
 Post-processes a binary labeling to ensure two connected partitions.

Protected Attributes

MapType m_dual_map
 The dual graph of the mesh, cached for performance.

Detailed Description

template<typename MeshType>
class vulpes::geometry::AbstractAgglomerationModel< MeshType >

Defines an abstract interface for mesh agglomeration strategies.

This class provides a common framework for various mesh partitioning and agglomeration algorithms (e.g., K-Means, ParMETIS, GNN-based). It exposes a uniform entry point to compute a labeling of mesh cells and then build the corresponding agglomerated (coarsened) mesh.

The primary strategies, identified by MethodType, are:

  • BisectNRef: Applies recursive bisection for N_ref levels, producing up to $2^{N_{ref}}$ partitions.
  • MultFactor: Recursively splits any partition whose vertex-vertex diameter exceeds a certain threshold, then finalizes partitions by connectivity.
  • DirectKWay: Performs a single-shot k-way partition (note: not all backends may support this).

All methods support a segregated mode, where disjoint subdomains of the mesh (identified by a MeshTag) are agglomerated independently.

Derived classes must implement the low-level bisection primitive bisectSubGraph() and/or the direct k-way routine directKWay().

Template Parameters
MeshTypeThe concrete mesh type being agglomerated (e.g., Mesh2D, Mesh3D).
See also
agglomerate(), invokeMethod(), bisectNRef(), multFactor()

Member Typedef Documentation

◆ float_t

template<typename MeshType>
using vulpes::geometry::AbstractAgglomerationModel< MeshType >::float_t = double

◆ index_t

template<typename MeshType>
using vulpes::geometry::AbstractAgglomerationModel< MeshType >::index_t = int64_t

◆ IndexTrackerType

template<typename MeshType>
using vulpes::geometry::AbstractAgglomerationModel< MeshType >::IndexTrackerType = datastructure::IndexTracker<index_t>

◆ IndVec

template<typename MeshType>
using vulpes::geometry::AbstractAgglomerationModel< MeshType >::IndVec = std::vector<index_t>

◆ MapType

template<typename MeshType>
using vulpes::geometry::AbstractAgglomerationModel< MeshType >::MapType = datastructure::CrsMap<index_t, index_t>

◆ ParamType

template<typename MeshType>
using vulpes::geometry::AbstractAgglomerationModel< MeshType >::ParamType = std::variant<index_t, float_t>

Member Function Documentation

◆ agglomerate()

template<typename MeshType>
virtual std::vector< MeshType > vulpes::geometry::AbstractAgglomerationModel< MeshType >::agglomerate ( const MeshType & mesh,
MethodType method_type,
ParamType params,
bool return_hierarchy = true,
const std::string & segregated_tag = "",
const IndVec & subset = {} )
pure virtual

Agglomerates a mesh according to a selected strategy.

This is the main entry point for agglomeration. It dispatches to the chosen method_type using the provided params. The operation can be restricted to a subset of cell IDs and can operate in a segregated fashion if a segregated_tag is provided.

Parameters
meshThe input mesh to agglomerate.
method_typeThe strategy to use, e.g., BisectNRef, MultFactor, DirectKWay.
paramsParameters for the chosen strategy:
return_hierarchyIf true, returns all intermediate meshes from recursive strategies. If false, returns only the final agglomerated mesh.
segregated_tagIf non-empty, specifies the mesh tag for segregated agglomeration, where each tagged region is processed independently. If the tags indicates parts of the domain that are not connected they are automatically recognised and split. The agglomeration procedure is applied to each sub domain independently.
subsetOptional list of cell IDs to agglomerate. If empty, the entire mesh is processed.
Returns
A vector of MeshType. If return_hierarchy is true, this includes all intermediate meshes; otherwise, it contains only the final result.
Precondition
For DirectKWay, k must be \(\ge 1\) and \(\le\) the number of cells being processed.
Note
The typical implementation flow is: (1) compute a label vector via invokeMethod(), then (2) build the new mesh via a call to a mesh construction method like mesh.agglomerateBase().
See also
invokeMethod(), directKWay(), multFactor(), bisectNRef()

Implemented in vulpes::geometry::GNNAgglomeration< MeshType >, vulpes::geometry::KMeansAgglomeration< MeshType >, and vulpes::geometry::ParmetisAgglomeration< MeshType >.

◆ bisectNRef()

template<typename MeshType>
std::vector< typename AbstractAgglomerationModel< MeshType >::IndVec > vulpes::geometry::AbstractAgglomerationModel< MeshType >::bisectNRef ( const MeshType & mesh,
const index_t n_refs,
IndexTrackerType & indicator,
const std::vector< bool > & agglomerate )

Applies recursive bisection n_refs times.

This method takes an initial partitioning and refines it by applying the bisectSubGraph() primitive recursively for n_refs levels. Each step splits a partition into two. The base cases are finalized by ensuring connectivity via connectedComponents().

Parameters
meshThe input mesh.
n_refsThe number of recursive bisection levels to apply ( \(n_{refs} \ge 0\)).
[in,out]indicatorThe label tracker, which is updated with the results.
agglomerateA boolean vector indicating which initial classes in indicator are eligible for bisection.
Returns
A hierarchy of label vectors, capturing the state of partitioning at each level of bisection.
See also
bisectSubGraph(), connectedComponents()

◆ bisectSubGraph()

template<typename MeshType>
virtual IndVec vulpes::geometry::AbstractAgglomerationModel< MeshType >::bisectSubGraph ( const MeshType & mesh,
const IndVec & subgraph )
protectedpure virtual

Backend implementation of a single bisection operation.

Given a set of cell IDs forming a subgraph, this pure virtual function must be implemented by derived classes to split the subgraph into two parts.

Parameters
meshThe input mesh.
subgraphA vector of cell IDs to be split.
Returns
A vector of binary labels (e.g., 0s and 1s) of the same size as subgraph, assigning each cell to one of the two new partitions.

Implemented in vulpes::geometry::GNNAgglomeration< MeshType >, vulpes::geometry::KMeansAgglomeration< MeshType >, and vulpes::geometry::ParmetisAgglomeration< MeshType >.

◆ connectedComponents()

template<typename MeshType>
void vulpes::geometry::AbstractAgglomerationModel< MeshType >::connectedComponents ( const IndVec & subset,
IndexTrackerType & indicator,
index_t & max_id )
protected

Splits a set of cells into its connected components.

This function examines the dual graph restricted to the cells in subset. If the subgraph is disconnected, each connected component is assigned a new, unique label. This is often used as a finalization step in recursive strategies.

Parameters
subsetThe set of cell IDs to process.
[in,out]indicatorThe global label tracker, which will be updated.
[in,out]max_idThe last used label ID; it is incremented for each new component found.

◆ directKWay()

template<typename MeshType>
virtual void vulpes::geometry::AbstractAgglomerationModel< MeshType >::directKWay ( const MeshType & mesh,
std::size_t n_groups,
IndexTrackerType & indicator,
const std::vector< bool > & agglomerate )
pure virtual

Performs a direct k-way partition on the (sub)mesh.

This method must be implemented by backends that support single-shot k-way partitioning (e.g., K-Means, ParMETIS). It partitions the active cells into n_groups sets, updating the indicator with the new labels.

Parameters
meshThe input mesh.
n_groupsThe target number of partitions.
[in,out]indicatorThe label tracker. It can be pre-filled to provide a warm start. It will be updated with the final labels.
agglomerateA boolean vector where the i-th element indicates if the i-th class in the initial indicator should be re-partitioned.

Implemented in vulpes::geometry::GNNAgglomeration< MeshType >, vulpes::geometry::KMeansAgglomeration< MeshType >, and vulpes::geometry::ParmetisAgglomeration< MeshType >.

◆ groupToBisection()

template<typename MeshType>
void vulpes::geometry::AbstractAgglomerationModel< MeshType >::groupToBisection ( const IndVec & subset,
const IndVec & classes,
IndexTrackerType & indicator,
index_t new_id )
protected

Post-processes a binary labeling to ensure two connected partitions.

Given a provisional two-class labeling for a subset of cells, this method refines the labels to ensure that the resulting two partitions are each internally connected. It can relabel "islands" of cells to join the surrounding partition.

Parameters
subsetThe set of cell IDs under consideration.
classesA vector of provisional binary labels for the cells in subset.
[in,out]indicatorThe global label tracker to update with the final bisection.
new_idThe fresh label ID to be assigned to one of the two final partitions.

◆ invokeMethod()

template<typename MeshType>
std::vector< typename AbstractAgglomerationModel< MeshType >::IndVec > vulpes::geometry::AbstractAgglomerationModel< MeshType >::invokeMethod ( const MeshType & mesh,
MethodType method_type,
ParamType params,
const std::string & segregation_tag,
const IndVec & subset )
protected

Dispatches to the correct agglomeration method to compute cell labels.

This is a wrapper function typically used by agglomerate(). It selects the appropriate backend method based on method_type and restricts the computation to subset if it is non-empty.

Parameters
meshThe input mesh.
method_typeThe strategy to apply.
paramsThe parameters for the chosen strategy.
segregation_tagIf non-empty, the mesh tag to use for segregated processing.
subsetAn optional subset of cell IDs to operate on.
Returns
A hierarchy of label vectors. For cells not in subset, the label is typically unchanged or set to a sentinel value (e.g., -1).

◆ multFactor()

template<typename MeshType>
std::vector< typename AbstractAgglomerationModel< MeshType >::IndVec > vulpes::geometry::AbstractAgglomerationModel< MeshType >::multFactor ( const MeshType & mesh,
const float_t target_h,
IndexTrackerType & indicator,
const std::vector< bool > & agglomerate )

Partitions the mesh based on a multiplicative factor strategy.

This method recursively bisects any group whose vertex-vertex diameter exceeds the target_h. After geometric splitting, each resulting group is finalized by splitting it into its connected components. It uses bisectSubGraph() as the core splitting primitive.

Parameters
meshThe input mesh.
target_hThe target characteristic length. Any group with a diameter larger than this will be split.
[in,out]indicatorThe label tracker, which is updated with the results.
agglomerateA boolean vector indicating which initial classes in indicator are eligible for splitting.
Returns
A hierarchy of label vectors, where each vector represents the partitioning at a successive level of refinement.
Precondition
target_h must be a positive value.
See also
connectedComponents(), bisectSubGraph()

Member Data Documentation

◆ dim

template<typename MeshType>
index_t vulpes::geometry::AbstractAgglomerationModel< MeshType >::dim = MeshType::self_dim
staticconstexpr

◆ m_dual_map

template<typename MeshType>
MapType vulpes::geometry::AbstractAgglomerationModel< MeshType >::m_dual_map
protected

The dual graph of the mesh, cached for performance.


The documentation for this class was generated from the following files: