CoMMA 1.3.2
A geometric agglomerator for unstructured meshes
Loading...
Searching...
No Matches
comma Namespace Reference

Classes

class  AgglomerationArgs
 Convenient class holding arguments for the parametrization of the agglomeration algorithm. More...
 
class  Agglomerator
 A class responsible to do the interface between the different kinds of agglomerator. More...
 
class  Agglomerator_Anisotropic
 Agglomerator_Anisotropic class is a child class of the Agglomerator class that specializes the implementation to the case of Anisotropic agglomeration. More...
 
class  Agglomerator_Biconnected
 Child class of Agglomerator_Isotropic where is implemented a specific biconnected algorithm for the agglomeration. We call it biconnected case, but it is the greedy algorithm in reality. More...
 
class  Agglomerator_Isotropic
 Agglomerator_Isotropic class is a child class of the Agglomerator class that specializes the implementation to the case of Isotropic agglomeration. More...
 
class  Agglomerator_Iterative
 Child class of Agglomerator_Isotropic which implements a specialized iterative algorithm for the search of fine cells. More...
 
class  AnisotropicArgs
 Convenient class holding arguments for the parametrization of the anisotropic agglomeration algorithm. More...
 
class  ARComputer
 Similar to a functor, the key point is the method that computes the AR and update the features of a cell. Here, AR is used lightly, and might be any quantity which should be minimized in the coarsening process. This is an abstract class. More...
 
class  ARDiameter
 ARComputer. Here, AR is the approximated diameter. More...
 
class  ARDiamOverMinEdge
 ARComputer. Here, AR is the ratio of the diameter over the smallest edge. More...
 
class  ARDiamOverRadius
 ARComputer. Here, AR is the ratio of the diameter over the estimated one (typically, in 2D, the squared root of the surface). It is the definition used in CoMMA from 1.1 up to 1.3.2. More...
 
class  ARExternalWeightOverRadius
 ARComputer. Here, AR is the ratio of the external weights over the measure. With dim equal to 2, it is roughly equivalent to the ration of the perimeter and the surface of the cell. Moreover, with dim = 2, it is equivalent to the definition used by CoMMA up to version 1.0. For an algebraic version (where no concern is given to adimensionalize the AR), use dim equal to 1. More...
 
class  ARExternalWeights
 ARComputer. Here, AR is the total external weights (that is, from a geometric point of view, the perimeter). Looking for the minimum leads in graph terms to a min-cut. More...
 
class  ARMaxBaryDistanceOverRadius
 ARComputer. Here, AR is the ratio of the maximum over minimum distance of the cell centers from the barycenter (computed as weighted average of centers). If a cell is totally internal, it won't be included in the computations. More...
 
class  ARMaxOverMinBaryDistance
 ARComputer. Here, AR is the ratio of the maximum over minimum distance of the cell centers from the barycenter (computed as weighted average of centers). If a cell is totally internal, it won't be included in the computations. More...
 
class  AROverInternalWeights
 ARComputer. Here, AR is one over the internal weights (looking for the minimum leads to the maximization of the internal weights). More...
 
class  AROverMeasure
 ARComputer. Here, AR is the reciprocal of the measure, hence the optimal solution should be the one with the max measure. More...
 
class  Bimap
 An easy and straight forward implementation of a Bimap. More...
 
class  CellFeatures
 Convenient class containing salient features of a cell. According to to the chosen AR computation (see ARComputer), some features may be outdated. More...
 
class  Coarse_Cell
 Class describing a coarse cell. More...
 
class  Coarse_Cell_Container
 Class implementing a custom container where the coarse cells are stored. More...
 
class  Coarse_Cell_Subgraph
 Class describing a coarse cell with a full description, that is, it also holds a subgraph describing how the fine cells are connected inside the coarse one. More...
 
struct  CustomPairGreaterFunctor
 Functor for pairs implementing a custom 'greater than'. It relies on the 'greater than' operator for the second elements and 'less than' for the first ones. More...
 
struct  CustomPairLessFunctor
 Functor for pairs implementing a custom 'less than'. It relies on the 'less than' operator for the second elements and 'greater than' for the first ones. More...
 
class  Dual_Graph
 A class implementing the CRS global graph representation of the global mesh. More...
 
class  Graph
 An interface class responsible of storing the cell centered dual graph and of acting on it (it is an interface for the global Dual_Graph and the Subgraph) More...
 
