MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lbsyseqn.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#pragma once
8
9#include "INCLUDE/maiatypes.h"
10#include "lbfunctions.h"
11
12namespace maia::lb {
13
14template <MInt nDim, MInt nDist>
15class LbSysEqn {
16 public:
17 virtual void calcEqDists(const MFloat zerothMoment, const MFloat* const firstMoment,
18 MFloat* const p_eqDist) const = 0;
19 virtual void calcEqDists(const MFloat zerothMoment, const MFloat squaredFirstMoment, const MFloat* const firstMoment,
20 MFloat* const p_eqDist) const = 0;
21#ifdef WAR_NVHPC_PSTL
22 virtual void calcEqDists(const MFloat zerothMoment, const MFloat* const firstMoment, MFloat* const p_eqDist,
23 const MInt* mFld1, const MInt* mFld2, const MFloat* mTp, const MInt* mDistFld) const = 0;
24 virtual void calcEqDists(const MFloat zerothMoment, const MFloat squaredFirstMoment, const MFloat* const firstMoment,
25 MFloat* const p_eqDist, const MInt* mFld1, const MInt* mFld2, const MFloat* mTp,
26 const MInt* mDistFld) const = 0;
27#endif
28 virtual void calcMacroVars(MFloat const* const p_dist, MFloat& p_rho, MFloat* const p_u) const = 0;
29 virtual void calcPrimitiveVars(MFloat const* const p_dist, MFloat& p_rho, MFloat* const p_u) const = 0;
30
31 void calcNonEqDists(const MFloat zerothMoment, const MFloat* const firstMoment, const MFloat* const p_dist,
32 MFloat* const p_nonEqDist) const {
33 // Calculate equlibirum distribution
34 std::array<MFloat, nDist> eqDist{};
35 calcEqDists(zerothMoment, firstMoment, eqDist.data());
36
37 // Calculate non-equilibium part
38 for(MInt j = 0; j < nDist; j++) {
39 p_nonEqDist[j] = p_dist[j] - eqDist[j];
40 }
41 };
42
43 void calcMomentumFlux(const MFloat& zerothMoment, const MFloat* const firstMoments, const MFloat* const dist,
44 MFloat* const momentumFlux) const {
46
47 std::array<MFloat, nDist> nonEqDist{};
48 calcNonEqDists(zerothMoment, firstMoments, dist, nonEqDist.data());
49
50 for(MInt d = 0; d < nDim * nDim; d++) {
51 momentumFlux[d] = F0;
52 }
53 for(MInt j = 0; j < nDist; j++) {
54 for(MInt k = 0; k < nDim; k++) {
55 for(MInt l = 0; l < nDim; l++) {
56 momentumFlux[k * nDim + l] += nonEqDist[j] * Ld::ppdfDir(j, k) * Ld::ppdfDir(j, l);
57 }
58 }
59 }
60 }
61};
62
63template <MInt nDim, MInt nDist>
64class LbSysEqnIncompressible : public LbSysEqn<nDim, nDist> {
65 public:
66 inline void calcEqDists(const MFloat p_rho, const MFloat* const p_u, MFloat* const p_eqDist) const override {
67 lbfunc::calcEqDists<nDim, nDist, false>(p_rho, p_u, p_eqDist);
68 }
69 inline void calcEqDists(const MFloat p_rho, const MFloat squaredVelocity, const MFloat* const p_u,
70 MFloat* const p_eqDist) const override {
71 lbfunc::calcEqDists<nDim, nDist, false>(p_rho, squaredVelocity, p_u, p_eqDist);
72 }
73#ifdef WAR_NVHPC_PSTL
74 inline void calcEqDists(const MFloat p_rho, MFloat const* const p_u, MFloat* const eqDist, const MInt* mFld1,
75 const MInt* mFld2, const MFloat* mTp, const MInt* mDistFld) const override {
76 lbfunc::calcEqDists<nDim, nDist, false>(p_rho, p_u, eqDist, mFld1, mFld2, mTp, mDistFld);
77 }
78 inline void calcEqDists(const MFloat p_rho, const MFloat squaredVelocity, MFloat const* const p_u,
79 MFloat* const eqDist, const MInt* mFld1, const MInt* mFld2, const MFloat* mTp,
80 const MInt* mDistFld) const override {
81 lbfunc::calcEqDists<nDim, nDist, false>(p_rho, squaredVelocity, p_u, eqDist, mFld1, mFld2, mTp, mDistFld);
82 }
83#endif
84 inline void calcMacroVars(MFloat const* const p_dist, MFloat& p_rho, MFloat* const p_u) const override {
85 lbfunc::calcMacroVars<nDim, nDist>(p_dist, p_rho, p_u);
86 }
87 inline void calcPrimitiveVars(MFloat const* const p_dist, MFloat& p_rho, MFloat* const p_u) const override {
88 calcMacroVars(p_dist, p_rho, p_u);
89 }
90};
91
92template <MInt nDim, MInt nDist>
93class LbSysEqnCompressible : public LbSysEqn<nDim, nDist> {
94 public:
95 inline void calcEqDists(const MFloat p_rho, const MFloat* const p_u, MFloat* const p_eqDist) const override {
96 lbfunc::calcEqDists<nDim, nDist, true>(p_rho, p_u, p_eqDist);
97 }
98 inline void calcEqDists(const MFloat p_rho, const MFloat squaredVelocity, const MFloat* const p_u,
99 MFloat* const p_eqDist) const override {
100 lbfunc::calcEqDists<nDim, nDist, true>(p_rho, squaredVelocity, p_u, p_eqDist);
101 }
102#ifdef WAR_NVHPC_PSTL
103 inline void calcEqDists(const MFloat p_rho, MFloat const* const p_u, MFloat* const eqDist, const MInt* mFld1,
104 const MInt* mFld2, const MFloat* mTp, const MInt* mDistFld) const override {
105 lbfunc::calcEqDists<nDim, nDist, true>(p_rho, p_u, eqDist, mFld1, mFld2, mTp, mDistFld);
106 }
107 inline void calcEqDists(const MFloat p_rho, const MFloat squaredVelocity, MFloat const* const p_u,
108 MFloat* const eqDist, const MInt* mFld1, const MInt* mFld2, const MFloat* mTp,
109 const MInt* mDistFld) const override {
110 lbfunc::calcEqDists<nDim, nDist, true>(p_rho, squaredVelocity, p_u, eqDist, mFld1, mFld2, mTp, mDistFld);
111 }
112#endif
113 inline void calcMacroVars(MFloat const* const p_dist, MFloat& p_rho, MFloat* const p_u) const override {
114 lbfunc::calcMacroVars<nDim, nDist, true>(p_dist, p_rho, p_u);
115 }
116 inline void calcPrimitiveVars(MFloat const* const p_dist, MFloat& p_rho, MFloat* const p_u) const override {
117 calcMacroVars(p_dist, p_rho, p_u);
118 }
119};
120
121} // namespace maia::lb
void calcEqDists(const MFloat p_rho, MFloat const *const p_u, MFloat *const eqDist, const MInt *mFld1, const MInt *mFld2, const MFloat *mTp, const MInt *mDistFld) const override
Definition: lbsyseqn.h:103
void calcMacroVars(MFloat const *const p_dist, MFloat &p_rho, MFloat *const p_u) const override
Definition: lbsyseqn.h:113
void calcEqDists(const MFloat p_rho, const MFloat *const p_u, MFloat *const p_eqDist) const override
Definition: lbsyseqn.h:95
void calcPrimitiveVars(MFloat const *const p_dist, MFloat &p_rho, MFloat *const p_u) const override
Definition: lbsyseqn.h:116
void calcEqDists(const MFloat p_rho, const MFloat squaredVelocity, MFloat const *const p_u, MFloat *const eqDist, const MInt *mFld1, const MInt *mFld2, const MFloat *mTp, const MInt *mDistFld) const override
Definition: lbsyseqn.h:107
void calcEqDists(const MFloat p_rho, const MFloat squaredVelocity, const MFloat *const p_u, MFloat *const p_eqDist) const override
Definition: lbsyseqn.h:98
virtual void calcEqDists(const MFloat zerothMoment, const MFloat squaredFirstMoment, const MFloat *const firstMoment, MFloat *const p_eqDist, const MInt *mFld1, const MInt *mFld2, const MFloat *mTp, const MInt *mDistFld) const =0
virtual void calcMacroVars(MFloat const *const p_dist, MFloat &p_rho, MFloat *const p_u) const =0
virtual void calcEqDists(const MFloat zerothMoment, const MFloat *const firstMoment, MFloat *const p_eqDist) const =0
virtual void calcPrimitiveVars(MFloat const *const p_dist, MFloat &p_rho, MFloat *const p_u) const =0
void calcNonEqDists(const MFloat zerothMoment, const MFloat *const firstMoment, const MFloat *const p_dist, MFloat *const p_nonEqDist) const
Definition: lbsyseqn.h:31
virtual void calcEqDists(const MFloat zerothMoment, const MFloat *const firstMoment, MFloat *const p_eqDist, const MInt *mFld1, const MInt *mFld2, const MFloat *mTp, const MInt *mDistFld) const =0
void calcMomentumFlux(const MFloat &zerothMoment, const MFloat *const firstMoments, const MFloat *const dist, MFloat *const momentumFlux) const
Definition: lbsyseqn.h:43
virtual void calcEqDists(const MFloat zerothMoment, const MFloat squaredFirstMoment, const MFloat *const firstMoment, MFloat *const p_eqDist) const =0
void calcEqDists(const MFloat p_rho, const MFloat squaredVelocity, MFloat const *const p_u, MFloat *const eqDist, const MInt *mFld1, const MInt *mFld2, const MFloat *mTp, const MInt *mDistFld) const override
Definition: lbsyseqn.h:78
void calcEqDists(const MFloat p_rho, const MFloat *const p_u, MFloat *const p_eqDist) const override
Definition: lbsyseqn.h:66
void calcEqDists(const MFloat p_rho, MFloat const *const p_u, MFloat *const eqDist, const MInt *mFld1, const MInt *mFld2, const MFloat *mTp, const MInt *mDistFld) const override
Definition: lbsyseqn.h:74
void calcMacroVars(MFloat const *const p_dist, MFloat &p_rho, MFloat *const p_u) const override
Definition: lbsyseqn.h:84
void calcPrimitiveVars(MFloat const *const p_dist, MFloat &p_rho, MFloat *const p_u) const override
Definition: lbsyseqn.h:87
void calcEqDists(const MFloat p_rho, const MFloat squaredVelocity, const MFloat *const p_u, MFloat *const p_eqDist) const override
Definition: lbsyseqn.h:69
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
Definition: pointbox.h:54
LB lattice descriptor for arrays depending on D and Q.