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

Abstact class for all the smoothing functionals. More...

#include <smoothingFunctionals3D.h>

+ Inheritance diagram for olb::SmoothingFunctional< T, Lattice >:
+ Collaboration diagram for olb::SmoothingFunctional< T, Lattice >:

Public Member Functions

virtual bool update (T physPosP[], int globic)
 
const std::deque< LatticePosAndWeight< T > > getData () const
 
int getNvoxelInterpPoints ()
 

Protected Member Functions

 SmoothingFunctional (T kernelLength, UnitConverter< T, Lattice > &converter, SuperLattice< T, Lattice > &sLattice, int nVoxelInterpPoints=2)
 Constructor.
 
virtual T smoothingFunction (T delta)=0
 The actual smoothing function.
 
virtual T compute (T physPosP[], T physPosL[])=0
 Returns the weight for smoothing.
 

Protected Attributes

_kernelLength
 
UnitConverter< T, Lattice > & _converter
 
SuperLattice< T, Lattice > & _sLattice
 
std::deque< LatticePosAndWeight< T > > _latticePosAndWeight
 
int _nVoxelInterpPoints
 

Detailed Description

template<typename T, typename Lattice>
class olb::SmoothingFunctional< T, Lattice >

Abstact class for all the smoothing functionals.

Definition at line 54 of file smoothingFunctionals3D.h.

Constructor & Destructor Documentation

◆ SmoothingFunctional()

template<typename T , typename Lattice >
olb::SmoothingFunctional< T, Lattice >::SmoothingFunctional ( T kernelLength,
UnitConverter< T, Lattice > & converter,
SuperLattice< T, Lattice > & sLattice,
int nVoxelInterpPoints = 2 )
protected

Constructor.

Definition at line 36 of file smoothingFunctionals3D.hh.

38 : _kernelLength(kernelLength),
39 _converter(converter),
40 _sLattice(sLattice),
41 _nVoxelInterpPoints(nVoxelInterpPoints)
42{
43 if (2.0*_kernelLength < converter.getPhysDeltaX()) {
44 throw std::out_of_range("2 * SmoothingFunctional::_kernelLength must be >= converter::getPhysDeltaX().");
45 }
46 if (_nVoxelInterpPoints < 2) {
47 throw std::out_of_range("SmoothingFunctional::_nVoxelInterpPoints must be >=2.");
48 }
49}
UnitConverter< T, Lattice > & _converter
SuperLattice< T, Lattice > & _sLattice
constexpr T getPhysDeltaX() const
returns grid spacing (voxel length) in m

References olb::SmoothingFunctional< T, Lattice >::_kernelLength, olb::SmoothingFunctional< T, Lattice >::_nVoxelInterpPoints, and olb::UnitConverter< T, DESCRIPTOR >::getPhysDeltaX().

+ Here is the call graph for this function:

Member Function Documentation

◆ compute()

template<typename T , typename Lattice >
virtual T olb::SmoothingFunctional< T, Lattice >::compute ( T physPosP[],
T physPosL[] )
protectedpure virtual

◆ getData()

template<typename T , typename Lattice >
const std::deque< LatticePosAndWeight< T > > olb::SmoothingFunctional< T, Lattice >::getData ( ) const
inline

Definition at line 59 of file smoothingFunctionals3D.h.

60 {
62 }
std::deque< LatticePosAndWeight< T > > _latticePosAndWeight

References olb::SmoothingFunctional< T, Lattice >::_latticePosAndWeight.

◆ getNvoxelInterpPoints()

template<typename T , typename Lattice >
int olb::SmoothingFunctional< T, Lattice >::getNvoxelInterpPoints ( )
inline

◆ smoothingFunction()

template<typename T , typename Lattice >
virtual T olb::SmoothingFunctional< T, Lattice >::smoothingFunction ( T delta)
protectedpure virtual

◆ update()

template<typename T , typename Lattice >
bool olb::SmoothingFunctional< T, Lattice >::update ( T physPosP[],
int globic )
virtual

Reimplemented in olb::vanWachemSmoothingFunctional< T, Lattice >.

Definition at line 52 of file smoothingFunctionals3D.hh.

