OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::SuperLocalAverage2D< T, W > Class Template Referencefinal

Averages given functor inside the local sphere. More...

#include <superLocalAverage2D.h>

+ Inheritance diagram for olb::SuperLocalAverage2D< T, W >:
+ Collaboration diagram for olb::SuperLocalAverage2D< T, W >:

Public Member Functions

 SuperLocalAverage2D (FunctorPtr< SuperF2D< T > > &&f, FunctorPtr< SuperIndicatorF2D< T > > &&indicatorF, T radius)
 Primary constructor.
 
bool operator() (W output[], const int input[]) override
 Returns average of functor _f evaluated on all cells both inside a sphere of _radius around input and indicated by _indicatorF.
 
- Public Member Functions inherited from olb::SuperF2D< T, T >
SuperF2D< T, W > & operator- (SuperF2D< T, W > &rhs)
 
SuperF2D< T, W > & operator+ (SuperF2D< T, W > &rhs)
 
SuperF2D< T, W > & operator* (SuperF2D< T, W > &rhs)
 
SuperF2D< T, W > & operator/ (SuperF2D< T, W > &rhs)
 
SuperStructure< T, 2 > & getSuperStructure ()
 
int getBlockFSize () const
 
BlockF2D< W > & getBlockF (int iCloc)
 
- Public Member Functions inherited from olb::GenericF< W, int >
virtual ~GenericF ()=default
 
int getSourceDim () const
 read only access to member variable _m
 
int getTargetDim () const
 read only access to member variable _n
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
bool operator() (W output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (W output[], int input0)
 
bool operator() (W output[], int input0, int input1)
 
bool operator() (W output[], int input0, int input1, int input2)
 
bool operator() (W output[], int input0, int input1, int input2, int input3)
 

Additional Inherited Members

- Public Types inherited from olb::SuperF2D< T, T >
using identity_functor_type
 
- Public Types inherited from olb::GenericF< W, int >
using targetType
 
using sourceType
 
- Public Attributes inherited from olb::GenericF< W, int >
std::shared_ptr< GenericF< W, int > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Protected Member Functions inherited from olb::SuperF2D< T, T >
 SuperF2D (SuperStructure< T, 2 > &superStructure, int targetDim)
 
- Protected Member Functions inherited from olb::GenericF< W, int >
 GenericF (int targetDim, int sourceDim)
 
- Protected Attributes inherited from olb::SuperF2D< T, T >
SuperStructure< T, 2 > & _superStructure
 
std::vector< std::unique_ptr< BlockF2D< W > > > _blockF
 Super functors may consist of several BlockF2D<W> derived functors.
 

Detailed Description

template<typename T, typename W = T>
class olb::SuperLocalAverage2D< T, W >

Averages given functor inside the local sphere.

Definition at line 36 of file superLocalAverage2D.h.

Constructor & Destructor Documentation

◆ SuperLocalAverage2D()

template<typename T , typename W >
olb::SuperLocalAverage2D< T, W >::SuperLocalAverage2D ( FunctorPtr< SuperF2D< T > > && f,
FunctorPtr< SuperIndicatorF2D< T > > && indicatorF,
T radius )

Primary constructor.

Parameters
fFunctor to be locally averaged
indicatorFIndicator describing relevant cells
radiusRadius of the locality sphere

Definition at line 35 of file superLocalAverage2D.hh.

39 : SuperF2D<T,W>(f->getSuperStructure(), f->getTargetDim()),
40 _f(std::move(f)),
41 _indicatorF(std::move(indicatorF)),
42 _radius(radius)
43{
44 this->getName() = "LocalAverage(" + _f->getName() + ")";
45
46 LoadBalancer<T>& load = _f->getSuperStructure().getLoadBalancer();
47
48 if ( _f->getBlockFSize() == load.size() &&
49 _indicatorF->getBlockFSize() == load.size() ) {
50 for (int iC = 0; iC < load.size(); ++iC) {
51 this->_blockF.emplace_back(
52 new BlockLocalAverage2D<T,W>(_f->getBlockF(iC),
53 _indicatorF->getBlockIndicatorF(iC),
54 _radius)
55 );
56 }
57 }
58}
std::string & getName()
Definition genericF.hh:51
std::vector< std::unique_ptr< BlockF2D< W > > > _blockF

References olb::SuperF2D< T, T >::_blockF, olb::GenericF< W, int >::getName(), and olb::LoadBalancer< T >::size().

+ Here is the call graph for this function:

Member Function Documentation

◆ operator()()

template<typename T , typename W >
bool olb::SuperLocalAverage2D< T, W >::operator() ( W output[],
const int input[] )
overridevirtual

Returns average of functor _f evaluated on all cells both inside a sphere of _radius around input and indicated by _indicatorF.

Reimplemented from olb::SuperF2D< T, T >.

Definition at line 61 of file superLocalAverage2D.hh.

62{
63 const auto& geometry = this->getSuperStructure().getCuboidDecomposition();
64 const auto& load = this->getSuperStructure().getLoadBalancer();
65
66 for (int i = 0; i < this->getTargetDim(); ++i) {
67 output[i] = 0.;
68 }
69
70 if (!_indicatorF(input)) {
71 return true;
72 }
73 LatticeR<3> latticeR(input);
74 auto centerOfCircle = geometry.getPhysR(latticeR);
75 IndicatorCircle2D<T> analyticalCircle(centerOfCircle.data(), _radius);
76 SuperIndicatorFfromIndicatorF2D<T> latticeCircle(
77 analyticalCircle,
78 _indicatorF->getSuperGeometry());
79
80 std::size_t voxels(0);
81 int inputTmp[3];
82 std::vector<util::KahanSummator<W>> summators(_f->getTargetDim(), util::KahanSummator<W>());
83
84 for (int iC = 0; iC < load.size(); ++iC) {
85 inputTmp[0] = load.glob(iC);
86 const auto& cuboid = geometry.get(inputTmp[0]);
87
88 for (inputTmp[1] = 0; inputTmp[1] < cuboid.getNx(); ++inputTmp[1]) {
89 for (inputTmp[2] = 0; inputTmp[2] < cuboid.getNy(); ++inputTmp[2]) {
90 if (latticeCircle(inputTmp) && _indicatorF(inputTmp)) {
91 T outputTmp[_f->getTargetDim()];
92 _f(outputTmp, inputTmp);
93 for (int i = 0; i < this->getTargetDim(); ++i) {
94 summators[i].add(outputTmp[i]);
95 }
96 voxels += 1;
97 }
98 }
99 }
100 }
101
102 for (int i = 0; i < _f->getTargetDim(); ++i) {
103 output[i] = summators[i].getSum();
104 }
105
106#ifdef PARALLEL_MODE_MPI
107 singleton::mpi().reduceAndBcast(voxels, MPI_SUM);
108#endif
109
110 if (voxels > 0) {
111 for (int i = 0; i < this->getTargetDim(); ++i) {
112#ifdef PARALLEL_MODE_MPI
113 singleton::mpi().reduceAndBcast(output[i], MPI_SUM);
114#endif
115 output[i] /= voxels;
116 }
117 }
118
119 return true;
120}
int getTargetDim() const
Definition genericF.hh:45
SuperStructure< T, 2 > & getSuperStructure()
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
CuboidDecomposition< T, D > & getCuboidDecomposition()
Read and write access to cuboid geometry.
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
MpiManager & mpi()
Vector< std::int32_t, D > LatticeR
Type for spatial block-local lattice coordinates.

References olb::singleton::mpi(), and olb::singleton::MpiManager::reduceAndBcast().

+ Here is the call graph for this function:

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