VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
InterpolationCoefficientsAdvectionDiffusion.h
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32//=======================================================================================
33#ifndef ADVECTION_DIFFUSION_SCALING_HELPER_FUNCTIONS_H
34#define ADVECTION_DIFFUSION_SCALING_HELPER_FUNCTIONS_H
35
37
38#include "lbm/constants/D3Q27.h"
39
41
42//using namespace vf::basics::constant;
43
44namespace vf::lbm::ad
45{
46
47// The Coefficients struct needs be created like this:
48// MomentsOnSourceNodeSet momentsSet;
49// momentsSet.calculatePPP(f, omega);
50// ... and so on
51// InterpolationCoefficients coeffs;
52// momentsSet.calculateCoefficients(coeffs);
53
54// Coefficients of the interpolation polynomial
59
60// Private struct - is only used within the MomentsOnSourceNodeSet
62{
67
68 constexpr void calculate(const real* const populations, const real* const populationsAD, const real omega)
69 {
70 using namespace vf::basics::constant;
71 real drho = c0o1;
72 real velocity100 = c0o1;
73 real velocity010 = c0o1;
74 real velocity001 = c0o1;
75 real oneOverRho = c0o1;
77 this->concentration = vf::lbm::getDensity(populationsAD);
78
85
89 this->dxConcentration = (this->concentration * velocity100 - momentAdvectionDiffusion100) * (c3o1 * omega);
90 this->dyConcentration = (this->concentration * velocity010 - momentAdvectionDiffusion010) * (c3o1 * omega);
91 this->dzConcentration = (this->concentration * velocity001 - momentAdvectionDiffusion001) * (c3o1 * omega);
92 }
93
94};
95
97{
98private:
107
108public:
109 constexpr void calculatePPP(const real* const populations, const real* const populationsAD, const real omegaDiffusivity)
110 {
111 momentsPPP.calculate(populations, populationsAD, omegaDiffusivity);
112 }
113
114 constexpr void calculateMPP(const real* const populations, const real* const populationsAD, const real omegaDiffusivity)
115 {
116 momentsMPP.calculate(populations, populationsAD, omegaDiffusivity);
117 }
118
119 constexpr void calculatePMP(const real* const populations, const real* const populationsAD, const real omegaDiffusivity)
120 {
121 momentsPMP.calculate(populations, populationsAD, omegaDiffusivity);
122 }
123
124 constexpr void calculateMMP(const real* const populations, const real* const populationsAD, const real omegaDiffusivity)
125 {
126 momentsMMP.calculate(populations, populationsAD, omegaDiffusivity);
127 }
128
129 constexpr void calculatePPM(const real* const populations, const real* const populationsAD, const real omegaDiffusivity)
130 {
131 momentsPPM.calculate(populations, populationsAD, omegaDiffusivity);
132 }
133
134 constexpr void calculateMPM(const real* const populations, const real* const populationsAD, const real omegaDiffusivity)
135 {
136 momentsMPM.calculate(populations, populationsAD, omegaDiffusivity);
137 }
138
139 constexpr void calculatePMM(const real* const populations, const real* const populationsAD, const real omegaDiffusivity)
140 {
141 momentsPMM.calculate(populations, populationsAD, omegaDiffusivity);
142 }
143
144 constexpr void calculateMMM(const real* const populations, const real* const populationsAD, const real omegaDiffusivity)
145 {
146 momentsMMM.calculate(populations, populationsAD, omegaDiffusivity);
147 }
148
150 {
151 using namespace vf::basics::constant;
152 real &d000 = coefficients.d000;
153 real &d100 = coefficients.d100, &d010 = coefficients.d010, &d001 = coefficients.d001;
154 real &d200 = coefficients.d200, &d020 = coefficients.d020, &d002 = coefficients.d002;
155 real &d110 = coefficients.d110, &d101 = coefficients.d101, &d011 = coefficients.d011;
156 real &d111 = coefficients.d111;
157
158 const real xoffsq = xoff * xoff;
159 const real yoffsq = yoff * yoff;
160 const real zoffsq = zoff * zoff;
161
162 const real dxxConcentration = (((momentsPPM.dxConcentration + momentsPMP.dxConcentration) + (momentsPMM.dxConcentration + momentsPPP.dxConcentration)) -
163 ((momentsMPM.dxConcentration + momentsMMP.dxConcentration) + (momentsMMM.dxConcentration + momentsMPP.dxConcentration))) * c1o4;
164 const real dyyConcentration = (((momentsPPM.dyConcentration + momentsMPP.dyConcentration) + (momentsMPM.dyConcentration + momentsPPP.dyConcentration)) -
165 ((momentsPMM.dyConcentration + momentsMMP.dyConcentration) + (momentsMMM.dyConcentration + momentsPMP.dyConcentration))) * c1o4;
166 const real dzzConcentration = (((momentsPMP.dzConcentration + momentsMPP.dzConcentration) + (momentsMMP.dzConcentration + momentsPPP.dzConcentration)) -
167 ((momentsPMM.dzConcentration + momentsMPM.dzConcentration) + (momentsMMM.dzConcentration + momentsPPM.dzConcentration))) * c1o4;
168
169
170
174
175 d100 = c1o4 * (((momentsPPM.concentration - momentsMMP.concentration) + (momentsPMP.concentration - momentsMPM.concentration)) +
176 ((momentsPPP.concentration - momentsMMM.concentration) + (momentsPMM.concentration - momentsMPP.concentration)));
177 d010 = c1o4 * (((momentsPPM.concentration - momentsMMP.concentration) + (momentsMPP.concentration - momentsPMM.concentration)) +
178 ((momentsPPP.concentration - momentsMMM.concentration) + (momentsMPM.concentration - momentsPMP.concentration)));
179 d001 = c1o4 * (((momentsPMP.concentration - momentsMPM.concentration) + (momentsMPP.concentration - momentsPMM.concentration)) +
180 ((momentsPPP.concentration - momentsMMM.concentration) + (momentsMMP.concentration - momentsPPM.concentration)));
181 d200 = c1o2 * dxxConcentration;
182 d020 = c1o2 * dyyConcentration;
183 d002 = c1o2 * dzzConcentration;
184 d110 = c1o2 * (((momentsPPP.concentration - momentsPMP.concentration) + (momentsPPM.concentration - momentsPMM.concentration)) +
185 ((momentsMMP.concentration - momentsMPP.concentration) + (momentsMMM.concentration - momentsMPM.concentration)));
186 d101 = c1o2 * (((momentsPPP.concentration - momentsPPM.concentration) + (momentsPMP.concentration - momentsPMM.concentration)) +
187 ((momentsMPM.concentration - momentsMPP.concentration) + (momentsMMM.concentration - momentsMMP.concentration)));
188 d011 = c1o2 * (((momentsPPP.concentration - momentsPPM.concentration) + (momentsMPP.concentration - momentsMPM.concentration)) +
189 ((momentsPMM.concentration - momentsPMP.concentration) + (momentsMMM.concentration - momentsMMP.concentration)));
190
191 d111 = ((momentsPPP.concentration - momentsMMM.concentration) + (momentsPMM.concentration - momentsMPP.concentration)) +
192 ((momentsMPM.concentration - momentsPMP.concentration) + (momentsMMP.concentration - momentsPPM.concentration));
193
194 d000 = c1o8 * (( - dxxConcentration - dyyConcentration - dzzConcentration) +
195 (((momentsPPP.concentration + momentsMMM.concentration) + (momentsPMM.concentration + momentsMPP.concentration)) +
196 ((momentsMPM.concentration + momentsPMP.concentration) + (momentsMMP.concentration + momentsPPM.concentration))));
197
202 // Coarse to Fine
203 // X------X
204 // | | x---x
205 // | ---+-+-> | ----> off-vector
206 // | | x---x
207 // X------X
209 // Fine to Coarse
210 // x------x
211 // | |
212 // | ---+--->X
213 // | | |
214 // x------x |
215 // offset-vector
216 //
218 d000 = d000 +
219 xoff * d100 + yoff * d010 + zoff * d001 +
220 xoffsq * d200 + yoffsq * d020 + zoffsq * d002 +
221 xoff * yoff * d110 + xoff * zoff * d101 + yoff * zoff * d011;
222 d100 = d100 + c2o1 * xoff * d200 + yoff * d110 + zoff * d101;
223 d010 = d010 + c2o1 * yoff * d020 + xoff * d110 + zoff * d011;
224 d001 = d001 + c2o1 * zoff * d002 + xoff * d101 + yoff * d011;
225
226 }
227
228};
229
230} // namespace vf::lbm::ad
231
232#endif
233
constexpr void calculateMMP(const real *const populations, const real *const populationsAD, const real omegaDiffusivity)
constexpr void calculatePPM(const real *const populations, const real *const populationsAD, const real omegaDiffusivity)
constexpr void calculateMMM(const real *const populations, const real *const populationsAD, const real omegaDiffusivity)
constexpr void calculatePMP(const real *const populations, const real *const populationsAD, const real omegaDiffusivity)
constexpr void calculatePPP(const real *const populations, const real *const populationsAD, const real omegaDiffusivity)
constexpr void calculateMPM(const real *const populations, const real *const populationsAD, const real omegaDiffusivity)
constexpr void calculateCoefficients(InterpolationCoefficients &coefficients, real xoff, real yoff, real zoff) const
constexpr void calculateMPP(const real *const populations, const real *const populationsAD, const real omegaDiffusivity)
constexpr void calculatePMM(const real *const populations, const real *const populationsAD, const real omegaDiffusivity)
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
constexpr real getIncompressibleVelocityX3(const real *const &f)
constexpr real getIncompressibleVelocityX2(const real *const &f)
constexpr real getDensity(const real *const &f)
constexpr void getCompressibleMacroscopicValues(const real *const &f, real &drho, real &oneOverRho, real &vx1, real &vx2, real &vx3)
constexpr real getIncompressibleVelocityX1(const real *const &f)
constexpr void calculate(const real *const populations, const real *const populationsAD, const real omega)