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

A class implementing the CRS global graph representation of the global mesh. More...

#include <Dual_Graph.h>

Inheritance diagram for comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >:
comma::Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >

Public Types

using BaseClass = Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >
 Parent class. More...
 
using CoMMAPairType = std::pair< CoMMAIndexType, CoMMAWeightType >
 Type of pair. More...
 
using CoMMASetOfPairType = std::set< CoMMAPairType, CustomPairGreaterFunctor< CoMMAPairType > >
 Type of set of pairs. More...
 
using ContainerIndexType = std::vector< CoMMAIndexType >
 Type for containers of indices. More...
 
using ContainerWeightType = std::vector< CoMMAWeightType >
 Type for containers of weights. More...
 
- Public Types inherited from comma::Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >
using ContainerIndexType = std::vector< CoMMAIndexType >
 Type for containers of indices. More...
 
using ContainerWeightType = std::vector< CoMMAWeightType >
 Type for containers of weights. More...
 
using ContainerIndexConstIt = typename ContainerIndexType::const_iterator
 Type for constant iterators of containers of indices. More...
 
using ContainerWeightConstIt = typename ContainerWeightType::const_iterator
 Type for constant iterators of containers of weights. More...
 

Public Member Functions

 Dual_Graph (const CoMMAIndexType &nb_c, const ContainerIndexType &m_crs_row_ptr, const ContainerIndexType &m_crs_col_ind, const ContainerWeightType &m_crs_values, const ContainerWeightType &volumes, const std::vector< std::vector< CoMMAWeightType > > &centers, const std::vector< CoMMAIntType > &n_bnd_faces, const CoMMAIntType dimension, const ContainerIndexType &anisotropic_compliant_fc)
 Constructor of the class. More...
 
 ~Dual_Graph () override=default
 Destructor of the class. More...
 
CoMMAIntType get_n_boundary_faces (const CoMMAIndexType idx_c) const
 Return how many boundary faces a certain cell has. More...
 
CoMMAIntType get_total_n_faces (const CoMMAIndexType idx_c) const
 Return total number of faces, that is, number of neighbours plus number of boundaries. More...
 
bool is_on_boundary (const CoMMAIndexType idx_c) const
 Whether a cell is on the boundary. More...
 
CoMMAWeightType estimated_boundary_weight (const CoMMAIndexType idx_c) const
 Approximate the value of a boundary face using the known internal faces. It uses a (geometric) average, so the result is correct only if the cell is a regular polygon. More...
 
CoMMAWeightType estimated_total_weight (const CoMMAIndexType idx_c) const
 Sum of wall the weights (faces) of a cell. Since there is no knowledge about boundary faces, the result is correct only if internal cell. More...
 
CoMMAWeightType get_center_direction (const CoMMAIndexType &a, const CoMMAIndexType &b, std::vector< CoMMAWeightType > &dir)
 Compute the direction from vertex a to vertex b and store it as unit vector in dir. More...
 
void tag_anisotropic_cells (std::vector< CoMMAWeightType > &alt_weights, ContainerWeightType &max_weights, std::vector< bool > &is_anisotropic, std::deque< CoMMAIndexType > &aniso_seeds_pool, const CoMMAWeightType threshold_anisotropy, const ContainerWeightType &priority_weights, const CoMMACellCouplingT cell_coupling, const CoMMAIndexType preserving)
 Tag cells as anisotropic if their aspect-ratio is over a given threshold and order them according to given priority. More...
 
CoMMAIndexType get_nb_cells () const
 Getter that returns the number of cells. More...
 
std::unordered_set< CoMMAIndexType > get_neighbourhood_of_cc (const std::unordered_set< CoMMAIndexType > &s_seeds, const std::vector< bool > &is_fc_agglomerated_tmp) const
 Get the fine cells neighbours of a coarse cell. More...
 
void compute_neighbourhood_of_cc (const std::unordered_set< CoMMAIndexType > &s_seeds, CoMMAIntType &nb_of_order_of_neighbourhood, std::unordered_map< CoMMAIndexType, CoMMAIntType > &d_n_of_seed, const CoMMAIntType max_card, const std::vector< bool > &is_fc_agglomerated_tmp) const
 Compute the dictionary of compactness of fine cells inside a coarse cell. More...
 
