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

#include <reductionF3D.h>

+ Inheritance diagram for olb::SmoothBlockIndicator3D< T, DESCRIPTOR >:
+ Collaboration diagram for olb::SmoothBlockIndicator3D< T, DESCRIPTOR >:

Public Member Functions

 SmoothBlockIndicator3D (IndicatorF3D< T > &f, T h, T eps, T sigma)
 
- Public Member Functions inherited from olb::BlockDataF3D< T, T >
 BlockDataF3D (BlockData< 3, T, T > &blockData)
 Constructor.
 
 BlockDataF3D (BlockF3D< T > &f)
 to store functor data, constuctor creates _blockData with functor data
 
BlockData< 3, T, T > & getBlockData ()
 returns _blockData
 
bool operator() (T output[], const int input[]) override
 access to _blockData via its get()
 
- 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
 
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)
 

Protected Attributes

const T _h
 Lattice spacing of the particle grid.
 
const T _sigma
 Important parameter for the Gaussian point spread Function (standard deviations)
 
const int _eps
 Size (always a multiple of 2) of the epsilon layer eps_phys = _eps * _h.
 
const int _wa
 size of the matrix of weight coefficients (from 3D Gaussian Function) _wa x _wa x _wa
 
IndicatorF3D< T > & _f
 _f holds the geometry
 
- Protected Attributes inherited from olb::BlockDataF3D< T, T >
std::unique_ptr< BlockData< 3, T, T > > _blockDataStorage
 
BlockData< 3, T, T > & _blockData
 
- Protected Attributes inherited from olb::BlockF3D< T >
BlockStructureD< 3 > & _blockStructure
 

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::BlockDataF3D< T, T >
 BlockDataF3D (int nx, int ny, int nz, int size=1)
 
- 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)
 

Detailed Description

template<typename T, typename DESCRIPTOR>
class olb::SmoothBlockIndicator3D< T, DESCRIPTOR >

Definition at line 82 of file reductionF3D.h.

Constructor & Destructor Documentation

◆ SmoothBlockIndicator3D()

template<typename T , typename DESCRIPTOR >
olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::SmoothBlockIndicator3D ( IndicatorF3D< T > & f,
T h,
T eps,
T sigma )

Definition at line 96 of file reductionF3D.hh.