class  GraphArgs
 Convenient class holding arguments defining the graph. More...
 
class  Neighbourhood
 Class representing the neighbourhood of a given cell in the graph. Mind that no information about the element being already agglomerated or not is known here. More...
 
class  Neighbourhood_Extended
 Class representing the neighbourhood of a given cell in the graph. In this derived class the neighbourhood is extended, meaning that all the neighbours seen so far are candidates. More...
 
class  Neighbourhood_Pure_Front
 Class representing the neighbourhood of a given cell in the graph. In this derived class, the neighbourhood is 'pure front-advancing', meaning that the next candidates are only the direct neighbours of the last added cell. More...
 
class  NeighbourhoodCreator
 Pure abstract class for a creator of Neighbourhood objects. It can create from scratch or by copy. More...
 
class  NeighbourhoodExtendedCreator
 Creator of Neighbourhood_Extended objects. It can create from scratch or by copy. More...
 
class  NeighbourhoodPureFrontCreator
 Creator of Neighbourhood_Extended objects. It can create from scratch or by copy. More...
 
class  Node
 Node data structure that represent a node of the tree. More...
 
class  PairFindFirstBasedFunctor
 Functor implementing an operator telling if a given value if the first one of pair. More...
 
struct  PairSecondBasedLessFunctor
 Functor for pairs implementing a less operator based only on the second element of the pair. More...
 
class  Priority_Pair
 Wrapper around the STL pair with custom 'less than' operator: as in the standard case, first we compare the first elements, then the second ones; however it relies on the 'greater than' on the first elements, e.g., (4,X) < (3,Y), whereas standard rules apply to second elements, e.g., (4,3) < (4,4). More...
 
class  Queue
 A template class implementing a custom queue data structure. More...
 
class  Seeds_Pool
 Class representing the pool of all the seeds for creating a coarse cell. More...
 
class  Seeds_Pool_Boundary_Priority
 Class representing the pool of all the seeds for creating a coarse cell. This derived class gives higher priority to cells that are on the border. More...
 
class  Seeds_Pool_Neighbourhood_Priority
 Class representing the pool of all the seeds for creating a coarse cell. This derived class gives higher priority to cells that are neighbours of already existing coarse cells. More...
 
struct  SPFullInitializator
 Functor performing the full initialization of a seeds pool. More...
 
struct  SPInitializator
 Functor performing the initialization of a seeds pool. More...
 
struct  SPOnePointInitializator
 Functor performing the one-point initialization of a seeds pool. More...
 
class  Subgraph
 A class implementing the CRS subgraph representation. It is used in the framework of CoMMA for the implementation of the CSR representation of the coarse cells. More...
 
class  Tree
 Tree structure that represent a coarse cell, the fine cell and the neighbours to them. More...
 

Enumerations

enum  CoMMACellT : CoMMAIntT {
  INTERIOR = 0 , VALLEY = 1 , RIDGE = 2 , CORNER = 3 ,
  EXTREME = 4 , N_CELL_TYPES = 4
}
 Type of an element according to its boundary faces / edges The terms come from the NIA paper: Nishikawa, Diskin, Thomas... More...
 
enum  CoMMANeighbourhoodT : CoMMAIntT { EXTENDED = 0 , PURE_FRONT = 1 }
 Type of neighbourhood (of a coarse cell) considered when agglomerating. More...
 
enum  CoMMASeedsPoolT : CoMMAIntT { BOUNDARY_PRIORITY = 0 , NEIGHBOURHOOD_PRIORITY = 1 , BOUNDARY_PRIORITY_ONE_POINT_INIT = 10 , NEIGHBOURHOOD_PRIORITY_ONE_POINT_INIT = 11 }
 Type of seeds pool ordering. More...
 
enum  CoMMAAspectRatioT : CoMMAIntT {
  DIAMETER_OVER_RADIUS = 0 , DIAMETER_OVER_MIN_EDGE , DIAMETER , ONE_OVER_MEASURE ,
  ONE_OVER_INTERNAL_WEIGHTS , PERIMETER_OVER_RADIUS , EXTERNAL_WEIGHTS , MAX_BARY_DIST_OVER_RADIUS ,
  MAX_OVER_MIN_BARY_DIST , ALGEBRAIC_PERIMETER_OVER_MEASURE
}
 Type of aspect-ratio. Notation: More...
 
