24#ifndef DYNAMICS_COLLISION_H
25#define DYNAMICS_COLLISION_H
44 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
46 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
60 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
64 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
66 V fEq[DESCRIPTOR::q] { };
68 const V omega =
parameters.template get<descriptors::OMEGA>();
69 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
70 cell[iPop] *= V{1} - omega;
71 cell[iPop] += omega * fEq[iPop];
85 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
90 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
94 V fEq[DESCRIPTOR::q] { };
96 const V omega =
parameters.template get<descriptors::OMEGA>();
98 for (
int iPop=1; iPop <= DESCRIPTOR::q/2; ++iPop) {
99 cell[iPop] = fEq[iPop];
100 cell[iPop+DESCRIPTOR::q/2] = fEq[iPop+DESCRIPTOR::q/2];
103 cell[iPop+DESCRIPTOR::q/2] += fNeq;
117 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
122 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
124 V fEq[DESCRIPTOR::q] { };
126 V j1[DESCRIPTOR::d] { };
127 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop ) {
128 for (
int iD=0; iD < DESCRIPTOR::d; ++iD ) {
129 j1[iD] += descriptors::c<DESCRIPTOR>(iPop,iD) * (cell[iPop] - fEq[iPop]);
132 const V omega =
parameters.template get<descriptors::OMEGA>();
133 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop ) {
135 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
136 fNeq += descriptors::c<DESCRIPTOR>(iPop,iD) * j1[iD];
138 fNeq *= descriptors::t<V,DESCRIPTOR>(iPop) * descriptors::invCs2<V,DESCRIPTOR>();
139 cell[iPop] = fEq[iPop] + (V{1} - omega) * fNeq;
150 return "ConstRhoBGK";
153 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
158 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
160 V fEq[DESCRIPTOR::q];
163 V deltaRho = V{1} -
parameters.template get<statistics::AVERAGE_RHO>();
164 V ratioRho = V{1} + deltaRho / statistic.rho;
166 const V omega =
parameters.template get<descriptors::OMEGA>();
168 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
169 cell[iPop] = ratioRho * (fEq[iPop] + descriptors::t<V,DESCRIPTOR>(iPop))
170 - descriptors::t<V,DESCRIPTOR>(iPop)
171 + (V{1} - omega) * (cell[iPop] - fEq[iPop]);
173 return {statistic.rho+deltaRho, statistic.uSqr};
184 return "PerPopulationBGK";
187 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
191 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
193 V fEq[DESCRIPTOR::q] { };
195 const auto omega =
parameters.template get<OMEGA>();
196 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
197 cell[iPop] *= V{1} - omega[iPop];
198 cell[iPop] += omega[iPop] * fEq[iPop];
214 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
219 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
221 V fPlus[DESCRIPTOR::q], fMinus[DESCRIPTOR::q];
222 V fEq[DESCRIPTOR::q], fEqPlus[DESCRIPTOR::q], fEqMinus[DESCRIPTOR::q];
224 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
225 fPlus[iPop] = 0.5 * (cell[iPop] + cell[descriptors::opposite<DESCRIPTOR>(iPop)]);
226 fMinus[iPop] = 0.5 * (cell[iPop] - cell[descriptors::opposite<DESCRIPTOR>(iPop)]);
228 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
229 fEqPlus[iPop] = 0.5 * (fEq[iPop] + fEq[descriptors::opposite<DESCRIPTOR>(iPop)]);
230 fEqMinus[iPop] = 0.5 * (fEq[iPop] - fEq[descriptors::opposite<DESCRIPTOR>(iPop)]);
233 const V omega =
parameters.template get<descriptors::OMEGA>();
234 const V magic =
parameters.template get<MAGIC>();
235 const V omega2 = V{1} / (magic / (V{1} / omega - 0.5) + V{0.5});
237 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
238 cell[iPop] -= omega * (fPlus[iPop] - fEqPlus[iPop]) + omega2 * (fMinus[iPop] - fEqMinus[iPop]);
252 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
254 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
256 for (
int iPop=1; iPop <= DESCRIPTOR::q/2; ++iPop) {
257 V cell_iPop = cell[iPop];
258 cell[iPop] = cell[descriptors::opposite<DESCRIPTOR>(iPop)];
259 cell[descriptors::opposite<DESCRIPTOR>(iPop)] = cell_iPop;
261 return {V{-1}, V{-1}};
274template <
typename COLLISION>
279 return "NguyenLaddCorrection<" + COLLISION::getName() +
">";
282 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
287 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
290 V rho, u[DESCRIPTOR::d];
291 MomentaF().computeRhoU(cell, rho, u);
292 for (
int iPop=1; iPop < DESCRIPTOR::q; ++iPop) {
293 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
294 cell[iPop] += 2 * rho * u[iD]*descriptors::c<DESCRIPTOR>(iPop,iD) * descriptors::t<V,DESCRIPTOR>(iPop) * descriptors::invCs2<V,DESCRIPTOR>();
297 return {rho, util::normSqr<V,DESCRIPTOR::d>(u)};
307 return "PartialBounceBack";
310 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
312 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
314 for (
int iPop=1; iPop <= DESCRIPTOR::q/2; ++iPop) {
315 std::swap(cell[iPop], cell[iPop+DESCRIPTOR::q/2]);
318 for (
int iPop=1; iPop < DESCRIPTOR::q; ++iPop) {
319 cell[iPop] = (rf - V{1}) * (cell[iPop] + descriptors::t<V,DESCRIPTOR>(iPop))
320 - descriptors::t<V,DESCRIPTOR>(iPop);
335 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
339 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
341 V fEq[DESCRIPTOR::q] { };
343 const V omega =
parameters.template get<descriptors::OMEGA>();
344 const V sink =
parameters.template get<SINK>();
345 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
346 cell[iPop] = (cell[iPop] + descriptors::t<V,DESCRIPTOR>(iPop))
347 - omega * ((cell[iPop] + descriptors::t<V,DESCRIPTOR>(iPop)) - descriptors::t<V,DESCRIPTOR>(iPop) * statistic.rho)
348 - sink * (cell[iPop] + descriptors::t<V,DESCRIPTOR>(iPop))
349 - descriptors::t<V,DESCRIPTOR>(iPop);
365 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
369 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
371 V fEq[DESCRIPTOR::q] { };
373 const V scattering =
parameters.template get<SCATTERING>();
374 const V absorption =
parameters.template get<ABSORPTION>();
375 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
376 cell[iPop] -= scattering * descriptors::norm_c<V,DESCRIPTOR>(iPop)*(cell[iPop] - fEq[iPop])
377 + absorption * descriptors::norm_c<V,DESCRIPTOR>(iPop)*(cell[iPop] + descriptors::t<V,DESCRIPTOR>(iPop));
388 return "FixedEquilibrium";
391 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
395 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
397 V fEq[DESCRIPTOR::q] { };
399 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
400 cell[iPop] = fEq[iPop];
Interface for post-processing steps – header file.
Top level namespace for all of OpenLB.
Return value of any collision.
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
typename MOMENTA::template type< DESCRIPTOR > MomentaF
typename meta::list< descriptors::OMEGA > parameters
static std::string getName()
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
typename meta::list< descriptors::OMEGA > parameters
static std::string getName()
typename MOMENTA::template type< DESCRIPTOR > MomentaF
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
static std::string getName()
typename meta::list< descriptors::OMEGA, statistics::AVERAGE_RHO > parameters
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename meta::list<> parameters
static std::string getName()
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename MOMENTA::template type< DESCRIPTOR > MomentaF
typename COLLISION::template type< DESCRIPTOR, MOMENTA, EQUILIBRIUM > CollisionO
Nguyen-Ladd Velocity Correction using momenta-defined velocity.
static std::string getName()
typename COLLISION::parameters parameters
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
static std::string getName()
typename meta::list<> parameters
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
static std::string getName()
typename meta::list< SCATTERING, ABSORPTION > parameters
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
static std::string getName()
typename meta::list< RF > parameters
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
typename meta::list< OMEGA > parameters
static std::string getName()
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
static std::string getName()
typename meta::list< descriptors::OMEGA, SINK > parameters
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename MOMENTA::template type< DESCRIPTOR > MomentaF
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
typename meta::list< descriptors::OMEGA > parameters
static std::string getName()
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
static std::string getName()
typename meta::list<> parameters
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename MOMENTA::template type< DESCRIPTOR > MomentaF
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > EquilibriumF
typename meta::list< descriptors::OMEGA, MAGIC > parameters
static std::string getName()
Base of a field whose size is defined by [C,U_1,...,U_N]^T * [1,V_1,...V_N].
Compute number of elements of a symmetric d-dimensional tensor.