VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
MacroscopicQuantities.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 LBM_CALCMAC_H
34#define LBM_CALCMAC_H
35
36#include <basics/DataTypes.h>
38
39#include "constants/D3Q27.h"
40
41namespace vf::lbm
42{
43
48constexpr real getDensity(const real *const &f /*[27]*/)
49{
50 return ((((f[dir::dPPP] + f[dir::dMMM]) + (f[dir::dMPM] + f[dir::dPMP])) +
51 ((f[dir::dMPP] + f[dir::dPMM]) + (f[dir::dMMP] + f[dir::dPPM]))) +
52 (((f[dir::d0MP] + f[dir::d0PM]) + (f[dir::d0MM] + f[dir::d0PP])) +
53 ((f[dir::dM0P] + f[dir::dP0M]) + (f[dir::dM0M] + f[dir::dP0P])) +
54 ((f[dir::dMP0] + f[dir::dPM0]) + (f[dir::dMM0] + f[dir::dPP0]))) +
55 f[dir::d000]) +
56 ((f[dir::dM00] + f[dir::dP00]) + (f[dir::d0M0] + f[dir::d0P0]) + (f[dir::d00M] + f[dir::d00P]));
57}
58
59// Incompressible Macroscopic Quantities
60constexpr real getIncompressibleVelocityX1(const real *const &f /*[27]*/)
61{
62 return ((((f[dir::dPPP] - f[dir::dMMM]) + (f[dir::dPMP] - f[dir::dMPM])) + ((f[dir::dPMM] - f[dir::dMPP]) + (f[dir::dPPM] - f[dir::dMMP]))) +
63 (((f[dir::dP0M] - f[dir::dM0P]) + (f[dir::dP0P] - f[dir::dM0M])) + ((f[dir::dPM0] - f[dir::dMP0]) + (f[dir::dPP0] - f[dir::dMM0]))) + (f[dir::dP00] - f[dir::dM00]));
64}
65
66constexpr real getIncompressibleVelocityX2(const real *const &f /*[27]*/)
67{
68 return ((((f[dir::dPPP] - f[dir::dMMM]) + (f[dir::dMPM] - f[dir::dPMP])) + ((f[dir::dMPP] - f[dir::dPMM]) + (f[dir::dPPM] - f[dir::dMMP]))) +
69 (((f[dir::d0PM] - f[dir::d0MP]) + (f[dir::d0PP] - f[dir::d0MM])) + ((f[dir::dMP0] - f[dir::dPM0]) + (f[dir::dPP0] - f[dir::dMM0]))) + (f[dir::d0P0] - f[dir::d0M0]));
70}
71
72constexpr real getIncompressibleVelocityX3(const real *const &f /*[27]*/)
73{
74 return ((((f[dir::dPPP] - f[dir::dMMM]) + (f[dir::dPMP] - f[dir::dMPM])) + ((f[dir::dMPP] - f[dir::dPMM]) + (f[dir::dMMP] - f[dir::dPPM]))) +
75 (((f[dir::d0MP] - f[dir::d0PM]) + (f[dir::d0PP] - f[dir::d0MM])) + ((f[dir::dM0P] - f[dir::dP0M]) + (f[dir::dP0P] - f[dir::dM0M]))) + (f[dir::d00P] - f[dir::d00M]));
76}
77
78constexpr void getIncompressibleMacroscopicValues(const real *const &f /*[27]*/, real &rho, real &vx1, real &vx2, real &vx3)
79{
80 rho = getDensity(f);
84}
85
86// Compressible Macroscopic Quantities
87constexpr real getCompressibleVelocityX1(const real *const &f27, const real& rho)
88{
89 return getIncompressibleVelocityX1(f27) / (rho + basics::constant::c1o1);
90}
91
92constexpr real getCompressibleVelocityX2(const real *const &f27, const real& rho)
93{
94 return getIncompressibleVelocityX2(f27) / (rho + basics::constant::c1o1);
95}
96
97constexpr real getCompressibleVelocityX3(const real *const &f27, const real& rho)
98{
99 return getIncompressibleVelocityX3(f27) / (rho + basics::constant::c1o1);
100}
101
102constexpr real getOneOverRho(real rho) {
103 return basics::constant::c1o1 / (rho + basics::constant::c1o1);
104}
105
106constexpr void getCompressibleMacroscopicValues(const real *const &f /*[27]*/, real &drho, real& oneOverRho, real &vx1, real &vx2, real &vx3)
107{
108 drho = getDensity(f);
113 vx1 *= oneOverRho;
114 vx2 *= oneOverRho;
115 vx3 *= oneOverRho;
116}
117
118constexpr void getCompressibleMacroscopicValues(const real *const &f /*[27]*/, real &drho, real &vx1, real &vx2, real &vx3)
119{
120 real oneOverRho = 0.0;
122}
123
124// Pressure
125constexpr real getPressure(const real *const &f27, const real& rho, const real& vx, const real& vy, const real& vz)
126{
127 return (f27[dir::dP00] + f27[dir::dM00] + f27[dir::d0P0] + f27[dir::d0M0] + f27[dir::d00P] + f27[dir::d00M] +
128 basics::constant::c2o1 *
129 (f27[dir::dPP0] + f27[dir::dMM0] + f27[dir::dPM0] + f27[dir::dMP0] + f27[dir::dP0P] + f27[dir::dM0M] +
130 f27[dir::dP0M] + f27[dir::dM0P] + f27[dir::d0PP] + f27[dir::d0MM] + f27[dir::d0PM] + f27[dir::d0MP]) +
131 basics::constant::c3o1 * (f27[dir::dPPP] + f27[dir::dMMP] + f27[dir::dPMP] + f27[dir::dMPP] + f27[dir::dPPM] +
132 f27[dir::dMMM] + f27[dir::dPMM] + f27[dir::dMPM]) -
133 rho - (vx * vx + vy * vy + vz * vz) * (basics::constant::c1o1 + rho)) *
134 basics::constant::c1o2 +
135 rho; // times zero for incompressible case // Attention: op defined directly to op = 1 ; ^^^^(1.0/op-0.5)=0.5
136}
137
139{
140 using namespace vf::basics::constant;
141 return c1o1 / (c3o1 * viscosity + c1o2);
142}
143}
144
145#endif
146
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
constexpr real getIncompressibleVelocityX3(const real *const &f)
constexpr void getIncompressibleMacroscopicValues(const real *const &f, real &rho, real &vx1, real &vx2, real &vx3)
constexpr real getIncompressibleVelocityX2(const real *const &f)
constexpr real getDensity(const real *const &f)
constexpr real getCompressibleVelocityX1(const real *const &f27, const real &rho)
constexpr real computeRelaxationFrequency(real viscosity)
constexpr real getCompressibleVelocityX3(const real *const &f27, const real &rho)
constexpr void getCompressibleMacroscopicValues(const real *const &f, real &drho, real &oneOverRho, real &vx1, real &vx2, real &vx3)
constexpr real getOneOverRho(real rho)
constexpr real getCompressibleVelocityX2(const real *const &f27, const real &rho)
constexpr real getPressure(const real *const &f27, const real &rho, const real &vx, const real &vy, const real &vz)
constexpr real getIncompressibleVelocityX1(const real *const &f)