MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lpt.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 _LPT_H
8#define _LPT_H
9
10#include <algorithm>
11#include <limits>
12#include <list>
13#include <memory>
14#include <numeric>
15#include <queue>
16#include <random>
17#include "GRID/cartesiangrid.h"
18#include "cartesiansolver.h"
19#include "lptbase.h"
20#include "lptbndrycell.h"
21#include "lptcellcollector.h"
22#include "lptcollision.h"
23#include "lptellipsoidal.h"
24#include "lptlib.h"
25#include "lptspherical.h"
26#include "lptspray.h"
27
28//#define LPT_DEBUG
29
30template <MInt nDim>
31class SprayModel;
32class CartesianSolver;
33
34template <MInt nDim>
35class MaterialState;
36
37template <MInt nDim>
39
40template <MInt nDim>
41class LPTEllipsoidal;
42
43template <MInt nDim>
44using particleSendQueue = std::vector<std::queue<maia::lpt::sendQueueType<nDim>>>;
45
46namespace maia {
47namespace lpt {
48
49// Create struct for easy timer identification
50struct Timers_ {
51 // Enum to store timer "names"
52 enum {
56
61
64
71
72 // Special enum value used to initialize timer array
73 _count
74 };
75};
76
77} // namespace lpt
78} // namespace maia
79
80
81template <MInt nDim>
82class LPT : public maia::CartesianSolver<nDim, LPT<nDim>> {
83 template <MInt nDim_>
84 friend class LPTBase;
85
86 template <MInt nDim_>
87 friend class LPTSpherical;
88
89 template <MInt nDim_>
90 friend class LPTEllipsoidal;
91
92 template <MInt nDim_>
93 friend class SprayModel;
94
95 template <MInt nDim_>
96 friend class CouplingParticle;
97
98 template <MInt nDim_, class SysEqn>
99 friend class CouplerFvParticle;
100
101 template <MInt nDim_, MInt nDist, class SysEqn>
102 friend class LbLpt;
103
104 template <MInt nDim_, class SysEqn>
106
107 template <MInt nDim_>
109
110 template <MInt nDim_>
111 friend class PostProcessingLPT;
112
113 template <MInt nDim_>
114 friend class ParticleCollision;
115
116 template <MInt nDim_>
117 friend class MaterialState;
118
119 public:
122
124 using Grid = typename CartesianSolver::Grid;
125 using GridProxy = typename CartesianSolver::GridProxy;
127
128 // used CartesianSolver
129 using CartesianSolver::domainId;
130 using CartesianSolver::domainOffset;
131 using CartesianSolver::getIdentifier;
132 using CartesianSolver::grid;
133 using CartesianSolver::haloCellId;
134 using CartesianSolver::isActive;
135 using CartesianSolver::localPartitionCellOffsets;
136 using CartesianSolver::m_bandWidth;
137 using CartesianSolver::m_freeIndices;
138 using CartesianSolver::m_innerBandWidth;
139 using CartesianSolver::m_Ma;
140 using CartesianSolver::m_noDirs;
141 using CartesianSolver::m_outerBandWidth;
142 using CartesianSolver::m_Re;
143 using CartesianSolver::m_recalcIds;
144 using CartesianSolver::m_residualInterval;
145 using CartesianSolver::m_restartFile;
146 using CartesianSolver::m_revDir;
147 using CartesianSolver::m_solutionInterval;
148 using CartesianSolver::m_solutionOffset;
149 using CartesianSolver::m_solutionTimeSteps;
150 using CartesianSolver::m_solverId;
151 using CartesianSolver::maxLevel;
152 using CartesianSolver::maxNoGridCells;
153 using CartesianSolver::maxRefinementLevel;
154 using CartesianSolver::maxUniformRefinementLevel;
155 using CartesianSolver::minLevel;
156 using CartesianSolver::mpiComm;
157 using CartesianSolver::neighborDomain;
158 using CartesianSolver::noDomains;
159 using CartesianSolver::noHaloCells;
160 using CartesianSolver::noNeighborDomains;
161 using CartesianSolver::noWindowCells;
162 using CartesianSolver::outputDir;
163 using CartesianSolver::restartDir;
164 using CartesianSolver::returnIdleRecord;
165 using CartesianSolver::returnLoadRecord;
166 using CartesianSolver::solverId;
167 using CartesianSolver::solverMethod;
168 using CartesianSolver::updateDomainInfo;
169 using CartesianSolver::windowCellId;
170
171 using CartesianSolver::exchangeData;
172
174
176
177 struct PrimitiveVariables;
179
181
183 Geom& geometry() const { return *m_geometry; }
184
186 LPT(const MInt solverId, GridProxy& gridProxy_, Geom& geometry_, const MPI_Comm comm);
187
188 virtual ~LPT() {
189 };
190
191 LPT(const LPT&) = delete; // Prevent copy-construction
192 LPT& operator=(const LPT&) = delete; // Prevent assignment
193
194 // partcile collision class
195 std::unique_ptr<ParticleCollision<nDim>> m_collisionModel;
196
197 //------------------- run-loop and grid-controller function calls -------------------------------
198
199 void preTimeStep() override;
200 MBool solutionStep() override;
201 void postTimeStep() override;
202
203 void initSolver() override;
204 void finalizeInitSolver() override;
205 void saveSolverSolution(const MBool /*unused*/, const MBool /*unused*/) override{};
206 void cleanUp() override{};
207
208
209 // adaptation related functions
210 void prepareAdaptation() override;
211 void setSensors(std::vector<std::vector<MFloat>>&, std::vector<MFloat>&, std::vector<std::bitset<64>>&,
212 std::vector<MInt>&) override;
213 void swapProxy(MInt, MInt) override;
214 void resizeGridMap() override;
215 void postAdaptation() override;
216 void finalizeAdaptation() override;
217 void removeChilds(const MInt) override;
218 void removeCell(const MInt) override;
219 void refineCell(const MInt) override;
220 void swapCells(const MInt, const MInt) override;
221 MInt cellOutside(const MFloat*, const MInt, const MInt) override;
222 void sensorParticle(std::vector<std::vector<MFloat>>& sensors, std::vector<std::bitset<64>>& sensorCellFlag,
223 std::vector<MFloat>& sensorWeight, MInt sensorOffset, MInt sen) override;
224 void sensorInterface(std::vector<std::vector<MFloat>>& sensors, std::vector<std::bitset<64>>& sensorCellFlag,
225 std::vector<MFloat>& sensorWeight, MInt sensorOffset, MInt sen) override;
226
229 this->startLoadTimer(AT_);
230
232
233 // If LPTSolver is inactive on one of the ranks we need this allreduce!
234 if(grid().hasInactiveRanks()) {
235 MPI_Allreduce(MPI_IN_PLACE, &m_forceAdaptation, 1, MPI_C_BOOL, MPI_LOR, grid().raw().mpiComm(), AT_,
236 "MPI_IN_PLACE", "m_forceAdaptation");
237 }
238
239 this->stopLoadTimer(AT_);
240
241 return m_forceAdaptation;
242 }
243
244 // restart related functions
245 MBool prepareRestart(MBool force, MBool&) override;
246 void writeRestartFile(const MBool, const MBool, const MString, MInt*) override;
248 void writeCellSolutionFile(const MString&, MInt*);
249 void reIntAfterRestart(MBool /*unused*/) override{};
251 void writeRestartFile(MBool /*unused*/) override{};
252
253 // partition related functions
254 void setCellWeights(MFloat*) override;
255 void getSolverTimings(std::vector<std::pair<std::string, MFloat>>&, const MBool allTimings) override;
256 void getDefaultWeights(MFloat* weights, std::vector<MString>& names) const override;
257 void getLoadQuantities(MInt* const loadQuantities) const override;
258 MFloat getCellLoad(const MInt cellId, const MFloat* const weights) const override;
259 void limitWeights(MFloat*) override;
260 void getDomainDecompositionInformation(std::vector<std::pair<MString, MInt>>& domainInfo) override;
261 MInt noSolverTimers(const MBool allTimings) override {
262#ifdef MAIA_TIMER_FUNCTION
263 TERMM_IF_COND(!allTimings, "FIXME: reduced timings mode not yet supported by LPT.");
264 static const MInt noAdditionTimers = 9;
265 return 2 + noAdditionTimers;
266#else
267 return 2;
268#endif
269 }
270 MInt noLoadTypes() const override { return 3 + m_weightSourceCells; };
271
272 // balance related functions
273 void resetSolverFull();
274 void resetSolver() override;
275 void balancePre() override;
276 void balancePost() override;
277 void finalizeBalance() override;
278 void cancelMpiRequests() override;
279
280 MInt noCellDataDlb() const override {
281 if(grid().isActive()) {
282 return 3;
283 // 0: cell int data
284 // 1: particle float data
285 // 2: particle int data
286 } else {
287 return 0;
288 }
289 }
290 MInt cellDataTypeDlb(const MInt dataId) const override {
291 if(dataId == 1) {
292 return MFLOAT;
293 } else if(dataId == 0 || dataId == 2) {
294 return MINT;
295 } else {
296 TERMM(1, "solverCelldataType: invalid data id");
297 }
298 };
299 MInt cellDataSizeDlb(const MInt dataId, const MInt cellId) override;
301 void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt* const bufferIdToCellId,
302 MInt* const data) override;
303 void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt* const bufferIdToCellId,
304 MFloat* const data) override;
305
307 void setCellDataDlb(const MInt dataId, const MInt* const data) override;
308 void setCellDataDlb(const MInt dataId, const MFloat* const data) override;
309
311 void getGlobalSolverVars(std::vector<MFloat>& globalFloatVars, std::vector<MInt>& globalIdVars) override;
312 void setGlobalSolverVars(std::vector<MFloat>& globalFloatVars, std::vector<MInt>& globalIdVars) override;
313
314 MBool hasSplitBalancing() const override { return true; }
315
320
321 MInt a_hasNeighbor(const MInt cellId, const MInt dir) const { return grid().tree().hasNeighbor(cellId, dir); }
322
323 MInt mpiTag(const MString exchangeType) {
324 switch((LPTmpiTag)string2enum(exchangeType)) {
325 case PARTICLE_COUNT: {
326 return 0;
327 }
328 case PARTICLE_FLOAT: {
329 if(!m_primaryExchange) {
330 return 1;
331 } else {
332 return 5;
333 }
334 }
335 case PARTICLE_INT: {
336 if(!m_primaryExchange) {
337 return 2;
338 } else {
339 return 6;
340 }
341 }
342 case SOURCE_TERMS: {
343 return 3;
344 }
345 case FLOW_FIELD: {
346 return 7;
347 }
348 case CHECK_ADAP: {
349 return 8;
350 }
351 case VELOCITY_SLOPES: {
352 return 14;
353 }
354 default: {
355 mTerm(1, AT_, "Unknown mpiTag");
356 return -1;
357 }
358 }
359 }
360
361 MFloat reduceData(const MInt cellId, MFloat* data, const MInt dataBlockSize = 1, const MBool average = true);
362
363 //---------------------- accessors to LPT cell- or particle collector ---------------------------
364
365 template <class LPTParticle = LPTSpherical<nDim>>
367 IF_CONSTEXPR(std::is_same_v<LPTParticle, LPTSpherical<nDim>>) { return m_partList.size(); }
368 IF_CONSTEXPR(std::is_same_v<LPTParticle, LPTEllipsoidal<nDim>>) { return m_partListEllipsoid.size(); }
369 mTerm(-1, AT_, "Unknown particle type");
370 }
371 MInt a_noSphericalParticles() const { return m_partList.size(); }
373 MInt a_noCells() const { return m_cells.size(); }
374
375 template <class LPTParticle>
376 std::vector<LPTParticle>& a_particleList() {
377 IF_CONSTEXPR(std::is_same_v<LPTParticle, LPTSpherical<nDim>>) { return m_partList; }
378 IF_CONSTEXPR(std::is_same_v<LPTParticle, LPTEllipsoidal<nDim>>) { return m_partListEllipsoid; }
379 mTerm(-1, AT_, "Unknown particle type");
380 }
381
382 MFloat& a_volumeFraction(const MInt cellId) { return m_cells.volumeFraction(cellId); }
383 MFloat a_volumeFraction(const MInt cellId) const { return m_cells.volumeFraction(cellId); }
384
385 MInt& a_noParticlesInCell(const MInt cellId) { return m_cells.noParticles(cellId); }
386 MInt a_noParticlesInCell(const MInt cellId) const { return m_cells.noParticles(cellId); }
387
388 MInt& a_noEllipsoidsInCell(const MInt cellId) { return m_cells.noEllipsoids(cellId); }
389 MInt a_noEllipsoidsInCell(const MInt cellId) const { return m_cells.noEllipsoids(cellId); }
390
391 MInt& a_bndryCellId(const MInt cellId) { return m_cells.bndryCellId(cellId); }
392 MInt a_bndryCellId(const MInt cellId) const { return m_cells.bndryCellId(cellId); }
393
394 MFloat& a_fluidVariable(const MInt cellId, const MInt var) { return m_cells.fluidVariable(cellId, var); }
395 MFloat a_fluidVariable(const MInt cellId, const MInt var) const { return m_cells.fluidVariable(cellId, var); }
396
397 MFloat& a_fluidVelocity(const MInt cellId, const MInt dim) { return m_cells.fluidVariable(cellId, PV.VV[dim]); }
398 MFloat a_fluidVelocity(const MInt cellId, const MInt dim) const { return m_cells.fluidVariable(cellId, PV.VV[dim]); }
399
400 MFloat& a_fluidDensity(const MInt cellId) { return m_cells.fluidVariable(cellId, PV.RHO); }
401 MFloat a_fluidDensity(const MInt cellId) const { return m_cells.fluidVariable(cellId, PV.RHO); }
402
403 MFloat& a_fluidPressure(const MInt cellId) { return m_cells.fluidVariable(cellId, PV.P); }
404 MFloat a_fluidPressure(const MInt cellId) const { return m_cells.fluidVariable(cellId, PV.P); }
405
406 MFloat& a_fluidTemperature(const MInt cellId) { return m_cells.fluidVariable(cellId, PV.T); }
407 MFloat a_fluidTemperature(const MInt cellId) const { return m_cells.fluidVariable(cellId, PV.T); }
408
409 MFloat& a_fluidSpecies(const MInt cellId) { return m_cells.fluidSpecies(cellId); }
410 MFloat a_fluidSpecies(const MInt cellId) const { return m_cells.fluidSpecies(cellId); }
411
412 MFloat& a_heatFlux(const MInt cellId) { return m_cells.heatFlux(cellId); }
413 MFloat a_heatFlux(const MInt cellId) const { return m_cells.heatFlux(cellId); }
414
415 MFloat& a_massFlux(const MInt cellId) { return m_cells.massFlux(cellId); }
416 MFloat a_massFlux(const MInt cellId) const { return m_cells.massFlux(cellId); }
417
418 MFloat& a_momentumFlux(const MInt cellId, const MInt dim) { return m_cells.momentumFlux(cellId, dim); }
419 MFloat a_momentumFlux(const MInt cellId, const MInt dim) const { return m_cells.momentumFlux(cellId, dim); }
420
421 MFloat& a_workFlux(const MInt cellId) { return m_cells.workFlux(cellId); }
422 MFloat a_workFlux(const MInt cellId) const { return m_cells.workFlux(cellId); }
423
424 MFloat& a_velocitySlope(const MInt cellId, const MInt varId, const MInt dir) {
425 return m_cells.velocitySlope(cellId, varId, dir);
426 }
427 MFloat a_velocitySlope(const MInt cellId, const MInt varId, const MInt dir) const {
428 return m_cells.velocitySlope(cellId, varId, dir);
429 }
430
431 void a_resetPropertiesSolver(const MInt cellId) { m_cells.resetProperties(cellId); }
432
433 MBool a_isHalo(const MInt cellId) const { return m_cells.hasProperty(cellId, LptCell::IsHalo); }
434 maia::lpt::cell::BitsetType::reference a_isHalo(const MInt cellId) {
435 return m_cells.hasProperty(cellId, LptCell::IsHalo);
436 }
437
438 MBool a_isWindow(const MInt cellId) const { return m_cells.hasProperty(cellId, LptCell::IsWindow); }
439 maia::lpt::cell::BitsetType::reference a_isWindow(const MInt cellId) {
440 return m_cells.hasProperty(cellId, LptCell::IsWindow);
441 }
442
443 MBool a_isValidCell(const MInt cellId) const { return m_cells.hasProperty(cellId, LptCell::IsValid); }
444 maia::lpt::cell::BitsetType::reference a_isValidCell(const MInt cellId) {
445 return m_cells.hasProperty(cellId, LptCell::IsValid);
446 }
447
448 MBool a_regridTrigger(const MInt cellId) const { return m_cells.hasProperty(cellId, LptCell::RegridTrigger); }
449 maia::lpt::cell::BitsetType::reference a_regridTrigger(const MInt cellId) {
450 return m_cells.hasProperty(cellId, LptCell::RegridTrigger);
451 }
452
453 MBool a_isBndryCell(const MInt cellId) const override { return a_bndryCellId(cellId) > -1; }
454
455 const MFloat& a_coordinate(const MInt cellId, const MInt dim) const {
456 if(a_isBndryCell(cellId)) {
457 return m_bndryCells->a[a_bndryCellId(cellId)].m_coordinates[dim];
458 }
459 return grid().tree().coordinate(cellId, dim);
460 }
461
462
463 //--------------------------LPT internal functions and data ----------------------------------------
464
465 template <class P, MInt a, MInt b>
466 void interpolateAndCalcWeights(P& particle, const MInt cellId, const MFloat* position, const MFloat* interpolatedVar,
467 std::vector<MFloat>& weight);
468
469 template <MInt a, MInt b, MBool interpolateVelocitySlopes>
470 void interpolateVariablesLS(const MInt cellId, const MFloat* const position, MFloat* const interpolatedVar);
471 template <MInt a, MInt b>
472 void interpolateVariablesLS(const MInt cellId, const MFloat* const position, MFloat* const interpolatedVar) {
473 interpolateVariablesLS<a, b, false>(cellId, position, interpolatedVar);
474 }
475
476 void updateFluidFraction();
477 MFloat injectionDuration() const { return m_sprayModel != nullptr ? m_sprayModel->injectionDuration() : m_time; }
478
479 MFloat timeSinceSOI() const { return m_sprayModel != nullptr ? m_sprayModel->timeSinceSOI() : m_time; }
480
482 if(m_sprayModel != nullptr) return m_spawnCellId;
483 if(domainId() == 0) {
484 return 1;
485 } else {
486 return -1;
487 }
488 }
489
490 // TODO labels:LPT,PP move to postData as soon as its available!
491 std::map<MInt, std::vector<MFloat>> m_injData;
492
493
495 MInt sumPart = 0;
496 MInt noPart = m_partList.size();
497 MPI_Allreduce(&noPart, &sumPart, 1, MPI_INT, MPI_SUM, mpiComm(), AT_, "INPLACE", "sumpart");
498 return sumPart;
499 }
500
502 MInt sumPart = 0;
503 MInt noPart = m_partListEllipsoid.size();
504 MPI_Allreduce(&noPart, &sumPart, 1, MPI_INT, MPI_SUM, mpiComm(), AT_, "INPLACE", "sumpart");
505 return sumPart;
506 }
507
508 template <class LPTParticle>
509 MBool pushToQueue(std::vector<std::map<MInt, MInt>>& pointsTo, const MInt partPos) {
510 std::vector<LPTParticle>& partList = a_particleList<LPTParticle>();
512 for(MInt d = 0; d < grid().noNeighborDomains(); d++) {
513 auto pos = pointsTo[d].find(partList[partPos].m_cellId);
514 // particle is inside a halo cell so send it...
515 if(pos != pointsTo[d].end()) {
516 thisSend.partPos = partPos;
517 thisSend.toCellId = pos->second;
518 m_queueToSend[d].push(thisSend);
519 return true;
520 }
521 }
522 return false;
523 }
524
525 protected:
526 // Types
527 std::vector<LPTSpherical<nDim>> m_partList;
528 std::vector<LPTEllipsoidal<nDim>> m_partListEllipsoid;
529
530 std::map<MInt, std::vector<MInt>> m_cellToNghbrHood;
531 std::map<MInt, std::vector<MInt>> m_cellToNghbrHoodInterpolation;
532
534 // Timers
535 // Timer group which holds all solver-wide timers
537 // Stores all solver-wide timers
538 std::array<MInt, Timers::_count> m_timers{};
539
542
544
551
554
556
557 // randon number for particle spawn at spanDomainId
558 std::mt19937_64 m_PRNGSpawn;
560 // random number for particle respawn at respawnDomain
561 std::mt19937_64 m_PRNGRespawn;
562 // randon number for particle initialisation on all ranks
563 // the value is not needed for a restart!
564 std::mt19937_64 m_PRNGInit;
565
567
568 std::vector<std::map<MInt, MInt>> m_pointsToHalo;
569 std::vector<std::map<MInt, MInt>> m_pointsToWindow;
570
571 std::map<MFloat, MFloat> m_terminalVelocity;
572
577
578 // parallel:
581 MPI_Request* m_sourceSendRequest = nullptr;
582 MPI_Request* m_sourceRecvRequest = nullptr;
583 std::vector<std::unique_ptr<MFloat[]>> m_sourceRecv{};
584 std::vector<std::unique_ptr<MFloat[]>> m_sourceSend{};
585
586 MPI_Request* m_checkAdaptationRecvRequest = nullptr;
587 MPI_Request* m_checkAdaptationSendRequest = nullptr;
588 std::vector<MInt> m_checkAdaptationRecv{};
589 std::vector<MInt> m_checkAdaptationSend{};
590
591 MPI_Request* m_flowSendRequest = nullptr;
592 MPI_Request* m_flowRecvRequest = nullptr;
593 MFloat** m_flowRecv = nullptr;
594 MFloat** m_flowSend = nullptr;
595
596 MPI_Request* m_slopesSendRequest = nullptr;
597 MPI_Request* m_slopesRecvRequest = nullptr;
598 MFloat** m_slopesRecv = nullptr;
599 MFloat** m_slopesSend = nullptr;
600
601 std::vector<MInt> m_sendSize{};
602 std::vector<MInt> m_recvSize{};
603
604 std::vector<MPI_Request> m_mpi_reqSendFloat{};
605 std::vector<MPI_Request> m_mpi_reqSendInt{};
606 std::vector<MPI_Request> m_mpi_reqSendSize{};
607 std::vector<MPI_Request> m_mpi_reqRecvFloat{};
608 std::vector<MPI_Request> m_mpi_reqRecvInt{};
609 std::vector<MPI_Status> m_mpi_statusProbe{};
610 std::vector<std::unique_ptr<MFloat[]>> m_sendBuffer{};
611 std::vector<std::unique_ptr<MFloat[]>> m_recvBuffer{};
612 std::vector<std::unique_ptr<MInt[]>> m_intSendBuffer{};
613 std::vector<std::unique_ptr<MInt[]>> m_intRecvBuffer{};
618
620
621 MPI_Status m_mpi_statusInt{};
622 MPI_Status m_mpi_statusFloat{};
623
626
631
634
639
641
643
645
647
649
651
652 void particleRespawn();
653
654 void spawnParticles();
655
656 MInt addParticle(const MInt cellId, const MFloat diameter, const MFloat particleDensityRatio, const MInt random = 1,
657 const MInt addMode = 0, const MFloat* velocity = nullptr, const MFloat* position = nullptr,
658 const MInt parcelSize = 1);
659
660 MInt addEllipsoid(const MInt cellId, const MFloat semiMinorAxis, const MFloat aspectRatio,
661 const MFloat particleDensityRatio, const MInt random = 1, const MInt addMode = 0,
662 const MFloat* velocity = nullptr, const MFloat* position = nullptr);
663
665
666 void writePartData();
668
669 // Particle sizes for exchange
670 template <class LPTParticle>
672 return LPTParticle::s_floatElements + LPTBase<nDim>::s_floatElements;
673 }
674 template <class LPTParticle>
676 return LPTParticle::s_intElements + LPTBase<nDim>::s_intElements;
677 }
678 template <class LPTParticle>
680 return m_exchangeBufferSize * elemPerP<LPTParticle>() + 1;
681 }
682 template <class LPTParticle>
684 return m_exchangeBufferSize * intElemPerP<LPTParticle>() + 1;
685 }
686
687 void exchangeParticles(const MBool collOnly, const MInt offset, const MBool allowNonLeaf = false);
688 template <class LPTParticle>
689 void exchangeParticles_(const MBool collOnly, const MInt offset, const MBool allowNonLeaf = false);
690 template <class LPTParticle>
691 void sendAndReceiveParticles(const MBool allowNonLeaf);
692 template <MBool allNeighbors, class LPTParticle>
693 void sendParticles();
694 template <MBool allNeighbors>
695 void receiveParticles();
696 template <MBool allNeighbors, class LPTParticle>
697 void receiveParticles_();
698 void exchangeOffset(MInt noParticles);
699 void exchangeSourceTerms();
700 void sendSourceTerms();
701 void receiveSourceTerms();
702 void sendFlowField();
703 void receiveFlowField();
704 void waitForSendReqs();
705 void sendVelocitySlopes();
707
708 void checkParticles();
709 void checkCells();
710 void resetSourceTerms(const MInt);
711
712 template <class T, class Pred>
713 void own_sort(T& c, Pred& p) {
714 using tag = typename std::iterator_traits<typename T::iterator>::iterator_category;
715 sort_impl_(c, p, tag());
716 }
717
718 template <class T, class Pred>
719 void sort_impl_(T& c, Pred& p, std::random_access_iterator_tag /*unused*/) {
720 std::sort(c.begin(), c.end(), p);
721 }
722
723 template <class T, class Pred>
724 void own_remove_if(T& c, Pred& p) {
725 using tag = typename std::iterator_traits<typename T::iterator>::iterator_category;
726 remove_if_impl_(c, p, tag());
727 }
728
729 template <class T, class Pred>
730 void remove_if_impl_(T& c, Pred& p, std::random_access_iterator_tag /*unused*/) {
731 c.erase(std::remove_if(c.begin(), c.end(), p), c.end());
732 }
733
734 MBool smallParticle(const LPTSpherical<nDim>& particle) { return (particle.m_diameter < m_sizeLimit); }
735
736 inline std::mt19937_64& randomSpawn(const MInt calls) {
737 ASSERT(domainId() == m_spawnDomainId, "");
738 m_PRNGSpawnCount += calls;
739 return m_PRNGSpawn;
740 }
741 inline std::mt19937_64& randomRespawn() {
742 ASSERT(domainId() == m_respawnDomain, "");
743 return m_PRNGRespawn;
744 }
745 inline std::mt19937_64& randomInit() {
746 ASSERT(!m_restart, "");
747 return m_PRNGInit;
748 }
749
750 private:
752
755 std::array<MFloat, nDim> m_globDomainLength{};
756 std::array<MFloat, nDim * 2> m_globBbox{0};
757
762
764
765 MFloat m_xCutOff = -1000.0;
766
768
772
779
780 // respawn properties
787 std::vector<MInt> m_respawnCells;
788
793
795
797
798 std::unique_ptr<SprayModel<nDim>> m_sprayModel;
799 static constexpr MInt m_addInjDataCnt = 4;
800
801 // particle spawn properties:
811 MInt m_spawnEmittDist = string2enum("PART_EMITT_DIST_UNIFORM");
814
815 std::unique_ptr<MaterialState<nDim>> m_material;
816
818
819 std::multimap<MInt, LPTSpherical<nDim>*> m_cellToPartMap;
820 std::multimap<MInt, LPTEllipsoidal<nDim>*> m_cellToEllipsMap;
821
823
824 // DLB reinitialization stage
826
830
831 // particle functions (placed in lpt_props.h)
837
840
841 void initMPI(const MBool = true);
843 void initSummary();
844 void initCollector();
845 void initBndryCells();
847 void initGridProperties();
849
851
852 void computeBoundingBox(MFloat* globalBbox) {
853 // if has cutoff, find solver specific bouding box, else use bounding box of raw grid
854 if(Context::propertyExists("cutOffCoordinates", m_solverId)
855 || Context::propertyExists("cutOffDirections", m_solverId)) {
856 MFloat bboxLocal[nDim * 2];
857 for(MInt i = 0; i < nDim; i++) {
858 bboxLocal[i] = std::numeric_limits<MFloat>::max();
859 bboxLocal[nDim + i] = std::numeric_limits<MFloat>::lowest();
860 }
861 // Find local max and min values
862 for(MInt cellId = 0; cellId < grid().noInternalCells(); cellId++) {
863 for(MInt i = 0; i < nDim; i++) {
864 bboxLocal[i] =
865 mMin(bboxLocal[i],
866 grid().tree().coordinate(cellId, i) - F1B2 * grid().cellLengthAtLevel(grid().tree().level(cellId)));
867 bboxLocal[nDim + i] =
868 mMax(bboxLocal[nDim + i],
869 grid().tree().coordinate(cellId, i) + F1B2 * grid().cellLengthAtLevel(grid().tree().level(cellId)));
870 }
871 }
872 for(MInt i = 0; i < 2 * nDim; i++)
873 globalBbox[i] = bboxLocal[i];
874 // reduce over all domains to find the global min and max values
875 MPI_Allreduce(MPI_IN_PLACE, &globalBbox[0], nDim, MPI_DOUBLE, MPI_MIN, mpiComm(), AT_, "MPI_IN_PLACE",
876 "m_bbox[0]");
877 MPI_Allreduce(MPI_IN_PLACE, &globalBbox[nDim], nDim, MPI_DOUBLE, MPI_MAX, mpiComm(), AT_, "MPI_IN_PLACE",
878 "m_bbox[nDim]");
879 } else {
880 for(MInt i = 0; i < 2 * nDim; i++) {
881 globalBbox[i] = grid().raw().globalBoundingBox()[i];
882 }
883 }
884 }
885
887
888 // void addBndryCell(const MInt cellId, std::array<MFloat, nDim + 1>& nbndryData, std::array<MFloat, nDim>& surfaceN,
889 // std::array<std::array<MFloat, nDim>, nDim + 1>& surfaceC, std::array<MFloat, nDim>& surfaceV);
890
891
892 void packParticles(std::vector<LPTSpherical<nDim>*>& particlesToSend, MInt* intBuffer, MFloat* floatBuffer,
893 std::vector<MInt>);
894 void packParticles(std::vector<LPTEllipsoidal<nDim>*>& particlesToSend, MInt* intBuffer, MFloat* floatBuffer,
895 std::vector<MInt>);
896
897 template <class LPTParticle, MBool t_search>
898 void unpackParticles(const MInt num, const MInt* intBuffer, const MFloat* floatBuffer, const MInt domainId = -1,
899 const MBool allowNonLeaf = false);
900 void unpackParticle(LPTSpherical<nDim>& thisParticle, const MInt* intBuffer, MInt& z, const MFloat* floatBuffer,
901 MInt& h, MInt& step, MInt id);
902 void unpackParticle(LPTEllipsoidal<nDim>& thisParticle, const MInt* intBuffer, MInt& z, const MFloat* floatBuffer,
903 MInt& h, MInt& step, MInt id);
904
905 void broadcastInjected(const MUint prevNumPart);
906 void recvInjected();
907
908 void sendInjected(const MUint prevNumPart);
909
910 void updateExchangeCells();
911
912 void motionEquation(const MInt offset);
913 void motionEquationEllipsoids(const MInt offset);
914 void evaporation(const MInt offset);
915 void coupling(MInt offset);
916 void advanceParticles(const MInt offset);
917 void perCellStats();
919 void reduceParticles();
921 void spawnTimeStep();
922 void sprayInjection();
923 // void collision();
924 void removeInvalidParticles(const MBool);
925
926 void wallCollision();
928 void writeCollData();
929
930 void setRegridTrigger();
931 void checkRegridTrigger();
932 void recvRegridTrigger();
933
934 void initializeTimers();
935
936 public:
939
940 MFloat time() const override { return m_time; }
941 MInt noVariables() const override {
942 // noParticlesInCell
943 return 1;
944 }
945
947
951
952 //-------------- Pass-Through accesors to the grid proxy ------------------------------------------
953
954 MInt c_noCells() const { return grid().tree().size(); }
955
956 MInt c_childId(const MInt cellId, const MInt pos) const { return grid().tree().child(cellId, pos); }
957
958 MInt c_noChildren(const MInt cellId) const { return grid().tree().noChildren(cellId); }
959
960 MInt c_parentId(const MInt cellId) const { return grid().tree().parent(cellId); }
961
962 MFloat c_cellLengthAtLevel(const MInt level) const { return grid().cellLengthAtLevel(level); }
963
964 MFloat c_cellLengthAtCell(const MInt cellId) const { return c_cellLengthAtLevel(c_level(cellId)); }
965
966 MInt c_level(const MInt cellId) const { return grid().tree().level(cellId); }
967
968 MInt a_level(const MInt cellId) const { return c_level(cellId); }
969
970 MFloat c_cellVolume(const MInt cellId) const { return grid().cellVolumeAtLevel(grid().tree().level(cellId)); }
971
972 MFloat c_coordinate(const MInt cellId, const MInt dir) const { return grid().tree().coordinate(cellId, dir); }
973
974 MBool c_isLeafCell(const MInt cellId) const { return grid().tree().isLeafCell(cellId); }
975
976 MLong c_globalId(const MInt cellId) const { return grid().tree().globalId(cellId); }
977
978 // override accessors as already defined in the solver!
979 MInt noInternalCells() const override { return grid().noInternalCells(); }
980 MInt domainId() const override { return grid().domainId(); }
981 MInt noDomains() const override { return grid().noDomains(); }
982
983 MInt c_hasNeighbor(const MInt cellId, const MInt dir) const { return grid().tree().hasNeighbor(cellId, dir); }
984
985 MInt c_neighborId(const MInt cellId, const MInt dir) const { return grid().tree().neighbor(cellId, dir); }
986
987 inline MBool a_validCell(const MInt cellId) {
988 if(cellId < 0 || cellId > a_noCells()) {
989 return false;
990 }
991 return true;
992 }
993
994
995 //-------------- empty functions for post-processing ------------------------------------------
996
998 std::cerr << "loadSampleVariables DgCartesianSolver " << timeStep << std::endl;
999 };
1000 void getSampleVariables(MInt cellId, const MFloat*& vars) {
1001 std::cerr << "getSampleVariables LPT " << cellId << " " << vars << std::endl;
1002 };
1003 void getSampleVariables(const MInt cellId, std::vector<MFloat>& /*vars*/) {
1004 std::cerr << "getSampleVariables LPT " << cellId << std::endl;
1005 };
1006 void calculateHeatRelease() { std::cerr << "calculateHeatRelease DgCartesianSolver " << std::endl; }
1007 void getHeatRelease(MFloat*& heatRelease) {
1008 std::cerr << "getHeatRelease DgCartesianSolver " << heatRelease << std::endl;
1009 }
1010};
1011
1014template <MInt nDim>
1016 static const MInt Segfault = std::numeric_limits<MInt>::min();
1017
1018 static constexpr MInt U = 0;
1019 static constexpr MInt V = 1;
1020 static constexpr MInt W = nDim == 3 ? 2 : Segfault;
1021 static constexpr std::array<MInt, 3> VV = {0, 1, 2};
1022 static constexpr MInt RHO = nDim;
1023 static constexpr MInt P = nDim + 1;
1024 static constexpr MInt T = nDim + 2;
1025
1026 static constexpr MInt m_noVars = nDim + 3;
1027 constexpr MInt noVars() const { return m_noVars; };
1028};
1029
1030#endif
GridCell
Grid cell Property Labels.
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
Definition: context.cpp:494
Definition: lpt.h:82
PrimitiveVariables PV
Definition: lpt.h:178
void sendSourceTerms()
exchanges the source terms on the LPT grid, non-Blocking version from above
Definition: lpt.cpp:7648
MFloat c_cellVolume(const MInt cellId) const
Definition: lpt.h:970
virtual ~LPT()
Definition: lpt.h:188
void cancelMpiRequests() override
actually doing same pre-partitioneing stuff during balcne
Definition: lpt.cpp:6855
void getHeatRelease(MFloat *&heatRelease)
Definition: lpt.h:1007
MInt m_noOuterBndryCells
Definition: lpt.h:792
MBool a_isBndryCell(const MInt cellId) const override
Definition: lpt.h:453
void readSpawnProps()
Read properties related to creating particles from configuration file.
MInt m_timeStepComputationInterval
Definition: lpt.h:575
MFloat calculateAverageRep()
MFloat a_fluidSpecies(const MInt cellId) const
Definition: lpt.h:410
MInt m_PRNGSpawnCount
Definition: lpt.h:559
MFloat m_sumEvapMass
Definition: lpt.h:640
MInt m_adaptationLevel
Definition: lpt.h:822
void checkCells()
some debug check for cells
Definition: lpt.cpp:6631
std::mt19937_64 & randomRespawn()
Definition: lpt.h:741
void broadcastInjected(const MUint prevNumPart)
Send newly created particles.
Definition: lpt.cpp:6221
LptCellCollector m_cells
Definition: lpt.h:175
void perCellStats()
set cell-particle mapping which is used to merge particle in reduceParticles!
Definition: lpt.cpp:2780
void motionEquationEllipsoids(const MInt offset)
void receiveParticles_()
receive particles that have been sent non-blocking before
Definition: lpt.cpp:3851
MBool m_heatCoupling
Definition: lpt.h:636
std::mt19937_64 & randomInit()
Definition: lpt.h:745
typename CartesianSolver::GridProxy GridProxy
Definition: lpt.h:125
MLong c_globalId(const MInt cellId) const
Definition: lpt.h:976
MInt a_hasNeighbor(const MInt cellId, const MInt dir) const
Definition: lpt.h:321
void calculateHeatRelease()
Definition: lpt.h:1006
void sendParticles()
send particles non-blocking
Definition: lpt.cpp:3705
MBool m_openRegridSend
Definition: lpt.h:629
void spawnParticles()
Spawn new particles (used for testing)
Definition: lpt.cpp:5734
std::vector< LPTParticle > & a_particleList()
Definition: lpt.h:376
MInt m_noRespawnDomains
Definition: lpt.h:784
void interpolateVariablesLS(const MInt cellId, const MFloat *const position, MFloat *const interpolatedVar)
calculates interpolated variables (in the range a, b) for a given position in a given cell
Definition: lpt.cpp:8063
void getCellDataDlb(const MInt dataId, const MInt oldNoCells, const MInt *const bufferIdToCellId, MInt *const data) override
Return solver data for DLB.
Definition: lpt.cpp:7026
MBool m_openParticleSend
Definition: lpt.h:625
void setCellDataDlb(const MInt dataId, const MInt *const data) override
Set solver data for DLB.
Definition: lpt.cpp:7123
MBool a_isWindow(const MInt cellId) const
Definition: lpt.h:438
void sendAndReceiveParticles(const MBool allowNonLeaf)
Particle transfer between solvers The particles to be sent are in the queueToSend array MBool mayExis...
Definition: lpt.cpp:3603
void interpolateAndCalcWeights(P &particle, const MInt cellId, const MFloat *position, const MFloat *interpolatedVar, std::vector< MFloat > &weight)
MInt intBufSize()
Definition: lpt.h:683
MInt mpiTag(const MString exchangeType)
Definition: lpt.h:323
MPI_Request * m_checkAdaptationSendRequest
Definition: lpt.h:587
MBool m_ellipsoids
Definition: lpt.h:769
MFloat & a_fluidTemperature(const MInt cellId)
Definition: lpt.h:406
std::map< MInt, std::vector< MInt > > m_cellToNghbrHoodInterpolation
Definition: lpt.h:531
MFloat a_fluidVelocity(const MInt cellId, const MInt dim) const
Definition: lpt.h:398
void motionEquation(const MInt offset)
Definition: lpt.cpp:2962
std::vector< MPI_Request > m_mpi_reqSendFloat
Definition: lpt.h:604
MInt c_childId(const MInt cellId, const MInt pos) const
Definition: lpt.h:956
void checkRegridTrigger()
check if any of the cells with the regrid Trigger also have particles inside
Definition: lpt.cpp:7470
void computeBoundingBox(MFloat *globalBbox)
Definition: lpt.h:852
void unpackParticle(LPTSpherical< nDim > &thisParticle, const MInt *intBuffer, MInt &z, const MFloat *floatBuffer, MInt &h, MInt &step, MInt id)
Unpack spherical particle from buffers.
Definition: lpt.cpp:6084
MFloat m_weightParticleCell
Definition: lpt.h:547
MFloat & a_massFlux(const MInt cellId)
Definition: lpt.h:415
MFloat getCellLoad(const MInt cellId, const MFloat *const weights) const override
Return the load of a single cell (given computational weights).
Definition: lpt.cpp:1988
void getLoadQuantities(MInt *const loadQuantities) const override
Return the cumulative load quantities on this domain.
Definition: lpt.cpp:1934
MLong m_addedParticle
Definition: lpt.h:817
Collector< LPTBndryCell< nDim > > * m_bndryCells
Definition: lpt.h:180
void balancePre() override
reset the solver during balancing
Definition: lpt.cpp:6867
void checkParticles()
some debug check for partcles
Definition: lpt.cpp:6441
MInt intElemPerP()
Definition: lpt.h:675
MInt m_initializationMethod
Definition: lpt.h:773
MFloat m_respawnPlane
Definition: lpt.h:782
std::vector< std::unique_ptr< MFloat[]> > m_sendBuffer
Definition: lpt.h:610
MBool prepareRestart(MBool force, MBool &) override
before writing a restart file
Definition: lpt.cpp:2547
void cleanUp() override
Definition: lpt.h:206
MInt domainId() const override
Return the domainId (rank)
Definition: lpt.h:980
MInt globalNoParticles()
Definition: lpt.h:494
void writeRestartFile(MBool) override
Definition: lpt.h:251
MInt & a_bndryCellId(const MInt cellId)
Definition: lpt.h:391
MFloat calculateTotalKineticEnergy()
void setCellWeights(MFloat *) override
set cell weight for partitioning
Definition: lpt.cpp:1827
void getSampleVariables(MInt cellId, const MFloat *&vars)
Definition: lpt.h:1000
MInt c_noChildren(const MInt cellId) const
Definition: lpt.h:958
void initCollector()
init LPT cell collector
Definition: lpt.cpp:153
MFloat a_fluidTemperature(const MInt cellId) const
Definition: lpt.h:407
MFloat m_FrMag
Definition: lpt.h:774
void remove_if_impl_(T &c, Pred &p, std::random_access_iterator_tag)
Definition: lpt.h:730
void initGridProperties()
calculate Grid Properties for periodic boundaries, adapted from rigedbodies
Definition: lpt.cpp:603
MFloat & a_fluidDensity(const MInt cellId)
Definition: lpt.h:400
MBool m_respawn
Definition: lpt.h:781
maia::lpt::cell::BitsetType::reference a_regridTrigger(const MInt cellId)
Definition: lpt.h:449
void finalizeAdaptation() override
reinit the solver after the full adaptation loop!
Definition: lpt.cpp:1434
MBool m_activeSecondaryBUp
Definition: lpt.h:761
void resizeGridMap() override
Swap the given cells.
Definition: lpt.cpp:1519
MInt a_noEllipsoidsInCell(const MInt cellId) const
Definition: lpt.h:389
MFloat m_spawnCoord[nDim]
Definition: lpt.h:809
void postAdaptation() override
post adaptation for split adaptation within the adaptation loop
Definition: lpt.cpp:1394
void sort_impl_(T &c, Pred &p, std::random_access_iterator_tag)
Definition: lpt.h:719
MInt a_noSphericalParticles() const
Definition: lpt.h:371
MInt a_level(const MInt cellId) const
Definition: lpt.h:968
LPT & operator=(const LPT &)=delete
MInt c_noCells() const
Definition: lpt.h:954
MInt cellOutside(const MFloat *, const MInt, const MInt) override
checks if a child lies outSide of the domain! necessary for refinement at the bndry!
Definition: lpt.cpp:1740
void loadSampleVariables(MInt timeStep)
Definition: lpt.h:997
MInt m_solutionStep
Definition: lpt.h:949
std::vector< MPI_Request > m_mpi_reqRecvInt
Definition: lpt.h:608
MInt loadParticleRestartFile()
Read particle restart file and create new particle instances accordingly.
Definition: lpt.cpp:4822
void refineCell(const MInt) override
refining a cartesian cell
Definition: lpt.cpp:1538
MInt m_collisions
Definition: lpt.h:791
MInt m_spawnParticlesCount
Definition: lpt.h:808
void writeCollData()
Definition: lpt.cpp:6433
void crankAngleSolutionOutput()
save a full solutionOutput at timeSteps closesed to a specified crankAngle Interval save a solution s...
Definition: lpt.cpp:7935
void recvRegridTrigger()
Definition: lpt.cpp:7507
MFloat m_weightBaseCell
Definition: lpt.h:545
MInt m_liftModelType
Definition: lpt.h:776
void getDomainDecompositionInformation(std::vector< std::pair< MString, MInt > > &domainInfo) override
Return decomposition information, i.e. number of local elements,...
Definition: lpt.cpp:2031
MInt a_noCells() const
Definition: lpt.h:373
typename maia::CartesianSolver< nDim, LPT > CartesianSolver
Definition: lpt.h:120
static constexpr MInt m_addInjDataCnt
Definition: lpt.h:799
std::unique_ptr< ParticleCollision< nDim > > m_collisionModel
Definition: lpt.h:195
MFloat m_spawnVelocity
Definition: lpt.h:810
void resetSourceTerms(const MInt)
reset all source terms with cellId larger than the offset
Definition: lpt.cpp:2112
MBool m_timeStepUpdated
Definition: lpt.h:576
MInt globalNoEllipsoids()
Definition: lpt.h:501
MBool m_evaporation
Definition: lpt.h:638
std::vector< MInt > m_checkAdaptationSend
Definition: lpt.h:589
std::vector< std::unique_ptr< MFloat[]> > m_recvBuffer
Definition: lpt.h:611
MFloat a_momentumFlux(const MInt cellId, const MInt dim) const
Definition: lpt.h:419
void readMomentumCouplingProps()
Read properties specific to the momentum coupling.
void exchangeParticles(const MBool collOnly, const MInt offset, const MBool allowNonLeaf=false)
Calls exchange for the different particle types.
Definition: lpt.cpp:3463
void resetSolver() override
actually doing some pre-balance-stuff
Definition: lpt.cpp:6655
MBool m_primaryExchange
Definition: lpt.h:579
MFloat m_cfl
Definition: lpt.h:796
MPI_Status m_mpi_statusInt
Definition: lpt.h:621
void readEllipsoidProps()
Read properties specific to ellipsoids.
void evaporation(const MInt offset)
Definition: lpt.cpp:2991
MInt noSolverTimers(const MBool allTimings) override
Definition: lpt.h:261
MBool fiveStageSolutionStep()
Splitting the solutionStep into 5 separate parts to match the 5-stage Runge-Kutta time-stepping for i...
Definition: lpt.cpp:2194
std::vector< std::unique_ptr< MFloat[]> > m_sourceSend
Definition: lpt.h:584
MInt injectorCellId() const
Definition: lpt.h:481
void initParticleLog()
void receiveSourceTerms()
exchanges the source terms on the LPT grid, non-Blocking version from above
Definition: lpt.cpp:7699
MInt c_neighborId(const MInt cellId, const MInt dir) const
Definition: lpt.h:985
MFloat ** m_slopesRecv
Definition: lpt.h:598
MBool m_momentumCoupling
Definition: lpt.h:635
void removeCell(const MInt) override
Remove the given cell.
Definition: lpt.cpp:1717
std::vector< MInt > m_checkAdaptationRecv
Definition: lpt.h:588
std::mt19937_64 m_PRNGSpawn
Definition: lpt.h:558
MFloat a_workFlux(const MInt cellId) const
Definition: lpt.h:422
void saveSolverSolution(const MBool, const MBool) override
Definition: lpt.h:205
MFloat a_velocitySlope(const MInt cellId, const MInt varId, const MInt dir) const
Definition: lpt.h:427
std::map< MFloat, MFloat > m_terminalVelocity
Definition: lpt.h:571
MInt noVariables() const override
Return the number of variables.
Definition: lpt.h:941
MPI_Request * m_flowSendRequest
Definition: lpt.h:591
MFloat m_weightParticle
Definition: lpt.h:548
std::mt19937_64 & randomSpawn(const MInt calls)
Definition: lpt.h:736
std::multimap< MInt, LPTSpherical< nDim > * > m_cellToPartMap
Definition: lpt.h:819
MBool m_nonBlockingComm
Definition: lpt.h:614
std::unique_ptr< MaterialState< nDim > > m_material
Definition: lpt.h:815
void particleRespawn()
respawn of Particles
Definition: lpt.cpp:3114
MBool m_periodicBC
Definition: lpt.h:753
MFloat & a_velocitySlope(const MInt cellId, const MInt varId, const MInt dir)
Definition: lpt.h:424
MFloat ** m_flowRecv
Definition: lpt.h:593
MLong m_spawnSeed
Definition: lpt.h:759
MInt addEllipsoid(const MInt cellId, const MFloat semiMinorAxis, const MFloat aspectRatio, const MFloat particleDensityRatio, const MInt random=1, const MInt addMode=0, const MFloat *velocity=nullptr, const MFloat *position=nullptr)
Add new ellipsoidal particle.
Definition: lpt.cpp:5607
MInt m_spawnDomainId
Definition: lpt.h:804
std::vector< std::unique_ptr< MFloat[]> > m_sourceRecv
Definition: lpt.h:583
MFloat & a_volumeFraction(const MInt cellId)
Definition: lpt.h:382
void resetSolverFull()
reset the solver during balancing
Definition: lpt.cpp:6822
MFloat ** m_slopesSend
Definition: lpt.h:599
MBool m_restart
Definition: lpt.h:767
void writePartData()
write particle snapshot to Netcdf file (using parallel output)
Definition: lpt.cpp:3997
void wallCollision()
collision step with LPT wall
Definition: lpt.cpp:3070
MBool smallParticle(const LPTSpherical< nDim > &particle)
Definition: lpt.h:734
MInt m_noSolutionSteps
Definition: lpt.h:948
typename maia::grid::tree::Tree< nDim >::Cell Cell
Definition: lpt.h:121
MFloat m_spawnParticlesConeAngle
Definition: lpt.h:805
std::vector< std::map< MInt, MInt > > m_pointsToHalo
Definition: lpt.h:568
MFloat c_coordinate(const MInt cellId, const MInt dir) const
Definition: lpt.h:972
std::vector< std::unique_ptr< MInt[]> > m_intRecvBuffer
Definition: lpt.h:613
MBool a_isHalo(const MInt cellId) const
Definition: lpt.h:433
MInt m_noRedistLayer
Definition: lpt.h:633
MPI_Request * m_checkAdaptationRecvRequest
Definition: lpt.h:586
MInt m_exchangeBufferSize
Definition: lpt.h:794
MInt & a_noParticlesInCell(const MInt cellId)
Definition: lpt.h:385
void removeInvalidParticles(const MBool)
Definition: lpt.cpp:2667
void writeParticleLog()
MBool pushToQueue(std::vector< std::map< MInt, MInt > > &pointsTo, const MInt partPos)
Definition: lpt.h:509
void balancePost() override
Reinitialize solver after setting solution data in DLB.
Definition: lpt.cpp:6920
MInt noCellDataDlb() const override
Methods to inquire solver data information.
Definition: lpt.h:280
void forceTimeStep(const MFloat timeStep)
Definition: lpt.h:318
void removeChilds(const MInt) override
coarseining a cartesian cell
Definition: lpt.cpp:1663
std::vector< MPI_Status > m_mpi_statusProbe
Definition: lpt.h:609
MFloat & a_fluidVelocity(const MInt cellId, const MInt dim)
Definition: lpt.h:397
MInt a_timeStepComputationInterval()
Definition: lpt.h:319
MInt c_level(const MInt cellId) const
Definition: lpt.h:966
MInt * m_respawnGlobalDomainOffsets
Definition: lpt.h:786
MFloat timeStep()
Definition: lpt.h:317
MInt bufSize()
Definition: lpt.h:679
MInt m_innerBound
Definition: lpt.h:828
void packParticles(std::vector< LPTSpherical< nDim > * > &particlesToSend, MInt *intBuffer, MFloat *floatBuffer, std::vector< MInt >)
Pack particles for sending.
Definition: lpt.cpp:5850
MBool m_forceAdaptation
Definition: lpt.h:829
LPT(const MInt solverId, GridProxy &gridProxy_, Geom &geometry_, const MPI_Comm comm)
Solver constructor.
MInt m_skewnessTimeStep
Definition: lpt.h:751
MBool m_openFlowSend
Definition: lpt.h:628
maia::lpt::cell::BitsetType::reference a_isHalo(const MInt cellId)
Definition: lpt.h:434
MFloat a_volumeFraction(const MInt cellId) const
Definition: lpt.h:383
void reIntAfterRestart(MBool) override
Definition: lpt.h:249
std::vector< std::map< MInt, MInt > > m_pointsToWindow
Definition: lpt.h:569
void getGlobalSolverVars(std::vector< MFloat > &globalFloatVars, std::vector< MInt > &globalIdVars) override
Get/set global solver variables during DLB.
Definition: lpt.cpp:7167
typename CartesianSolver::Grid Grid
Definition: lpt.h:124
void sendFlowField()
exchanges the flow Field data on the LPT grid, non-Blocking version
Definition: lpt.cpp:7739
void countParticlesInCells()
set accessor for a_noParticlesInCell which is used for the particle-sensor during adaptation
Definition: lpt.cpp:2741
void initializeTimers()
Initializes the communication timers.
Definition: lpt.cpp:7984
void spawnTimeStep()
spawn new particles and compute their timeStep NOTE: this is an older functionality which is only use...
Definition: lpt.cpp:2624
MPI_Request * m_slopesRecvRequest
Definition: lpt.h:597
particleSendQueue< nDim > m_queueToSend
Definition: lpt.h:566
void setGlobalSolverVars(std::vector< MFloat > &globalFloatVars, std::vector< MInt > &globalIdVars) override
Set global solver variables for DLB (same on each domain)
Definition: lpt.cpp:7204
void receiveVelocitySlopes()
exchanges the velocity slopes on the LPT grid, non-Blocking version
Definition: lpt.cpp:7901
void particleWallCollisionStep(const MInt)
MFloat & a_fluidPressure(const MInt cellId)
Definition: lpt.h:403
MBool m_limitWeights
Definition: lpt.h:552
MFloat m_spawnDir[nDim]
Definition: lpt.h:806
MPI_Request * m_slopesSendRequest
Definition: lpt.h:596
MInt m_shadowWidth
Definition: lpt.h:827
std::map< MInt, std::vector< MInt > > m_cellToNghbrHood
Definition: lpt.h:530
MFloat c_cellLengthAtLevel(const MInt level) const
Definition: lpt.h:962
MBool m_wallCollisions
Definition: lpt.h:789
MInt & a_noEllipsoidsInCell(const MInt cellId)
Definition: lpt.h:388
std::vector< MInt > m_respawnCells
Definition: lpt.h:787
void initialCondition()
Initialize particles.
MInt a_noParticles()
Definition: lpt.h:366
void coupling(MInt offset)
Definition: lpt.cpp:3014
void writeRestartFile(const MBool, const MBool, const MString, MInt *) override
writing a restart File as regularly called from the grid-controller!
Definition: lpt.cpp:2578
std::vector< MPI_Request > m_mpi_reqRecvFloat
Definition: lpt.h:607
MPI_Request * m_sourceRecvRequest
Definition: lpt.h:582
MBool oneStageSolutionStep()
single solution step for pure LPT computation or without interleafed coupling!
Definition: lpt.cpp:2387
MFloat calculateVRMS()
void sensorInterface(std::vector< std::vector< MFloat > > &sensors, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MFloat > &sensorWeight, MInt sensorOffset, MInt sen) override
set the sensors around the boundary positions to get the markedCells
Definition: lpt.cpp:1368
std::vector< MPI_Request > m_mpi_reqSendSize
Definition: lpt.h:606
MFloat m_time
Definition: lpt.h:555
MFloat m_particleResiduum
Definition: lpt.h:642
void initMPI(const MBool=true)
Init MPI buffers and communication datastructures.
Definition: lpt.cpp:374
MInt m_sleepLPT
Definition: lpt.h:540
MInt noDomains() const override
Definition: lpt.h:981
void saveDebugRestartFile()
writing a restart File NOTE: for debugging purposes only!
Definition: lpt.cpp:2597
void limitWeights(MFloat *) override
Limit weight of base cell.
Definition: lpt.cpp:1919
MFloat & a_fluidVariable(const MInt cellId, const MInt var)
Definition: lpt.h:394
MInt m_sprayAngleModel
Definition: lpt.h:813
MBool m_weightSourceCells
Definition: lpt.h:553
void mergeParticles(LPTSpherical< nDim > *partA, LPTSpherical< nDim > *partB)
Definition: lpt.cpp:2890
MPI_Request * m_sourceSendRequest
Definition: lpt.h:581
void writeParticleRestartFile()
Write particle restart file.
Definition: lpt.cpp:4304
MInt a_bndryCellId(const MInt cellId) const
Definition: lpt.h:392
MInt m_spawnCellId
Definition: lpt.h:803
MInt m_motionEquationType
Definition: lpt.h:778
MInt m_respawnDomain
Definition: lpt.h:783
MPI_Request * m_flowRecvRequest
Definition: lpt.h:592
std::vector< MPI_Request > m_mpi_reqSendInt
Definition: lpt.h:605
MFloat m_sutherlandConstant
Definition: lpt.h:937
void updateFluidFraction()
Definition: lpt.cpp:6286
MBool m_receiveFlowField
Definition: lpt.h:616
MInt a_noParticlesInCell(const MInt cellId) const
Definition: lpt.h:386
const MFloat & a_coordinate(const MInt cellId, const MInt dim) const
Definition: lpt.h:455
MFloat m_timeStep
Definition: lpt.h:573
void exchangeOffset(MInt noParticles)
In case of multisolver, communicate particle id offset to ensure consistent particle ids across the s...
Definition: lpt.cpp:3963
MInt m_nonBlockingStage
Definition: lpt.h:615
void finalizeBalance() override
re-inits the solver after the balance
Definition: lpt.cpp:7243
MFloat timeSinceSOI() const
Definition: lpt.h:479
MFloat ** m_flowSend
Definition: lpt.h:594
MFloat c_cellLengthAtCell(const MInt cellId) const
Definition: lpt.h:964
std::mt19937_64 m_PRNGRespawn
Definition: lpt.h:561
void unpackParticles(const MInt num, const MInt *intBuffer, const MFloat *floatBuffer, const MInt domainId=-1, const MBool allowNonLeaf=false)
Unpack particles.
Definition: lpt.cpp:6008
void setSensors(std::vector< std::vector< MFloat > > &, std::vector< MFloat > &, std::vector< std::bitset< 64 > > &, std::vector< MInt > &) override
set the sensors for a single adaptation step
Definition: lpt.cpp:1285
MBool m_spawnParticles
Definition: lpt.h:802
void initSolver() override
Definition: lpt.cpp:53
std::array< MFloat, nDim > m_globDomainLength
Definition: lpt.h:755
MFloat m_weightSpawnCell
Definition: lpt.h:549
std::vector< LPTEllipsoidal< nDim > > m_partListEllipsoid
Definition: lpt.h:528
MBool m_openSlopesSend
Definition: lpt.h:630
MInt m_noSendParticles
Definition: lpt.h:619
LPT(const LPT &)=delete
std::multimap< MInt, LPTEllipsoidal< nDim > * > m_cellToEllipsMap
Definition: lpt.h:820
MFloat m_timeStepOld
Definition: lpt.h:574
MFloat & a_momentumFlux(const MInt cellId, const MInt dim)
Definition: lpt.h:418
MBool solutionStep() override
Time stepping of particles NOTE: the solutionStep is split into sub-steps, to allow for an interleafe...
Definition: lpt.cpp:2139
void own_remove_if(T &c, Pred &p)
Definition: lpt.h:724
MFloat time() const override
Return the time.
Definition: lpt.h:940
MInt c_parentId(const MInt cellId) const
Definition: lpt.h:960
void getDefaultWeights(MFloat *weights, std::vector< MString > &names) const override
Return the default weights for all load quantities.
Definition: lpt.cpp:1888
void sendInjected(const MUint prevNumPart)
void getSampleVariables(const MInt cellId, std::vector< MFloat > &)
Definition: lpt.h:1003
void exchangeSourceTerms()
exchanges the source terms on the LPT grid, this is necessary a) before writing the cell solution fil...
Definition: lpt.cpp:7620
std::unique_ptr< SprayModel< nDim > > m_sprayModel
Definition: lpt.h:798
void receiveFlowField()
exchanges the flow Field data on the LPT grid, non-Blocking version
Definition: lpt.cpp:7784
MInt * m_respawnDomainRanks
Definition: lpt.h:785
MFloat m_sizeLimit
Definition: lpt.h:758
MInt m_timerGroup
Definition: lpt.h:536
MBool m_engineSetup
Definition: lpt.h:754
void waitForSendReqs()
wait on all mpi send calls, prior to balance, adaptation or IO
Definition: lpt.cpp:7818
MBool m_massCoupling
Definition: lpt.h:637
MLong m_ellipsoidRandomOrientationSeed
Definition: lpt.h:771
MFloat m_xCutOff
Definition: lpt.h:765
void initBndryCells()
init LPT boundary-cells used for the wall-collision
Definition: lpt.cpp:352
void initParticleVector()
init LPT spherical and ellipsoids particle vectors (i.e. set length and read non-dimensionalisation P...
MFloat a_massFlux(const MInt cellId) const
Definition: lpt.h:416
MBool m_domainIdOutput
Definition: lpt.h:543
MFloat & a_fluidSpecies(const MInt cellId)
Definition: lpt.h:409
MFloat a_fluidPressure(const MInt cellId) const
Definition: lpt.h:404
MInt m_spawnEmittDist
Definition: lpt.h:811
std::vector< std::unique_ptr< MInt[]> > m_intSendBuffer
Definition: lpt.h:612
std::vector< MInt > m_sendSize
Definition: lpt.h:601
void prepareAdaptation() override
prepare solver adaptation
Definition: lpt.cpp:1214
MInt m_dragModelType
Definition: lpt.h:775
void postTimeStep() override
after the LPT time-Step!
Definition: lpt.cpp:2512
MBool m_openSourceSend
Definition: lpt.h:627
void preTimeStep() override
prepare the LPT timeStep
Definition: lpt.cpp:2069
void getSolverTimings(std::vector< std::pair< std::string, MFloat > > &, const MBool allTimings) override
Get solver timings.
Definition: lpt.cpp:1861
void swapProxy(MInt, MInt) override
Definition: lpt.cpp:1528
MInt m_torqueModelType
Definition: lpt.h:777
maia::lpt::cell::BitsetType::reference a_isWindow(const MInt cellId)
Definition: lpt.h:439
std::mt19937_64 m_PRNGInit
Definition: lpt.h:564
void findSpawnCellId()
Find spawn cellId.
MInt m_restartTimeStep
Definition: lpt.h:950
void own_sort(T &c, Pred &p)
Definition: lpt.h:713
MPI_Status m_mpi_statusFloat
Definition: lpt.h:622
MInt cellDataSizeDlb(const MInt dataId, const MInt cellId) override
Return data size to be communicated during DLB for a grid cell and given data id.
Definition: lpt.cpp:6933
Geom * m_geometry
Definition: lpt.h:173
void reduceParticles()
Definition: lpt.cpp:2805
MInt m_loadBalancingReinitStage
Definition: lpt.h:825
void a_resetPropertiesSolver(const MInt cellId)
Definition: lpt.h:431
MBool c_isLeafCell(const MInt cellId) const
Definition: lpt.h:974
MInt noLoadTypes() const override
Definition: lpt.h:270
void interpolateVariablesLS(const MInt cellId, const MFloat *const position, MFloat *const interpolatedVar)
Definition: lpt.h:472
MBool m_nonDimensional
Definition: lpt.h:946
void exchangeParticles_(const MBool collOnly, const MInt offset, const MBool allowNonLeaf=false)
exchange particles to neighboring domains, can be either non-blocking or blocking communication!
Definition: lpt.cpp:3478
MFloat m_spawnDiameter
Definition: lpt.h:807
MFloat a_fluidVariable(const MInt cellId, const MInt var) const
Definition: lpt.h:395
void readModelProps()
Read model configuration properties from configuration file.
void receiveParticles()
Calls particle receive function for different particle types.
Definition: lpt.cpp:3836
MFloat & a_workFlux(const MInt cellId)
Definition: lpt.h:421
MInt c_hasNeighbor(const MInt cellId, const MInt dir) const
Definition: lpt.h:983
std::vector< LPTSpherical< nDim > > m_partList
Definition: lpt.h:527
MFloat injectionDuration() const
Definition: lpt.h:477
Geom & geometry() const
Access the solver's geometry.
Definition: lpt.h:183
MFloat computeTimeStep()
computes the non-dimensional LPT time-step on the assumption that a particle may only travel for a co...
Definition: lpt.cpp:7533
MFloat a_fluidDensity(const MInt cellId) const
Definition: lpt.h:401
MBool m_couplingRedist
Definition: lpt.h:632
maia::lpt::cell::BitsetType::reference a_isValidCell(const MInt cellId)
Definition: lpt.h:444
void initSummary()
Print information at the start of simulation.
Definition: lpt.cpp:5778
MInt m_maxNoBndryCells
Definition: lpt.h:790
MInt m_maxNoParticles
Definition: lpt.h:763
MBool a_validCell(const MInt cellId)
Definition: lpt.h:987
MFloat m_weightLeafCell
Definition: lpt.h:546
MFloat m_spawnDistSigmaCoeff
Definition: lpt.h:812
void recvInjected()
receive particles generated during injection
Definition: lpt.cpp:5812
void finalizeInitSolver() override
Definition: lpt.cpp:1179
MBool forceAdaptation() override
Returns the LPT adaptation forcing.
Definition: lpt.h:228
void sendVelocitySlopes()
exchanges the velocity slopes on the LPT grid, non-Blocking version
Definition: lpt.cpp:7861
void sensorParticle(std::vector< std::vector< MFloat > > &sensors, std::vector< std::bitset< 64 > > &sensorCellFlag, std::vector< MFloat > &sensorWeight, MInt sensorOffset, MInt sen) override
set the sensors around the particle positions to get the markedCells
Definition: lpt.cpp:1349
void advanceParticles(const MInt offset)
Definition: lpt.cpp:3041
void updateExchangeCells()
Set exchange properties in LPT cell collector (a_isHalo/a_isWindow) and set m_pointsToHalo and m_poin...
Definition: lpt.cpp:6339
void calculateTerminalVelocities()
calculates the terminal velocity of particles used for initialization
MFloat reduceData(const MInt cellId, MFloat *data, const MInt dataBlockSize=1, const MBool average=true)
reduce data to lower level
Definition: lpt.cpp:8020
MFloat m_sutherlandPlusOne
Definition: lpt.h:938
MFloat m_weightMulitSolverFactor
Definition: lpt.h:550
MInt m_noSourceTerms
Definition: lpt.h:580
void swapCells(const MInt, const MInt) override
swap Cell information when the grid collector is restructured during adaptation cleanup
Definition: lpt.cpp:1782
MInt addParticle(const MInt cellId, const MFloat diameter, const MFloat particleDensityRatio, const MInt random=1, const MInt addMode=0, const MFloat *velocity=nullptr, const MFloat *position=nullptr, const MInt parcelSize=1)
Add new particle.
Definition: lpt.cpp:5495
MInt a_noEllipsoidalParticles() const
Definition: lpt.h:372
MInt m_ellipsoidRandomOrientation
Definition: lpt.h:770
void writeCellSolutionFile(const MString &, MInt *)
Write lpt cell based solution file currently ony used for debugging!
Definition: lpt.cpp:5285
void setRegridTrigger()
set a_regridTriggerG around all particles to allow for an adaptation check
Definition: lpt.cpp:7373
MInt cellDataTypeDlb(const MInt dataId) const override
Definition: lpt.h:290
MBool m_receiveVelocitySlopes
Definition: lpt.h:617
MInt noInternalCells() const override
Return the number of internal cells within this solver.
Definition: lpt.h:979
MBool a_regridTrigger(const MInt cellId) const
Definition: lpt.h:448
MFloat & a_heatFlux(const MInt cellId)
Definition: lpt.h:412
std::array< MFloat, nDim *2 > m_globBbox
Definition: lpt.h:756
MBool m_openParticleInjSend
Definition: lpt.h:624
void addBndryCell(const MInt, MFloat *, MFloat *, MFloatScratchSpace &, MFloat *)
add an LPT bndryCell to the collector and fill the data
Definition: lpt.cpp:6391
MFloat a_heatFlux(const MInt cellId) const
Definition: lpt.h:413
std::map< MInt, std::vector< MFloat > > m_injData
Definition: lpt.h:491
std::vector< MInt > m_recvSize
Definition: lpt.h:602
MBool m_activePrimaryBUp
Definition: lpt.h:760
std::array< MInt, Timers::_count > m_timers
Definition: lpt.h:538
MBool m_skipLPT
Definition: lpt.h:541
MInt elemPerP()
Definition: lpt.h:671
void sprayInjection()
Definition: lpt.cpp:2644
MBool hasSplitBalancing() const override
Return if load balancing for solver is split into multiple methods or implemented in balance()
Definition: lpt.h:314
MBool a_isValidCell(const MInt cellId) const
Definition: lpt.h:443
MFloat m_diameter
particle diameter
Definition: lptspherical.h:76
Definition: lblpt.h:30
This class is a ScratchSpace.
Definition: scratch.h:758
void startLoadTimer(const MString name)
Definition: solver.h:293
MPI_Comm mpiComm() const
Return the MPI communicator used by this solver.
Definition: solver.h:380
MInt solverId() const
Return the solverId.
Definition: solver.h:425
const MInt m_solverId
a unique solver identifier
Definition: solver.h:90
void stopLoadTimer(const MString &name)
Definition: solver.h:295
constexpr GridProxy & grid() const
constexpr MInt size() const
Return size (i.e., currently used number of nodes)
Definition: container.h:89
Class that represents LPT cell collector.
MFloat & momentumFlux(const MInt id, const MInt dim)
Accessor for momentumFlux.
MInt noEllipsoids(const MInt id) const
MFloat & velocitySlope(const MInt id, const MInt varId, const MInt dim)
MInt bndryCellId(const MInt id) const
MFloat fluidSpecies(const MInt id) const
MFloat volumeFraction(const MInt id) const
MFloat & heatFlux(const MInt id)
Accessor for heatFlux.
MInt noParticles(const MInt id) const
MFloat & massFlux(const MInt id)
Accessor for massFlux.
BitsetType::reference hasProperty(const MInt id, const LptCell p)
Accessor for properties.
MFloat & workFlux(const MInt id)
Accessor for workFlux.
MFloat fluidVariable(const MInt id, const MInt var) const
void resetProperties(const MInt id)
Reset all properties.
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
Definition: enums.cpp:20
LPTmpiTag
Definition: enums.h:426
@ FLOW_FIELD
Definition: enums.h:426
@ PARTICLE_INT
Definition: enums.h:426
@ CHECK_ADAP
Definition: enums.h:426
@ VELOCITY_SLOPES
Definition: enums.h:426
@ PARTICLE_COUNT
Definition: enums.h:426
@ PARTICLE_FLOAT
Definition: enums.h:426
@ SOURCE_TERMS
Definition: enums.h:426
@ MINT
Definition: enums.h:269
@ MFLOAT
Definition: enums.h:269
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
constexpr T mMin(const T &x, const T &y)
Definition: functions.h:90
constexpr T mMax(const T &x, const T &y)
Definition: functions.h:94
std::vector< std::queue< maia::lpt::sendQueueType< nDim > > > particleSendQueue
Definition: lpt.h:44
int32_t MInt
Definition: maiatypes.h:62
uint32_t MUint
Definition: maiatypes.h:63
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
int64_t MLong
Definition: maiatypes.h:64
bool MBool
Definition: maiatypes.h:58
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allreduce
Namespace for auxiliary functions/classes.
Static indices for accessing primitive variables in nDim spatial dimensions.
Definition: lpt.h:1015
constexpr MInt noVars() const
Definition: lpt.h:1027
static constexpr MInt P
Definition: lpt.h:1023
static constexpr std::array< MInt, 3 > VV
Definition: lpt.h:1021
static constexpr MInt RHO
Definition: lpt.h:1022
static constexpr MInt T
Definition: lpt.h:1024