libMesh
Classes | Functions
libMesh::Parallel::Utils Namespace Reference

Classes

struct  Convert
 A utility to convert a double to some sort of KeyType, for interpreting how histogram bounds relate to KeyType positions. More...
 
struct  Convert< Hilbert::HilbertIndices >
 
struct  Convert< std::pair< FirstKeyType, SecondKeyType > >
 A pseudoinverse for converting bounds back to pairs of key types. More...
 

Functions

template<typename KeyType >
bool is_sorted (const std::vector< KeyType > &v)
 
template<typename KeyType >
double to_double (const KeyType &k)
 A utility function which converts whatever KeyType is to a double for the histogram bounds. More...
 
template<typename FirstKeyType , typename SecondKeyType >
double to_double (const std::pair< FirstKeyType, SecondKeyType > &k)
 A utility function for pairs of key types. More...
 
template<>
double to_double (const Hilbert::HilbertIndices &bvt)
 

Function Documentation

◆ is_sorted()

template<typename KeyType >
bool libMesh::Parallel::Utils::is_sorted ( const std::vector< KeyType > &  v)
inline
Returns
true if the vector v is sorted, false otherwise.

Requires O(N) comparisons, where N is the length of the vector. This was implemented because std::is_sorted() was an STL extension at the time.

Definition at line 52 of file parallel_conversion_utils.h.

53 {
54  if (v.empty())
55  return true;
56 
57  for (auto i : IntRange<std::size_t>(1, v.size()))
58  if (v[i] < v[i-1])
59  return false;
60 
61  return true;
62 }

Referenced by libMesh::Parallel::BinSorter< KeyType, IdxType >::BinSorter(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::Parallel::Histogram< KeyType, IdxType >::Histogram(), and ParallelSortTest::testSort().

◆ to_double() [1/3]

template<>
double libMesh::Parallel::Utils::to_double ( const Hilbert::HilbertIndices &  bvt)
inline

Definition at line 122 of file parallel_conversion_utils.h.

123 {
124  return static_cast<double>(bvt.rack2);
125 }

◆ to_double() [2/3]

template<typename KeyType >
double libMesh::Parallel::Utils::to_double ( const KeyType &  k)
inline

A utility function which converts whatever KeyType is to a double for the histogram bounds.

Definition at line 70 of file parallel_conversion_utils.h.

71 {
72  return static_cast<double>(k);
73 }

Referenced by libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Histogram< KeyType, IdxType >::make_histogram(), and to_double().

◆ to_double() [3/3]

template<typename FirstKeyType , typename SecondKeyType >
double libMesh::Parallel::Utils::to_double ( const std::pair< FirstKeyType, SecondKeyType > &  k)
inline

A utility function for pairs of key types.

When finding bounds, the second entry of the pair is effectively "rounded away".

Definition at line 112 of file parallel_conversion_utils.h.

113 {
114  return to_double(k.first);
115 }

References to_double().

libMesh::Parallel::Utils::to_double
double to_double(const Hilbert::HilbertIndices &bvt)
Definition: parallel_conversion_utils.h:122