CoMMA 1.3.2
A geometric agglomerator for unstructured meshes
Loading...
Searching...
No Matches
comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > Class Template Reference

Agglomerator_Anisotropic class is a child class of the Agglomerator class that specializes the implementation to the case of Anisotropic agglomeration. More...

#include <Agglomerator.h>

Inheritance diagram for comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >:
comma::Agglomerator< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >

Public Types

using AnisotropicLine = std::deque< CoMMAIndexType >
 Container for an anisotropic line. More...
 
using AnisotropicLinePtr = std::shared_ptr< AnisotropicLine >
 (Shared) Pointer to an anisotropic line More...
 
using CoMMAPairType = std::pair< CoMMAIndexType, CoMMAWeightType >
 Type of pair. More...
 
using CoMMASetOfPairType = std::set< CoMMAPairType, CustomPairGreaterFunctor< CoMMAPairType > >
 Type of set of pairs. More...
 

Public Member Functions

 Agglomerator_Anisotropic (std::shared_ptr< Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > graph, std::shared_ptr< Coarse_Cell_Container< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > cc_graph, std::shared_ptr< Seeds_Pool< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > seeds_pool, CoMMAIntType dimension, const CoMMAWeightType threshold_anisotropy, const std::vector< CoMMAIndexType > &agglomerationLines_Idx, const std::vector< CoMMAIndexType > &agglomerationLines, const std::vector< CoMMAWeightType > &priority_weights, const bool build_lines, const bool odd_line_length, const std::optional< CoMMAIndexType > max_cells_in_line, CoMMACellCouplingT cell_coupling=CoMMACellCouplingT::MAX_WEIGHT, const bool force_line_direction=true)
 Constructor. More...
 
 ~Agglomerator_Anisotropic () override=default
 Destructor. More...
 
void agglomerate_one_level (const CoMMAIntType goal_card, const CoMMAIntType min_card, const CoMMAIntType max_card, const std::vector< CoMMAWeightType > &priority_weights, bool correction_steps) override
 Specialization of the pure virtual function to the class Agglomerator_Anisotropic. We add the override key as a guard to possible mistakes: https://stackoverflow.com/questions/46446652/is-there-any-point-in-using-override-when-overriding-a-pure-virtual-function. More...
 
void update_seeds_pool ()
 Update the seeds pool with the neighbours of the anisotropic cells agglomerated so far. More...
 
void export_anisotropic_lines (CoMMAIntType level, std::vector< CoMMAIndexType > &aniso_lines_idx, std::vector< CoMMAIndexType > &aniso_lines) const
 Function that prepares the anisotropic lines for output. More...
 
- Public Member Functions inherited from comma::Agglomerator< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >
 Agglomerator (std::shared_ptr< Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > graph, std::shared_ptr< Coarse_Cell_Container< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > cc_graph, std::shared_ptr< Seeds_Pool< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > seeds_pool, CoMMAIntType dimension)
 The constructor of the interface. More...
 
virtual ~Agglomerator ()=default
 The destructor of the class. More...
 
std::vector< CoMMAIndexType > get_fc_2_cc () const
 Accessor to retrieve the fine cells to coarse cells from the coarse cell graphs class. More...
 
virtual void agglomerate_one_level (const CoMMAIntType goal_card, const CoMMAIntType min_card, const CoMMAIntType max_card, const std::vector< CoMMAWeightType > &priority_weights, bool correction_steps)=0
 Pure virtual function which implementation is specified in the related child classes and that defines the agglomeration of one level. More...
 

Public Attributes

std::vector< CoMMAIndexType > _nb_lines
 Vector of number of Anisotropic agglomeration lines per level. More...
 
std::vector< std::vector< AnisotropicLinePtr > > _v_lines
 _v_lines : Agglomeration lines structure: More...
 
bool _should_agglomerate
 Whether agglomeration is possible: for instance, if anisotropy requested but no anisotropic cells found, there is no actual need. More...
 

Protected Member Functions

bool build_anisotropic_lines (const std::vector< CoMMAWeightType > &priority_weights, const CoMMAWeightType threshold_anisotropy)
 Build the anisotropic lines at the first level (only called at the first level of agglomeration). Two main steps are performed:
. More...
 