- Public Member Functions inherited from comma::Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >
 Graph (const CoMMAIndexType &nb_c, const ContainerIndexType &m_crs_row_ptr, const ContainerIndexType &m_crs_col_ind, const ContainerWeightType &m_crs_values, const ContainerWeightType &volumes)
 Constructor of the class. More...
 
virtual ~Graph ()=default
 Destructor of the class. More...
 
void DFS (const CoMMAIndexType &i_fc)
 Depth First Search (DFS) recursive function. More...
 
void BFS (const CoMMAIndexType &root)
 Breadth First Search (BFS) function. More...
 
CoMMAIntType get_nb_of_neighbours (const CoMMAIndexType i_c) const
 Retrieve the number of neighbours. More...
 
ContainerIndexType get_neighbours (const CoMMAIndexType &i_c) const
 Based on the CRS representation retrieves the neighbours of the cell given as an input. More...
 
ContainerIndexConstIt neighbours_cbegin (const CoMMAIndexType &i_c) const
 Get constant pointer to the first neighbour of cell i_c. More...
 
ContainerIndexConstIt neighbours_cend (const CoMMAIndexType &i_c) const
 Get constant pointer to the element following the last neighbour of cell i_c. More...
 
ContainerWeightType get_weights (const CoMMAIndexType &i_c) const
 Based on the area of the faces composing the cell given as an input, we retrieve the faces connecting the given cell with the neighbourhood that can be described also as the weight of the graph. More...
 
ContainerWeightConstIt weights_cbegin (const CoMMAIndexType &i_c) const
 Get constant pointer to the first neighbour of cell i_c. More...
 
ContainerWeightConstIt weights_cend (const CoMMAIndexType &i_c) const
 Get constant pointer to the element following the last neighbour of cell i_c. More...
 
bool check_connectivity ()
 Check the connectivity of the graph. More...
 
CoMMAIntType compute_min_fc_compactness_inside_a_cc (const std::unordered_set< CoMMAIndexType > &s_fc) const
 Compute the minimum compactness of fine cells inside a coarse cell. More...
 
std::unordered_map< CoMMAIndexType, CoMMAIntType > compute_fc_compactness_inside_a_cc (const std::unordered_set< CoMMAIndexType > &s_fc) const
 Compute the dictionary of compactness of fine cells inside a coarse cell. More...
 

Public Attributes

const std::vector< CoMMAIntType > & _n_bnd_faces
 Vector telling how many boundary faces each cell has. More...
 
const std::unordered_set< CoMMAIndexType > _s_anisotropic_compliant_cells
 Elements that are checked if they are anisotropic. If an element satisfies the condition for being anisotropic (typically, AR > threshold) but it not in this set, it will not considered as anisotropic. We use a set to ensure uniqueness. More...
 
const std::vector< std::vector< CoMMAWeightType > > & _centers
 Vector of cell centers. More...
 
std::function< CoMMAWeightType(const CoMMAWeightType, const CoMMAWeightType)> _compute_AR
 Function which computes the aspect-ratio from the minimum and maximum faces
In 3D: $ AR = sqrt(\frac{max_{surf}}{min_{surf}}) $
In 2D: $ AR = \frac{max_{surf}}{min_{surf}} $
(Recall that in 2D a face is actually an edge) More...
 