enum  CoMMACellCouplingT : CoMMAIntT { MAX_WEIGHT = 0 , MIN_DISTANCE = 1 }
 Type of coupling between cells in an anisotropic line. More...
 

Functions

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void agglomerate_one_level (const std::vector< CoMMAIndexType > &adjMatrix_row_ptr, const std::vector< CoMMAIndexType > &adjMatrix_col_ind, const std::vector< CoMMAWeightType > &adjMatrix_areaValues, const std::vector< CoMMAWeightType > &volumes, const std::vector< std::vector< CoMMAWeightType > > &centers, const std::vector< CoMMAWeightType > &priority_weights, const std::vector< CoMMAIndexType > &anisotropicCompliantCells, const std::vector< CoMMAIntType > &n_bnd_faces, bool build_anisotropic_lines, bool is_anisotropic, bool odd_line_length, CoMMAWeightType threshold_anisotropy, CoMMASeedsPoolT seed_ordering_type, std::vector< CoMMAIndexType > &fc_to_cc, std::vector< CoMMAIndexType > &agglomerationLines_Idx, std::vector< CoMMAIndexType > &agglomerationLines, bool correction, CoMMAIntType dimension, CoMMAIntType goal_card, CoMMAIntType min_card, CoMMAIntType max_card, CoMMAAspectRatioT aspect_ratio=CoMMAAspectRatioT::DIAMETER_OVER_RADIUS, CoMMAIntType singular_card_thresh=1, std::optional< CoMMAIndexType > max_cells_in_line=std::nullopt, CoMMACellCouplingT aniso_cell_coupling=CoMMACellCouplingT::MAX_WEIGHT, bool force_line_direction=true, CoMMAIntType fc_choice_iter=1, CoMMANeighbourhoodT neighbourhood_type=CoMMANeighbourhoodT::EXTENDED)
 Main function of the agglomerator, it is used as an interface to build up all the agglomeration process. The result will be the definition of the agglomerated cells fc_to_cc. More...
 
template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void agglomerate_one_level (const GraphArgs< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > &graph, const AgglomerationArgs< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > &agglo, const AnisotropicArgs< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > &aniso, std::vector< CoMMAIndexType > &fc_to_cc, std::vector< CoMMAIndexType > &aniso_lines_indices, std::vector< CoMMAIndexType > &aniso_lines)
 Main function of the agglomerator, it is used as an interface to build up all the agglomeration process. The result will be the definition of the agglomerated cells fc_to_cc. More...
 
template<bool condition, typename typeA , typename typeB >
void fill_value (typeA &a, typeB &b)
 Assign from type to another only if a compile-time condition is verified. More...
 
template<typename T >
T constexpr _sq (const T x)
 Square. More...
 
template<typename T >
T constexpr _cb (const T x)
 Cube. More...
 
template<unsigned int p, typename T >
T constexpr int_power (const T x)
 Raise a quantity to an integer power. More...
 
template<typename T >
bool constexpr dot_deviate (const T dot)
 Tell whether the dot product given as input comes from two parallel vectors. Compared against deviate_thresh. More...
 
template<typename T >
dot_product (const std::vector< T > &a, const std::vector< T > &b)
 Compute the dot product between two vectors. No check on size is performed. More...
 
template<typename T >
get_direction (const std::vector< T > &a, const std::vector< T > &b, std::vector< T > &dir)
 Compute the direction from point a to point b and store it as unit vector in dir. More...
 
template<typename T >
squared_euclidean_distance (const std::vector< T > &a, const std::vector< T > &b)
 Compute the squared Euclidean distance between two points seen as vectors. We use vectors because we can have both 2- and 3D points (also we can have 3D points even if the dimension given to CoMMA is 2D, e.g., with CODA pseudo-2D meshes). The dimension used as reference is the one of the first point. More...
 
template<typename CoMMAContainerPairType >
std::vector< typename CoMMAContainerPairType::value_type::first_type > vector_of_first_elements (const CoMMAContainerPairType &cont)
 Given a container of pairs, return a vector with first elements only. More...
 
template<typename KeyT , typename ValueT >
std::unordered_set< KeyT > d_keys_to_set (const std::unordered_map< KeyT, ValueT > &dict)
 Utility function for creating a set out of the keys of a map. More...
 
