24#ifndef SUPER_INTEGRAL_F_2D_HH
25#define SUPER_INTEGRAL_F_2D_HH
38template <
typename T,
typename W>
41 :
SuperF2D<T,W>(f->getSuperStructure(), f->getTargetDim()+1),
43 _indicatorF(std::move(indicatorF))
45 this->
getName() =
"Sum("+_f->getName()+
")";
49 if ( _f->getBlockFSize() == load.
size() &&
50 _indicatorF->getBlockFSize() == load.
size() ) {
51 for (
int iC = 0; iC < load.
size(); ++iC) {
54 _indicatorF->getBlockIndicatorF(iC))
60template <
typename T,
typename W>
65 std::forward<decltype(f)>(f),
66 superGeometry.getMaterialIndicator(material))
69template <
typename T,
typename W>
76 for (
int i = 0; i < this->getTargetDim(); ++i) {
80 if (this->_blockF.empty()) {
81 W outputTmp[_f->getTargetDim()];
82 int inputTmp[_f->getSourceDim()];
83 std::size_t voxels(0);
85 for (
int iC = 0; iC < load.
size(); ++iC) {
87 inputTmp[0] = load.
glob(iC);
88 for (inputTmp[1] = 0; inputTmp[1] < cuboid.
getNx(); ++inputTmp[1]) {
89 for (inputTmp[2] = 0; inputTmp[2] < cuboid.
getNy(); ++inputTmp[2]) {
90 if (_indicatorF(inputTmp)) {
91 _f(outputTmp,inputTmp);
92 for (
int i = 0; i < _f->getTargetDim(); ++i) {
93 output[i] += outputTmp[i];
100 output[_f->getTargetDim()] = voxels;
103 for (
int iC = 0; iC < load.
size(); ++iC) {
104 this->getBlockF(iC)(output, input);
108#ifdef PARALLEL_MODE_MPI
109 for (
int i = 0; i < this->getTargetDim(); ++i) {
110 singleton::mpi().reduceAndBcast(output[i], MPI_SUM);
117template <
typename T,
typename W>
120 :
SuperF2D<T,W>(f->getSuperStructure(), f->getTargetDim()),
122 _indicatorF(std::move(indicatorF))
124 this->
getName() =
"Integral("+_f->getName()+
")";
128 if ( _f->getBlockFSize() == load.
size() &&
129 _indicatorF->getBlockFSize() == load.
size() ) {
130 for (
int iC = 0; iC < load.
size(); ++iC) {
133 _indicatorF->getBlockIndicatorF(iC))
139template <
typename T,
typename W>
144 std::forward<decltype(f)>(f),
145 superGeometry.getMaterialIndicator(material))
148template <
typename T,
typename W>
155 for (
int i = 0; i < this->getTargetDim(); ++i) {
159 if (this->_blockF.empty()) {
160 W outputTmp[_f->getTargetDim()];
161 int inputTmp[_f->getSourceDim()];
163 for (
int iC = 0; iC < load.
size(); ++iC) {
165 const W weight = pow(cuboid.
getDeltaR(), 2);
166 inputTmp[0] = load.
glob(iC);
167 for (inputTmp[1] = 0; inputTmp[1] < cuboid.
getNx(); ++inputTmp[1]) {
168 for (inputTmp[2] = 0; inputTmp[2] < cuboid.
getNy(); ++inputTmp[2]) {
169 if (_indicatorF(inputTmp)) {
170 _f(outputTmp,inputTmp);
171 for (
int i = 0; i < this->getTargetDim(); ++i) {
172 output[i] += outputTmp[i] * weight;
180 for (
int iC = 0; iC < load.
size(); ++iC) {
181 this->getBlockF(iC)(output, input);
185#ifdef PARALLEL_MODE_MPI
186 for (
int i = 0; i < this->getTargetDim(); ++i) {
BlockIntegral2D integrates f on a indicated subset.
BlockSum2D sums all components of f over a indicated subset.
A regular single 2D cuboid is the basic component of a 2D cuboid structure which defines the grid.
T getDeltaR() const
Read access to the distance of cuboid nodes.
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.
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.
SuperIntegral2D integrates f on a indicated subset.
bool operator()(W output[], const int input[]) override
SuperIntegral2D(FunctorPtr< SuperF2D< T, W > > &&f, FunctorPtr< SuperIndicatorF2D< T > > &&indicatorF)
Constructor for integrating f on a indicated subset.
virtual void communicate()
SuperSum2D sums all components of f over a indicated subset.
SuperSum2D(FunctorPtr< SuperF2D< T, W > > &&f, FunctorPtr< SuperIndicatorF2D< T > > &&indicatorF)
Constructor for summing f on a indicated subset.
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.