CoMMA 1.3.2
A geometric agglomerator for unstructured meshes
Loading...
Searching...
No Matches
Util.h File Reference
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include "CoMMA/Args.h"

Go to the source code of this file.

Classes

struct  comma::CustomPairLessFunctor< PairT >
 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...
 
struct  comma::CustomPairGreaterFunctor< PairT >
 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  comma::PairSecondBasedLessFunctor< PairT >
 Functor for pairs implementing a less operator based only on the second element of the pair. More...
 
class  comma::PairFindFirstBasedFunctor< PairT >
 Functor implementing an operator telling if a given value if the first one of pair. More...
 

Namespaces

namespace  comma
 

Macros

#define CoMMAUnused(var)   (void)(var)
 Convenient function to avoid unused warnings. More...
 

Functions

template<typename T >
T constexpr comma::_sq (const T x)
 Square. More...
 
template<typename T >
T constexpr comma::_cb (const T x)
 Cube. More...
 
template<unsigned int p, typename T >
T constexpr comma::int_power (const T x)
 Raise a quantity to an integer power. More...
 
template<typename T >
bool constexpr comma::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 >
comma::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 >
comma::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 >
comma::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 > comma::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 > comma::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 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)
 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 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. More...
 
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. More...
 

Variables

constexpr double comma::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...
 

Macro Definition Documentation

◆ CoMMAUnused

#define CoMMAUnused (   var)    (void)(var)

Convenient function to avoid unused warnings.