28#ifndef LB_GUOZHAO_DYNAMICS_H
29#define LB_GUOZHAO_DYNAMICS_H
54template <
typename DESCRIPTOR>
57 template <
typename RHO,
typename U,
typename USQR,
typename EPSILON,
typename V=RHO>
61 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
62 c_u += descriptors::c<DESCRIPTOR>(iPop,iD)*u[iD];
65 * descriptors::t<V,DESCRIPTOR>(iPop)
67 + descriptors::invCs2<V,DESCRIPTOR>() * c_u
68 + descriptors::invCs2<V,DESCRIPTOR>() * descriptors::invCs2<V,DESCRIPTOR>() * V{0.5} * c_u * c_u / epsilon
69 - descriptors::invCs2<V,DESCRIPTOR>() * V{0.5} * uSqr / epsilon)
70 - descriptors::t<V,DESCRIPTOR>(iPop);
74template <
typename DESCRIPTOR>
77 template <
typename CELL,
typename RHO,
typename U,
typename OMEGA,
typename EPSILON,
typename K,
typename NU,
typename FORCE,
typename V=
typename CELL::value_t>
78 static void addExternalForce(CELL& cell,
const RHO& rho,
const U& u,
const OMEGA& omega,
const EPSILON& epsilon,
const K& k,
const NU& nu,
const FORCE& force)
any_platform
80 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
82 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
83 c_u += descriptors::c<DESCRIPTOR>(iPop,iD)*u[iD];
85 c_u *= descriptors::invCs2<V,DESCRIPTOR>()*descriptors::invCs2<V,DESCRIPTOR>()/epsilon;
87 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
89 ( (epsilon*(V)descriptors::c<DESCRIPTOR>(iPop,iD)-u[iD]) * descriptors::invCs2<V,DESCRIPTOR>()/epsilon
90 + c_u * descriptors::c<DESCRIPTOR>(iPop,iD)
94 forceTerm *= descriptors::t<V,DESCRIPTOR>(iPop);
95 forceTerm *= V(1) - omega/V(2);
97 cell[iPop] += forceTerm;
102 template <
typename CELL,
typename U,
typename EPSILON,
typename K,
typename NU,
typename FORCE,
typename BODY_F,
typename V=
typename CELL::value_t>
105 const V uMag =
util::sqrt( util::normSqr<V,DESCRIPTOR::d>(u) );
109 for (
int iDim=0; iDim <DESCRIPTOR::d; iDim++) {
110 force[iDim] = -u[iDim]*epsilon*nu/k - epsilon*Fe/
util::sqrt(k)*uMag*u[iDim] + bodyF[iDim]*epsilon;
119 return "GuoZhaoSecondOrder";
122 template <
typename DESCRIPTOR,
typename MOMENTA>
126 template <
typename RHO,
typename U>
128 assert(
"GuoZhaoSecondOrder::compute(int, RHO&, U&) should never be called." &&
false);
132 template <
typename CELL,
typename PARAMETERS,
typename FEQ,
typename V=
typename CELL::value_t>
134 const V epsilon = cell.template getField<descriptors::EPSILON>();
135 V rho, u[DESCRIPTOR::d];
136 MomentaF().computeRhoU(cell, rho, u);
137 const V uSqr = util::normSqr<V,DESCRIPTOR::d>(u);
138 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
141 return {rho, util::normSqr<V,DESCRIPTOR::d>(u)};
149 return "GuoEpsilonForcing";
152 template <
typename DESCRIPTOR,
typename MOMENTA>
155 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
158 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
160 using MomentaF =
typename Forced<MOMENTA>::template type<DESCRIPTOR>;
161 using CollisionO =
typename COLLISION::template type<DESCRIPTOR,Forced<MOMENTA>,EQUILIBRIUM>;
163 static_assert(COLLISION::parameters::template contains<descriptors::OMEGA>(),
164 "COLLISION must be parametrized using relaxation frequency OMEGA");
166 template <
typename CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
168 V rho, u[DESCRIPTOR::d];
169 MomentaF().computeRhoU(cell, rho, u);
171 const V omega = parameters.template get<descriptors::OMEGA>();
172 const V epsilon = cell.template getField<descriptors::EPSILON>();
173 const V k = cell.template getField<descriptors::K>();
174 const V nu = cell.template getField<descriptors::NU>();
175 auto force = cell.template getField<descriptors::FORCE>();
176 auto bodyF = cell.template getField<descriptors::BODY_FORCE>();
179 return {rho, util::normSqr<V,DESCRIPTOR::d>(u)};
183 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
189template <
typename T,
typename DESCRIPTOR,
typename MOMENTA=momenta::BulkTuple>
198template <
typename T,
typename DESCRIPTOR,
typename MOMENTA=momenta::BulkTuple>
Instantiation of Momenta tuples which define the computation and definition of momenta in a specific ...
Descriptor for all types of 2D and 3D lattices.
Interface for post-processing steps – header file.
File provides a generic interface for the computation and definition of momenta (density,...
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Top level namespace for all of OpenLB.
Interface for post-processing steps – header file.
Return value of any collision.
Compute dynamics parameter OMEGA locally using Smagorinsky LES model.
Dynamics constructed as a tuple of momenta, equilibrium and collision.
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename COLLISION::template type< DESCRIPTOR, Forced< MOMENTA >, EQUILIBRIUM > CollisionO
typename Forced< MOMENTA >::template type< DESCRIPTOR > MomentaF
static std::string getName()
typename COLLISION::parameters combined_parameters
typename Forced< MOMENTA >::template type< DESCRIPTOR > combined_momenta
typename EQUILIBRIUM::template type< DESCRIPTOR, Forced< MOMENTA > > combined_equilibrium
typename MOMENTA::template type< DESCRIPTOR > MomentaF
CellStatistic< V > compute(CELL &cell, PARAMETERS ¶meters, FEQ &fEq) any_platform
auto compute(int iPop, const RHO &rho, const U &u) any_platform
static std::string getName()
static V secondOrder(int iPop, const RHO &rho, const U &u, const USQR &uSqr, const EPSILON &epsilon) any_platform
Computation of equilibrium distribution, second order in u.
static void updateExternalForce(CELL &cell, const U &u, const EPSILON &epsilon, const K &k, const NU &nu, FORCE &force, BODY_F &bodyF) any_platform
Updates the force terms with the reaction from the porous matrix, before applying it.
static void addExternalForce(CELL &cell, const RHO &rho, const U &u, const OMEGA &omega, const EPSILON &epsilon, const K &k, const NU &nu, const FORCE &force) any_platform
Add a force term after BGK collision.
Set of functions commonly used in LB computations – header file.