OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
olb::SuperCalcF2D< T, W, F > Class Template Reference

Arithmetic operations for SuperF2D functors. More...

#include <superCalcF2D.h>

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

Public Member Functions

 SuperCalcF2D (FunctorPtr< SuperF2D< T, W > > &&f, FunctorPtr< SuperF2D< T, W > > &&g)
 
 SuperCalcF2D (W scalar, FunctorPtr< SuperF2D< T, W > > &&g)
 
 SuperCalcF2D (FunctorPtr< SuperF2D< T, W > > &&f, W scalar)
 
bool operator() (W output[], const int input[]) override
 has to be implemented for 'every' derived class
 
- Public Member Functions inherited from olb::SuperF2D< T, W >
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)
 
bool operator() (W output[], const int input[]) override
 
- 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)
 

Protected Attributes

FunctorPtr< SuperF2D< T, W > > _f
 
FunctorPtr< SuperF2D< T, W > > _g
 
- Protected Attributes inherited from olb::SuperF2D< T, W >
SuperStructure< T, 2 > & _superStructure
 
std::vector< std::unique_ptr< BlockF2D< W > > > _blockF
 Super functors may consist of several BlockF2D<W> derived functors.
 

Additional Inherited Members

- Public Types inherited from olb::SuperF2D< T, W >
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, W >
 SuperF2D (SuperStructure< T, 2 > &superStructure, int targetDim)
 
- Protected Member Functions inherited from olb::GenericF< W, int >
 GenericF (int targetDim, int sourceDim)
 

Detailed Description

template<typename T, typename W, template< typename > class F>
class olb::SuperCalcF2D< T, W, F >

Arithmetic operations for SuperF2D functors.

Template Parameters
FFunction object defining the arithmetic operation to be perfomed e.g. std::minus for substraction

Block level functors are instantiated for operations if at least one input functor exposes block level functors. See BlockCalcF2D

Global queries are not delegated to block level functors to prevent unnecessary synchronization.

Warning: Allocation error possible in functors that have multiple functor evaluation like SuperSum2D

Definition at line 55 of file superCalcF2D.h.

Constructor & Destructor Documentation

◆ SuperCalcF2D() [1/3]

template<typename T , typename W , template< typename > class F>
olb::SuperCalcF2D< T, W, F >::SuperCalcF2D ( FunctorPtr< SuperF2D< T, W > > && f,
FunctorPtr< SuperF2D< T, W > > && g )

Definition at line 36 of file superCalcF2D.hh.

38 : SuperF2D<T,W>(
39 f->getSuperStructure(),
40 f->getTargetDim() > g->getTargetDim() ? f->getTargetDim() : g->getTargetDim()),
41 _f(std::move(f)),
42 _g(std::move(g))
43{
45 _f->getTargetDim() == _g->getTargetDim() || _f->getTargetDim() == 1 || _g->getTargetDim() == 1,
46 "Componentwise operation must be well defined.");
47
48 this->getName() = "(" + _f->getName() + F<T>::symbol + _g->getName() + ")";
49
50 std::swap(_f->_ptrCalcC, this->_ptrCalcC);
51
52 LoadBalancer<T>& load = _f->getSuperStructure().getLoadBalancer();
53
54 if ( _f->getBlockFSize() == load.size() ) {
55 if ( _g->getBlockFSize() == load.size() ) {
56 // both functors expose the correct count of block level functors
57 for (int iC = 0; iC < load.size(); ++iC) {
58 this->_blockF.emplace_back(
59 new BlockCalcF2D<W,F>(_f->getBlockF(iC), _g->getBlockF(iC))
60 );
61 }
62 }
63 else {
64 // operate on super functor `g` and block level functors provided by `f`
65 for (int iC = 0; iC < load.size(); ++iC) {
66 this->_blockF.emplace_back(
67 new BlockCalcF2D<W,F>(_f->getBlockF(iC), *g, load.glob(iC))
68 );
69 }
70 }
71 }
72 else if ( _g->getBlockFSize() == load.size() ) {
73 // operate on block level functors provided by `f` and super functor `g`
74 for (int iC = 0; iC < load.size(); ++iC) {
75 this->_blockF.emplace_back(
76 new BlockCalcF2D<W,F>(*f, load.glob(iC), _g->getBlockF(iC))
77 );
78 }
79 }
80}
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
FunctorPtr< SuperF2D< T, W > > _g
FunctorPtr< SuperF2D< T, W > > _f
std::vector< std::unique_ptr< BlockF2D< W > > > _blockF
Super functors may consist of several BlockF2D<W> derived functors.
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45