- Public Attributes inherited from comma::Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >
CoMMAIndexType _number_of_cells
 Number of nodes in the Graph (it corresponds to the number of cells in the subgraph or the dual graph. More...
 
std::vector< bool > _visited
 Helper vector for the DFS. More...
 
ContainerIndexType _m_CRS_Row_Ptr
 Vector of row pointer of CRS representation. More...
 
ContainerIndexType _m_CRS_Col_Ind
 Vector of column index of CRS representation. More...
 
ContainerWeightType _m_CRS_Values
 Vector of area weight of CRS representation. More...
 
ContainerWeightType _volumes
 Vector of volumes. More...
 

Detailed Description

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

A class implementing the CRS global graph representation of the global mesh.

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

◆ BaseClass

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
using comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::BaseClass = Graph<CoMMAIndexType, CoMMAWeightType, CoMMAIntType>

Parent class.

◆ CoMMAPairType

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

Type of pair.

◆ CoMMASetOfPairType

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

Type of set of pairs.

◆ ContainerIndexType

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
using comma::Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::ContainerIndexType = std::vector<CoMMAIndexType>

Type for containers of indices.

◆ ContainerWeightType

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
using comma::Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::ContainerWeightType = std::vector<CoMMAWeightType>

Type for containers of weights.

Constructor & Destructor Documentation

◆ Dual_Graph()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::Dual_Graph ( const CoMMAIndexType &  nb_c,
const ContainerIndexType m_crs_row_ptr,
const ContainerIndexType m_crs_col_ind,
const ContainerWeightType m_crs_values,
const ContainerWeightType volumes,
const std::vector< std::vector< CoMMAWeightType > > &  centers,
const std::vector< CoMMAIntType > &  n_bnd_faces,
const CoMMAIntType  dimension,
const ContainerIndexType anisotropic_compliant_fc 
)
inline

Constructor of the class.

Parameters
[in]nb_cNumber of cells
[in]m_crs_row_ptrThe row pointer of the CRS representation
[in]m_crs_col_indThe column index of the CRS representation
[in]m_crs_valuesThe 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]n_bnd_facesVector telling how many boundary faces each cell has
[in]dimensionDimensionality of the problem, 2- or 3D
[in]anisotropic_compliant_fcSet of compliant fc cells (in the most of the case all)

◆ ~Dual_Graph()

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

Destructor of the class.

Member Function Documentation

◆ compute_neighbourhood_of_cc()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::compute_neighbourhood_of_cc ( const std::unordered_set< CoMMAIndexType > &  s_seeds,
CoMMAIntType &  nb_of_order_of_neighbourhood,
std::unordered_map< CoMMAIndexType, CoMMAIntType > &  d_n_of_seed,
const CoMMAIntType  max_card,
const std::vector< bool > &  is_fc_agglomerated_tmp 
) const
inline

Compute the dictionary of compactness of fine cells inside a coarse cell.

Parameters
[in]s_seedsSet of seeds for which the neighbourhood must be computed. Generally they are the fine cells composing the coarse cell for which we are trying to compute the neighbourhood.
[in]nb_of_order_of_neighbourhoodorder Of the neighbourhood at which we want to extend the dictionary
[out]d_n_of_seedDictionary of the neighbourhood given as an output. The key of the associative structure is the index of the fine cell, the value is the order of the distance.
[in]max_cardMaximum cardinality
[in]is_fc_agglomerated_tmpVector reporting the already agglomerated cell, useful in the algorithm

◆ estimated_boundary_weight()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
CoMMAWeightType comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::estimated_boundary_weight ( const CoMMAIndexType  idx_c) const
inline

Approximate the value of a boundary face using the known internal faces. It uses a (geometric) average, so the result is correct only if the cell is a regular polygon.

Parameters
[in]idx_cIndex of the cell
Returns
An approximation of the surface of a boundary face

◆ estimated_total_weight()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
CoMMAWeightType comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::estimated_total_weight ( const CoMMAIndexType  idx_c) const
inline

Sum of wall the weights (faces) of a cell. Since there is no knowledge about boundary faces, the result is correct only if internal cell.

Parameters
[in]idx_cIndex of the cell
Returns
Total weight

◆ get_center_direction()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
CoMMAWeightType comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::get_center_direction ( const CoMMAIndexType &  a,
const CoMMAIndexType &  b,
std::vector< CoMMAWeightType > &  dir 
)
inline

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

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)
Note
This is just a wrapper around get_direction.

◆ get_n_boundary_faces()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
CoMMAIntType comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::get_n_boundary_faces ( const CoMMAIndexType  idx_c) const
inline

Return how many boundary faces a certain cell has.

