OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::BlockFiniteDifference3D< T > Class Template Reference

functor to get pointwise finite difference Dissipation on local lattice, if globIC is not on the local processor, the returned vector is empty More...

#include <latticeDerivatives3D.h>

+ Inheritance diagram for olb::BlockFiniteDifference3D< T >:
+ Collaboration diagram for olb::BlockFiniteDifference3D< T >:

Public Member Functions

 BlockFiniteDifference3D (BlockGeometry< T, 3 > &blockGeometry, BlockF3D< T > &blockFunctor, std::list< int > &matNumber)
 
bool operator() (T output[], const int input[]) override
 has to be implemented for 'every' derived class
 
- Public Member Functions inherited from olb::BlockF3D< T >
 ~BlockF3D () override
 virtual destructor for defined behaviour
 
virtual BlockStructureD< 3 > & getBlockStructure () const
 
BlockF3D< T > & operator- (BlockF3D< T > &rhs)
 
BlockF3D< T > & operator+ (BlockF3D< T > &rhs)
 
BlockF3D< T > & operator* (BlockF3D< T > &rhs)
 
BlockF3D< T > & operator/ (BlockF3D< 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
 
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::BlockF3D< T >
 BlockF3D (BlockStructureD< 3 > &blockStructure, int targetDim)
 
- Protected Member Functions inherited from olb::GenericF< T, int >
 GenericF (int targetDim, int sourceDim)
 
- Protected Attributes inherited from olb::BlockF3D< T >
BlockStructureD< 3 > & _blockStructure
 

Detailed Description

template<typename T>
class olb::BlockFiniteDifference3D< T >

functor to get pointwise finite difference Dissipation on local lattice, if globIC is not on the local processor, the returned vector is empty

Definition at line 40 of file latticeDerivatives3D.h.

Constructor & Destructor Documentation

◆ BlockFiniteDifference3D()

template<typename T >
olb::BlockFiniteDifference3D< T >::BlockFiniteDifference3D ( BlockGeometry< T, 3 > & blockGeometry,
BlockF3D< T > & blockFunctor,
std::list< int > & matNumber )

Definition at line 35 of file latticeDerivatives3D.hh.

37 : BlockF3D<T>(blockFunctor.getBlockStructure(), 3*blockFunctor.getTargetDim()), _blockGeometry(blockGeometry), _blockFunctor(blockFunctor), _matNumber(matNumber)
38{
39 this->getName() = "FiniteDifference";
40 _targetDim = _blockFunctor.getTargetDim();
41 _n[0] = this-> _blockGeometry.getNx()-1;
42 _n[1] = this-> _blockGeometry.getNy()-1;
43 _n[2] = this-> _blockGeometry.getNz()-1;
44
45}
int getNy() const
Read only access to block height.
int getNx() const
Read only access to block width.
int getNz() const
Read only access to block height.
std::string & getName()
read and write access to name
Definition genericF.hh:51

References olb::GenericF< T, int >::getName(), olb::BlockStructureD< D >::getNx(), olb::BlockStructureD< D >::getNy(), and olb::BlockStructureD< D >::getNz().

+ Here is the call graph for this function:

Member Function Documentation

◆ operator()()

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

has to be implemented for 'every' derived class

Implements olb::GenericF< T, int >.

Definition at line 48 of file latticeDerivatives3D.hh.

49{
50// // derivation tensor
51 std::vector<std::vector<T>> fdGrad;
52
53 fdGrad.resize(_targetDim);
54 for (int i = 0; i < _targetDim; i++) {
55 fdGrad[i].resize(3);
56 }
57
58 for (int i = 0; i < 3; i++) {
59 int fInput_p[3];
60 fInput_p[0] = input[0];
61 fInput_p[1] = input[1];
62 fInput_p[2] = input[2];
63 fInput_p[i]+=1;
64
65 int fInput_2p[3];
66 fInput_2p[0] = input[0];
67 fInput_2p[1] = input[1];
68 fInput_2p[2] = input[2];
69 fInput_2p[i]+=2;
70
71 int fInput_3p[3];
72 fInput_3p[0] = input[0];
73 fInput_3p[1] = input[1];
74 fInput_3p[2] = input[2];
75 fInput_3p[i]+=3;
76
77 int fInput_4p[3];
78 fInput_4p[0] = input[0];
79 fInput_4p[1] = input[1];
80 fInput_4p[2] = input[2];
81 fInput_4p[i]+=4;
82
83 int fInput_n[3];
84 fInput_n[0] = input[0];
85 fInput_n[1] = input[1];
86 fInput_n[2] = input[2];
87 fInput_n[i]-=1;
88
89 int fInput_2n[3];
90 fInput_2n[0] = input[0];
91 fInput_2n[1] = input[1];
92 fInput_2n[2] = input[2];
93 fInput_2n[i]-=2;
94
95 int fInput_3n[3];
96 fInput_3n[0] = input[0];
97 fInput_3n[1] = input[1];
98 fInput_3n[2] = input[2];
99 fInput_3n[i]-=3;
100
101 int fInput_4n[3];
102 fInput_4n[0] = input[0];
103 fInput_4n[1] = input[1];
104 fInput_4n[2] = input[2];
105 fInput_4n[i]-=4;
106
107 T fOutput[_targetDim];
108 _blockFunctor(fOutput,input);
109
110 if (input[i] < 3) {
111 if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_2p[0], fInput_2p[1], fInput_2p[2]})) == _matNumber.end()) {
112 T fOutput_p[_targetDim];
113 _blockFunctor(fOutput_p,fInput_p);
114 for (int j=0; j < _targetDim; j++) {
115 fdGrad[j][i]= -fOutput[j] + fOutput_p[j];
116 }
117 }
118 else {
119 T fOutput_p[_targetDim];
120 _blockFunctor(fOutput_p,fInput_p);
121 T fOutput_2p[_targetDim];
122 _blockFunctor(fOutput_2p,fInput_2p);
123 for (int j=0; j < _targetDim; j++) {
124 fdGrad[j][i]=fd::boundaryGradient(fOutput[j], fOutput_p[j], fOutput_2p[j]);
125 }
126 }
127 }
128 else if (input[i] > _n[i]-3) {
129 if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_2n[0], fInput_2n[1], fInput_2n[2]})) == _matNumber.end()) {
130 T fOutput_n[_targetDim];
131 _blockFunctor(fOutput_n,fInput_n);
132 for (int j=0; j < _targetDim; j++) {
133 fdGrad[j][i]= -fOutput_n[j] + fOutput[j];
134 }
135 }
136 else {
137 T fOutput_n[_targetDim];
138 _blockFunctor(fOutput_n,fInput_n);
139 T fOutput_2n[_targetDim];
140 _blockFunctor(fOutput_2n,fInput_2n);
141 for (int j=0; j < _targetDim; j++) {
142 fdGrad[j][i]=fd::boundaryGradient(-fOutput[j], -fOutput_n[j], -fOutput_2n[j]);
143 }
144 }
145 }
146 else {
147 if ( std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_n[0], fInput_n[1], fInput_n[2]})) == _matNumber.end() &&
148 std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_p[0], fInput_p[1], fInput_p[2]})) == _matNumber.end() ) {
149 for (int j=0; j < _targetDim; j++) {
150 fdGrad[j][i]=0.;
151 }
152 // boundary treatment with Second-order asymmetric gradient
153 }
154 else if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_n[0], fInput_n[1], fInput_n[2]})) == _matNumber.end()) {
155 if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_2p[0], fInput_2p[1], fInput_2p[2]})) == _matNumber.end()) {
156 T fOutput_p[_targetDim];
157 _blockFunctor(fOutput_p,fInput_p);
158 for (int j=0; j < _targetDim; j++) {
159 fdGrad[j][i]= -fOutput[j] + fOutput_p[j];
160 }
161 }
162 else {
163 T fOutput_p[_targetDim];
164 _blockFunctor(fOutput_p,fInput_p);
165 T fOutput_2p[_targetDim];
166 _blockFunctor(fOutput_2p,fInput_2p);
167 for (int j=0; j < _targetDim; j++) {
168 fdGrad[j][i]=fd::boundaryGradient(fOutput[j], fOutput_p[j], fOutput_2p[j]);
169 }
170 }
171 }
172 else if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_p[0], fInput_p[1], fInput_p[2]})) == _matNumber.end() ) {
173 if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_2n[0], fInput_2n[1], fInput_2n[2]})) == _matNumber.end()) {
174 T fOutput_n[_targetDim];
175 _blockFunctor(fOutput_n,fInput_n);
176 for (int j=0; j < _targetDim; j++) {
177 fdGrad[j][i]= -fOutput_n[j] + fOutput[j];
178 }
179 }
180 else {
181 T fOutput_n[_targetDim];
182 _blockFunctor(fOutput_n,fInput_n);
183 T fOutput_2n[_targetDim];
184 _blockFunctor(fOutput_2n,fInput_2n);
185 for (int j=0; j < _targetDim; j++) {
186 fdGrad[j][i]=fd::boundaryGradient(-fOutput[j], -fOutput_n[j], -fOutput_2n[j]);
187 }
188 }
189 }
190 else {
191 //inner domain 8th order central difference
192 T fOutput_n[_targetDim];
193 _blockFunctor(fOutput_n,fInput_n);
194
195 T fOutput_2n[_targetDim];
196 _blockFunctor(fOutput_2n,fInput_2n);
197
198 T fOutput_3n[_targetDim];
199 _blockFunctor(fOutput_3n,fInput_3n);
200
201 T fOutput_4n[_targetDim];
202 _blockFunctor(fOutput_4n,fInput_4n);
203
204 T fOutput_p[_targetDim];
205 _blockFunctor(fOutput_p,fInput_p);
206
207 T fOutput_2p[_targetDim];
208 _blockFunctor(fOutput_2p,fInput_2p);
209
210 T fOutput_3p[_targetDim];
211 _blockFunctor(fOutput_3p,fInput_3p);
212
213 T fOutput_4p[_targetDim];
214 _blockFunctor(fOutput_4p,fInput_4p);
215 for (int j=0; j < _targetDim; j++) {
216 //fdGrad[j][i]=fd::centralGradient(fOutput_p[j], fOutput_n[j]);
217 fdGrad[j][i]=((T)672*(fOutput_p[j]-fOutput_n[j])+(T)168*(fOutput_2n[j]-fOutput_2p[j])
218 +(T)32*(fOutput_3p[j]-fOutput_3n[j])+(T)3*(fOutput_4n[j]-fOutput_4p[j])) / 840.;
219 }
220 }
221 }
222 for (int i=0; i < 3; i++) {
223 for (int j=0; j < _targetDim; j++) {
224 output[j*3+i] = fdGrad[j][i];
225 }
226 }
227 }
228 return true;
229}
std::enable_if_t< sizeof...(L)==D, int > get(L... latticeR) const
Read-only access to a material number.
constexpr T boundaryGradient(T u_0, T u_1, T u_2) any_platform
Second-order asymmetric gradient (u_1 = u(x+1))

References olb::fd::boundaryGradient().

+ Here is the call graph for this function:

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