template<typename IndexT , typename IntT >
void filter_cells_by_n_edges (const std::vector< IndexT > &indices, const std::vector< IntT > &n_bnd_faces, const std::unordered_set< IntT > &allowed, std::vector< IndexT > &filtered)
 Given the connectivity of the graph, filter cells keeping only those with the desired number of edges / neighbours. More...
 
template<typename IndexT , typename DistT >
void compute_neighbourhood_based_wall_distance (const std::vector< IndexT > &neigh_idxs, const std::vector< IndexT > &neighs, const std::vector< IndexT > &wall, std::vector< DistT > &dist)
 Compute a neighbourhood-base wall-distance, that is, the distance of a given cell from a wall is the number of cells though which the minimum path starting from the cell and ending at the wall. For example, in a Cartesian grids this is equivalent to the minimum of the Manhattan distance.
If the vector defining the wall is empty, return negative values.
If a cell is unconnected to the domain with the wall, its distance will be negative.
It takes a compressed version of the connectivity of the mesh. It uses a BFS algorithm to visit all the cells. More...
 
template<typename IndexT , typename RealT , typename IntT >
void build_coarse_graph (const std::vector< IndexT > &f2c, const std::vector< IndexT > &f_adj_idx, const std::vector< IndexT > &f_adj, const std::vector< RealT > &f_weights, const std::vector< RealT > &f_volumes, const std::vector< std::vector< RealT > > &f_centers, const std::vector< RealT > &f_priority, const std::vector< IntT > &f_n_bnd, std::vector< IndexT > &c_adj_idx, std::vector< IndexT > &c_adj, std::vector< RealT > &c_weights, std::vector< RealT > &c_volumes, std::vector< std::vector< RealT > > &c_centers, std::vector< RealT > &c_priority, std::vector< IntT > &c_n_bnd)
 Build a coarse graph from the fine graph and the result of a previous agglomeration. More...
 

Variables

constexpr CoMMAIntT iter_agglo_max_iter = 4
 Maximum allowed iterations for the iterative algorithm, see Agglomerator_Iterative. More...
 
constexpr double deviate_thresh = 0.9396926207859084
 Threshold used in combination with a dot product to tell whether two vector deviate. It is set to $ \cos(20^\circ) $. More...
 

Enumeration Type Documentation

◆ CoMMAAspectRatioT

enum comma::CoMMAAspectRatioT : CoMMAIntT

Type of aspect-ratio. Notation:

  • $ fc $ = Fine Cell, $ CC $ = Coarse cell = $ \{fc_i\}_i $:
  • Distance: $ d(x,\, y) $
  • Measure: in 3D, volume of the CC, $ vol(CC) $
  • Radius: approximation of the characteristic length $ \rho(CC) = \sqrt[dim]{vol(CC)} $
  • Barycenter: $ x^b_{CC} = \sum_{fc \in CC} vol_{fc} x^b_{fc} $
  • Diameter: $ diam = max_{fc_i, fc_j \in CC} d(x^b_{fc_i},\, x^b_{fc_j}) $
  • Perimeter: external weights, $ \pi(CC) $
  • Internal weights: sum of the surfaces of the internal facets, $ \sigma(CC) $
Enumerator
DIAMETER_OVER_RADIUS 

Diameter over radius, $ AR = \frac{diam(CC)}{\rho(CC)} $

DIAMETER_OVER_MIN_EDGE 

Diameter over minimum edge ( $ =min_{fc_i, fc_j \in CC}
 d(x^b_{fc_i},\, x^b_{fc_j}) $)

DIAMETER 

Diameter, $ AR = diam(CC) $

ONE_OVER_MEASURE 

One over the measure (e.g., volume) of the cell, $ AR = \frac{1}{vol(CC)} $

ONE_OVER_INTERNAL_WEIGHTS 

One over the internal weights, $ AR = \frac{1}{\sigma(CC)} $

PERIMETER_OVER_RADIUS 

Perimeter over radius, $ AR = \frac{\pi(CC)}{\rho(CC)} $

EXTERNAL_WEIGHTS 

External weights, that is, perimeter, $ AR = \pi(CC) $

MAX_BARY_DIST_OVER_RADIUS 

Maximum FC-center distance from barycenter over radius

MAX_OVER_MIN_BARY_DIST 