References olb::SuperF2D< T, W >::_blockF, olb::SuperCalcF2D< T, W, F >::_f, olb::SuperCalcF2D< T, W, F >::_g, olb::GenericF< W, int >::getName(), OLB_ASSERT, and olb::LoadBalancer< T >::size().

+ Here is the call graph for this function:

◆ SuperCalcF2D() [2/3]

template<typename T , typename W , template< typename > class F>
olb::SuperCalcF2D< T, W, F >::SuperCalcF2D ( W scalar,
FunctorPtr< SuperF2D< T, W > > && g )

Definition at line 83 of file superCalcF2D.hh.

85 std::unique_ptr<SuperF2D<T,W>>(new SuperConst2D<T,W>(g->getSuperStructure(), scalar)),
86 std::forward<decltype(g)>(g))
87{ }
SuperCalcF2D(FunctorPtr< SuperF2D< T, W > > &&f, FunctorPtr< SuperF2D< T, W > > &&g)

◆ SuperCalcF2D() [3/3]

template<typename T , typename W , template< typename > class F>
olb::SuperCalcF2D< T, W, F >::SuperCalcF2D ( FunctorPtr< SuperF2D< T, W > > && f,
W scalar )

Definition at line 90 of file superCalcF2D.hh.

92 std::forward<decltype(f)>(f),
93 std::unique_ptr<SuperF2D<T,W>>(new SuperConst2D<T,W>(f->getSuperStructure(), scalar)))
94{ }

Member Function Documentation

◆ operator()()

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

has to be implemented for 'every' derived class

Implements olb::GenericF< W, int >.

Definition at line 97 of file superCalcF2D.hh.

98{
99 if ( _f->getTargetDim() == 1 || _g->getTargetDim() == 1 ) {
100 // scalar operation
101 W scalar;
102 if ( _f->getTargetDim() == 1 ) {
103 // apply the scalar f to possibly multidimensional g
104 _f(&scalar, input);
105 _g(output, input);
106
107 for (int i = 0; i < this->getTargetDim(); i++) {
108 output[i] = F<T>()(scalar, output[i]);
109 }
110 }
111 else {
112 // apply scalar g to possibly multidimensional f
113 _f(output, input);
114 _g(&scalar, input);
115
116 for (int i = 0; i < this->getTargetDim(); i++) {
117 output[i] = F<T>()(output[i], scalar);
118 }
119 }
120 }
121 else {
122 // componentwise operation on equidimensional functors
123 W* outputF = output;
124 W outputG[this->getTargetDim()];
125
126 _f(outputF, input);
127 _g(outputG, input);
128
129 for (int i = 0; i < this->getTargetDim(); i++) {
130 output[i] = F<T>()(outputF[i], outputG[i]);
131 }
132 }
133 return true;
134}

Member Data Documentation

◆ _f

template<typename T , typename W , template< typename > class F>
FunctorPtr<SuperF2D<T,W> > olb::SuperCalcF2D< T, W, F >::_f
protected

Definition at line 57 of file superCalcF2D.h.

◆ _g

template<typename T , typename W , template< typename > class F>
FunctorPtr<SuperF2D<T,W> > olb::SuperCalcF2D< T, W, F >::_g
protected

Definition at line 58 of file superCalcF2D.h.


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