MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lbsolverdxqy.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef LBSOLVERDXQY_H
8#define LBSOLVERDXQY_H
9
10#include <random>
11#include "lbfunctions.h"
12#include "lbinterfacedxqy.h"
13#include "lblatticedescriptor.h"
14#include "lbsolver.h"
15#include "lbsrctermcontroller.h"
16
17#include "lbsyseqn.h"
18
19template <MInt nDim, MInt nDist, class SysEqn>
20class LbBndCndDxQy;
21
22template <MInt nDim, MInt nDist, class SysEqn>
23class LbInterfaceDxQy;
24
28template <MInt nDim, MInt nDist, class SysEqn>
29class LbSolverDxQy : public LbSolver<nDim> {
30 public:
31 const SysEqn m_sysEqn{};
32
36
37 LbSolverDxQy(MInt id, MInt noDistributions, GridProxy& gridProxy_, Geometry<nDim>& geometry_, const MPI_Comm comm);
39
40 using Base::a_alphaGasLim;
41 using Base::a_coordinate;
42 using Base::a_diffusivity;
43 using Base::a_distribution;
44 using Base::a_distributionThermal;
45 using Base::a_distributionTransport;
46 using Base::a_externalForces;
47 using Base::a_hasNeighbor;
48 using Base::a_isActive;
49 using Base::a_isBndryGhostCell;
50 using Base::a_isHalo;
51 using Base::a_isInterfaceChild;
52 using Base::a_kappa;
53 using Base::a_level;
54 using Base::a_levelSetFunctionMB;
55 using Base::a_noCells;
56 using Base::a_nu;
57 using Base::a_nuT;
58 using Base::a_oldDistribution;
59 using Base::a_oldDistributionThermal;
60 using Base::a_oldDistributionTransport;
61 using Base::a_oldVariable;
62 using Base::a_oldVariables_ptr;
63 using Base::a_variable;
64 using Base::a_variables_ptr;
65 using Base::c_cellLengthAtLevel;
66 using Base::c_isLeafCell;
67 using Base::c_level;
68 using Base::c_neighborId;
69 using Base::c_noChildren;
70 using Base::c_parentId;
71 using Base::centerOfGravity;
72 using Base::domainId;
73 using Base::exchangeData;
74 using Base::getReLambdaAndUrmsInit;
75 using Base::grid;
76 using Base::initNu;
77 using Base::m_activeCellList;
78 using Base::m_activeCellListLvlOffset;
79 using Base::m_adaptation;
80 using Base::m_arraySize;
81 using Base::m_bandWidth;
82 using Base::m_calculateDissipation;
83 using Base::m_cells;
84 using Base::m_controlVelocity;
85 using Base::m_Cs;
86 using Base::m_currentMaxNoCells;
87 using Base::m_deltaX;
88 using Base::m_densityFluctuations;
89 using Base::m_densityGradient;
90 using Base::m_diffusivity;
91 using Base::m_domainLength;
92 using Base::m_EELiquid;
93 using Base::m_extractedCells;
94 using Base::m_Fext;
95 using Base::m_FftInit;
96 using Base::m_finalRe;
97 using Base::m_Ga;
98 using Base::m_geometry;
99 using Base::m_geometryIntersection;
100 using Base::m_gridPoints;
101 using Base::m_initDensityGradient;
102 using Base::m_initFromCoarse;
103 using Base::m_initialNoCells;
104 using Base::m_initMethod;
105 using Base::m_initRe;
106 using Base::m_initStartTime;
107 using Base::m_initTime;
108 using Base::m_innerEnergy;
109 using Base::m_isCompressible;
110 using Base::m_isEELiquid;
111 using Base::m_isRefined;
112 using Base::m_isThermal;
113 using Base::m_isTransport;
114 using Base::m_kappa;
115 using Base::m_levelSetId;
116 using Base::m_Ma;
117 using Base::m_maxNoSets;
118 using Base::m_maxResId;
119 using Base::m_MijLij;
120 using Base::m_MijMij;
121 using Base::m_momentumFlux;
122 using Base::m_noEmbeddedBodies;
123 using Base::m_noPeakModes;
124 using Base::m_nu;
125 using Base::m_omega;
126 using Base::m_particleMomentumCoupling;
127 using Base::m_Pe;
128 using Base::m_Pr;
129 using Base::m_Re;
130 using Base::m_referenceLength;
131 using Base::m_ReLambda;
132 using Base::m_rescoordinates;
133 using Base::m_residual;
134 using Base::m_residualInterval;
135 using Base::m_resRePos;
136 using Base::m_resTimestepPos;
137 using Base::m_ReTau;
138 using Base::m_solutionInterval;
139 using Base::m_tanhInit;
140 using Base::m_tanhScaleFactor;
141 using Base::m_tmpResidual;
142 using Base::m_tmpResidualLvl;
143 using Base::m_totalEnergy;
144#ifdef WAR_NVHPC_PSTL
145 using Base::m_distFld;
146 using Base::m_distType;
147 using Base::m_faculty;
148 using Base::m_idFld;
149 using Base::m_mFld1;
150 using Base::m_mFld2;
151 using Base::m_nFld;
152 using Base::m_oppositeDist;
153 using Base::m_pFld;
154 using Base::m_ppdfDir;
155 using Base::m_tp;
156#endif
157 using Base::m_updateAfterPropagation;
158 using Base::m_updateMacroscopicLocation;
159 using Base::m_UrmsInit;
160 using Base::m_velocityControl;
161 using Base::m_volumeAccel;
162 using Base::m_volumeAccelBase;
163 using Base::maxLevel;
164 using Base::minLevel;
165 using Base::mpiComm;
166 using Base::noDomains;
167 using Base::noInternalCells;
168 using Base::noVariables;
169 using Base::outputDir;
170 using Base::PV;
171 using Base::saveUVWRhoTOnlyPar;
172 using Base::solverMethod;
173 using Base::swap_variables;
174
175 using Base::computeFFTStatistics;
176 using Base::m_resFileName;
177 using Base::mRes;
178
180 static constexpr MInt m_noDistributions = nDist;
181
182 template <MInt nDim_, MInt nDist_, class SysEqn_>
183 friend class LbBndCndDxQy;
184
185 template <MInt nDim_, MInt nDist_, class SysEqn_>
186 friend class LbInterfaceDxQy;
187
188 template <MInt nDim_>
189 friend class LbInterface;
190
191 template <MInt nDim_, MInt nDist_, class SysEqn_>
192 friend class CouplingLB;
193
194 constexpr SysEqn sysEqn() const { return m_sysEqn; }
195
196 virtual void initializeLatticeBgk();
197 inline void initLatticeBgkFftPipe();
198 inline void initLatticeBgkFftChannel();
199 inline void initLatticeBgkFftMixing();
200 inline void initLatticeBgkFftMixingFilter();
202 virtual void initLatticeBgkLaminarChannel();
203 virtual void initLatticeBgkTurbulentChannel();
204 virtual void initLatticeBgkTurbulentMixing();
205 virtual void initLatticeBgkTurbulentBoundary();
206 virtual void initLatticeBgkTurbulentPipe();
207 virtual void initLatticeBgkTurbulentDuct();
208 virtual void initLatticeBgkLaminarPipe();
209 virtual void initLatticeBgkVortex();
210 virtual void initLatticeBgkTGV();
216
217 // generalized direction init
218 virtual void initLatticeBgkLaminarDir(MInt dir);
219
220 virtual void initLatticeBgkLaminar();
221
222 // General init for PPDFs
223 void initEqDistFunctions();
225 virtual void initThermalEqDistFunctions();
226 virtual void initTransportEqDistFunctions();
227 virtual void restartInitLb();
228 virtual void propagation_step() override;
229 virtual void propagation_step_vol() override;
230 virtual void propagation_step_thermal() override;
231 virtual void propagation_step_thermal_vol() override;
232 virtual void propagation_step_transport() override;
233 virtual void propagation_step_transport_vol() override;
234 virtual void propagation_step_thermaltransport() override;
235 virtual void propagation_step_thermaltransport_vol() override;
236 template <MInt timeStepOffset = 0>
238 virtual void updateVariablesFromOldDist() override;
239 virtual void updateVariablesFromOldDist_preCollision() override;
240 virtual void volumeForces();
241 virtual void controlVelocity();
242 virtual void averageGlobalVelocity(const MInt dir);
243
244 // Member functions needed for generic call of functions for adaptation
245 virtual void removeChildsLb(const MInt parentId);
246 virtual void refineCellLb(const MInt parentId, const MInt* childIds);
247 virtual void restartBndCnd();
248
249 void sensorVorticity(std::vector<std::vector<MFloat>>& sensors, std::vector<std::bitset<64>>& sensorCellFlag,
250 std::vector<MFloat>& sensorWeight, MInt sensorOffset, MInt sen) override;
251 void sensorDivergence(std::vector<std::vector<MFloat>>& sensors, std::vector<std::bitset<64>>& sensorCellFlag,
252 std::vector<MFloat>& sensorWeight, MInt sensorOffset, MInt sen) override;
253 void sensorTotalPressure(std::vector<std::vector<MFloat>>& sensors, std::vector<std::bitset<64>>& sensorCellFlag,
254 std::vector<MFloat>& sensorWeight, MInt sensorOffset, MInt sen) override;
255 void sensorInterface(std::vector<std::vector<MFloat>>& sensors, std::vector<std::bitset<64>>& sensorCellFlag,
256 std::vector<MFloat>& sensorWeight, MInt sensorOffset, MInt sen) override;
257 void sensorMeanStress(std::vector<std::vector<MFloat>>& sensors, std::vector<std::bitset<64>>& sensorCellFlag,
258 std::vector<MFloat>& sensorWeight, MInt sensorOffset, MInt sen) override;
259
260 template <MBool useSmagorinsky>
262 void clb_collision_step() override;
263 void clb_smagorinsky_collision_step() override;
264 void cumulant_collision_step() override;
265 virtual void bgki_collision_step();
266 virtual void bgki_thermal_collision_step();
267 virtual void bgki_innerEnergy_collision_step();
268 virtual void bgki_totalEnergy_collision_step();
269 virtual void bgkc_transport_collision_step();
273 void bgki_collision_step_Guo_forcing() override;
274 template <MBool compressible = false>
275 inline void calculateMomentumFlux(const MInt pCellId);
276 template <MBool compressible = false>
277 inline void calculateMomentumFlux(const MInt pCellId, MFloat* const momentumFlux);
278 template <MBool compressible = false>
279 inline void calculateMacroscopicVariables(const MInt cellId, MFloat& rho, MFloat* const u);
281 template <MBool optimized, MBool useSmagorinsky>
283 void mrt_collision_step() override;
284 void mrt2_collision_step() override;
285 void mrt_smagorinsky_collision_step() override;
286 void bgki_euler_collision_step() override;
287 void bgki_init_collision_step() override;
288 void bgkc_collision_step() override;
289 void bgki_dynamic_smago_collision_step() override;
290 template <MInt mode>
292 template <MInt thermalMode>
294 template <MInt thermalMode>
296 void bgki_smagorinsky_collision_step() override;
297 void bgki_smagorinsky_collision_step2() override;
298 void bgki_smago_wall_collision_step() override;
299
300 template <MBool useSmagorinsky>
302 void rbgk_collision_step() override;
303 void rbgk_smagorinsky_collision_step() override;
304 void rbgk_dynamic_smago_collision_step() override;
305
306 virtual void calculateResidual();
307 void initSrcTermController() override;
308 void initSrcTerms() override;
309 void preCollisionSrcTerm() override;
310 void postCollisionSrcTerm() override;
311 void postPropagationSrcTerm() override;
312 void postCollisionBc() override;
313 void postPropagationBc() override;
314 virtual void calcNodalLsValues();
315 // virtual void writeToResidualFile(const MChar* text);
316 virtual MBool maxResidual();
317 void averageSGSTensors(const MInt direction, MInt& count, std::vector<MFloat>& meanTensors);
319 void updateViscosity() override;
320 void calculateSGSTensors();
321
322 std::mt19937 randNumGen;
323 std::uniform_real_distribution<> distrib{0.0, 1.0};
324
325#ifdef WAR_NVHPC_PSTL
326 void initArraysForPSTL();
327#endif
328
329 protected:
331
335
336 protected:
338
340
341 private:
342 void prolongation();
343 void restriction();
344
345 void initPressureForce() override;
346 void initVolumeForces() override;
347 template <MBool compressible>
348 void initRunCorrection_();
349 void initRunCorrection() override;
350
352
353 // Constants for Law of the Wall
354 const MFloat C1, C2, C3, C4;
355
356 public:
357 inline void setEqDists(const MInt cellId, const MFloat rho, const MFloat* const velocity);
358 inline void setEqDists(const MInt cellId, const MFloat rho, const MFloat squaredVelocity,
359 const MFloat* const velocity);
360 inline void setEqDistsThermal(const MInt cellId, const MFloat T, const MFloat rho, const MFloat* const velocity);
361 inline void setEqDistsThermal(const MInt cellId, const MFloat T, const MFloat rho, const MFloat squaredVelocity,
362 const MFloat* const velocity);
363 template <MInt thermalMode>
364 inline void setEqDistsThermal_(const MInt cellId, const MFloat T, const MFloat rho, const MFloat* const velocity);
365 template <MInt thermalMode>
366 inline void setEqDistsThermal_(const MInt cellId, const MFloat T, const MFloat rho, const MFloat squaredVelocity,
367 const MFloat* const velocity);
368 inline void setEqDistsTransport(const MInt cellId, const MFloat C, const MFloat* const velocity);
369 inline void setEqDistsTransport(const MInt cellId, const MFloat C, const MFloat squaredVelocity,
370 const MFloat* const velocity);
371
372 std::array<MFloat, nDist> getEqDists(const MFloat rho, const MFloat* const velocity);
373 std::array<MFloat, nDist> getEqDists(const MFloat rho, const MFloat squaredVelocity, const MFloat* const velocity);
374 std::array<MFloat, nDist> getEqDistsThermal(const MFloat t, const MFloat rho, const MFloat* const velocity);
375 std::array<MFloat, nDist> getEqDistsThermal(const MFloat t, const MFloat rho, const MFloat squaredVelocity,
376 const MFloat* const velocity);
377 template <MInt thermalMode>
378 std::array<MFloat, nDist> getEqDistsThermal_(const MFloat t, const MFloat rho, const MFloat* const velocity);
379 template <MInt thermalMode>
380 std::array<MFloat, nDist> getEqDistsThermal_(const MFloat t, const MFloat rho, const MFloat squaredVelocity,
381 const MFloat* const velocity);
382 std::array<MFloat, nDist> getEqDistsTransport(const MFloat c, const MFloat* const velocity);
383 std::array<MFloat, nDist> getEqDistsTransport(const MFloat c, const MFloat squaredVelocity,
384 const MFloat* const velocity);
385};
386
387// TODO: Unify different equations/systems of equations
388
400template <MInt nDim, MInt nDist, class SysEqn>
402 const MFloat* const velocity) {
403 std::array<MFloat, nDist> eqDist;
404#ifdef WAR_NVHPC_PSTL
405 sysEqn().calcEqDists(rho, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(), m_tp.data(), m_distFld.data());
406 for(MInt dist = 0; dist < nDist; dist++) {
407 a_distribution(cellId, dist) = eqDist[dist];
408 a_oldDistribution(cellId, dist) = eqDist[dist];
409 }
410#else
411 sysEqn().calcEqDists(rho, velocity, eqDist.data());
412
413 std::copy_n(eqDist.begin(), nDist, &a_distribution(cellId, 0));
414 std::copy_n(eqDist.begin(), nDist, &a_oldDistribution(cellId, 0));
415#endif
416}
417
430template <MInt nDim, MInt nDist, class SysEqn>
432 const MFloat squaredVelocity, const MFloat* const velocity) {
433 std::array<MFloat, nDist> eqDist;
434#ifdef WAR_NVHPC_PSTL
435 sysEqn().calcEqDists(rho, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(), m_tp.data(),
436 m_distFld.data());
437 for(MInt dist = 0; dist < nDist; dist++) {
438 a_distribution(cellId, dist) = eqDist[dist];
439 a_oldDistribution(cellId, dist) = eqDist[dist];
440 }
441#else
442 sysEqn().calcEqDists(rho, squaredVelocity, velocity, eqDist.data());
443
444 std::copy_n(eqDist.begin(), nDist, &a_distribution(cellId, 0));
445 std::copy_n(eqDist.begin(), nDist, &a_oldDistribution(cellId, 0));
446#endif
447}
448
461template <MInt nDim, MInt nDist, class SysEqn>
462inline void LbSolverDxQy<nDim, nDist, SysEqn>::setEqDistsThermal(const MInt cellId, const MFloat T, const MFloat rho,
463 const MFloat* const velocity) {
464 if(m_innerEnergy) {
465 setEqDistsThermal_<1>(cellId, T, rho, velocity);
466 } else if(m_totalEnergy) {
467 setEqDistsThermal_<2>(cellId, T, rho, velocity);
468 } else {
469 setEqDistsThermal_<0>(cellId, T, rho, velocity);
470 }
471}
472
487template <MInt nDim, MInt nDist, class SysEqn>
488template <MInt thermalMode>
489inline void LbSolverDxQy<nDim, nDist, SysEqn>::setEqDistsThermal_(const MInt cellId, const MFloat T, const MFloat rho,
490 const MFloat* const velocity) {
491 std::array<MFloat, nDist> eqDist;
492#ifdef WAR_NVHPC_PSTL
493 IF_CONSTEXPR(thermalMode == 0) {
494 lbfunc::calcEqDistsThermal<nDim, nDist>(T, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(), m_tp.data(),
495 m_distFld.data());
496 }
497 IF_CONSTEXPR(thermalMode == 1) {
498 lbfunc::calcEqDistsInnerEnergy<nDim, nDist>(T, rho, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(),
499 m_tp.data(), m_distFld.data());
500 }
501 IF_CONSTEXPR(thermalMode == 2) {
502 lbfunc::calcEqDistsTotalEnergy<nDim, nDist>(T, rho, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(),
503 m_tp.data(), m_distFld.data());
504 }
505 for(MInt dist = 0; dist < nDist; dist++) {
506 a_distributionThermal(cellId, dist) = eqDist[dist];
507 a_oldDistributionThermal(cellId, dist) = eqDist[dist];
508 }
509#else
510 IF_CONSTEXPR(thermalMode == 0) { lbfunc::calcEqDistsThermal<nDim, nDist>(T, velocity, eqDist.data()); }
511 IF_CONSTEXPR(thermalMode == 1) { lbfunc::calcEqDistsInnerEnergy<nDim, nDist>(T, rho, velocity, eqDist.data()); }
512 IF_CONSTEXPR(thermalMode == 2) { lbfunc::calcEqDistsTotalEnergy<nDim, nDist>(T, rho, velocity, eqDist.data()); }
513 std::copy_n(eqDist.begin(), nDist, &a_distributionThermal(cellId, 0));
514 std::copy_n(eqDist.begin(), nDist, &a_oldDistributionThermal(cellId, 0));
515#endif
516}
517
531template <MInt nDim, MInt nDist, class SysEqn>
532inline void LbSolverDxQy<nDim, nDist, SysEqn>::setEqDistsThermal(const MInt cellId, const MFloat T, const MFloat rho,
533 const MFloat squaredVelocity,
534 const MFloat* const velocity) {
535 if(m_innerEnergy) {
536 setEqDistsThermal_<1>(cellId, T, rho, squaredVelocity, velocity);
537 } else if(m_totalEnergy) {
538 setEqDistsThermal_<2>(cellId, T, rho, squaredVelocity, velocity);
539 } else {
540 setEqDistsThermal_<0>(cellId, T, rho, squaredVelocity, velocity);
541 }
542}
543
559template <MInt nDim, MInt nDist, class SysEqn>
560template <MInt thermalMode>
561inline void LbSolverDxQy<nDim, nDist, SysEqn>::setEqDistsThermal_(const MInt cellId, const MFloat T, const MFloat rho,
562 const MFloat squaredVelocity,
563 const MFloat* const velocity) {
564 std::array<MFloat, nDist> eqDist;
565#ifdef WAR_NVHPC_PSTL
566 IF_CONSTEXPR(thermalMode == 0) {
567 lbfunc::calcEqDistsThermal<nDim, nDist>(T, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(),
568 m_tp.data(), m_distFld.data());
569 }
570 IF_CONSTEXPR(thermalMode == 1) {
571 lbfunc::calcEqDistsInnerEnergy<nDim, nDist>(T, rho, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(),
572 m_mFld2.data(), m_tp.data(), m_distFld.data());
573 }
574 IF_CONSTEXPR(thermalMode == 2) {
575 lbfunc::calcEqDistsTotalEnergy<nDim, nDist>(T, rho, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(),
576 m_mFld2.data(), m_tp.data(), m_distFld.data());
577 }
578 for(MInt dist = 0; dist < nDist; dist++) {
579 a_distributionThermal(cellId, dist) = eqDist[dist];
580 a_oldDistributionThermal(cellId, dist) = eqDist[dist];
581 }
582#else
583 IF_CONSTEXPR(thermalMode == 0) {
584 lbfunc::calcEqDistsThermal<nDim, nDist>(T, squaredVelocity, velocity, eqDist.data());
585 }
586 IF_CONSTEXPR(thermalMode == 1) {
587 lbfunc::calcEqDistsInnerEnergy<nDim, nDist>(T, rho, squaredVelocity, velocity, eqDist.data());
588 }
589 IF_CONSTEXPR(thermalMode == 2) {
590 lbfunc::calcEqDistsTotalEnergy<nDim, nDist>(T, rho, squaredVelocity, velocity, eqDist.data());
591 }
592 std::copy_n(eqDist.begin(), nDist, &a_distributionThermal(cellId, 0));
593 std::copy_n(eqDist.begin(), nDist, &a_oldDistributionThermal(cellId, 0));
594#endif
595}
596
606template <MInt nDim, MInt nDist, class SysEqn>
608 const MFloat* const velocity) {
609 std::array<MFloat, nDist> eqDist;
610#ifdef WAR_NVHPC_PSTL
611 lbfunc::calcEqDistsTransport<nDim, nDist>(C, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(), m_tp.data(),
612 m_distFld.data());
613 for(MInt dist = 0; dist < nDist; dist++) {
614 a_distributionTransport(cellId, dist) = eqDist[dist];
615 a_oldDistributionTransport(cellId, dist) = eqDist[dist];
616 }
617#else
618 lbfunc::calcEqDistsTransport<nDim, nDist>(C, velocity, eqDist.data());
619
620 std::copy_n(eqDist.begin(), nDist, &a_distributionTransport(cellId, 0));
621 std::copy_n(eqDist.begin(), nDist, &a_oldDistributionTransport(cellId, 0));
622#endif
623}
624
637template <MInt nDim, MInt nDist, class SysEqn>
639 const MFloat squaredVelocity,
640 const MFloat* const velocity) {
641 std::array<MFloat, nDist> eqDist;
642#ifdef WAR_NVHPC_PSTL
643 lbfunc::calcEqDistsTransport<nDim, nDist>(C, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(),
644 m_tp.data(), m_distFld.data());
645 for(MInt dist = 0; dist < nDist; dist++) {
646 a_distributionTransport(cellId, dist) = eqDist[dist];
647 a_oldDistributionTransport(cellId, dist) = eqDist[dist];
648 }
649#else
650 lbfunc::calcEqDistsTransport<nDim, nDist>(C, squaredVelocity, velocity, eqDist.data());
651
652 std::copy_n(eqDist.begin(), nDist, &a_distributionTransport(cellId, 0));
653 std::copy_n(eqDist.begin(), nDist, &a_oldDistributionTransport(cellId, 0));
654#endif
655}
656
667template <MInt nDim, MInt nDist, class SysEqn>
668std::array<MFloat, nDist> LbSolverDxQy<nDim, nDist, SysEqn>::getEqDists(const MFloat rho,
669 const MFloat* const velocity) {
670 std::array<MFloat, nDist> eqDist{};
671#ifdef WAR_NVHPC_PSTL
672 sysEqn().calcEqDists(rho, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(), m_tp.data(), m_distFld.data());
673#else
674 sysEqn().calcEqDists(rho, velocity, eqDist.data());
675#endif
676 return eqDist;
677}
678
690template <MInt nDim, MInt nDist, class SysEqn>
691std::array<MFloat, nDist> LbSolverDxQy<nDim, nDist, SysEqn>::getEqDists(const MFloat rho, const MFloat squaredVelocity,
692 const MFloat* const velocity) {
693 std::array<MFloat, nDist> eqDist{};
694#ifdef WAR_NVHPC_PSTL
695 sysEqn().calcEqDists(rho, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(), m_tp.data(),
696 m_distFld.data());
697#else
698 sysEqn().calcEqDists(rho, squaredVelocity, velocity, eqDist.data());
699#endif
700 return eqDist;
701}
702
714template <MInt nDim, MInt nDist, class SysEqn>
715std::array<MFloat, nDist> LbSolverDxQy<nDim, nDist, SysEqn>::getEqDistsThermal(const MFloat t, const MFloat rho,
716 const MFloat* const velocity) {
717 if(m_innerEnergy) {
718 return getEqDistsThermal_<1>(t, rho, velocity);
719 } else if(m_totalEnergy) {
720 return getEqDistsThermal_<2>(t, rho, velocity);
721 } else {
722 return getEqDistsThermal_<0>(t, rho, velocity);
723 }
724}
725
739template <MInt nDim, MInt nDist, class SysEqn>
740template <MInt thermalMode>
741std::array<MFloat, nDist> LbSolverDxQy<nDim, nDist, SysEqn>::getEqDistsThermal_(const MFloat t, const MFloat rho,
742 const MFloat* const velocity) {
743 std::array<MFloat, nDist> eqDist;
744#ifdef WAR_NVHPC_PSTL
745 IF_CONSTEXPR(thermalMode == 0) {
746 lbfunc::calcEqDistsThermal<nDim, nDist>(t, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(), m_tp.data(),
747 m_distFld.data());
748 }
749 IF_CONSTEXPR(thermalMode == 1) {
750 lbfunc::calcEqDistsInnerEnergy<nDim, nDist>(t, rho, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(),
751 m_tp.data(), m_distFld.data());
752 }
753 IF_CONSTEXPR(thermalMode == 2) {
754 lbfunc::calcEqDistsTotalEnergy<nDim, nDist>(t, rho, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(),
755 m_tp.data(), m_distFld.data());
756 }
757#else
758 IF_CONSTEXPR(thermalMode == 0) { lbfunc::calcEqDistsThermal<nDim, nDist>(t, velocity, eqDist.data()); }
759 IF_CONSTEXPR(thermalMode == 1) { lbfunc::calcEqDistsInnerEnergy<nDim, nDist>(t, rho, velocity, eqDist.data()); }
760 IF_CONSTEXPR(thermalMode == 2) { lbfunc::calcEqDistsTotalEnergy<nDim, nDist>(t, rho, velocity, eqDist.data()); }
761#endif
762 return eqDist;
763}
764
777template <MInt nDim, MInt nDist, class SysEqn>
778std::array<MFloat, nDist> LbSolverDxQy<nDim, nDist, SysEqn>::getEqDistsThermal(const MFloat t, const MFloat rho,
779 const MFloat squaredVelocity,
780 const MFloat* const velocity) {
781 if(m_innerEnergy) {
782 return getEqDistsThermal_<1>(t, rho, squaredVelocity, velocity);
783 } else if(m_totalEnergy) {
784 return getEqDistsThermal_<2>(t, rho, squaredVelocity, velocity);
785 } else {
786 return getEqDistsThermal_<0>(t, rho, squaredVelocity, velocity);
787 }
788}
789
804template <MInt nDim, MInt nDist, class SysEqn>
805template <MInt thermalMode>
806std::array<MFloat, nDist> LbSolverDxQy<nDim, nDist, SysEqn>::getEqDistsThermal_(const MFloat t, const MFloat rho,
807 const MFloat squaredVelocity,
808 const MFloat* const velocity) {
809 std::array<MFloat, nDist> eqDist;
810#ifdef WAR_NVHPC_PSTL
811 IF_CONSTEXPR(thermalMode == 0) {
812 lbfunc::calcEqDistsThermal<nDim, nDist>(t, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(),
813 m_tp.data(), m_distFld.data());
814 }
815 IF_CONSTEXPR(thermalMode == 1) {
816 lbfunc::calcEqDistsInnerEnergy<nDim, nDist>(t, rho, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(),
817 m_mFld2.data(), m_tp.data(), m_distFld.data());
818 }
819 IF_CONSTEXPR(thermalMode == 2) {
820 lbfunc::calcEqDistsTotalEnergy<nDim, nDist>(t, rho, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(),
821 m_mFld2.data(), m_tp.data(), m_distFld.data());
822 }
823#else
824 IF_CONSTEXPR(thermalMode == 0) {
825 lbfunc::calcEqDistsThermal<nDim, nDist>(t, squaredVelocity, velocity, eqDist.data());
826 }
827 IF_CONSTEXPR(thermalMode == 1) {
828 lbfunc::calcEqDistsInnerEnergy<nDim, nDist>(t, rho, squaredVelocity, velocity, eqDist.data());
829 }
830 IF_CONSTEXPR(thermalMode == 2) {
831 lbfunc::calcEqDistsTotalEnergy<nDim, nDist>(t, rho, squaredVelocity, velocity, eqDist.data());
832 }
833#endif
834 return eqDist;
835}
836
848template <MInt nDim, MInt nDist, class SysEqn>
850 const MFloat* const velocity) {
851 std::array<MFloat, nDist> eqDist;
852#ifdef WAR_NVHPC_PSTL
853 lbfunc::calcEqDistsTransport<nDim, nDist>(c, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(), m_tp.data(),
854 m_distFld.data());
855#else
856 lbfunc::calcEqDistsTransport<nDim, nDist>(c, velocity, eqDist.data());
857#endif
858 return eqDist;
859}
860
873template <MInt nDim, MInt nDist, class SysEqn>
875 const MFloat squaredVelocity,
876 const MFloat* const velocity) {
877 std::array<MFloat, nDist> eqDist;
878#ifdef WAR_NVHPC_PSTL
879 lbfunc::calcEqDistsTransport<nDim, nDist>(c, squaredVelocity, velocity, eqDist.data(), m_mFld1.data(), m_mFld2.data(),
880 m_tp.data(), m_distFld.data());
881#else
882 lbfunc::calcEqDistsTransport<nDim, nDist>(c, squaredVelocity, velocity, eqDist.data());
883#endif
884 return eqDist;
885}
886
896template <MInt nDim, MInt nDist, class SysEqn>
897template <MBool compressible>
899 MFloat* const u) {
900#ifdef WAR_NVHPC_PSTL
901 std::array<MFloat, nDist> oldDist;
902 for(MInt dist = 0; dist < nDist; dist++) {
903 oldDist[dist] = a_oldDistribution(cellId, dist);
904 }
905 const MInt fldlen = Ld::dxQyFld();
906 lbfunc::calcMacroVars<nDim, nDist, compressible>(oldDist.data(), rho, u, m_pFld.data(), m_nFld.data(), fldlen);
907#else
908 const MFloat* const dist = &a_oldDistribution(cellId, 0);
909 lbfunc::calcMacroVars<nDim, nDist, compressible>(dist, rho, u);
910#endif
911}
912
918template <MInt nDim, MInt nDist, class SysEqn>
919template <MBool compressible>
920inline void LbSolverDxQy<nDim, nDist, SysEqn>::calculateMomentumFlux(const MInt pCellId, MFloat* const momentumFlux) {
921 TRACE();
922
923 const MFloat rho = a_variable(pCellId, PV->RHO);
924#ifndef WAR_NVHPC_PSTL
925 const MFloat* const u = &a_variable(pCellId, PV->U);
926 const MFloat* const dist = &a_oldDistribution(pCellId, 0);
927 sysEqn().calcMomentumFlux(rho, u, dist, momentumFlux);
928#else
929 std::array<MFloat, nDim> u;
930 std::array<MFloat, nDist> dist;
931 for(MInt d = 0; d < nDim; d++) {
932 u[d] = a_variable(pCellId, d);
933 }
934 for(MInt d = 0; d < nDist; d++) {
935 dist[d] = a_oldDistribution(pCellId, d);
936 }
937 sysEqn().calcMomentumFlux(rho, u.data(), dist.data(), momentumFlux);
938#endif
939}
940
948template <MInt nDim, MInt nDist, class SysEqn>
949template <MBool compressible>
951 TRACE();
952
953 calculateMomentumFlux<compressible>(pCellId, m_momentumFlux[pCellId]);
954}
955
956#endif
MFloat & a_variable(const MInt cellId, const MInt varId, const MInt id=0)
Definition: coupling.h:528
Interface class holding all relevant data and methods for treating prolongation, restriction and init...
This class represents all LB models.
Definition: lbsolverdxqy.h:29
void updateViscosity() override
Update viscosity (a_nu and a_oldNu)
void sensorInterface(std::vector< std::vector< MFloat > > &sensors, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MFloat > &sensorWeight, MInt sensorOffset, MInt sen) override
Simple boundary sensor for ensuring boundary refinement during adaptation.
void postPropagationSrcTerm() override
Calls the post collision routine of the source term controller.
void sensorDivergence(std::vector< std::vector< MFloat > > &sensors, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MFloat > &sensorWeight, MInt sensorOffset, MInt sen) override
virtual void bgkc_transport_collision_step()
Collision step for Transport Lattice-Boltzmann.
void sensorTotalPressure(std::vector< std::vector< MFloat > > &sensors, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MFloat > &sensorWeight, MInt sensorOffset, MInt sen) override
void initLatticeBgkGaussDiffusion()
constexpr SysEqn sysEqn() const
Definition: lbsolverdxqy.h:194
virtual void averageGlobalVelocity(const MInt dir)
calculate average velocity of velocity component dir
void calculateSGSTensors()
Calculate tensors for dynamic Smagorinsky constant.
void bgki_euler_collision_step() override
void bgki_thermal_collision_step_base()
virtual void propagation_step_transport() override
Propagation step for Transport Lattice-Boltzmann.
void initNonEqDistFunctions()
std::uniform_real_distribution distrib
Definition: lbsolverdxqy.h:323
void bgki_thermal_and_transport_collision_step_base()
Collision step for coupled Thermal Transport Lattice-Boltzmann.
typename LbSolver< nDim >::GridProxy GridProxy
Definition: lbsolverdxqy.h:34
static constexpr MInt m_noDistributions
Definition: lbsolverdxqy.h:180
const MFloat C2
Definition: lbsolverdxqy.h:354
void initSrcTerms() override
Initialize the source term controller.
void initRunCorrection() override
virtual void propagation_step_thermaltransport() override
Propagation step for coupled Thermal Transport Lattice-Boltzmann.
void initArraysForPSTL()
virtual void propagation_step_thermal() override
void setEqDists(const MInt cellId, const MFloat rho, const MFloat *const velocity)
Set BOTH distributions to equilibrium.
Definition: lbsolverdxqy.h:401
virtual void restartInitLb()
void bgkc_collision_step() override
virtual void refineCellLb(const MInt parentId, const MInt *childIds)
: Initialize child variables from parent
void clb_collision_step_base()
void rbgk_collision_step_base()
virtual void bgki_innerEnergy_collision_step()
void setEqDistsThermal(const MInt cellId, const MFloat T, const MFloat rho, const MFloat *const velocity)
Calls function for setting thermal distributions to equilibrium.
Definition: lbsolverdxqy.h:462
virtual void initLatticeBgkTurbulentDuct()
void bgki_smagorinsky_collision_step() override
void calculateDissipation()
Calculate total energy, dissipation, and subgrid dissipation for Smagorinsky.
std::mt19937 randNumGen
Definition: lbsolverdxqy.h:322
void initLatticeBgkFftMixingFilter()
virtual void bgki_thermal_collision_step()
void rbgk_dynamic_smago_collision_step() override
void bgki_dynamic_smago_collision_step() override
void(LbSolverDxQy< nDim, nDist, SysEqn >::* m_initMethodPtr)()
Pointers for the Boundary Conditions, for flow solving.
Definition: lbsolverdxqy.h:339
const MFloat C4
Definition: lbsolverdxqy.h:354
void initLatticeBgkFftChannel()
void initLatticeBgkLaminarCylinder()
virtual void propagation_step_thermal_vol() override
Propagation step for Thermal Lattice-Boltzmann.
void cumulant_collision_step() override
virtual void initLatticeBgkTurbulentMixing()
void bgki_smago_wall_collision_step() override
virtual void bgkc_totalenergy_transport_collision_step()
Collision step for coupled Thermal Transport Lattice-Boltzmann.
void initPressureForce() override
void bgki_init_collision_step() override
Consistent initialization step of the LBGK algorithm.
std::array< MFloat, nDist > getEqDistsTransport(const MFloat c, const MFloat *const velocity)
Return transport distributions to equilibrium.
Definition: lbsolverdxqy.h:849
void bgki_smagorinsky_collision_step_base()
void updateMacroscopicVariables()
Update macroscopic variables according to incoming PPDF.
virtual void initLatticeBgkLaminar()
virtual void propagation_step_thermaltransport_vol() override
Propagation step for coupled Thermal Transport Lattice-Boltzmann.
void mrt_smagorinsky_collision_step() override
const MFloat C3
Definition: lbsolverdxqy.h:354
void bgki_smagorinsky_collision_step2() override
virtual void initLatticeBgkTurbulentPipe()
virtual void propagation_step() override
standard OpenMP propagation step
void rbgk_smagorinsky_collision_step() override
std::array< MFloat, nDist > getEqDistsThermal(const MFloat t, const MFloat rho, const MFloat *const velocity)
Calls function to return the thermal equilibrium distribution.
Definition: lbsolverdxqy.h:715
virtual void initTransportEqDistFunctions()
Calculates equilibrium distribution functions after initialization of macroscopic variables.
void clb_collision_step() override
void mrt_collision_step() override
virtual void propagation_step_vol() override
This function propagates the locally calculated PPDFs to the neighboring cells after the collision st...
void mrt_collision_step_base()
Collision step for the MRT-Algorithm.
std::array< MFloat, nDist > getEqDistsThermal_(const MFloat t, const MFloat rho, const MFloat *const velocity)
Return thermal distributions to equilibrium.
Definition: lbsolverdxqy.h:741
void mrt2_collision_step() override
void setEqDistsTransport(const MInt cellId, const MFloat C, const MFloat *const velocity)
Set BOTH transport distributions to equilibrium.
Definition: lbsolverdxqy.h:607
void initLatticeBgkFftPipe()
virtual void initThermalEqDistFunctions()
Calculates equilibrium distribution functions after initialization of macroscopic variables.
void calculateMacroscopicVariables(const MInt cellId, MFloat &rho, MFloat *const u)
Calculate macroscopic variables for a given cell.
Definition: lbsolverdxqy.h:898
std::array< MFloat, nDist > getEqDists(const MFloat rho, const MFloat *const velocity)
Calls function to return the equilibrium distribution.
Definition: lbsolverdxqy.h:668
LbInterfaceDxQy< nDim, nDist, SysEqn > * m_interface
Definition: lbsolverdxqy.h:334
virtual void bgki_totalEnergy_collision_step()
void initLatticeBgkFftMixing()
const SysEqn m_sysEqn
Definition: lbsolverdxqy.h:31
MFloat m_smallestCellLength
Definition: lbsolverdxqy.h:351
void setEqDistsThermal_(const MInt cellId, const MFloat T, const MFloat rho, const MFloat *const velocity)
Set BOTH thermal distributions to equilibrium.
Definition: lbsolverdxqy.h:489
void initLatticeBgkFftIsotropicTurbulence()
void postPropagationBc() override
void initRunCorrection_()
Iterative initialize routine to obtained a valid density and non-eq field.
void sensorVorticity(std::vector< std::vector< MFloat > > &sensors, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MFloat > &sensorWeight, MInt sensorOffset, MInt sen) override
void calculateMomentumFlux(const MInt pCellId)
Calculate and set momentum flux for a given cell.
Definition: lbsolverdxqy.h:950
LbBndCnd * m_bndCnd
Pointers for the Boundary Conditions, for flow solving.
Definition: lbsolverdxqy.h:332
void rbgk_collision_step() override
void initEqDistFunctions()
Calculates equilibrium distribution functions after initialization of macroscopic variables.
virtual void restartBndCnd()
Restart bndCnd object.
virtual void updateVariablesFromOldDist_preCollision() override
virtual void initLatticeBgkTGV()
void preCollisionSrcTerm() override
Calls the pre collision routine of the source term controller.
void postCollisionBc() override
void clb_smagorinsky_collision_step() override
virtual void initLatticeBgkLaminarDir(MInt dir)
Initializes standard Lattice BGK laminar with or without a direction.
void initLatticeBgkGaussAdvection()
virtual MBool maxResidual()
virtual void initLatticeBgkVortex()
void initLatticeBgkGaussPulse()
void initLatticeBgkSpinningVorticies()
virtual void initializeLatticeBgk()
Initializes standard Lattice BGK.
maia::lb::LbSrcTermController< nDim, nDist, SysEqn > m_srcTermController
Definition: lbsolverdxqy.h:333
virtual void initLatticeBgkTurbulentBoundary()
virtual void initLatticeBgkLaminarChannel()
virtual void controlVelocity()
control velocity of a periodic channel flow via volume forces
void sensorMeanStress(std::vector< std::vector< MFloat > > &sensors, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MFloat > &sensorWeight, MInt sensorOffset, MInt sen) override
virtual void initLatticeBgkLaminarPipe()
virtual void calcNodalLsValues()
virtual void removeChildsLb(const MInt parentId)
: Initialize parent variables from children
void updateVariablesFromOldDist_()
virtual void initLatticeBgkTurbulentChannel()
void averageSGSTensors(const MInt direction, MInt &count, std::vector< MFloat > &meanTensors)
Calculate average SGS tensor.
void bgki_collision_step_Guo_forcing() override
const MFloat C1
Definition: lbsolverdxqy.h:354
void initSrcTermController() override
Initialize the source term controller.
virtual void calculateResidual()
Calculates residuals and prints to file.
void postCollisionSrcTerm() override
Calls the post collision routine of the source term controller.
virtual void bgkc_thermal_transport_collision_step()
Collision step for coupled Thermal Transport Lattice-Boltzmann.
virtual void bgki_collision_step()
virtual void volumeForces()
apply volumeForces to the oldDistributions
virtual void bgkc_innerenergy_transport_collision_step()
Collision step for coupled Thermal Transport Lattice-Boltzmann.
virtual void updateVariablesFromOldDist() override
virtual void propagation_step_transport_vol() override
Propagation step for Transport Lattice-Boltzmann.
void initVolumeForces() override
Front-end to control all source terms in a wrapping manner.
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
Definition: pointbox.h:54
LB lattice descriptor for arrays depending on D and Q.