Maximum over minimum FC-center distance from barycenter

ALGEBRAIC_PERIMETER_OVER_MEASURE 

Algebraic-like perimeter over measure, that is, external weights over cell weight

◆ CoMMACellCouplingT

enum comma::CoMMACellCouplingT : CoMMAIntT

Type of coupling between cells in an anisotropic line.

Enumerator
MAX_WEIGHT 

Maximum edge-weight (i.e., max area)

MIN_DISTANCE 

Minimum centers distance

◆ CoMMACellT

enum comma::CoMMACellT : CoMMAIntT

Type of an element according to its boundary faces / edges The terms come from the NIA paper: Nishikawa, Diskin, Thomas...

Enumerator
INTERIOR 

Interior cell, no boundary faces.

VALLEY 

Valley, one boundary face.

RIDGE 

Ridge, two boundary faces.

CORNER 

Corners, three boundary faces.

EXTREME 

Extreme value, should not be used.

N_CELL_TYPES 

Total number of values.

◆ CoMMANeighbourhoodT

enum comma::CoMMANeighbourhoodT : CoMMAIntT

Type of neighbourhood (of a coarse cell) considered when agglomerating.

Enumerator
EXTENDED 

Extended, all neighbours of the coarse cell.

PURE_FRONT 

Pure front, only neighbours of the last added fine cell.

◆ CoMMASeedsPoolT

enum comma::CoMMASeedsPoolT : CoMMAIntT

Type of seeds pool ordering.

Enumerator
BOUNDARY_PRIORITY 

The number of boundary faces has highest priority

NEIGHBOURHOOD_PRIORITY 

The neighbourhood has highest priority (neighbours of coarse cells have priority)

BOUNDARY_PRIORITY_ONE_POINT_INIT 

The number of boundary faces has highest priority, and initialize with one point only then let evolve

NEIGHBOURHOOD_PRIORITY_ONE_POINT_INIT 

The neighbourhood has highest priority, and initialize with one point only then let evolve

Function Documentation

◆ _cb()

template<typename T >
T constexpr comma::_cb ( const T  x)
inlineconstexpr

Cube.

Template Parameters
TThe type of the quantity
Parameters
[in]xThe quantity
Returns
the cube of x

◆ _sq()

template<typename T >
T constexpr comma::_sq ( const T  x)
inlineconstexpr

Square.

Template Parameters
TThe type of the quantity
Parameters
[in]xThe quantity
Returns
the square of x

◆ agglomerate_one_level() [1/2]

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::agglomerate_one_level ( const GraphArgs< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > &  graph,
const AgglomerationArgs< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > &  agglo,
const AnisotropicArgs< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > &  aniso,
std::vector< CoMMAIndexType > &  fc_to_cc,
std::vector< CoMMAIndexType > &  aniso_lines_indices,
std::vector< CoMMAIndexType > &  aniso_lines 
)
inline

Main function of the agglomerator, it is used as an interface to build up all the agglomeration process. The result will be the definition of the agglomerated cells fc_to_cc.

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
Parameters
[in]graphDefinition of the graph, see GraphArgs.
[in]aggloParametrization of the isotropic agglomeration algorithm, see AgglomerationArgs.
[in]anisoParametrization of the anisotropic agglomeration algorithm, see AnisotropicArgs.
[out]fc_to_ccVector telling the ID of the coarse cell to which a fine cell belongs after agglomeration.
[in,out]aniso_lines_indicesConnectivity for the agglomeration lines
[in,out]aniso_linesVector storing all the elements of the anisotropic lines
Note
This version is just a wrapper around the other agglomerate_one_level
Author
Nicolas Lantos, Alberto Remigi, and Riccardo Milani
Contributor
Karim Anemiche
License
This project is released under the Mozilla Public License 2.0, see https://mozilla.org/MPL/2.0/

