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

Arithmetic operations for SuperF3D functors. More...

#include <superCalcF3D.h>

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

Public Member Functions

 SuperCalcF3D (FunctorPtr< SuperF3D< T, W > > &&f, FunctorPtr< SuperF3D< T, W > > &&g)
 
 SuperCalcF3D (W scalar, FunctorPtr< SuperF3D< T, W > > &&g)
 
 SuperCalcF3D (FunctorPtr< SuperF3D< 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::SuperF3D< T, W >
SuperF3D< T, W > & operator- (SuperF3D< T, W > &rhs)
 
SuperF3D< T, W > & operator+ (SuperF3D< T, W > &rhs)
 
SuperF3D< T, W > & operator* (SuperF3D< T, W > &rhs)
 
SuperF3D< T, W > & operator/ (SuperF3D< T, W > &rhs)
 
SuperStructure< T, 3 > & getSuperStructure ()
 
int getBlockFSize () const
 
BlockF3D< W > & getBlockF (int iCloc)
 
bool operator() (W output[], const int input[])
 
- 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< SuperF3D< T, W > > _f
 
FunctorPtr< SuperF3D< T, W > > _g
 
- Protected Attributes inherited from olb::SuperF3D< T, W >
SuperStructure< T, 3 > & _superStructure
 
std::vector< std::unique_ptr< BlockF3D< W > > > _blockF
 Super functors may consist of several BlockF3D<W> derived functors.
 

Additional Inherited Members

- Public Types inherited from olb::SuperF3D< 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)
 
- Static Public Attributes inherited from olb::SuperF3D< T, W >
static constexpr bool isSuper
 
static constexpr unsigned d
 
- Protected Member Functions inherited from olb::SuperF3D< T, W >
 SuperF3D (SuperStructure< T, 3 > &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::SuperCalcF3D< T, W, F >

Arithmetic operations for SuperF3D 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 BlockCalcF3D.

All operations are performed componentwise if functor target dimensions are equal. If at least one of the target dimensions is equal to 1 it is applied to the other functor as a scalar (i.e. scalar multiplication, addition...).

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

Definition at line 58 of file superCalcF3D.h.

Constructor & Destructor Documentation

◆ SuperCalcF3D() [1/3]

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

Definition at line 37 of file superCalcF3D.hh.

39 : SuperF3D<T,W>(
40 f->getSuperStructure(),
41 f->getTargetDim() > g->getTargetDim() ? f->getTargetDim() : g->getTargetDim()),
42 _f(std::move(f)),
43 _g(std::move(g))
44{
46 _f->getTargetDim() == _g->getTargetDim() || _f->getTargetDim() == 1 || _g->getTargetDim() == 1,
47 "Componentwise operation must be well defined.");
48
49 this->getName() = "(" + _f->getName() + F<T>::symbol + _g->getName() + ")";
50
51 std::swap(_f->_ptrCalcC, this->_ptrCalcC);
52
53 LoadBalancer<T>& load = _f->getSuperStructure().getLoadBalancer();
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 BlockCalcF3D<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 BlockCalcF3D<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 BlockCalcF3D<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< SuperF3D< T, W > > _g
FunctorPtr< SuperF3D< T, W > > _f
std::vector< std::unique_ptr< BlockF3D< W > > > _blockF
Super functors may consist of several BlockF3D<W> derived functors.
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45

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

+ Here is the call graph for this function:

◆ SuperCalcF3D() [2/3]

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

Definition at line 83 of file superCalcF3D.hh.

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

◆ SuperCalcF3D() [3/3]

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

Definition at line 90 of file superCalcF3D.hh.

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

Member Function Documentation

◆ operator()()

template<typename T , typename W , template< typename > class F>
bool olb::SuperCalcF3D< 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 superCalcF3D.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<SuperF3D<T,W> > olb::SuperCalcF3D< T, W, F >::_f
protected

Definition at line 60 of file superCalcF3D.h.

◆ _g

template<typename T , typename W , template< typename > class F>
FunctorPtr<SuperF3D<T,W> > olb::SuperCalcF3D< T, W, F >::_g
protected

Definition at line 61 of file superCalcF3D.h.


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