8 #ifndef DISTRIBUTION_DISTRIBUTION_H_
9 #define DISTRIBUTION_DISTRIBUTION_H_
14 #include "eckit/config/Configuration.h"
15 #include "eckit/exception/Exceptions.h"
16 #include "eckit/geometry/Point2.h"
17 #include "eckit/mpi/Comm.h"
18 #include "oops/util/missingValues.h"
19 #include "oops/util/TypeTraits.h"
80 virtual void assignRecord(
const std::size_t RecNum,
const std::size_t LocNum,
81 const eckit::geometry::Point2 & point) {}
108 virtual void patchObs(std::vector<bool> & isPatchObs)
const = 0;
118 virtual void min(
int & x)
const = 0;
119 virtual void min(std::size_t & x)
const = 0;
120 virtual void min(
float & x)
const = 0;
121 virtual void min(
double & x)
const = 0;
132 virtual void min(std::vector<int> & x)
const = 0;
133 virtual void min(std::vector<std::size_t> & x)
const = 0;
134 virtual void min(std::vector<float> & x)
const = 0;
135 virtual void min(std::vector<double> & x)
const = 0;
145 virtual void max(
int & x)
const = 0;
146 virtual void max(std::size_t & x)
const = 0;
147 virtual void max(
float & x)
const = 0;
148 virtual void max(
double & x)
const = 0;
159 virtual void max(std::vector<int> & x)
const = 0;
160 virtual void max(std::vector<std::size_t> & x)
const = 0;
161 virtual void max(std::vector<float> & x)
const = 0;
162 virtual void max(std::vector<double> & x)
const = 0;
174 template <
typename T>
176 static_assert(util::any_is_same<T, int, std::size_t, float, double>::value,
177 "in the call to createAccumulator<T>(), "
178 "T must be int, size_t, float or double");
192 template <
typename T>
194 static_assert(util::any_is_same<T, int, std::size_t, float, double>::value,
195 "in the call to createAccumulator<T>(size_t n), "
196 "T must be int, size_t, float or double");
215 virtual void allGatherv(std::vector<util::DateTime> &x)
const = 0;
216 virtual void allGatherv(std::vector<std::string> &x)
const = 0;
225 virtual std::string
name()
const = 0;
239 virtual std::unique_ptr<Accumulator<int>>
241 virtual std::unique_ptr<Accumulator<std::size_t>>
243 virtual std::unique_ptr<Accumulator<float>>
245 virtual std::unique_ptr<Accumulator<double>>
257 virtual std::unique_ptr<Accumulator<std::vector<int>>>
259 virtual std::unique_ptr<Accumulator<std::vector<std::size_t>>>
261 virtual std::unique_ptr<Accumulator<std::vector<float>>>
263 virtual std::unique_ptr<Accumulator<std::vector<double>>>
class for distributing obs across multiple process elements
virtual void min(std::vector< std::size_t > &x) const =0
virtual bool isIdentity() const
Returns true if the distribution assigns all records to all PEs, false otherwise.
virtual void max(int &x) const =0
Calculates the global maximum (over all locations on all PEs) of a location-dependent quantity.
std::unique_ptr< Accumulator< std::vector< T > > > createAccumulator(std::size_t n) const
Create an object that can be used to calculate the sums of n location-dependent quantities over locat...
virtual void allGatherv(std::vector< size_t > &x) const =0
Gather observation data from all processes and deliver the combined data to all processes.
virtual void max(std::size_t &x) const =0
virtual bool isNonoverlapping() const
Returns true if the distribution does not assign any record to more than one PE, false otherwise.
const eckit::mpi::Comm & comm_
Local MPI communicator.
virtual void allGatherv(std::vector< util::DateTime > &x) const =0
virtual void min(std::vector< double > &x) const =0
virtual std::unique_ptr< Accumulator< int > > createAccumulatorImpl(int init) const =0
Create an object that can be used to calculate the sum of a location-dependent quantity over location...
virtual void allGatherv(std::vector< int > &x) const =0
virtual std::unique_ptr< Accumulator< std::vector< float > > > createAccumulatorImpl(const std::vector< float > &init) const =0
virtual std::unique_ptr< Accumulator< std::vector< double > > > createAccumulatorImpl(const std::vector< double > &init) const =0
virtual void max(double &x) const =0
virtual std::string name() const =0
virtual void patchObs(std::vector< bool > &isPatchObs) const =0
Sets each element of the provided vector to true if the corresponding location is a "patch obs",...
virtual std::unique_ptr< Accumulator< std::size_t > > createAccumulatorImpl(std::size_t init) const =0
virtual void max(std::vector< int > &x) const =0
Calculates the global maxima (over all locations on all PEs) of multiple location-dependent quantitie...
virtual bool isMyRecord(std::size_t RecNum) const =0
Returns true if record RecNum has been assigned to the calling PE during a previous call to assignRec...
size_t rank() const
Accessor to MPI rank.
virtual void allGatherv(std::vector< std::string > &x) const =0
Distribution(const eckit::mpi::Comm &Comm)
virtual void min(int &x) const =0
Calculates the global minimum (over all locations on all PEs) of a location-dependent quantity.
virtual void allGatherv(std::vector< double > &x) const =0
virtual void allGatherv(std::vector< float > &x) const =0
virtual void min(std::vector< float > &x) const =0
virtual void min(std::vector< int > &x) const =0
Calculates the global minima (over all locations on all PEs) of multiple location-dependent quantitie...
virtual void min(std::size_t &x) const =0
virtual void max(float &x) const =0
virtual void min(float &x) const =0
virtual void max(std::vector< std::size_t > &x) const =0
virtual void max(std::vector< double > &x) const =0
virtual void max(std::vector< float > &x) const =0
virtual size_t globalUniqueConsecutiveLocationIndex(size_t loc) const =0
Map the index of a location held on the calling process to the index of the corresponding element of ...
virtual std::unique_ptr< Accumulator< std::vector< std::size_t > > > createAccumulatorImpl(const std::vector< std::size_t > &init) const =0
virtual std::unique_ptr< Accumulator< std::vector< int > > > createAccumulatorImpl(const std::vector< int > &init) const =0
Create an object that can be used to calculate the sums of multiple location-dependent quantities ove...
virtual void assignRecord(const std::size_t RecNum, const std::size_t LocNum, const eckit::geometry::Point2 &point)
If the record RecNum has not yet been assigned to a PE, assigns it to the appropriate PE.
std::unique_ptr< Accumulator< T > > createAccumulator() const
Create an object that can be used to calculate the sum of a location-dependent quantity over location...
virtual void computePatchLocs()
If necessary, identifies locations of "patch obs", i.e.
virtual std::unique_ptr< Accumulator< float > > createAccumulatorImpl(float init) const =0
virtual std::unique_ptr< Accumulator< double > > createAccumulatorImpl(double init) const =0
virtual void min(double &x) const =0