◆ agglomerate_one_level() [2/2]

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::agglomerate_one_level ( const std::vector< CoMMAIndexType > &  adjMatrix_row_ptr,
const std::vector< CoMMAIndexType > &  adjMatrix_col_ind,
const std::vector< CoMMAWeightType > &  adjMatrix_areaValues,
const std::vector< CoMMAWeightType > &  volumes,
const std::vector< std::vector< CoMMAWeightType > > &  centers,
const std::vector< CoMMAWeightType > &  priority_weights,
const std::vector< CoMMAIndexType > &  anisotropicCompliantCells,
const std::vector< CoMMAIntType > &  n_bnd_faces,
bool  build_anisotropic_lines,
bool  is_anisotropic,
bool  odd_line_length,
CoMMAWeightType  threshold_anisotropy,
CoMMASeedsPoolT  seed_ordering_type,
std::vector< CoMMAIndexType > &  fc_to_cc,
std::vector< CoMMAIndexType > &  agglomerationLines_Idx,
std::vector< CoMMAIndexType > &  agglomerationLines,
bool  correction,
CoMMAIntType  dimension,
CoMMAIntType  goal_card,
CoMMAIntType  min_card,
CoMMAIntType  max_card,
CoMMAAspectRatioT  aspect_ratio = CoMMAAspectRatioT::DIAMETER_OVER_RADIUS,
CoMMAIntType  singular_card_thresh = 1,
std::optional< CoMMAIndexType >  max_cells_in_line = std::nullopt,
CoMMACellCouplingT  aniso_cell_coupling = CoMMACellCouplingT::MAX_WEIGHT,
bool  force_line_direction = true,
CoMMAIntType  fc_choice_iter = 1,
CoMMANeighbourhoodT  neighbourhood_type = CoMMANeighbourhoodT::EXTENDED 
)

