OpenLB 1.7
Loading...
Searching...
No Matches
definitionRule.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Julius Jessberger
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef DYNAMICS_MOMENTA_DEFINITION_RULE_H
25#define DYNAMICS_MOMENTA_DEFINITION_RULE_H
26
27namespace olb {
28
29namespace momenta {
30
33 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
34 void defineRho(CELL& cell, V rho) any_platform
35 { }
36
37 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
38 void defineU(CELL& cell, const V u[DESCRIPTOR::d]) any_platform
39 { }
40
41 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
42 void defineRhoU(CELL& cell,
43 V rho, const V u[DESCRIPTOR::d]) any_platform
44 { }
45
46 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
47 void defineAllMomenta(CELL& cell,
48 V rho, const V u[DESCRIPTOR::d],
50 { }
51
52 static std::string getName(){
53 return "DefineSeparately";
54 }
55};
56
60struct DefineToEq {
61 template <typename TYPE, typename CELL, typename RHO, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
62 void defineRho(CELL& cell, const RHO& rho) any_platform
63 {
64 // get fluid velocity u
65 const auto u = cell.template getField<descriptors::VELOCITY>();
66
67 // set new equilibrium state with rho and u
69 }
70
71 template <typename TYPE, typename CELL, typename U, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
72 void defineU(CELL& cell, const U& u) any_platform
73 { }
74
75 template <typename TYPE, typename CELL, typename RHO, typename U, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
76 void defineRhoU(CELL& cell,
77 const RHO& rho, const U& u) any_platform
78 {
79 defineRho<TYPE>(cell, rho);
80 }
81
82 template <typename TYPE, typename CELL, typename RHO, typename U, typename PI, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
83 void defineAllMomenta(CELL& cell,
84 const RHO& rho, const U& u, const PI& pi) any_platform
85 {
86 defineRho<TYPE>(cell, rho);
87 }
88
89 static std::string getName(){
90 return "DefineToEq";
91 }
92};
93
97 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
98 void defineRho(CELL& cell, V rho) any_platform
99 {
100 // get old equilibrium data (oldRho, u)
101 V oldRho, u[DESCRIPTOR::d];
102 TYPE().computeRhoU(cell, oldRho, u);
103 TYPE().inverseShiftRhoU(cell, oldRho, u);
104
105 // modify the equilibrium part of the population from (oldRho, u) to (rho, u)
106 lbm<DESCRIPTOR>::defineNEq(cell, oldRho, u, rho, u);
107 }
108
109 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
110 void defineU(CELL& cell, const V u[DESCRIPTOR::d]) any_platform
111 {
112 // get old equilibrium data (rho, oldU)
113 V rho, oldU[DESCRIPTOR::d];
114 TYPE().computeRhoU(cell, rho, oldU);
115 TYPE().inverseShiftRhoU(cell, rho, oldU);
116
117 // modify the equilibrium part of the population from (rho, oldU) to (rho, u)
118 lbm<DESCRIPTOR>::defineNEq(cell, rho, oldU, rho, u);
119 }
120
121 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
122 void defineRhoU(CELL& cell,
123 V rho, const V u[DESCRIPTOR::d]) any_platform
124 {
125 V oldRho, oldU[DESCRIPTOR::d];
126 TYPE().computeRhoU(cell, oldRho, oldU);
127 TYPE().inverseShiftRhoU(cell, oldRho, oldU);
128
129 lbm<DESCRIPTOR>::defineNEq(cell, oldRho, oldU, rho, u);
130 }
131
132 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
133 void defineAllMomenta(CELL& cell,
134 V rho, const V u[DESCRIPTOR::d],
136 {
137 lbm<DESCRIPTOR>::defineNEqFromPi(cell, rho, u, pi);
138 }
139
140 static std::string getName(){
141 return "DefineToNEq";
142 }
143};
144
148 template <typename TYPE, typename CELL, typename RHO, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
149 void defineRho(CELL& cell, RHO& rho) any_platform
150 {
151 DefineToNEq().defineRho<TYPE>(cell, rho);
152 }
153
154 template <typename TYPE, typename CELL, typename U, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
155 void defineU(CELL& cell, U& u) any_platform
156 { }
157
158 template <typename TYPE, typename CELL, typename RHO, typename U, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
159 void defineRhoU(CELL& cell, RHO& rho, U& u) any_platform
160 {
161 defineRho<TYPE>(cell, rho);
162 }
163
164 template <typename TYPE, typename CELL, typename RHO, typename U, typename PI, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
165 void defineAllMomenta(CELL& cell,
166 RHO& rho, U& u, PI& pi) any_platform
167 {
168 DefineToNEq().defineAllMomenta<TYPE>(cell, rho, u, pi);
169 }
170
171 static std::string getName(){
172 return "DefineUSeparately";
173 }
174};
175
178// In defineRho, the computation of the old momenta does not use the external
179// field, but uses lbHelpers::computeRhoU as in the bulk.
181 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
182 void defineRho(CELL& cell, V rho) any_platform
183 {
184 // get old equilibrium data (oldRho, u)
185 V oldRho, u[DESCRIPTOR::d];
186 // only this line is different to DefineUSeparately
187 lbm<DESCRIPTOR>::computeRhoU(cell, oldRho, u);
188 TYPE().inverseShiftRhoU(cell, oldRho, u);
189
190 // modify the equilibrium part of the population from (oldRho, u) to (rho, u)
191 lbm<DESCRIPTOR>::defineNEq(cell, oldRho, u, rho, u);
192 }
193
194 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
195 void defineU(CELL& cell, const V u[DESCRIPTOR::d]) any_platform
196 { }
197
198 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
199 void defineRhoU(CELL& cell,
200 V rho, const V u[DESCRIPTOR::d]) any_platform
201 {
202 defineRho<TYPE>(cell, rho);
203 }
204
205 template <typename TYPE, typename CELL, typename V=typename CELL::value_t, typename DESCRIPTOR=typename CELL::descriptor_t>
206 void defineAllMomenta(CELL& cell,
207 V rho, const V u[DESCRIPTOR::d],
209 {
210 DefineUSeparately().defineAllMomenta<TYPE>(cell, rho, u, pi);
211 }
212
213 static std::string getName(){
214 return "DefineUSeparatelyTrace";
215 }
216};
217
218}
219
220}
221
222#endif
Top level namespace for all of OpenLB.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78
static void defineEqFirstOrder(CELL &cell, const NEWRHO &newRho, const NEWU &newU) any_platform
Definition lbm.h:389
static void defineNEq(CELL &cell, const OLDRHO &oldRho, const OLDU &oldU, const NEWRHO &newRho, const NEWU &newU) any_platform
Definition lbm.h:397
static void defineNEqFromPi(CELL &cell, const RHO &rho, const U &u, const PI &pi) any_platform
Definition lbm.h:410
static void computeRhoU(CELL &cell, RHO &rho, U &u) any_platform
Computation of hydrodynamic variables.
Definition lbm.h:219
The momenta are defined one after the other.
void defineRhoU(CELL &cell, V rho, const V u[DESCRIPTOR::d]) any_platform
void defineAllMomenta(CELL &cell, V rho, const V u[DESCRIPTOR::d], const V pi[util::TensorVal< DESCRIPTOR >::n]) any_platform
void defineU(CELL &cell, const V u[DESCRIPTOR::d]) any_platform
void defineRho(CELL &cell, V rho) any_platform
static std::string getName()
When momenta are changed, a new equilibrium state is set.
void defineAllMomenta(CELL &cell, const RHO &rho, const U &u, const PI &pi) any_platform
static std::string getName()
void defineRhoU(CELL &cell, const RHO &rho, const U &u) any_platform
void defineU(CELL &cell, const U &u) any_platform
void defineRho(CELL &cell, const RHO &rho) any_platform
When momenta are changed, the equilibrium part of the population is modified while the non-equilibriu...
static std::string getName()
void defineRho(CELL &cell, V rho) any_platform
void defineAllMomenta(CELL &cell, V rho, const V u[DESCRIPTOR::d], const V pi[util::TensorVal< DESCRIPTOR >::n]) any_platform
void defineU(CELL &cell, const V u[DESCRIPTOR::d]) any_platform
void defineRhoU(CELL &cell, V rho, const V u[DESCRIPTOR::d]) any_platform
defineRho leads to a new non-equilibrium population, defineU only sets the velocity data.
void defineAllMomenta(CELL &cell, V rho, const V u[DESCRIPTOR::d], const V pi[util::TensorVal< DESCRIPTOR >::n]) any_platform
void defineRhoU(CELL &cell, V rho, const V u[DESCRIPTOR::d]) any_platform
void defineU(CELL &cell, const V u[DESCRIPTOR::d]) any_platform
void defineRho(CELL &cell, V rho) any_platform
defineRho leads to a new non-equilibrium population, defineU only sets the velocity data.
void defineU(CELL &cell, U &u) any_platform
void defineRhoU(CELL &cell, RHO &rho, U &u) any_platform
void defineRho(CELL &cell, RHO &rho) any_platform
void defineAllMomenta(CELL &cell, RHO &rho, U &u, PI &pi) any_platform
Compute number of elements of a symmetric d-dimensional tensor.
Definition util.h:210