24#ifndef DYNAMICS_FORCING_H
25#define DYNAMICS_FORCING_H
37template <
template <
typename>
typename Forced = momenta::Forced>
43 template <
typename DESCRIPTOR,
typename MOMENTA>
46 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
49 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
51 using MomentaF =
typename Forced<MOMENTA>::template type<DESCRIPTOR>;
52 using CollisionO =
typename COLLISION::template type<DESCRIPTOR,Forced<MOMENTA>,EQUILIBRIUM>;
54 static_assert(COLLISION::parameters::template contains<descriptors::OMEGA>(),
55 "COLLISION must be parametrized using relaxation frequency OMEGA");
57 template <
typename CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
59 V rho, u[DESCRIPTOR::d];
60 MomentaF().computeRhoU(cell, rho, u);
62 const V omega = parameters.template get<descriptors::OMEGA>();
63 const auto force = cell.template getField<descriptors::FORCE>();
65 return {rho, util::normSqr<V,DESCRIPTOR::d>(u)};
69 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
77 return "AdeGuoForcing";
80 template <
typename DESCRIPTOR,
typename MOMENTA>
83 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
86 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
88 using MomentaF =
typename MOMENTA::template type<DESCRIPTOR>;
89 using CollisionO =
typename COLLISION::template type<DESCRIPTOR,MOMENTA,EQUILIBRIUM>;
91 static_assert(COLLISION::parameters::template contains<descriptors::OMEGA>(),
92 "COLLISION must be parametrized using relaxation frequency OMEGA");
94 template <
typename CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
96 const auto u = cell.template getField<descriptors::VELOCITY>();
97 const V rho =
MomentaF().computeRho(cell);
99 const V omega = parameters.template get<descriptors::OMEGA>();
100 const auto source = cell.template getField<descriptors::SOURCE>();
101 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
104 sourceTerm *= descriptors::t<V,DESCRIPTOR>(iPop);
105 sourceTerm *= (V{1} - omega * V{0.5});
106 cell[iPop] += sourceTerm;
108 return {rho, util::normSqr<V,DESCRIPTOR::d>(u)};
112 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
120 return "MultiComponentGuoForcing";
122 template <
typename DESCRIPTOR,
typename MOMENTA>
124 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
126 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
128 using MomentaF =
typename Forced<MOMENTA>::template type<DESCRIPTOR>;
129 using CollisionO =
typename COLLISION::template type<DESCRIPTOR,Forced<MOMENTA>,EQUILIBRIUM>;
130 static_assert(COLLISION::parameters::template contains<descriptors::OMEGA>(),
131 "COLLISION must be parametrized using relaxation frequency OMEGA");
132 template <
typename CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
134 V rho, u[DESCRIPTOR::d];
135 MomentaF().computeRhoU(cell, rho, u);
137 const V omega = parameters.template get<descriptors::OMEGA>();
138 const auto force = cell.template getField<descriptors::FORCE>();
140 return {rho, util::normSqr<V,DESCRIPTOR::d>(u)};
143 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
150 return "KupershtokhForcing";
153 template <
typename DESCRIPTOR,
typename MOMENTA>
156 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
159 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
161 using MomentaF =
typename MOMENTA::template type<DESCRIPTOR>;
163 using CollisionO =
typename COLLISION::template type<DESCRIPTOR,MOMENTA,EQUILIBRIUM>;
165 template <
typename CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
169 const auto statistic =
CollisionO().apply(cell, parameters);
170 const auto force = cell.template getField<descriptors::FORCE>();
171 V uPlusDeltaU[DESCRIPTOR::d];
172 for (
int iVel=0; iVel < DESCRIPTOR::d; ++iVel) {
173 uPlusDeltaU[iVel] = u[iVel] + force[iVel];
175 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
176 cell[iPop] +=
EquilibriumF().compute(iPop, statistic.rho, uPlusDeltaU)
183 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
190 template <
typename EQUILIBRIUM>
191 struct VelocityShiftedEquilibrium {
192 static std::string getName() {
193 return "ShanChen<" + EQUILIBRIUM::getName() +
">";
196 template <
typename DESCRIPTOR,
typename MOMENTA>
201 template <
typename RHO,
typename U>
206 template <
typename CELL,
typename PARAMETERS,
typename FEQ,
typename V=
typename CELL::value_t>
208 V rho, u[DESCRIPTOR::d], uSqr{};
209 MomentaF().computeRhoU(cell, rho, u);
210 const auto force = cell.template getFieldPointer<descriptors::FORCE>();
211 for (
int iVel=0; iVel<DESCRIPTOR::d; ++iVel) {
212 u[iVel] += force[iVel] / parameters.template get<descriptors::OMEGA>();
213 uSqr += u[iVel] * u[iVel];
215 for (
unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
225 return "ShanChenForcing";
228 template <
typename DESCRIPTOR,
typename MOMENTA>
231 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
232 using combined_equilibrium =
typename VelocityShiftedEquilibrium<EQUILIBRIUM>::template type<DESCRIPTOR,MOMENTA>;
234 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
237 using CollisionO =
typename COLLISION::template type<DESCRIPTOR,MOMENTA,VelocityShiftedEquilibrium<EQUILIBRIUM>>;
239 template <
typename CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
241 V rho, u[DESCRIPTOR::d] { };
242 MomentaF().computeRhoU(cell, rho, u);
244 return {rho, util::normSqr<V,DESCRIPTOR::d>(u)};
248 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
254 return "LinearVelocityForcing";
257 template <
typename DESCRIPTOR,
typename MOMENTA>
260 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
263 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
265 using MomentaF =
typename MOMENTA::template type<DESCRIPTOR>;
266 using CollisionO =
typename COLLISION::template type<DESCRIPTOR,MOMENTA,EQUILIBRIUM>;
268 template <
typename CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
271 MomentaF().computeAllMomenta(cell, rho, u, pi);
272 auto force = cell.template getFieldPointer<descriptors::FORCE>();
273 int nDim = DESCRIPTOR::d;
278 auto v = cell.template getFieldPointer<descriptors::V12>();
279 for (
int iDim=0; iDim<nDim; ++iDim) {
280 forceSave[iDim] = force[iDim];
281 force[iDim] += v[iDim];
282 for (
int jDim=0; jDim<nDim; ++jDim) {
283 force[iDim] += v[jDim + iDim*nDim + nDim]*u[jDim];
286 for (
int iVel=0; iVel<nDim; ++iVel) {
287 u[iVel] += force[iVel] / V{2.};
290 auto statistics =
CollisionO().apply(cell, parameters);
291 V newOmega = parameters.template get<descriptors::OMEGA>();
294 for (
int iVel=0; iVel<nDim; ++iVel) {
295 force[iVel] = forceSave[iVel];
301 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
Dynamics combination rule implementing the forcing scheme by Shan and Chen.
static std::string getName()
typename VelocityShiftedEquilibrium< EQUILIBRIUM >::template type< DESCRIPTOR, MOMENTA > combined_equilibrium
typename COLLISION::parameters combined_parameters
typename momenta::Forced< MOMENTA >::template type< DESCRIPTOR > combined_momenta
Interface for post-processing steps – header file.
Top level namespace for all of OpenLB.
Return value of any collision.
typename MOMENTA::template type< DESCRIPTOR > MomentaF
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename COLLISION::template type< DESCRIPTOR, MOMENTA, EQUILIBRIUM > CollisionO
Dynamics combination rule implementing the forcing scheme by Guo et al.
static std::string getName()
typename MOMENTA::template type< DESCRIPTOR > combined_momenta
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > combined_equilibrium
typename COLLISION::parameters combined_parameters
typename Forced< MOMENTA >::template type< DESCRIPTOR > MomentaF
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename COLLISION::template type< DESCRIPTOR, Forced< MOMENTA >, EQUILIBRIUM > CollisionO
Dynamics combination rule implementing the forcing scheme by Guo et al.
static std::string getName()
typename Forced< MOMENTA >::template type< DESCRIPTOR > combined_momenta
typename EQUILIBRIUM::template type< DESCRIPTOR, Forced< MOMENTA > > combined_equilibrium
typename COLLISION::parameters combined_parameters
combined_equilibrium< DESCRIPTOR, MOMENTA, EQUILIBRIUM > EquilibriumF
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename MOMENTA::template type< DESCRIPTOR > MomentaF
typename COLLISION::template type< DESCRIPTOR, MOMENTA, EQUILIBRIUM > CollisionO
Dynamics combination rule implementing the forcing scheme by Kupershtokh et al.
typename momenta::Forced< MOMENTA >::template type< DESCRIPTOR > combined_momenta
typename COLLISION::parameters combined_parameters
static std::string getName()
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > combined_equilibrium
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters)
typename COLLISION::template type< DESCRIPTOR, MOMENTA, EQUILIBRIUM > CollisionO
typename MOMENTA::template type< DESCRIPTOR > MomentaF
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > combined_equilibrium
static std::string getName()
typename MOMENTA::template type< DESCRIPTOR > combined_momenta
typename COLLISION::parameters combined_parameters
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
Dynamics combination rule implementing the forcing scheme by Guo et al. with barycentric velocity.
typename EQUILIBRIUM::template type< DESCRIPTOR, Forced< MOMENTA > > combined_equilibrium
typename COLLISION::parameters combined_parameters
static std::string getName()
typename Forced< MOMENTA >::template type< DESCRIPTOR > combined_momenta
typename MOMENTA::template type< DESCRIPTOR > MomentaF
CellStatistic< V > compute(CELL &cell, PARAMETERS ¶meters, FEQ &fEq) any_platform
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
auto compute(int iPop, const RHO &rho, const U &u) any_platform
typename COLLISION::template type< DESCRIPTOR, MOMENTA, VelocityShiftedEquilibrium< EQUILIBRIUM > > CollisionO
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
combined_momenta< DESCRIPTOR, MOMENTA > MomentaF
static void addExternalForce(CELL &cell, const RHO &rho, const U &u, const OMEGA &omega, const FORCE &force) any_platform
Add a force term after BGK collision.
Compute number of elements of a symmetric d-dimensional tensor.