24#ifndef SUPER_AVERAGE_2D_HH
25#define SUPER_AVERAGE_2D_HH
33template <
typename T,
typename W>
36 :
SuperF2D<T,W>(f->getSuperStructure(), f->getTargetDim()+1),
38 _indicatorF(std::move(indicatorF))
40 this->
getName() =
"Average("+_f->getName()+
")";
44 if ( _f->getBlockFSize() == load.
size() &&
45 _indicatorF->getBlockFSize() == load.
size() ) {
46 for (
int iC = 0; iC < load.
size(); ++iC) {
49 _indicatorF->getBlockIndicatorF(iC))
55template <
typename T,
typename W>
60 std::forward<decltype(f)>(f),
61 superGeometry.getMaterialIndicator(material))
64template <
typename T,
typename W>
71 for (
int i = 0; i < _f->getTargetDim(); ++i) {
75 W outputTmp[_f->getTargetDim()];
76 int inputTmp[_f->getSourceDim()];
77 std::size_t voxels(0);
79 for (
int iC = 0; iC < load.
size(); ++iC) {
81 inputTmp[0] = load.
glob(iC);
82 for (inputTmp[1] = 0; inputTmp[1] < cuboid.
getNx(); ++inputTmp[1]) {
83 for (inputTmp[2] = 0; inputTmp[2] < cuboid.
getNy(); ++inputTmp[2]) {
84 if (_indicatorF(inputTmp)) {
85 _f(outputTmp,inputTmp);
86 for (
int i = 0; i < _f->getTargetDim(); ++i) {
87 output[i] += outputTmp[i];
96#ifdef PARALLEL_MODE_MPI
97 for (
int i = 0; i < _f->getTargetDim(); ++i) {
103 output[_f->getTargetDim()] = voxels;
104 for (
int i = 0; i < _f->getTargetDim(); ++i) {
105 output[i] /= output[_f->getTargetDim()];
BlockAverage2D returns the average in each component of f on a indicated subset.
A regular single 2D cuboid is the basic component of a 2D cuboid structure which defines the grid.
int getNx() const
Read access to cuboid width.
int getNy() const
Read access to cuboid height.
A cuboid structure represents the grid of a considered domain.
Cuboid2D< T > & get(int i)
Read and write access to the cuboids.
Smart pointer for managing the various ways of passing functors around.
std::string & getName()
read and write access to name
Base class for all LoadBalancer.
SuperAverage2D returns the average in each component of f on a indicated subset.
bool operator()(W output[], const int input[]) override
Global average operator.
SuperAverage2D(FunctorPtr< SuperF2D< T, W > > &&f, FunctorPtr< SuperIndicatorF2D< T > > &&indicatorF)
Constructor for determining the average of f on a indicated subset.
represents all functors that operate on a SuperStructure<T,2> in general
std::vector< std::unique_ptr< BlockF2D< W > > > _blockF
Super functors may consist of several BlockF2D<W> derived functors.
SuperStructure< T, 2 > & getSuperStructure()
Representation of a statistic for a parallel 2D geometry.
virtual void communicate()
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
Top level namespace for all of OpenLB.