bool is_high_coupling (const CoMMAWeightType weight, const CoMMAWeightType ref_weight)
 Tell whether a weight should be considered as high coupling between two cells. More...
 
void find_cell_candidates_for_line_max_weight (const CoMMAIndexType seed, const std::vector< bool > &to_treat, const std::vector< CoMMAWeightType > &weights, const std::vector< CoMMAWeightType > &max_weights, CoMMASetOfPairType &candidates)
 Find cells which are good candidates to be added to the anisotropic line. In order to identify the candidate, the weights are considered. More...
 
void find_cell_candidates_for_line_direction (const CoMMAIndexType seed, const std::vector< bool > &to_treat, const std::vector< CoMMAWeightType > &weights, const std::vector< CoMMAWeightType > &max_weights, const std::vector< CoMMAWeightType > &prev_dir, const bool check_weight, CoMMASetOfPairType &candidates)
 Find cells which are good candidates to be added to the anisotropic line. In order to identify the candidate, the direction is compared to the last reported one; additionally, if requested, the weights can also be considered. More...
 

Protected Attributes

std::deque< CoMMAIndexType > _aniso_neighbours
 Neighbours of the anisotropic cells agglomerated. They are used to update the seeds pool. More...
 
bool _odd_line_length
 Whether anisotropic lines with odd length are allowed. More...
 
std::optional< CoMMAIndexType > _max_cells_in_line
 Maximum number of cells in an anisotropic line; when this value is reached, all reaming cells are discarded, hence considered as isotropic. More...
 
CoMMACellCouplingT _cell_coupling
 
bool _force_line_direction
 
- Protected Attributes inherited from comma::Agglomerator< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >
CoMMAIntType _dimension
 Dimensionality of the problem (_dimension = 2 -> 2D, _dimension = 3 -> 3D) More...
 
CoMMAIntType _min_neighbourhood = 3
 Minimum number of neighbourhood we extend to search the neighbourhood in the greedy algorithm. Set as default to 3. More...
 
CoMMAIntType _min_card = 0
 Minimum cardinality (default = 0, meaning, equal to the dimension) More...
 
