OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::BlockLocalAverage2D< T, W > Class Template Referencefinal

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

#include <blockLocalAverage2D.h>

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

Public Member Functions

 BlockLocalAverage2D (BlockF2D< W > &f, BlockIndicatorF2D< 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::BlockF2D< T >
virtual BlockStructureD< 2 > & getBlockStructure ()
 virtual destructor for defined behaviour
 
void setBlockStructure (BlockStructureD< 2 > *blockStructure)
 
BlockF2D< T > & operator- (BlockF2D< T > &rhs)
 
BlockF2D< T > & operator+ (BlockF2D< T > &rhs)
 
BlockF2D< T > & operator* (BlockF2D< T > &rhs)
 
BlockF2D< T > & operator/ (BlockF2D< T > &rhs)
 
- Public Member Functions inherited from olb::GenericF< T, 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
 
virtual bool operator() (T output[], const int input[])=0
 has to be implemented for 'every' derived class
 
bool operator() (T output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (T output[], int input0)
 
bool operator() (T output[], int input0, int input1)
 
bool operator() (T output[], int input0, int input1, int input2)
 
bool operator() (T output[], int input0, int input1, int input2, int input3)
 

Additional Inherited Members

- Public Types inherited from olb::GenericF< T, int >
using targetType
 
using sourceType
 
- Public Attributes inherited from olb::GenericF< T, int >
std::shared_ptr< GenericF< T, int > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Protected Member Functions inherited from olb::BlockF2D< T >
 BlockF2D (BlockStructureD< 2 > &blockStructure, int targetDim)
 
 BlockF2D (int targetDim)
 
- Protected Member Functions inherited from olb::GenericF< T, int >
 GenericF (int targetDim, int sourceDim)
 
- Protected Attributes inherited from olb::BlockF2D< T >
BlockStructureD< 2 > * _blockStructure
 

Detailed Description

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

Averages given functor inside the local sphere.

Note that the average is calculated over the intersection between local sphere and block cuboid. i.e. results will differ compared to SuperLocalAverage2D if the local sphere intersects the neighboring blocks.

Definition at line 40 of file blockLocalAverage2D.h.

Constructor & Destructor Documentation

◆ BlockLocalAverage2D()

template<typename T , typename W >
olb::BlockLocalAverage2D< T, W >::BlockLocalAverage2D ( BlockF2D< W > & f,
BlockIndicatorF2D< 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 blockLocalAverage2D.hh.

39 : BlockF2D<W>(f.getBlockStructure(), f.getTargetDim()),
40 _f(f),
41 _indicatorF(indicatorF),
42 _radius(radius)
43{
44 this->getName() = "BlockLocalAverage(" + _f.getName() + ")";
45}
virtual BlockStructureD< 2 > & getBlockStructure()
virtual destructor for defined behaviour
int getTargetDim() const
read only access to member variable _n
Definition genericF.hh:45
std::string & getName()
read and write access to name
Definition genericF.hh:51

References olb::GenericF< T, S >::getName(), and olb::GenericF< T, int >::getName().

+ Here is the call graph for this function:

Member Function Documentation

◆ operator()()

template<typename T , typename W >
bool olb::BlockLocalAverage2D< T, W >::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.

Definition at line 48 of file blockLocalAverage2D.hh.

49{
50 const auto& geometry = _indicatorF.getBlockGeometry();
51
52 for (int i = 0; i < this->getTargetDim(); ++i) {
53 output[i] = 0.;
54 }
55
56 if (!_indicatorF(input)) {
57 return true;
58 }
59
60 T centerOfCircle[2];
61 geometry.getPhysR(centerOfCircle, input);
62 IndicatorCircle2D<T> analyticalCircle(centerOfCircle, _radius);
63 BlockIndicatorFfromIndicatorF2D<T> latticeCircle(
64 analyticalCircle,
65 _indicatorF.getBlockGeometry());
66
67 std::size_t voxels(0);
68 int inputTmp[2];
69
70 for (inputTmp[0] = 0; inputTmp[0] < geometry.getNx(); ++inputTmp[0]) {
71 for (inputTmp[1] = 0; inputTmp[1] < geometry.getNy(); ++inputTmp[1]) {
72 if (latticeCircle(inputTmp) && _indicatorF(inputTmp)) {
73 T outputTmp[_f.getTargetDim()];
74 _f(outputTmp, inputTmp);
75 for (int i = 0; i < this->getTargetDim(); ++i) {
76 output[i] += outputTmp[i];
77 }
78 voxels += 1;
79 }
80 }
81 }
82
83 if (voxels > 0) {
84 for (int i = 0; i < this->getTargetDim(); ++i) {
85 output[i] /= voxels;
86 }
87 }
88
89 return true;
90}

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