1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
/* Lattice Boltzmann sample, written in C++, using the OpenLB
* library
*
* Copyright (C) 2019 Davide Dapelo
* E-mail contact: info@openlb.net
* The most recent release of OpenLB can be downloaded at
* <http://www.openlb.net/>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/* Helper functionals for Lagrangian two-way coupling methods -- header file.
*/
#ifndef LB_TWO_WAY_HELPER_FUNCTIONALS_H
#define LB_TWO_WAY_HELPER_FUNCTIONALS_H
#include "functors/lattice/reductionF3D.h"
namespace olb {
/** Data structure for smoothing functionals.
* Stores the lattice position of a cell within smoothing kernel length
* and the related multiplicative weight.
*/
template<typename T>
struct LatticePosAndWeight {
int globic = 0;
int latticePos[3] = {0, 0, 0};
T weight = T();
};
/** Abstract class for particle Reynolds number computation within drag model.
* Its raison d'etre consists of not being templetized in Lattice.
*/
template<typename T, template<typename V> class Particle>
class ParticleReynoldsNumber {
public:
/// Returns the particle Reynolds number. globicFull = { globic, latticeRoundedP[0, ..., 2] }
virtual T operator() (Particle<T>* p, T magU, int globicFull[])=0;
/// Destructor
virtual ~ParticleReynoldsNumber() {};
protected:
T _RePmin = 0.01;
};
/** Abstract class for particle Reynolds number computation within drag model.
*/
template<typename T, typename Lattice, template<typename V> class Particle>
class ParticleReynoldsNumberBase : public ParticleReynoldsNumber<T, Particle> {
public:
/// Destructor
virtual ~ParticleReynoldsNumberBase() {};
protected:
/// Constructor
ParticleReynoldsNumberBase(UnitConverter<T, Lattice>& converter);
UnitConverter<T, Lattice>& _converter; // reference to a UnitConverter
};
/** Class class for Newtonian particle Reynolds number computation within drag model.
*/
template<typename T, typename Lattice, template<typename V> class Particle>
class NewtonianParticleReynoldsNumber: public ParticleReynoldsNumberBase<T,Lattice,Particle> {
public:
/// Constructor
NewtonianParticleReynoldsNumber(UnitConverter<T, Lattice>& converter);
/// Destructor
~NewtonianParticleReynoldsNumber() {};
/// Returns the particle Reynolds number. globicFull = { globic, latticeRoundedP[0, ..., 2] }
virtual T operator() (Particle<T>* p, T magU, int globicFull[]) override;
};
/** Class class for power-law particle Reynolds number computation within drag model.
*/
template<typename T, typename Lattice, template<typename V> class Particle>
class PowerLawParticleReynoldsNumber: public ParticleReynoldsNumberBase<T,Lattice,Particle> {
public:
/// Constructor
PowerLawParticleReynoldsNumber (
UnitConverter<T, Lattice>& converter, SuperLattice3D<T, Lattice>& sLattice );
/// Destructor
~PowerLawParticleReynoldsNumber() {};
/// Returns the particle Reynolds number. globicFull = { globic, latticeRoundedP[0, ..., 2] }
virtual T operator() (Particle<T>* p, T magU, int globicFull[]) override;
protected:
SuperLattice3D<T, Lattice>& _sLattice; // reference to a lattice
};
/** Abstact class for all the local forward-coupling models,
* viz., momentum coupling from fluid to particle.
* Input parameters in attice units.
*/
template<typename T, typename Lattice>
class TwoWayHelperFunctional {
public:
/// Computes the momentum transfer from fluid to particle.
virtual bool operator() ( T gF[], T latticeVelF[], T latticeVelP[],
T physPosP[], int latticeRoundedP[],
int globic )=0;
virtual ~TwoWayHelperFunctional();
protected:
/// Constructor
TwoWayHelperFunctional ( UnitConverter<T, Lattice>& converter,
SuperLattice3D<T, Lattice>& sLattice );
UnitConverter<T, Lattice>& _converter; // reference to a UnitConverter
SuperLattice3D<T, Lattice>& _sLattice; // reference to a lattice
std::shared_ptr<SuperLatticeInterpDensity3Degree3D<T, Lattice> > _interpLatticeDensity;
std::shared_ptr<SuperLatticeInterpPhysVelocity3D<T, Lattice> > _interpLatticeVelocity ;
};
/** Naive way
*/
template<typename T, typename Lattice>
class NaiveMomentumExchange : public TwoWayHelperFunctional<T, Lattice> {
public:
/// Constructor
NaiveMomentumExchange ( UnitConverter<T, Lattice>& converter,
SuperLattice3D<T, Lattice>& sLattice,
std::shared_ptr<SuperLatticeInterpDensity3Degree3D<T, Lattice> > interpLatticeDensity );
/// Computes the momentum transfer from fluid to particle.
virtual bool operator() ( T gF[], T latticeVelF[], T latticeVelP[],
T physPosP[], int latticeRoundedP[],
int globic ) override;
};
/** Using Ladd mechanism
*/
template<typename T, typename Lattice>
class LaddMomentumExchange : public TwoWayHelperFunctional<T, Lattice> {
public:
/// Constructor
LaddMomentumExchange ( UnitConverter<T, Lattice>& converter,
SuperLattice3D<T, Lattice>& sLattice,
std::shared_ptr<SuperLatticeInterpDensity3Degree3D<T, Lattice> > interpLatticeDensity,
std::shared_ptr<SuperLatticeInterpPhysVelocity3D<T, Lattice> > interpLatticeVelocity );
/// Computes the momentum transfer from fluid to particle.
virtual bool operator() ( T gF[], T latticeVelF[], T latticeVelP[],
T physPosP[], int latticeRoundedP[],
int globic ) override;
};
/** Abstact class for all the smoothing functionals.
*/
template<typename T, typename Lattice>
class SmoothingFunctional {
public:
// Returns the size of _latticePosAndWeight
int getSize();
// Returns the lattice position of the i-th element of _latticePosAndWeight
void getLatticePos(int latticePos[], int i);
// Returns the globic of the i-th element of _latticePosAndWeight
int getGlobic(int i);
// Returns the weight relative to the i-th element of _latticePosAndWeight
T getWeight(int i);
// Rebuilds _latticePosAndWeight with the new cells within _kernelLength from the bubble's position
bool update(T physPosP[], int globic);
protected:
/// Constructor
SmoothingFunctional(T kernelLength, UnitConverter<T, Lattice>& converter, SuperLattice3D<T, Lattice>& sLattice);
/// The actual smoothing function
virtual T smoothingFunction(T delta)=0;
/// Returns the weight for smoothing.
virtual T compute(T physPosP[], T physPosL[])=0;
T _kernelLength; // Kernel's smoothing length.
UnitConverter<T, Lattice>& _converter; // reference to a UnitConverter
SuperLattice3D<T, Lattice>& _sLattice; // reference to a lattice
// positions and weights of the cells within _kernelLength from bubble's position
std::deque<LatticePosAndWeight<T> > _latticePosAndWeight;
};
/** Abstact class for all the linear-averaging smoothing functionals.
*/
template<typename T, typename Lattice>
class LinearAveragingSmoothingFunctional : public SmoothingFunctional<T, Lattice> {
protected:
/// Constructor
LinearAveragingSmoothingFunctional(T kernelLength, UnitConverter<T, Lattice>& converter, SuperLattice3D<T, Lattice>& sLattice);
/// Returns the weight for smoothing.
virtual T compute(T physPosP[], T physPosL[]) override;
};
/** Abstact class for all the volume-averaging smoothing functionals.
*/
template<typename T, typename Lattice>
class VolumeAveragingSmoothingFunctional : public SmoothingFunctional<T, Lattice> {
protected:
/// Constructor
VolumeAveragingSmoothingFunctional(T kernelLength, UnitConverter<T, Lattice>& converter, SuperLattice3D<T, Lattice>& sLattice);
/// Returns the weight for smoothing.
virtual T compute(T physPosP[], T physPosL[]) override;
};
/** Smoothing functional as in Deen et al (2004), Chem. Eng. Sci 59.
*/
template<typename T, typename Lattice>
class DeenSmoothingFunctional : public LinearAveragingSmoothingFunctional<T, Lattice> {
public:
/// Constructor
DeenSmoothingFunctional(T kernelLength, UnitConverter<T, Lattice>& converter, SuperLattice3D<T, Lattice>& sLattice);
protected:
/// The actual smoothing function
virtual T smoothingFunction(T delta) override;
};
/** Stepwise smoothing functional.
*/
template<typename T, typename Lattice>
class StepSmoothingFunctional : public VolumeAveragingSmoothingFunctional<T, Lattice> {
public:
/// Constructor
StepSmoothingFunctional(T kernelLength, UnitConverter<T, Lattice>& converter, SuperLattice3D<T, Lattice>& sLattice);
protected:
/// The actual smoothing function
virtual T smoothingFunction(T delta) override;
};
}
#endif
|