CoMMAIntType _max_card = 0
 Maximum cardinality (default = 0, meaning, 5 or 10 for, resp., 2- and 3D. More...
 
CoMMAIntType _goal_card = 0
 Goal cardinality (default = 0, meaning, 4 or 8 for, resp., 2- and 3D. More...
 
CoMMAIntType _threshold_card = 0
 Threshold cardinality (default = 0, meaning, equal to the dimension) More...
 
std::vector< CoMMAIndexType > _l_nb_of_cells
 List of number of cells per coarse cell created. More...
 
std::shared_ptr< Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > _fc_graph
 Dual_Graph object determining Fine cells graph and hence the connectivity. More...
 
std::shared_ptr< Coarse_Cell_Container< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > _cc_graph
 pointer to Coarse_Cell_Container element More...
 
std::shared_ptr< Seeds_Pool< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > _seeds_pool
 Seeds_Pool object giving the order in which the fine cells should be considered when agglomerating. More...
 

Detailed Description

template<typename CoMMAIndexType, typename CoMMAWeightType, typename CoMMAIntType>
class comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >

Agglomerator_Anisotropic class is a child class of the Agglomerator class that specializes the implementation to the case of Anisotropic agglomeration.

Template Parameters
CoMMAIndexTypethe CoMMA index type for the global index of the mesh
CoMMAWeightTypethe CoMMA weight type for the weights (volume or area) of the nodes or edges of the Mesh
CoMMAIntTypethe CoMMA type for integers

Member Typedef Documentation

◆ AnisotropicLine

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
using comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::AnisotropicLine = std::deque<CoMMAIndexType>

Container for an anisotropic line.

◆ AnisotropicLinePtr

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
using comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::AnisotropicLinePtr = std::shared_ptr<AnisotropicLine>

(Shared) Pointer to an anisotropic line

◆ CoMMAPairType

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
using comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::CoMMAPairType = std::pair<CoMMAIndexType, CoMMAWeightType>

Type of pair.

◆ CoMMASetOfPairType

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
using comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::CoMMASetOfPairType = std::set<CoMMAPairType, CustomPairGreaterFunctor<CoMMAPairType> >

Type of set of pairs.

Constructor & Destructor Documentation

◆ Agglomerator_Anisotropic()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::Agglomerator_Anisotropic ( std::shared_ptr< Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > >  graph,
std::shared_ptr< Coarse_Cell_Container< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > >  cc_graph,
std::shared_ptr< Seeds_Pool< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > >  seeds_pool,
CoMMAIntType  dimension,
const CoMMAWeightType  threshold_anisotropy,
const std::vector< CoMMAIndexType > &  agglomerationLines_Idx,
const std::vector< CoMMAIndexType > &  agglomerationLines,
const std::vector< CoMMAWeightType > &  priority_weights,
const bool  build_lines,
const bool  odd_line_length,
const std::optional< CoMMAIndexType >  max_cells_in_line,
CoMMACellCouplingT  cell_coupling = CoMMACellCouplingT::MAX_WEIGHT,
const bool  force_line_direction = true 
)
inline

Constructor.

Parameters
[in]graphDual_Graph object that determines the connectivity of the matrix
[in]cc_graphContainer for the coarse cells
[in]seeds_poolSeeds_Pool object giving the order in which the fine cells should be considered when agglomerating
[in]dimensionDimension of the problem
[in]agglomerationLines_IdxConnectivity for the agglomeration lines: each element points to a particular element in the vector agglomerationLines
[in]agglomerationLinesVector storing all the elements of the anisotropic lines
[in]threshold_anisotropyValue of the aspect-ratio above which a cell is considered as anisotropic
[in]priority_weightsWeights used to set the order telling where to start agglomerating. The higher the weight, the higher the priority
[in]build_linesWhether lines joining the anisotropic cells should be built
[in]odd_line_lengthWhether anisotropic lines with odd length are allowed
[in]max_cells_in_lineMaximum number of cells in an anisotropic line; when this value is reached, all reaming cells are discarded, hence considered as isotropic
[in]cell_couplingCoMMACellCouplingT indicating the type of coupling to consider when building anisotropic lines
[in]force_line_directionWhether a continuous direction of the line should be enforced when building it

◆ ~Agglomerator_Anisotropic()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::~Agglomerator_Anisotropic ( )
overridedefault

Destructor.

Member Function Documentation

◆ agglomerate_one_level()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::agglomerate_one_level ( const CoMMAIntType  goal_card,
const CoMMAIntType  min_card,
const CoMMAIntType  max_card,
const std::vector< CoMMAWeightType > &  priority_weights,
bool  correction_steps 
)
inlineoverridevirtual

Specialization of the pure virtual function to the class Agglomerator_Anisotropic. We add the override key as a guard to possible mistakes: https://stackoverflow.com/questions/46446652/is-there-any-point-in-using-override-when-overriding-a-pure-virtual-function.

Parameters
[in]goal_cardgoal cardinality of the coarse cell
[in]min_cardminimum cardinality of the coarse cell
[in]max_cardmaximum cardinality of the coarse cell
[in]priority_weightsWeights used to set the order telling where to start agglomerating. The higher the weight, the higher the priority
[in]correction_stepsit defines if corrections for the isotropic algorithm are activated or not, for anisotropic algorithm not taken into account.
Note
The input arguments are not used since the structure of the anisotropic agglomerator is fixed: cells belonging to the same anisotropic lines are agglomerated pairwise (by 3 on some rare occasions).

Implements comma::Agglomerator< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >.

◆ build_anisotropic_lines()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
bool comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::build_anisotropic_lines ( const std::vector< CoMMAWeightType > &  priority_weights,
const CoMMAWeightType  threshold_anisotropy 
)
inlineprotected

Build the anisotropic lines at the first level (only called at the first level of agglomeration). Two main steps are performed:
.

  1. Tag anisotropic cells (via the dual graph)
  2. Build anisotropic lines
Parameters
[in]priority_weightsWeights used to set the order telling where to start
[in]threshold_anisotropyValue of the aspect-ratio above which a cell is
Returns
whether at least one line was built
Todo:
Not properly efficient. We risk to do twice the operations (we overwrite the seed). This is not proper

◆ export_anisotropic_lines()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::export_anisotropic_lines ( CoMMAIntType  level,
std::vector< CoMMAIndexType > &  aniso_lines_idx,
std::vector< CoMMAIndexType > &  aniso_lines 
) const
inline

Function that prepares the anisotropic lines for output.

Parameters
[in]levelof the agglomeration process into the Multigrid algorithm
[out]aniso_lines_idxConnectivity for the agglomeration lines: each element points to a particular element in the vector aniso_lines
[out]aniso_linesVector storing all the elements of the anisotropic lines

◆ find_cell_candidates_for_line_direction()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::find_cell_candidates_for_line_direction ( const CoMMAIndexType  seed,
const std::vector< bool > &  to_treat,
const std::vector< CoMMAWeightType > &  weights,
const std::vector< CoMMAWeightType > &  max_weights,
const std::vector< CoMMAWeightType > &  prev_dir,
const bool  check_weight,
CoMMASetOfPairType candidates 
)
inlineprotected

Find cells which are good candidates to be added to the anisotropic line. In order to identify the candidate, the direction is compared to the last reported one; additionally, if requested, the weights can also be considered.

Parameters
[in]seedLast cell to be added to the line.
[in]to_treatVector of booleans telling whether a cell should be considered.
[in]weightsWeights of the graph.
[in]max_weightsVector holding for each cell the maximum weight among its neighbours.
[in]prev_dirPrevious direction.
[in]check_weightWhether to check weight of the potential candidate
[out]candidatesSet of the candidates, which are pairs of cell ID and related priority.

◆ find_cell_candidates_for_line_max_weight()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::find_cell_candidates_for_line_max_weight ( const CoMMAIndexType  seed,
const std::vector< bool > &  to_treat,
const std::vector< CoMMAWeightType > &  weights,
const std::vector< CoMMAWeightType > &  max_weights,
CoMMASetOfPairType candidates 
)
inlineprotected

Find cells which are good candidates to be added to the anisotropic line. In order to identify the candidate, the weights are considered.

Parameters
[in]seedLast cell to be added to the line.
[in]to_treatVector of booleans telling whether a cell should be considered.
[in]weightsWeights of the graph.
[in]max_weightsVector holding for each cell the maximum weight among its neighbours.
[out]candidatesSet of the candidates, which are pairs of cell ID and related priority.

◆ is_high_coupling()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
bool comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::is_high_coupling ( const CoMMAWeightType  weight,
const CoMMAWeightType  ref_weight 
)
inlineprotected

Tell whether a weight should be considered as high coupling between two cells.

Parameters
[in]weightValue to be examined
[in]ref_weightReference against which the value will be compared
Returns
whether the given value is a mark of high-coupling

◆ update_seeds_pool()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::update_seeds_pool ( )
inline

Update the seeds pool with the neighbours of the anisotropic cells agglomerated so far.

Member Data Documentation

◆ _aniso_neighbours

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
std::deque<CoMMAIndexType> comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_aniso_neighbours
protected

Neighbours of the anisotropic cells agglomerated. They are used to update the seeds pool.

◆ _cell_coupling

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
CoMMACellCouplingT comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_cell_coupling
protected

Type of cell coupling to consider when building aniso lines

◆ _force_line_direction

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
bool comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_force_line_direction
protected

Whether the force the direction of the anisotropic lines to remain straight

◆ _max_cells_in_line

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
std::optional<CoMMAIndexType> comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_max_cells_in_line
protected

Maximum number of cells in an anisotropic line; when this value is reached, all reaming cells are discarded, hence considered as isotropic.

◆ _nb_lines

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
std::vector<CoMMAIndexType> comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_nb_lines

Vector of number of Anisotropic agglomeration lines per level.

◆ _odd_line_length

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
bool comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_odd_line_length
protected

Whether anisotropic lines with odd length are allowed.

◆ _should_agglomerate

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
bool comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_should_agglomerate

Whether agglomeration is possible: for instance, if anisotropy requested but no anisotropic cells found, there is no actual need.

◆ _v_lines

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
std::vector<std::vector<AnisotropicLinePtr> > comma::Agglomerator_Anisotropic< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_v_lines

_v_lines : Agglomeration lines structure:

  • vector: level, 0 = fine, 1 = coarse
  • vector: identifier of the line
  • deque: line cells
  • e.g., _v_lines[0] --> agglomeration lines at the finest level

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