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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
/* 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.
*/
/* Models for Lagrangian forward-coupling methods -- generic implementation.
*/
#ifndef LB_FORWARD_COUPLING_MODELS_HH
#define LB_FORWARD_COUPLING_MODELS_HH
namespace olb {
////////////////////// Class LocalBaseCouplingModel ////////////////////////
template<typename T, typename Lattice, template<typename V> class Particle>
LocalBaseForwardCouplingModel<T,Lattice,Particle>::LocalBaseForwardCouplingModel (
UnitConverter<T, Lattice>& converter,
SuperLattice3D<T, Lattice>& sLattice,
SuperGeometry3D<T>& sGeometry,
DragModel<T, Particle>& dragModel )
: _sGeometry(sGeometry),
_converter(converter),
_sLattice(sLattice),
_dragModel(dragModel)
{
this->_interpLatticeDensity = std::make_shared<SuperLatticeInterpDensity3Degree3D<T, Lattice> > (
this->_sLattice, _sGeometry, this->_converter );
this->_interpLatticeVelocity = std::make_shared<SuperLatticeInterpPhysVelocity3D<T, Lattice> > (
this->_sLattice, this->_converter );
}
template<typename T, typename Lattice, template<typename V> class Particle>
bool LocalBaseForwardCouplingModel<T,Lattice,Particle>::operator() (Particle<T>* p, int globic)
{
/// Getting the particle and its containing cell's position
T physPosP[3] = {T(), T(), T()}; // particle's physical position
physPosP[0] = (p->getPos()[0]);
physPosP[1] = (p->getPos()[1]);
physPosP[2] = (p->getPos()[2]);
// particle's dimensionless position, rounded at neighbouring voxel
int latticeRoundedPosP[3] = {0, 0, 0};
this->_sLattice.getCuboidGeometry().get(globic).getLatticeR (
latticeRoundedPosP, physPosP );
// { globic, latticeRoundedP[0, ..., 2] }
int globicFull[4] = { globic,
latticeRoundedPosP[0],
latticeRoundedPosP[1],
latticeRoundedPosP[2] };
// Particle's velocity
T physVelP[3] = {T(), T(), T()}; // Physical
physVelP[0] = (p->getVel()[0]);
physVelP[1] = (p->getVel()[1]);
physVelP[2] = (p->getVel()[2]);
// Lattice
T latticeVelP[3] = {T(), T(), T()}; // particle's dimensionless velocity
latticeVelP[0] = this->_converter.getLatticeVelocity(physVelP[0]);
latticeVelP[1] = this->_converter.getLatticeVelocity(physVelP[1]);
latticeVelP[2] = this->_converter.getLatticeVelocity(physVelP[2]);
// Lattice's velocity at particle's location
T physVelF[3] = {T(), T(), T()}; // Physical
this->_interpLatticeVelocity->operator() (physVelF, physPosP, globic);
// Lattice
T latticeVelF[3] = {T(), T(), T()}; // Lattice's dimensionless velocity at particle's location
latticeVelF[0] = this->_converter.getLatticeVelocity(physVelF[0]);
latticeVelF[1] = this->_converter.getLatticeVelocity(physVelF[1]);
latticeVelF[2] = this->_converter.getLatticeVelocity(physVelF[2]);
// Computing fluid-particle momentum transfer
T gF[3] = {T(), T(), T()}; // force density gF
this->_momentumExchange->operator() ( gF, latticeVelF, latticeVelP,
physPosP, latticeRoundedPosP, globic);
// Computing drag coefficient
T Cd = this->_dragModel(p, latticeVelF, latticeVelP, globicFull);
/// Computing drag force in dimensionless units
T latticePRad = p->getRad() / _converter.getConversionFactorLength();
T latticeForceP[3] = {T(), T(), T()}; // dimensionless force acting on the particle
latticeForceP[0] = .5 * Cd * M_PI*pow(latticePRad,2) * gF[0] * (latticeVelF[0] - latticeVelP[0]);
latticeForceP[1] = .5 * Cd * M_PI*pow(latticePRad,2) * gF[1] * (latticeVelF[1] - latticeVelP[1]);
latticeForceP[2] = .5 * Cd * M_PI*pow(latticePRad,2) * gF[2] * (latticeVelF[2] - latticeVelP[2]);
/// Computing physical drag force
std::vector<T> physForceP(3, T()); // physical force acting on the particle
physForceP[0] = latticeForceP[0] * this->_converter.getConversionFactorForce();
physForceP[1] = latticeForceP[1] * this->_converter.getConversionFactorForce();
physForceP[2] = latticeForceP[2] * this->_converter.getConversionFactorForce();
/// Updating the particle
p->setStoreForce(physForceP);
return true;
}
////////////////////// Class NaiveForwardCouplingModel ////////////////////////
template<typename T, typename Lattice, template<typename V> class Particle>
NaiveForwardCouplingModel<T,Lattice,Particle>::NaiveForwardCouplingModel (
UnitConverter<T, Lattice>& converter,
SuperLattice3D<T, Lattice>& sLattice,
SuperGeometry3D<T>& sGeometry,
DragModel<T, Particle>& dragModel )
: LocalBaseForwardCouplingModel<T,Lattice,Particle>(converter, sLattice, sGeometry, dragModel)
{
this->_momentumExchange = std::make_shared<NaiveMomentumExchange<T, Lattice> > (
this->_converter, this->_sLattice, this->_interpLatticeDensity );
}
////////////////////// Class LaddForwardCouplingModel ////////////////////////
template<typename T, typename Lattice, template<typename V> class Particle>
LaddForwardCouplingModel<T,Lattice,Particle>::LaddForwardCouplingModel (
UnitConverter<T, Lattice>& converter,
SuperLattice3D<T, Lattice>& sLattice,
SuperGeometry3D<T>& sGeometry,
DragModel<T, Particle>& dragModel )
: LocalBaseForwardCouplingModel<T,Lattice,Particle>(converter, sLattice, sGeometry, dragModel)
{
this->_momentumExchange = std::make_shared<LaddMomentumExchange<T, Lattice> > (
this->_converter, this->_sLattice,
this->_interpLatticeDensity, this->_interpLatticeVelocity );
}
////////////////////// Class NonLocalBaseCouplingModel ////////////////////////
template<typename T, typename Lattice, template<typename V> class Particle>
NonLocalBaseForwardCouplingModel<T,Lattice,Particle>::NonLocalBaseForwardCouplingModel (
UnitConverter<T, Lattice>& converter,
SuperLattice3D<T, Lattice>& sLattice,
SuperGeometry3D<T>& sGeometry,
DragModel<T, Particle>& dragModel,
SmoothingFunctional<T, Lattice>& smoothingFunctional )
: _sGeometry(sGeometry),
_converter(converter),
_sLattice(sLattice),
_dragModel(dragModel),
_smoothingFunctional(smoothingFunctional)
{
this->_interpLatticeDensity = std::make_shared<SuperLatticeInterpDensity3Degree3D<T, Lattice> > (
this->_sLattice, _sGeometry, this->_converter );
this->_interpLatticeVelocity = std::make_shared<SuperLatticeInterpPhysVelocity3D<T, Lattice> > (
this->_sLattice, this->_converter );
}
template<typename T, typename Lattice, template<typename V> class Particle>
bool NonLocalBaseForwardCouplingModel<T,Lattice,Particle>::operator() (Particle<T>* p, int globic)
{
/// Getting the particle and its containing cell's position
T physPosP[3] = {T(), T(), T()}; // particle's physical position
physPosP[0] = (p->getPos()[0]);
physPosP[1] = (p->getPos()[1]);
physPosP[2] = (p->getPos()[2]);
//std::cout << "globic=" << globic << " physPosP=(" << physPosP[0] << ", " << physPosP[1] << ", " << physPosP[2] << ")" << std::endl; // <---
// particle's dimensionless position, rounded at neighbouring voxel
int latticeRoundedPosP[3] = {0, 0, 0};
this->_sLattice.getCuboidGeometry().get(globic).getLatticeR (
latticeRoundedPosP, physPosP );
// { globic, latticeRoundedP[0, ..., 2] }
int globicFull[4] = { globic,
latticeRoundedPosP[0],
|