MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lbsrctermgravity.cpp
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 "lbsrctermgravity.h"
8
9#include "UTIL/parallelfor.h"
10#include "lbsrctermcontroller.h"
11#include "lbsyseqn.h"
12
13namespace maia::lb {
14
15template <MInt nDim, MInt nDist, class SysEqn>
17 auto& s = m_solver; // alias for readability
18 const MInt solverId = s->solverId();
19
20 if(Context::propertyExists("volumeAcceleration", solverId)) {
21 m_mode = Mode::DIRECT;
22 for(MInt i = 0; i < nDim; i++) {
31 m_acceleration[i] = Context::getSolverProperty<MFloat>("volumeAcceleration", solverId, AT_, i);
32 }
33 }
41 if(Context::propertyExists("Ga", solverId)) {
42 m_mode = Mode::GALILEO;
43 ASSERT(Context::propertyLength("Ga") == nDim, "Ga should be of size nDim");
44 const MFloat nu = s->m_Ma / F1BCS / s->m_Re * s->m_referenceLength;
45 for(MInt n = 0; n < nDim; n++) {
46 m_Ga[n] = Context::getSolverProperty<MFloat>("Ga", solverId, AT_, m_Ga.data(), n);
47 const MFloat gravity = m_Ga[n] * POW2(nu) / POW3(s->m_referenceLength);
48 m_acceleration[n] = gravity;
49 }
50 }
51
52 // Save density gradient for initial condition
53 for(MInt n = 0; n < nDim; n++) {
54 m_solver->m_volumeAccel[n] = m_acceleration[n];
55 }
56}
57
58template <MInt nDim, MInt nDist, class SysEqn>
61
62 std::array<MFloat, nDim> densityGradient{};
63 for(MInt n = 0; n < nDim; n++) {
64 densityGradient[n] = m_acceleration[n] * F1BCSsq;
65 }
66
67 for(MInt dir = 0; dir < nDim; dir++) {
68 for(MInt mi = 0; mi < Ld::dxQyFld(); mi++) {
69 m_forcing[Ld::nFld(dir, mi)] += Ld::tp(Ld::distType(Ld::nFld(dir, mi))) * -1.0 * densityGradient[dir];
70 m_forcing[Ld::pFld(dir, mi)] += Ld::tp(Ld::distType(Ld::pFld(dir, mi))) * 1.0 * densityGradient[dir];
71 }
72 }
73
74 // Save forcing for BC and interface
75 for(MInt j = 0; j < nDist; j++) {
76 m_solver->m_Fext[j] = m_forcing[j];
77 }
78}
79
80template <MInt nDim, MInt nDist, class SysEqn>
82 TRACE();
83 const auto& s = m_solver; // alias for readability
84
85 const MInt timeStep = s->getCurrentTimeStep();
86 maia::parallelFor<true>(0, s->m_currentMaxNoCells, [=](MInt index) {
87 const MInt cellId = s->m_activeCellList[index];
88 const MInt lvlDiff = s->maxLevel() - s->a_level(cellId);
89 if((timeStep) % IPOW2(lvlDiff) != 0) return;
90 for(MInt j = 0; j < nDist - 1; j++) {
91 s->a_oldDistribution(cellId, j) += FPOW2(lvlDiff) * m_forcing[j];
92 }
93 });
94}
95
96//---registration for LbSrcTermFactory class------------------------------------
97static const LbRegSrcTerm<LbSrcTermGravity<2, 9, LbSysEqnCompressible<2, 9>>> reg_SpongeRhoConstd2q9C("LB_GRAVITY");
98static const LbRegSrcTerm<LbSrcTermGravity<2, 9, LbSysEqnIncompressible<2, 9>>> reg_SpongeRhoConstd2q9("LB_GRAVITY");
99static const LbRegSrcTerm<LbSrcTermGravity<3, 27, LbSysEqnCompressible<3, 27>>> reg_SpongeRhoConstd3q27C("LB_GRAVITY");
100static const LbRegSrcTerm<LbSrcTermGravity<3, 27, LbSysEqnIncompressible<3, 27>>> reg_SpongeRhoConstd3q27("LB_GRAVITY");
101
102} // namespace maia::lb
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 apply_postPropagation() override
void readProperties() override
constexpr Real POW3(const Real x)
Definition: functions.h:123
constexpr Real POW2(const Real x)
Definition: functions.h:119
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
LB lattice descriptor for arrays depending on D and Q.