libMesh
Public Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
libMesh::Parallel::Histogram< KeyType, IdxType > Class Template Reference

Defines a histogram to be used in parallel in conjunction with a BinSorter. More...

#include <parallel_histogram.h>

Inheritance diagram for libMesh::Parallel::Histogram< KeyType, IdxType >:
[legend]

Public Member Functions

 Histogram (const Parallel::Communicator &comm, const std::vector< KeyType > &d)
 Constructor. More...
 
void make_histogram (const IdxType nbins, KeyType max, KeyType min)
 The actual function which sorts the data into nbins. More...
 
void build_histogram ()
 Build the histogram across all processors and store the result in the input vector hist. More...
 
const std::vector< IdxType > & get_histogram () const
 
IdxType n_bins () const
 The number of bins in the histogram. More...
 
IdxType local_bin_size (const IdxType bin) const
 
IdxType global_bin_size (const IdxType bin) const
 
double lower_bound (const IdxType bin) const
 
double upper_bound (const IdxType bin) const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Attributes

const Parallel::Communicator_communicator
 

Private Types

typedef std::vector< KeyType >::const_iterator IterType
 

Private Attributes

const std::vector< KeyType > & data
 
std::vector< IdxType > hist
 
std::vector< double > bin_bounds
 
std::vector< IterTypebin_iters
 

Detailed Description

template<typename KeyType, typename IdxType = unsigned int>
class libMesh::Parallel::Histogram< KeyType, IdxType >

Defines a histogram to be used in parallel in conjunction with a BinSorter.

Author
Benjamin S. Kirk
John W. Peterson
Date
2007 Used in conjunction with a BinSorter for parallel sorting.

Definition at line 51 of file parallel_histogram.h.

Member Typedef Documentation

◆ IterType

template<typename KeyType , typename IdxType = unsigned int>
typedef std::vector<KeyType>::const_iterator libMesh::Parallel::Histogram< KeyType, IdxType >::IterType
private

Definition at line 54 of file parallel_histogram.h.

Constructor & Destructor Documentation

◆ Histogram()

template<typename KeyType , typename IdxType = unsigned int>
libMesh::Parallel::Histogram< KeyType, IdxType >::Histogram ( const Parallel::Communicator comm,
const std::vector< KeyType > &  d 
)
explicit

Constructor.

Member Function Documentation

◆ build_histogram()

template<typename KeyType , typename IdxType = unsigned int>
void libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram ( )

Build the histogram across all processors and store the result in the input vector hist.

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited

◆ get_histogram()

template<typename KeyType , typename IdxType >
const std::vector< IdxType > & libMesh::Parallel::Histogram< KeyType, IdxType >::get_histogram ( ) const
Returns
The raw histogram data to the user.

Definition at line 125 of file parallel_histogram.h.

126 {
127  return hist;
128 }
std::vector< IdxType > hist

◆ global_bin_size()

template<typename KeyType , typename IdxType >
IdxType libMesh::Parallel::Histogram< KeyType, IdxType >::global_bin_size ( const IdxType  bin) const
Returns
The size of global bin bin.

Requires that the user first call build_histogram().

Definition at line 159 of file parallel_histogram.h.

160 {
161  libmesh_assert_less (bin, hist.size());
162 
163  // The number of entries in the bin (globally)
164  return hist[bin];
165 }
std::vector< IdxType > hist

◆ local_bin_size()

template<typename KeyType , typename IdxType >
IdxType libMesh::Parallel::Histogram< KeyType, IdxType >::local_bin_size ( const IdxType  bin) const
Returns
The size of local bin bin.

Definition at line 146 of file parallel_histogram.h.

147 {
148  libmesh_assert_less ((bin+1), bin_iters.size());
149 
150  // The number of entries in the bin (locally)
151  return cast_int<IdxType>
152  (std::distance (bin_iters[bin], bin_iters[bin+1]));
153 }
std::vector< IterType > bin_iters

◆ lower_bound()

template<typename KeyType , typename IdxType >
double libMesh::Parallel::Histogram< KeyType, IdxType >::lower_bound ( const IdxType  bin) const
Returns
The lower boundary of bin bin.

Definition at line 171 of file parallel_histogram.h.

172 {
173  libmesh_assert_less ((bin+1), bin_bounds.size());
174 
175  return bin_bounds[bin];
176 }
std::vector< double > bin_bounds

◆ make_histogram()

template<typename KeyType , typename IdxType = unsigned int>
void libMesh::Parallel::Histogram< KeyType, IdxType >::make_histogram ( const IdxType  nbins,
KeyType  max,
KeyType  min 
)

The actual function which sorts the data into nbins.

Currently based on the global min and max which you must provide e.g. by using MPI.

◆ n_bins()

template<typename KeyType , typename IdxType >
IdxType libMesh::Parallel::Histogram< KeyType, IdxType >::n_bins ( ) const

The number of bins in the histogram.

Definition at line 134 of file parallel_histogram.h.

135 {
136  if (bin_iters.empty())
137  return 0;
138 
139  return cast_int<IdxType>(bin_iters.size()-1);
140 }
std::vector< IterType > bin_iters

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::MeshBase::partition().

94  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited

◆ upper_bound()

template<typename KeyType , typename IdxType >
double libMesh::Parallel::Histogram< KeyType, IdxType >::upper_bound ( const IdxType  bin) const
Returns
The upper boundary of bin bin.

Definition at line 182 of file parallel_histogram.h.

183 {
184  libmesh_assert_less ((bin+1), bin_bounds.size());
185 
186  return bin_bounds[bin+1];
187 }
std::vector< double > bin_bounds

Member Data Documentation

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ bin_bounds

template<typename KeyType , typename IdxType = unsigned int>
std::vector<double> libMesh::Parallel::Histogram< KeyType, IdxType >::bin_bounds
private

Definition at line 117 of file parallel_histogram.h.

◆ bin_iters

template<typename KeyType , typename IdxType = unsigned int>
std::vector<IterType> libMesh::Parallel::Histogram< KeyType, IdxType >::bin_iters
private

Definition at line 118 of file parallel_histogram.h.

◆ data

template<typename KeyType , typename IdxType = unsigned int>
const std::vector<KeyType>& libMesh::Parallel::Histogram< KeyType, IdxType >::data
private

Definition at line 115 of file parallel_histogram.h.

◆ hist

template<typename KeyType , typename IdxType = unsigned int>
std::vector<IdxType> libMesh::Parallel::Histogram< KeyType, IdxType >::hist
private

Definition at line 116 of file parallel_histogram.h.


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