Main function of the agglomerator, it is used as an interface to build up all the agglomeration process. The result will be the definition of the agglomerated cells fc_to_cc.

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
Parameters
[in]adjMatrix_row_ptrthe row pointer of the CRS representation
[in]adjMatrix_col_indthe column index of the CRS representation
[in]adjMatrix_areaValuesthe weight of the CRS representation (in CoMMA case will be the area of the faces that in the graph representation are the edges between two nodes represented by the cell centers.
[in]volumesThe volumes of the cells
[in]centersCell centers
[in]priority_weightsWeights used to set the order telling where to start agglomerating. The higher the weight, the higher the priority
[in]anisotropicCompliantCellsList of cells which have to be looked for anisotropy
[in]n_bnd_facesVector telling how many boundary faces each cell has
[in]build_anisotropic_linesWhether lines joining the anisotropic cells should be built, otherwise, if the anisotropic agglomeration is activated, the lines should be provided, see agglomerationLines_Idx and agglomerationLines
[in]is_anisotropicWhether to consider an anisotropic agglomeration
[in]odd_line_lengthWhether anisotropic lines with odd length are allowed
[in]threshold_anisotropyValue of the aspect-ratio above which a cell is considered as anisotropic. If negative, all compliant cells are considered as anisotropic
[in]seed_ordering_typeType of ordering for the seeds of the coarse cells. Possible values (see CoMMASeedsPoolT):
  • 0: The number of boundary faces has highest priority
  • 1: The neighbourhood has highest priority (neighbours of coarse cells have priority)
  • 10: The number of boundary faces has highest priority, and initialize with one point only then let evolve
  • 11: The neighbourhood has highest priority, and initialize with one point only then let evolve
[out]fc_to_ccVector telling the ID of the coarse cell to which a fine cell belongs after agglomeration. The vector is cleared and then resized to the right size.
[in,out]agglomerationLines_IdxConnectivity for the agglomeration lines: each element points to a particular element in the vector agglomerationLines. The vector is cleared and then resized to the right size.
[in,out]agglomerationLinesVector storing all the elements of the anisotropic lines. The vector is cleared and then resized to the right size.
[in]correctionWhether to apply correction step (avoid isolated cells) after agglomeration
[in]dimensionDimensionality of the problem, 2- or 3D
[in]goal_cardDesired cardinality of the coarse cells (might not be ensured)
[in]min_cardMinimum cardinality accepted for the coarse cells
[in]max_cardMaximum cardinality accepted for the coarse cells
[in]aspect_ratioType of aspect-ratio (see CoMMAAspectRatioT)
[in]singular_card_thresh(optional, default=1) Cardinality below which a coarse is considered as singular, hence, compliant for correction
[in]max_cells_in_line[Optional] Maximum number of cells in an anisotropic line; when this value is reached, all reaming cells are discarded, hence considered as isotropic
[in]aniso_cell_couplingCoMMACellCouplingT indicating the type of coupling to consider when building anisotropic lines
[in]force_line_directionWhether to force the direction of the anisotropic lines to remain straight
[in]fc_choice_iter(optional, default=1) Number of iterations allowed for the algorithm choosing which fine cell to add next. The cost grows exponentially, hence use small values.
[in]neighbourhood_type(optional, default=Extended) Type of neighbourhood to use when growing a coarse cell. See CoMMANeighbourhoodT for more details. Two alternatives:
  • Extended: requested with 0, standard algorithm where we consider every neighbour of the coarse cell as candidate.
  • Pure Front Advancing: requested with 1, only direct neighbours of the last added cell are candidates.
Exceptions
invalid_argumentwhenever dimension is not 2 nor 3, cardinalities are smaller than 1 or not in order, line building is disabled but lines are not provided, or number of iterations is negative or greater than iter_agglo_max_iter.
Author
Nicolas Lantos, Alberto Remigi, and Riccardo Milani
Contributor
Karim Anemiche
License
This project is released under the Mozilla Public License 2.0, see https://mozilla.org/MPL/2.0/

◆ build_coarse_graph()

template<typename IndexT , typename RealT , typename IntT >
void comma::build_coarse_graph ( const std::vector< IndexT > &  f2c,
const std::vector< IndexT > &  f_adj_idx,
const std::vector< IndexT > &  f_adj,
const std::vector< RealT > &  f_weights,
const std::vector< RealT > &  f_volumes,
const std::vector< std::vector< RealT > > &  f_centers,
const std::vector< RealT > &  f_priority,
const std::vector< IntT > &  f_n_bnd,
std::vector< IndexT > &  c_adj_idx,
std::vector< IndexT > &  c_adj,
std::vector< RealT > &  c_weights,
std::vector< RealT > &  c_volumes,
std::vector< std::vector< RealT > > &  c_centers,
std::vector< RealT > &  c_priority,
std::vector< IntT > &  c_n_bnd 
)

Build a coarse graph from the fine graph and the result of a previous agglomeration.

Template Parameters
IndexTType for indices
RealTType for reals
IntTType for integers
Parameters
[in]f2cResult of the previous agglomeration
[in]f_adj_idxAdjacency indices of the fine graph
[in]f_adjAdjacency of the fine graph
[in]f_weightsAdjacency weights of the fine graph
[in]f_volumesVolumes of the previous graph
[in]f_centersCenters of the cells of the fine graph
[in]f_priorityPriorities of the cells of the fine graph
[in]f_n_bndNumber of boundary faces of the cells of the fine graph
[out]c_adj_idxAdjacency indices of the coarse graph
[out]c_adjAdjacency of the coarse graph
[out]c_weightsAdjacency weights of the coarse graph
[out]c_volumesVolumes of the previous graph
[out]c_centersCenters of the cells of the coarse graph
[out]c_priorityPriorities of the cells of the coarse graph (computed as maximum of the priorities of the fine cells)
[out]c_n_bndNumber of boundary faces of the cells of the coarse graph

◆ compute_neighbourhood_based_wall_distance()

template<typename IndexT , typename DistT >
void comma::compute_neighbourhood_based_wall_distance ( const std::vector< IndexT > &  neigh_idxs,
const std::vector< IndexT > &  neighs,
const std::vector< IndexT > &  wall,
std::vector< DistT > &  dist 
)

Compute a neighbourhood-base wall-distance, that is, the distance of a given cell from a wall is the number of cells though which the minimum path starting from the cell and ending at the wall. For example, in a Cartesian grids this is equivalent to the minimum of the Manhattan distance.
If the vector defining the wall is empty, return negative values.
If a cell is unconnected to the domain with the wall, its distance will be negative.
It takes a compressed version of the connectivity of the mesh. It uses a BFS algorithm to visit all the cells.

Template Parameters
IndexTType for cell indices
DistTType for distance (should be signed)
Parameters
[in]neigh_idxsIndices used to recover the neighbours of each cells provided in neighs. The length is $ N_{cells} + 1 $
[in]neighsNeighbours of the cells
[in]wallCells composing the wall from which the distance is computed
[out]distDistance from the wall. This vector is resized inside the function to hold all the cells
Warning
This function is experimental. Moreover, since CoMMA has knowledge of the current domain only, this function might not give the right result if the domain has been partitioned. It is advised to use this function only when considering one domain only.

◆ d_keys_to_set()

template<typename KeyT , typename ValueT >
std::unordered_set< KeyT > comma::d_keys_to_set ( const std::unordered_map< KeyT, ValueT > &  dict)
inline

Utility function for creating a set out of the keys of a map.

Template Parameters
KeyTType of the keys of the map
ValueTType of the values of the map
Parameters
[in]dictA map
Returns
a set

◆ dot_deviate()

template<typename T >
bool constexpr comma::dot_deviate ( const T  dot)
inlineconstexpr

Tell whether the dot product given as input comes from two parallel vectors. Compared against deviate_thresh.

Template Parameters
TInput type
Parameters
[in]dotDot product
Returns
true if higher than a reference threshold

◆ dot_product()

template<typename T >
T comma::dot_product ( const std::vector< T > &  a,
const std::vector< T > &  b 
)
inline

Compute the dot product between two vectors. No check on size is performed.

Template Parameters
TInput type
Parameters
[in]aFirst vector
[in]bSecond vector
Returns
the dot product

◆ fill_value()

template<bool condition, typename typeA , typename typeB >
void comma::fill_value ( typeA &  a,
typeB &  b 
)

Assign from type to another only if a compile-time condition is verified.

Template Parameters
conditionBoolean telling if the assignment should be done. It has to be a constexpr
typeAType of the destination of the assignment
typeBType of the source of the assignment
Parameters
[in]aDestination of the assignment
[in]bSource of the assignment

◆ filter_cells_by_n_edges()

template<typename IndexT , typename IntT >
void comma::filter_cells_by_n_edges ( const std::vector< IndexT > &  indices,
const std::vector< IntT > &  n_bnd_faces,
const std::unordered_set< IntT > &  allowed,
std::vector< IndexT > &  filtered 
)
inline

Given the connectivity of the graph, filter cells keeping only those with the desired number of edges / neighbours.

Template Parameters
IndexTType for indices.
IntTType for integers.
Parameters
[in]indicesIndices of the connectivity of the graph.
[in]n_bnd_facesNumber of boundary faces per cell.
[in]allowedSet with the accepted number of edges.
[out]filteredFiltered cells.

◆ get_direction()

template<typename T >
T comma::get_direction ( const std::vector< T > &  a,
const std::vector< T > &  b,
std::vector< T > &  dir 
)
inline

Compute the direction from point a to point b and store it as unit vector in dir.

Template Parameters
TInput type
Parameters
[in]aStarting point
[in]bEnd point
[out]dirUnit vector of the direction
Returns
the distance from the two points (the norm used for the normalization)

◆ int_power()

template<unsigned int p, typename T >
T constexpr comma::int_power ( const T  x)
inlineconstexpr

Raise a quantity to an integer power.

Template Parameters
pThe power
TThe type of the quantity
Parameters
[in]xThe quantity
Returns
$ x^p $

◆ squared_euclidean_distance()

template<typename T >
T comma::squared_euclidean_distance ( const std::vector< T > &  a,
const std::vector< T > &  b 
)
inline

Compute the squared Euclidean distance between two points seen as vectors. We use vectors because we can have both 2- and 3D points (also we can have 3D points even if the dimension given to CoMMA is 2D, e.g., with CODA pseudo-2D meshes). The dimension used as reference is the one of the first point.

Template Parameters
TType for real numbers
Parameters
[in]aFirst point
[in]bSecond point
Returns
The squared Euclidean distance between the two points

◆ vector_of_first_elements()

template<typename CoMMAContainerPairType >
std::vector< typename CoMMAContainerPairType::value_type::first_type > comma::vector_of_first_elements ( const CoMMAContainerPairType &  cont)
inline

Given a container of pairs, return a vector with first elements only.

Template Parameters
CoMMAContainerPairTypeType of the input container
Parameters
[in]contA container of pairs from which the first elements will be extracted
Returns
The first elements of each pair

Variable Documentation

◆ deviate_thresh

constexpr double comma::deviate_thresh = 0.9396926207859084
constexpr

Threshold used in combination with a dot product to tell whether two vector deviate. It is set to $ \cos(20^\circ) $.

◆ iter_agglo_max_iter

constexpr CoMMAIntT comma::iter_agglo_max_iter = 4
constexpr

Maximum allowed iterations for the iterative algorithm, see Agglomerator_Iterative.