Parameters
[in]idx_cIndex of the cell
Returns
the number of boundary faces

◆ get_nb_cells()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
CoMMAIndexType comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::get_nb_cells ( ) const
inline

Getter that returns the number of cells.

Returns
number of cells

◆ get_neighbourhood_of_cc()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
std::unordered_set< CoMMAIndexType > comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::get_neighbourhood_of_cc ( const std::unordered_set< CoMMAIndexType > &  s_seeds,
const std::vector< bool > &  is_fc_agglomerated_tmp 
) const
inline

Get the fine cells neighbours of a coarse cell.

Parameters
[in]s_seedsSet of seeds for which the neighbourhood should be computed. Generally they are the fine cells composing the coarse cell for which we are trying to compute the neighbourhood.
[in]is_fc_agglomerated_tmpVector reporting the already agglomerated cell, useful in the algorithm
Returns
The set of neighbours

◆ get_total_n_faces()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
CoMMAIntType comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::get_total_n_faces ( const CoMMAIndexType  idx_c) const
inline

Return total number of faces, that is, number of neighbours plus number of boundaries.

Parameters
[in]idx_cIndex of the cell
Returns
the number of faces

◆ is_on_boundary()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
bool comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::is_on_boundary ( const CoMMAIndexType  idx_c) const
inline

Whether a cell is on the boundary.

Parameters
[in]idx_cIndex of the cell
Returns
Whether a cell is on the boundary

◆ tag_anisotropic_cells()

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
void comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::tag_anisotropic_cells ( std::vector< CoMMAWeightType > &  alt_weights,
ContainerWeightType max_weights,
std::vector< bool > &  is_anisotropic,
std::deque< CoMMAIndexType > &  aniso_seeds_pool,
const CoMMAWeightType  threshold_anisotropy,
const ContainerWeightType priority_weights,
const CoMMACellCouplingT  cell_coupling,
const CoMMAIndexType  preserving 
)
inline

Tag cells as anisotropic if their aspect-ratio is over a given threshold and order them according to given priority.

Parameters
[out]alt_weightsAlternative version of graph edge weights computed if necessary (according to cell_coupling)
[out]max_weightsArray of the maximum weight: the biggest area of the faces composing the given fine cell
[out]is_anisotropicVector of length equal to the total number of cell telling whether a cell is anisotropic
[out]aniso_seeds_poolContainer containing the anisotropic cells in the order they should be considered when computing the lines
[in]threshold_anisotropyValue of the aspect ratio above which a cell is considered anisotropic. If negative, all compliant cells are 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]cell_couplingCoMMACellCouplingT indicating the type of coupling to consider when building anisotropic lines
[in]preservingif 0 does not hit only the BL prism to preserve the boundary layer otherwise 2 for 2D or 3 for the 3D to preserve the BL only in the anisotropic agglomeration

Member Data Documentation

◆ _centers

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
const std::vector<std::vector<CoMMAWeightType> >& comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_centers

Vector of cell centers.

◆ _compute_AR

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
std::function<CoMMAWeightType(const CoMMAWeightType, const CoMMAWeightType)> comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_compute_AR

Function which computes the aspect-ratio from the minimum and maximum faces
In 3D: $ AR = sqrt(\frac{max_{surf}}{min_{surf}}) $
In 2D: $ AR = \frac{max_{surf}}{min_{surf}} $
(Recall that in 2D a face is actually an edge)

◆ _n_bnd_faces

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
const std::vector<CoMMAIntType>& comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_n_bnd_faces

Vector telling how many boundary faces each cell has.

◆ _s_anisotropic_compliant_cells

template<typename CoMMAIndexType , typename CoMMAWeightType , typename CoMMAIntType >
const std::unordered_set<CoMMAIndexType> comma::Dual_Graph< CoMMAIndexType, CoMMAWeightType, CoMMAIntType >::_s_anisotropic_compliant_cells

Elements that are checked if they are anisotropic. If an element satisfies the condition for being anisotropic (typically, AR > threshold) but it not in this set, it will not considered as anisotropic. We use a set to ensure uniqueness.


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