23 #include "libmesh/libmesh_common.h"    24 #include "libmesh/parallel.h"    25 #include "libmesh/parallel_bin_sorter.h"    26 #include "libmesh/parallel_hilbert.h"    27 #include "libmesh/parallel_histogram.h"    28 #include "libmesh/parallel_conversion_utils.h"    37 template <
typename KeyType, 
typename IdxType>
    39                                        const std::vector<KeyType> & d) :
    48 template <
typename KeyType, 
typename IdxType>
    53   libmesh_assert_less (min, max);
    61   const std::vector<IdxType> & histogram =
    69     IdxType local_data_size = cast_int<IdxType>(data.size());
    70     IdxType global_data_size = cast_int<IdxType>(local_data_size);
    72     this->comm().sum(global_data_size);
    74     std::vector<IdxType> target_bin_size (nbins, global_data_size / nbins);
    77     for (IdxType i=0; i<(global_data_size % nbins); i++)
    82       std::vector<double> bin_bounds (nbins+1);
    83       bin_iters.resize  (nbins+1, data.begin());
    86       bin_iters[0]  = data.begin();
    90       IdxType current_histogram_bin = 0;
   100       for (IdxType b=0; b<nbins; ++b)
   104           int current_bin_size = 0;
   108           while ((current_bin_size +
   109                   cast_int<int>(histogram[current_histogram_bin]) +
   110                   delta) <= cast_int<int>(target_bin_size[b]))
   113               if ((current_histogram_bin+1) == phist.
n_bins())
   116               current_bin_size += histogram[current_histogram_bin++];
   119           delta += current_bin_size - 
static_cast<int>(target_bin_size[b]);
   122           bin_bounds[b+1] = phist.
upper_bound (current_histogram_bin);
   124             std::lower_bound(bin_iters[b], data.end(),
   129       bin_iters[nbins]  = data.end();
   142 #ifdef LIBMESH_HAVE_LIBHILBERT BinSorter(const Parallel::Communicator &comm, const std::vector< KeyType > &d)
const std::vector< KeyType > & data
IdxType n_bins() const
The number of bins in the histogram. 
The libMesh namespace provides an interface to certain functionality in the library. 
void build_histogram()
Build the histogram across all processors and store the result in the input vector hist...
double upper_bound(const IdxType bin) const
bool is_sorted(const std::vector< KeyType > &v)
void make_histogram(const IdxType nbins, KeyType max, KeyType min)
The actual function which sorts the data into nbins. 
Perform a parallel sort using a bin-sort method. 
An object whose state is distributed along a set of processors. 
static KeyType to_key_type(const double f)
Defines a histogram to be used in parallel in conjunction with a BinSorter. 
double to_double(const KeyType &k)
A utility function which converts whatever KeyType is to a double for the histogram bounds...
void binsort(const IdxType nbins, KeyType max, KeyType min)
The actual function which sorts the data into nbins. 
const std::vector< IdxType > & get_histogram() const