53{
54 // Bottom-left corner of a cube centered at the particle, with side 2*_kernelLength
55 T physPosMin[3] = {T(), T(), T()};
56 physPosMin[0] = physPosP[0] - _kernelLength;
57 physPosMin[1] = physPosP[1] - _kernelLength;
58 physPosMin[2] = physPosP[2] - _kernelLength;
59 int latticePosMin[3] = {0, 0, 0};
60 this->_sLattice.getCuboidGeometry().get(globic).getLatticeR (
61 latticePosMin, physPosMin );
62
63 // Top-right corner of a cube centered at the particle, with side 2*_kernelLength
64 T physPosMax[3] = {T(), T(), T()};
65 physPosMax[0] = physPosP[0] + _kernelLength;
66 physPosMax[1] = physPosP[1] + _kernelLength;
67 physPosMax[2] = physPosP[2] + _kernelLength;
68 int latticePosMax[3] = {0, 0, 0};
69 this->_sLattice.getCuboidGeometry().get(globic).getLatticeR (
70 latticePosMax, physPosMax );
71
72 // Clearing the _latticePosAndWeight list
74
75 T normalizer = T();
76 int iLatticePos[3] = {0, 0, 0};
77 // Cycling all the cells on a cube containing a sphee centered in bubble's position and with kernel smoothing length as radius
78 for (iLatticePos[0]=latticePosMin[0]; iLatticePos[0]<=latticePosMax[0]; iLatticePos[0]++) {
79 for (iLatticePos[1]=latticePosMin[1]; iLatticePos[1]<=latticePosMax[1]; iLatticePos[1]++) {
80 for (iLatticePos[2]=latticePosMin[2]; iLatticePos[2]<=latticePosMax[2]; iLatticePos[2]++) {
81
82 T iPhysPos[3] = {T(), T(), T()};
83 this->_sLattice.getCuboidGeometry().get(globic).getPhysR (
84 iPhysPos, iLatticePos );
85
86 // Is the voxel within a smooting kernel length from the bubble's position?
87 if ( util::pow(physPosP[0] - iPhysPos[0], 2) +
88 util::pow(physPosP[1] - iPhysPos[1], 2) +
89 util::pow(physPosP[2] - iPhysPos[2], 2) < util::pow(_kernelLength, 2) ) {
90
91 // Adding the voxel's position (and relative weight) to the _latticePosAndWeight list
92 LatticePosAndWeight<T> item;
93 item.latticePos[0] = iLatticePos[0];
94 item.latticePos[1] = iLatticePos[1];
95 item.latticePos[2] = iLatticePos[2];
96 item.weight = this->compute(physPosP, iPhysPos);
97
98 normalizer += item.weight;
99 _latticePosAndWeight.push_back(item);
100 }
101 }
102 }
103 }
104
105 // If normalizer is zero, then no voxels are within a kernel smoothing length from the bubble's location.
106 // And it is a problem.
107 if (normalizer == T()) {
108 std::cout << "ERROR: SmoothingFunctional::update(...):" << std::endl
109 << "[smoothingFunctional] physPosP: "
110 << physPosP[0] << " "
111 << physPosP[1] << " "
112 << physPosP[2] << std::endl
113 << "[smoothingFunctional] physPosMin: "
114 << physPosMin[0] << " "
115 << physPosMin[1] << " "
116 << physPosMin[2] << std::endl
117 << "[smoothingFunctional] physPosMax: "
118 << latticePosMax[0] << " "
119 << latticePosMax[1] << " "
120 << latticePosMax[2] << std::endl
121 << "[smoothingFunctional] normalizer: "
122 << normalizer << std::endl;
123 return false;
124 }
125
126 // Normalizing to one
127 for (auto&& i : _latticePosAndWeight) {
128 i.weight /= normalizer;
129 }
130 return true;
131}
virtual T compute(T physPosP[], T physPosL[])=0
Returns the weight for smoothing.
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112

References olb::LatticePosAndWeight< T >::latticePos, olb::util::pow(), and olb::LatticePosAndWeight< T >::weight.

+ Here is the call graph for this function:

Member Data Documentation

◆ _converter

template<typename T , typename Lattice >
UnitConverter<T, Lattice>& olb::SmoothingFunctional< T, Lattice >::_converter
protected

Definition at line 76 of file smoothingFunctionals3D.h.

◆ _kernelLength

template<typename T , typename Lattice >
T olb::SmoothingFunctional< T, Lattice >::_kernelLength
protected

Definition at line 75 of file smoothingFunctionals3D.h.

◆ _latticePosAndWeight

template<typename T , typename Lattice >
std::deque<LatticePosAndWeight<T> > olb::SmoothingFunctional< T, Lattice >::_latticePosAndWeight
protected

Definition at line 79 of file smoothingFunctionals3D.h.

◆ _nVoxelInterpPoints

template<typename T , typename Lattice >
int olb::SmoothingFunctional< T, Lattice >::_nVoxelInterpPoints
protected

Definition at line 80 of file smoothingFunctionals3D.h.

◆ _sLattice

template<typename T , typename Lattice >
SuperLattice<T, Lattice>& olb::SmoothingFunctional< T, Lattice >::_sLattice
protected

Definition at line 77 of file smoothingFunctionals3D.h.


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