MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lpt_props.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#include <cmath>
8#include "UTIL/functions.h"
9#include "lpt.h"
10
19template <MInt nDim>
21 TRACE();
22
23 m_log << "reading model properties...";
24
25 m_restart = false;
26 m_restart = Context::getSolverProperty<MBool>("restartFile", solverId(), AT_, &m_restart);
27
28 m_restartTimeStep = Context::getSolverProperty<MInt>("restartTimeStep", solverId(), AT_);
29
30 m_maxNoParticles = 1E6;
31 m_maxNoParticles = Context::getSolverProperty<MInt>("maxNoParticles", solverId(), AT_, &m_maxNoParticles);
32
41 m_exchangeBufferSize =
42 Context::getSolverProperty<MInt>("particleExchangeBufferSize", solverId(), AT_, &m_exchangeBufferSize);
43
44
52 m_sizeLimit = 1E-12;
53 m_sizeLimit = Context::getSolverProperty<MFloat>("particleSizeLimit", solverId(), AT_, &m_sizeLimit);
54
62 m_spawnParticles = false;
63 m_spawnParticles = Context::getSolverProperty<MBool>("spawnParticles", solverId(), AT_, &m_spawnParticles);
64
65 if(m_spawnParticles) {
66 m_log << "Particle spawning has been activated." << std::endl;
67 }
68
76 m_activePrimaryBUp = false;
77 m_activePrimaryBUp = Context::getSolverProperty<MBool>("sprayPrimaryBUp", solverId(), AT_, &m_activePrimaryBUp);
85 m_activeSecondaryBUp = false;
86 m_activeSecondaryBUp = Context::getSolverProperty<MBool>("spraySecondaryBUp", solverId(), AT_, &m_activeSecondaryBUp);
95 m_ellipsoids = false;
96 m_ellipsoids = Context::getSolverProperty<MBool>("particleIncludeEllipsoids", solverId(), AT_, &m_ellipsoids);
97
117 m_collisions = Context::getSolverProperty<MInt>("particleCollisions", solverId(), AT_, &m_collisions);
118
119 if(m_collisions > 0) {
120 m_collisionModel = std::unique_ptr<ParticleCollision<nDim>>(
121 new ParticleCollision<nDim>(this, m_collisions, solverId(), domainId(), noDomains(), mpiComm()));
122 }
123
132 m_wallCollisions = Context::getSolverProperty<MBool>("particleWallCollisions", solverId(), AT_, &m_wallCollisions);
133
150 m_initializationMethod =
151 Context::getSolverProperty<MInt>("particleInitializationMethod", solverId(), AT_, &m_initializationMethod);
152
176 m_dragModelType = Context::getSolverProperty<MInt>("particleDrag", solverId(), AT_, &m_dragModelType);
177
190 m_liftModelType = Context::getSolverProperty<MInt>("particleLift", solverId(), AT_, &m_liftModelType);
191
204 m_torqueModelType = Context::getSolverProperty<MInt>("particleTorque", solverId(), AT_, &m_torqueModelType);
205
225 m_motionEquationType = Context::getSolverProperty<MInt>("motionEquation", solverId(), AT_, &m_motionEquationType);
226
239 m_respawn = Context::getSolverProperty<MBool>("particleRespawn", solverId(), AT_, &m_respawn);
240
241 if(m_respawn) {
249 m_respawnPlane = Context::getSolverProperty<MFloat>("particleRespawnPlane", solverId(), AT_);
250
251 // create a vector of cells which are used for the "respawning" of particles
252 MFloat halfLength = NAN;
253 for(MInt i = 0; i < noInternalCells(); i++) {
254 if(!c_isLeafCell(i)) continue;
255 MInt level = c_level(i);
256 halfLength = c_cellLengthAtLevel(level + 1);
257 if(fabs(c_coordinate(i, 0) - m_respawnPlane) < halfLength) {
258 auto weightedTimes = static_cast<MInt>(pow(pow(2, nDim), (maxRefinementLevel() - level)));
259 for(MInt count = 0; count < weightedTimes; ++count) {
260 m_respawnCells.push_back(i);
261 }
262 }
263 }
264 m_log << m_respawnCells.size() << " respawn cells found in this solver" << std::endl;
265 }
266
277 m_xCutOff = Context::getSolverProperty<MFloat>("particlePartOffset", solverId(), AT_, &m_xCutOff);
278
286 m_momentumCoupling = false;
287 m_momentumCoupling =
288 Context::getSolverProperty<MBool>("particleMomentumCoupling", solverId(), AT_, &m_momentumCoupling);
289 if(m_momentumCoupling) {
290 m_log << "Momentum coupling has been activated." << std::endl;
291 }
292
300 m_heatCoupling = false;
301 m_heatCoupling = Context::getSolverProperty<MBool>("particleHeatCoupling", solverId(), AT_, &m_heatCoupling);
302
303 if(m_heatCoupling) {
304 m_log << "Heat coupling has been activated." << std::endl;
305 }
306
314 m_massCoupling = false;
315 m_massCoupling = Context::getSolverProperty<MBool>("particleMassCoupling", solverId(), AT_, &m_massCoupling);
316 if(m_massCoupling) {
317 m_log << "Mass coupling has been activated." << std::endl;
318 }
319
327 m_evaporation = false;
328 m_evaporation = Context::getSolverProperty<MBool>("particleEvaporation", solverId(), AT_, &m_evaporation);
329
330 if(m_evaporation) {
331 m_log << "Evaporation modeling has been activated." << std::endl;
332 }
333
343 m_maxNoBndryCells = Context::getSolverProperty<MInt>("maxNoBndryCells", solverId(), AT_);
344
345
354 MInt range[2] = {2, 0};
355 for(MInt i = 0; i < 2; i++) {
356 range[i] = Context::getSolverProperty<MInt>("particleAdapRange", solverId(), AT_, &range[i], i);
357 }
358
359 mAlloc(m_bandWidth, maxRefinementLevel() + 1, "m_bandWidth", 0, AT_);
360 m_bandWidth[maxRefinementLevel() - 1] = range[0];
361 for(MInt i = maxRefinementLevel() - 2; i >= 0; i--) {
362 m_bandWidth[i] = (m_bandWidth[i + 1] / 2) + 1 + range[1];
363 }
364
365 m_innerBound = Context::getSolverProperty<MInt>("innerBound", solverId(), AT_, &m_innerBound);
366
367 MFloat referenceTemperature = 273.15;
380 referenceTemperature =
381 Context::getSolverProperty<MFloat>("referenceTemperature", m_solverId, AT_, &referenceTemperature);
382
383 m_sutherlandConstant = 110.4;
395 m_sutherlandConstant =
396 Context::getSolverProperty<MFloat>("sutherlandConstant", solverId(), AT_, &m_sutherlandConstant);
397
398 m_sutherlandConstant /= referenceTemperature;
399 m_sutherlandPlusOne = m_sutherlandConstant + F1;
400
413 m_cfl = 1.0;
414 m_cfl = Context::getSolverProperty<MFloat>("cfl", solverId(), AT_, &m_cfl);
415
416 m_timeStepComputationInterval = m_restart ? -1 : 0;
431 m_timeStepComputationInterval =
432 Context::getSolverProperty<MInt>("timeStepComputationInterval", solverId(), AT_, &m_timeStepComputationInterval);
433
434
435 m_nonBlockingComm = Context::getSolverProperty<MBool>("nonBlockingComm", solverId(), AT_, &m_nonBlockingComm);
436
437 if(m_nonBlockingComm) {
438 m_nonBlockingStage = 0;
439 if(m_ellipsoids) {
440 cerr0 << "LPT-Warning: nonBlocking currently only works with either spherical or ellipsoidal particles "
441 << "--> disabling exchange of spherical particles" << std::endl;
442 }
443 }
444
453 m_weightBaseCell = 0.0;
454 m_weightBaseCell = Context::getSolverProperty<MFloat>("weightBaseCell", solverId(), AT_, &m_weightBaseCell);
464 m_weightLeafCell = 0.0;
465 m_weightLeafCell = Context::getSolverProperty<MFloat>("weightLeafCell", solverId(), AT_, &m_weightLeafCell);
475 m_weightParticleCell = 0.1;
476 m_weightParticleCell =
477 Context::getSolverProperty<MFloat>("weightParticleCell", solverId(), AT_, &m_weightParticleCell);
486 m_weightParticle = 1.0;
487 m_weightParticle = Context::getSolverProperty<MFloat>("weightParticle", solverId(), AT_, &m_weightParticle);
496 m_weightSpawnCell = 0.0;
497 m_weightSpawnCell = Context::getSolverProperty<MFloat>("weightSpawnCell", solverId(), AT_, &m_weightSpawnCell);
506 m_weightMulitSolverFactor = 1.0;
507 m_weightMulitSolverFactor =
508 Context::getSolverProperty<MFloat>("weightMulitSolverFactor", solverId(), AT_, &m_weightMulitSolverFactor);
517 m_limitWeights = false;
518 m_limitWeights = Context::getSolverProperty<MBool>("limitDLBWeights", solverId(), AT_, &m_limitWeights);
519
520 m_weightSourceCells = false;
521 m_weightSourceCells =
522 Context::getSolverProperty<MBool>("weightLPTSourceCells", solverId(), AT_, &m_weightSourceCells);
523
524 m_domainIdOutput = false;
525 m_domainIdOutput = Context::getSolverProperty<MBool>("domainIdOutput", m_solverId, AT_, &m_domainIdOutput);
526
527 // LPT sleep time in milli-seconds
528 m_sleepLPT = -1;
529 m_sleepLPT = Context::getSolverProperty<MInt>("sleepTimeLPT", m_solverId, AT_, &m_sleepLPT);
530
531 m_skipLPT = false;
532 m_skipLPT = Context::getSolverProperty<MBool>("skipLPT", m_solverId, AT_, &m_skipLPT);
533
534 m_log << "finished" << std::endl;
535}
536
545template <MInt nDim>
554 m_spawnSeed = 5489U;
555 if(Context::propertyExists("spawnSeed", solverId())) {
556 m_spawnSeed = (MLong)Context::getSolverProperty<MInt>("spawnSeed", solverId(), AT_);
557 }
558 // initialise the psydo-randon number generator with the given seed
559 // this is done identically on all ranks and for all random numbers!
560 m_PRNGSpawn.seed(m_spawnSeed);
561 m_PRNGRespawn.seed(m_spawnSeed);
562
571 m_spawnDiameter = 0.00001;
572 m_spawnDiameter = Context::getSolverProperty<MFloat>("spawnDiameter", solverId(), AT_, &m_spawnDiameter);
573
582 m_spawnVelocity = Context::getSolverProperty<MFloat>("spawnParticlesInitVelo", solverId(), AT_, &m_spawnVelocity);
583
592 m_spawnParticlesCount =
593 Context::getSolverProperty<MInt>("spawnParticlesCount", solverId(), AT_, &m_spawnParticlesCount);
594
602 m_spawnDistSigmaCoeff =
603 Context::getSolverProperty<MFloat>("spawnDistSigmaCoeff", solverId(), AT_, &m_spawnDistSigmaCoeff);
604
605 m_spawnParticlesConeAngle =
606 Context::getSolverProperty<MFloat>("spawnParticlesConeAngle", solverId(), AT_, &m_spawnParticlesConeAngle);
615 for(MInt i = 0; i < nDim; i++) {
616 m_spawnDir[i] = 0;
617 if(i == 0) m_spawnDir[i] = 1.0;
618 }
619
620 if(Context::propertyExists("spawnDir", solverId())) {
621 if(Context::propertyLength("spawnDir", solverId()) != nDim) {
622 TERMM(1, "Need to give a Coordinate for every dimension");
623 }
624
625 for(MInt i = 0; i < nDim; i++) {
626 m_spawnDir[i] = Context::getSolverProperty<MFloat>("spawnDir", solverId(), AT_, i);
627 }
628 }
629
637 m_engineSetup = false;
638 m_engineSetup = Context::getSolverProperty<MBool>("engineSetup", solverId(), AT_, &m_engineSetup);
639}
640
649template <MInt nDim>
659 m_ellipsoidRandomOrientation = Context::getSolverProperty<MInt>("particleEllipsoidRandomOrientation", solverId(), AT_,
660 &m_ellipsoidRandomOrientation);
667 m_ellipsoidRandomOrientationSeed = 4865U;
668 if(Context::propertyExists("particleEllipsoidRandomOrientationSeed", solverId())) {
669 m_ellipsoidRandomOrientationSeed =
670 (MLong)Context::getSolverProperty<MInt>("particleEllipsoidRandomOrientationSeed", solverId(), AT_);
671 }
672}
673
682template <MInt nDim>
691 m_couplingRedist = false;
692 m_couplingRedist = Context::getSolverProperty<MBool>("particleCouplingRedist", solverId(), AT_, &m_couplingRedist);
693
694 if(m_couplingRedist) {
702 m_noRedistLayer = Context::getSolverProperty<MInt>("particleNoRedistLayer", solverId(), AT_, &m_noRedistLayer);
703
704 if(m_noRedistLayer > grid().noHaloLayers() && noDomains() > 1) {
705 mTerm(-1, AT_, "ERROR: Number of halo layers needs to be higher than the redistribution area!");
706 }
707
708 m_log << "Momentum redistribution is active with a redistribution area of " << m_noRedistLayer << std::endl;
709 }
710}
711
720template <MInt nDim>
722 const MBool redetermination = m_spawnCellId >= 0;
723 const MInt lastSpawnCellId = m_spawnCellId;
724 const MInt lastSpawnDomainId = m_spawnDomainId;
725
726 m_spawnCellId = -1;
734 if(Context::propertyExists("spawnCoordinates", solverId())) {
735 if(Context::propertyLength("spawnCoordinates", solverId()) != nDim) {
736 TERMM(1, "Need to give a Coordinate for every dimension");
737 }
738
739 for(MInt i = 0; i < nDim; i++) {
740 m_spawnCoord[i] = Context::getSolverProperty<MFloat>("spawnCoordinates", solverId(), AT_, i);
741 }
742
743 m_spawnCellId = grid().findContainingLeafCell(&m_spawnCoord[0]);
744
745 // If we are running parallel we need to find the cell which is
746 // closest to the given coordinates on all domains.
747 if(noDomains() > 1) {
748 MInt spawnDomain = domainId();
749 MInt minDomain = -1;
750 if(m_spawnCellId < 0 || a_isHalo(m_spawnCellId)) {
751 spawnDomain = std::numeric_limits<MInt>::max();
752 }
753
754 // If more than one domain has cells with the same distance only
755 // spawn on the domain with the lowest Id
756 MPI_Allreduce(&spawnDomain, &minDomain, 1, MPI_INT, MPI_MIN, mpiComm(), AT_, "spawnDomain", "minDomain");
757
758 if(minDomain != domainId()) {
759 m_spawnCellId = -1;
760 }
761
762 m_spawnDomainId = minDomain;
763
764 m_log << " LPT selected spawn-cell " << m_spawnCellId << " on domain " << m_spawnDomainId << std::endl;
765 if(domainId() == m_spawnDomainId) {
766 std::cerr << " LPT selected spawn-cell " << m_spawnCellId << " on domain " << m_spawnDomainId
767 << " with coordinates " << c_coordinate(m_spawnCellId, 0) << " " << c_coordinate(m_spawnCellId, 1)
768 << " " << c_coordinate(m_spawnCellId, nDim - 1) << std::endl;
769 }
770 }
771
772 if(redetermination) {
773 std::cerr << " LPT spawn-cellId was redetermined";
774 if(m_spawnCellId < 0) {
775 std::cerr << " and spawnDomain changed from " << domainId() << " to " << m_spawnDomainId;
776 std::cerr << " left-over mass was : " << m_particleResiduum << std::endl;
777 } else {
778 std::cerr << std::endl;
779 }
780 }
781 if(lastSpawnCellId < 0 && m_spawnCellId > 0 && lastSpawnDomainId > 0) {
782 std::cerr << "Revieved left-over mass is : " << m_particleResiduum << std::endl;
783 }
784 if((m_spawnDomainId + 1 > noDomains() && noDomains() > 1) || (m_spawnCellId < 0 && noDomains() == 1)) {
785 TERMM(-1, "Invalid spawn coordinates, values are probably outside the fluid-domain/box?");
786 }
787 }
788}
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
Definition: alloc.h:173
static MInt propertyLength(const MString &name, MInt solverId=m_noSolvers)
Returns the number of elements of a property.
Definition: context.cpp:538
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
Definition: context.cpp:494
void readSpawnProps()
Read properties related to creating particles from configuration file.
void readMomentumCouplingProps()
Read properties specific to the momentum coupling.
void readEllipsoidProps()
Read properties specific to ellipsoids.
void findSpawnCellId()
Find spawn cellId.
void readModelProps()
Read model configuration properties from configuration file.
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
InfoOutFile m_log
std::ostream cerr0
int32_t MInt
Definition: maiatypes.h:62
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