98 : BlockDataF3D<T, T>((int)((f.getMax()[0] - f.getMin()[0]) / h + ( util::round(eps*0.5)*2+2 )),
99 (int)((f.getMax()[1] - f.getMin()[1]) / h + ( util::round(eps*0.5)*2+2 )),
100 (int)((f.getMax()[2] - f.getMin()[2]) / h + ( util::round(eps*0.5)*2+2 ))),
101 _h(h),
102 _sigma(sigma),
103 _eps(util::round(eps*0.5)*2),
104 _wa(_eps+1),
105 _f(f)
106{
107 this->getName() = "SmoothBlockIndicator3D";
108 T value, dx, dy, dz;
109 T weights[this->_wa][this->_wa][this->_wa];
110 T sum = 0;
111 const int iStart = util::floor(this->_wa*0.5);
112 const int iEnd = util::ceil(this->_wa*0.5);
113
114 // calculate weights: they are constants, but calculation here is less error-prone than hardcoding these parameters
115 for (int x = -iStart; x < iEnd; ++x) {
116 for (int y = -iStart; y < iEnd; ++y) {
117 for (int z = -iStart; z < iEnd; ++z) {
118 weights[x+iStart][y+iStart][z+iStart] = util::exp(-(x*x+y*y+z*z)/(2*this->_sigma*this->_sigma)) / (util::pow(this->_sigma,3)*util::sqrt(util::pow(2,3)*util::pow(M_PI,3)));
119 // important because sum of all weigths only equals 1 for this->_wa -> infinity
120 sum += weights[x+iStart][y+iStart][z+iStart];
121 }
122 }
123 }
124 const T invSum = 1./sum;
125
126 for (int iX=0; iX<this->getBlockData().getNx(); ++iX) {
127 for (int iY=0; iY<this->getBlockData().getNy(); ++iY) {
128 for (int iZ=0; iZ<this->getBlockData().getNz(); ++iZ) {
129 bool output[1];
130 value = 0;
131
132 // input: regarded point (center)
133 T input[] = {
134 _f.getMin()[0] + iX*_h,
135 _f.getMin()[1] + iY*_h,
136 _f.getMin()[2] + iZ*_h
137 };
138
139 /*
140 * three loops to look at every point (which weight is not 0) around the regarded point
141 * sum all weighted porosities
142 */
143 for (int x = -iStart; x < iEnd; ++x) {
144 for (int y = -iStart; y < iEnd; ++y) {
145 for (int z = -iStart; z < iEnd; ++z) {
146 dx = x*_h;
147 dy = y*_h;
148 dz = z*_h;
149
150 // move from regarded point to point in neighborhood
151 input[0] += dx;
152 input[1] += dy;
153 input[2] += dz;
154
155 // get porosity
156 _f(output,input);
157
158 // sum porosity
159 value += output[0] * weights[x+iStart][y+iStart][z+iStart];
160
161 // move back to center
162 input[0] -= dx;
163 input[1] -= dy;
164 input[2] -= dz;
165 }
166 }
167 }
168 /*
169 * Round to 3 decimals
170 * See above sum != 1.0, that's the reason for devision, otherwise porosity will never reach 0
171 */
172 this->getBlockData().get({iX,iY,iZ},0) = value*invSum;//nearbyint(1000*value/sum)/1000.0;
173 }
174 }
175 }
176}
#define M_PI
BlockData< 3, T, T > & getBlockData()
returns _blockData
U & get(std::size_t iCell, int iD=0)
Definition blockData.hh:94
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
virtual Vector< S, 3 > & getMax()
virtual Vector< S, 3 > & getMin()
const int _wa
size of the matrix of weight coefficients (from 3D Gaussian Function) _wa x _wa x _wa
const int _eps
Size (always a multiple of 2) of the epsilon layer eps_phys = _eps * _h.
const T _h
Lattice spacing of the particle grid.
IndicatorF3D< T > & _f
_f holds the geometry
const T _sigma
Important parameter for the Gaussian point spread Function (standard deviations)
typename std::integral_constant< TYPE, VALUE >::type value
Identity type to wrap non-type template arguments.
Definition meta.h:96
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
ADf< T, DIM > ceil(const ADf< T, DIM > &a)
Definition aDiff.h:900
ADf< T, DIM > floor(const ADf< T, DIM > &a)
Definition aDiff.h:869
ADf< T, DIM > round(const ADf< T, DIM > &a)
Definition aDiff.h:928
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112
ADf< T, DIM > exp(const ADf< T, DIM > &a)
Definition aDiff.h:455

References olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_f, olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_h, olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_sigma, olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_wa, olb::util::ceil(), olb::util::exp(), olb::util::floor(), olb::BlockData< D, T, U >::get(), olb::BlockDataF3D< T, T >::getBlockData(), olb::IndicatorF3D< S >::getMin(), olb::GenericF< T, int >::getName(), olb::BlockStructureD< D >::getNx(), olb::BlockStructureD< D >::getNy(), olb::BlockStructureD< D >::getNz(), M_PI, olb::util::pow(), and olb::util::sqrt().

+ Here is the call graph for this function:

Member Data Documentation

◆ _eps

template<typename T , typename DESCRIPTOR >
const int olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_eps
protected

Size (always a multiple of 2) of the epsilon layer eps_phys = _eps * _h.

Definition at line 97 of file reductionF3D.h.

◆ _f

template<typename T , typename DESCRIPTOR >
IndicatorF3D<T>& olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_f
protected

_f holds the geometry

Definition at line 101 of file reductionF3D.h.

◆ _h

template<typename T , typename DESCRIPTOR >
const T olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_h
protected

Lattice spacing of the particle grid.

Definition at line 93 of file reductionF3D.h.

◆ _sigma

template<typename T , typename DESCRIPTOR >
const T olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_sigma
protected

Important parameter for the Gaussian point spread Function (standard deviations)

Definition at line 95 of file reductionF3D.h.

◆ _wa

template<typename T , typename DESCRIPTOR >
const int olb::SmoothBlockIndicator3D< T, DESCRIPTOR >::_wa
protected

size of the matrix of weight coefficients (from 3D Gaussian Function) _wa x _wa x _wa

Definition at line 99 of file reductionF3D.h.


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