OpenLB 1.8.1
Loading...
Searching...
No Matches
powerLawBGKdynamics.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2012, 2015 Mathias J. Krause, Vojtech Cvrcek, Davide Dapelo
4 * 2022 Nando Suntoyo, Adrian Kummerlaender
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
31#ifndef POWER_LAW_BGK_DYNAMICS_H
32#define POWER_LAW_BGK_DYNAMICS_H
33
34#include "dynamics/dynamics.h"
35#include "core/cell.h"
36
37#include "collisionLES.h"
38#include "porousBGKdynamics.h"
39
40namespace olb {
41
42// *INDENT-OFF*
43
44namespace powerlaw {
45
47 template <typename T, typename DESCRIPTOR,typename FIELD>
48 static constexpr auto isValid(FieldD<T,DESCRIPTOR,FIELD> value) {
49 return value > 0;
50 }
51};
53 template <typename T, typename DESCRIPTOR,typename FIELD>
54 static constexpr auto isValid(FieldD<T,DESCRIPTOR,FIELD> value) {
55 return value > 0;
56 }
57 };
58struct M : public descriptors::FIELD_BASE<1> {
59 template <typename T, typename DESCRIPTOR,typename FIELD>
60 static constexpr auto isValid(FieldD<T,DESCRIPTOR,FIELD> value) {
61 return value > 0;
62 }
63 };
64struct N : public descriptors::FIELD_BASE<1> {
65 template <typename T, typename DESCRIPTOR,typename FIELD>
66 static constexpr auto isValid(FieldD<T,DESCRIPTOR,FIELD> value) {
67 return value > 0;
68 }
69 };
70
71// The following is used for Herschel-Bulkley only
74
76template <typename COLLISION, bool HERSCHELBULKLEY=false>
78 using parameters = typename COLLISION::parameters::template include<
80 >;
81
82 static std::string getName()
83 {
84 return "powerlaw::OmegaFromCell<" + COLLISION::getName() + ">";
85 }
86
87 template <typename CELL, typename PARAMETERS, typename OMEGA, typename RHO, typename PI, typename V=typename CELL::value_t>
88 static V computeOmega(CELL& cell, PARAMETERS& parameters, OMEGA& omega0, RHO& rho, PI& pi) any_platform
89 {
90 using DESCRIPTOR = typename CELL::descriptor_t;
91 V pre2 = V{0.5} * descriptors::invCs2<V,DESCRIPTOR>() * omega0 / rho; // strain rate tensor prefactor
92 pre2 *= pre2;
93 V gamma{};
94 if constexpr (DESCRIPTOR::template provides<descriptors::SHEAR_RATE_MAGNITUDE>()) {
95 gamma = cell.template getField<descriptors::SHEAR_RATE_MAGNITUDE>();
96 }
97 else {
98 if constexpr (DESCRIPTOR::template provides<descriptors::FORCE>()) {
99 // Cannot be done in just one line, it gives error - I don't know why. Davide Dapelo
100 const auto force = cell.template getField<descriptors::FORCE>();
101 gamma = util::sqrt(V{2}*pre2*lbm<DESCRIPTOR>::computePiNeqNormSqr(cell, force));
102 }
103 else {
104 gamma = util::sqrt(V{2}*pre2*lbm<DESCRIPTOR>::computePiNeqNormSqr(cell));
105 }
106 }
107 if constexpr(HERSCHELBULKLEY) {
108 gamma = util::max(parameters.template get<SHEAR_RATE_MIN>(), gamma);
109 }
110 V m = parameters.template get<M>();
111 V n = parameters.template get<N>();
112 V nuNew = m * util::pow(gamma, n-V{1}); // Ostwald-de Waele relation
113 if constexpr(HERSCHELBULKLEY) {
114 // Second term necessary for Herschel-Bulkley relation
115 nuNew += parameters.template get<YIELD_STRESS>() / gamma;
116 }
117 V newOmega = V{1} / (nuNew*descriptors::invCs2<V,DESCRIPTOR>() + V{0.5});
118 V omegaMax = parameters.template get<OMEGA_MAX>();
119 newOmega = util::min(newOmega, omegaMax);
120 V omegaMin = parameters.template get<OMEGA_MIN>();
121 newOmega = util::max(newOmega, omegaMin);
122 return newOmega;
123 }
124
125 template <typename DESCRIPTOR, typename MOMENTA, typename EQUILIBRIUM>
126 struct type {
127 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
128 using CollisionO = typename COLLISION::template type<DESCRIPTOR, MOMENTA, EQUILIBRIUM>;
129
130 template <typename CELL, typename PARAMETERS, typename V=typename CELL::value_t>
132 {
133 V rho, u[DESCRIPTOR::d], pi[util::TensorVal<DESCRIPTOR>::n] { };
134 MomentaF().computeAllMomenta(cell, rho, u, pi);
135 const V oldOmega = cell.template getField<descriptors::OMEGA>();
136 const V newOmega = computeOmega(cell, parameters, oldOmega, rho, pi);
137 cell.template setField<descriptors::OMEGA>(newOmega);
138 parameters.template set<descriptors::OMEGA>(newOmega);
139 return CollisionO().apply(cell, parameters);
140 }
141 };
142};
143
144template <int... NORMAL>
146
148template <int... NORMAL>
150 static std::string getName()
151 {
152 return "PeriodicPressureOffset";
153 }
154
155 template <typename DESCRIPTOR, typename MOMENTA>
156 using combined_momenta = typename MOMENTA::template type<DESCRIPTOR>;
157
158 template <typename DESCRIPTOR, typename MOMENTA, typename EQUILIBRIUM>
159 using combined_equilibrium = typename EQUILIBRIUM::template type<DESCRIPTOR,MOMENTA>;
160
161 template <typename DESCRIPTOR, typename MOMENTA, typename EQUILIBRIUM, typename COLLISION>
163 using CollisionO = typename COLLISION::template type<DESCRIPTOR, MOMENTA, EQUILIBRIUM>;
164
165 template <typename CELL, typename PARAMETERS, typename V=typename CELL::value_t>
166 CellStatistic<V> apply(CELL& cell, PARAMETERS& parameters) any_platform
167 {
168 static constexpr auto populations = util::populationsContributingToDirection<DESCRIPTOR, NORMAL...>();
169
170 auto statistic = CollisionO().apply(cell, parameters);
171 const V densityOffset = parameters.template get<PRESSURE_OFFSET<NORMAL...>>();
172 for (unsigned iPop : populations) {
173 cell[iPop] += (cell[iPop] + descriptors::t<V,DESCRIPTOR>(iPop)) * densityOffset;
174 }
175 return statistic;
176 }
177 };
178
179 template <typename DESCRIPTOR, typename MOMENTA, typename EQUILIBRIUM, typename COLLISION>
180 using combined_parameters = typename COLLISION::parameters
181 ::template include<PRESSURE_OFFSET<NORMAL...>>;
182};
183
184}
185
187template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
189 T, DESCRIPTOR,
190 MOMENTA,
193>;
194
196template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
198 T, DESCRIPTOR,
199 MOMENTA,
203>;
204
206template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
208 T, DESCRIPTOR,
209 MOMENTA,
212>;
213
215template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
217 T, DESCRIPTOR,
218 MOMENTA,
222>;
223
225template<typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
227 T, DESCRIPTOR,
228 MOMENTA,
231>;
232
234template<typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
236 T, DESCRIPTOR,
237 MOMENTA,
241>;
242
244template<typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
246 T, DESCRIPTOR,
247 MOMENTA,
250>;
251
252// *INDENT-ON*
253
254}
255
256#endif
Definition of a LB cell – header file.
Plain old scalar vector.
constexpr T invCs2() any_platform
Definition functions.h:107
constexpr T t(unsigned iPop, tag::CUM) any_platform
Definition cum.h:108
Expr sqrt(Expr x)
Definition expr.cpp:225
Expr min(Expr a, Expr b)
Definition expr.cpp:249
Expr max(Expr a, Expr b)
Definition expr.cpp:245
Expr pow(Expr base, Expr exp)
Definition expr.cpp:235
constexpr auto populationsContributingToDirection() any_platform
Return array of population indices where c[iPop][iD] == NORMAL[iD].
Definition util.h:232
Top level namespace for all of OpenLB.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:77
Return value of any collision.
Definition interface.h:45
Base of a field whose size is defined by [C_0,C_1,C_2]^T * [1,D,Q].
Definition fields.h:52
Dynamics constructed as a tuple of momenta, equilibrium and collision.
Definition interface.h:308
Dynamics combination rule implementing the forcing scheme by Guo et al.
Definition forcing.h:38
static V computePiNeqNormSqr(CELL &cell, const FORCE &force) any_platform
Computes squared norm of non-equilibrium part of 2nd momentum for forced dynamics.
Definition lbm.h:506
static constexpr auto isValid(FieldD< T, DESCRIPTOR, FIELD > value)
static constexpr auto isValid(FieldD< T, DESCRIPTOR, FIELD > value)
static constexpr auto isValid(FieldD< T, DESCRIPTOR, FIELD > value)
static constexpr auto isValid(FieldD< T, DESCRIPTOR, FIELD > value)
CellStatistic< V > apply(CELL &cell, PARAMETERS &parameters) any_platform
typename COLLISION::template type< DESCRIPTOR, MOMENTA, EQUILIBRIUM > CollisionO
typename MOMENTA::template type< DESCRIPTOR > MomentaF
Compute and update cell-wise OMEGA using Oswald-de-waele model.
static V computeOmega(CELL &cell, PARAMETERS &parameters, OMEGA &omega0, RHO &rho, PI &pi) any_platform
typename COLLISION::parameters::template include< descriptors::OMEGA, OMEGA_MIN, OMEGA_MAX, M, N, YIELD_STRESS, SHEAR_RATE_MIN > parameters
typename COLLISION::template type< DESCRIPTOR, MOMENTA, EQUILIBRIUM > CollisionO
CellStatistic< V > apply(CELL &cell, PARAMETERS &parameters) any_platform
Combination rule to realize a pressure drop at a periodic boundary.
typename MOMENTA::template type< DESCRIPTOR > combined_momenta
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > combined_equilibrium
typename COLLISION::parameters ::template include< PRESSURE_OFFSET< NORMAL... > > combined_parameters
Compute number of elements of a symmetric d-dimensional tensor.
Definition util.h:216