24#ifndef FINITE_DIFFERENCE_2D_H
25#define FINITE_DIFFERENCE_2D_H
40 return (u_xp1_yp1 - u_xp1_ym1 - u_xm1_yp1 + u_xm1_ym1) / T{4};
45constexpr T
d2u_dxdy(T u_xm1_ym1, T u_xm1, T u_ym1,
48 return - (u_xp1 + u_yp1 + u_xm1 + u_ym1 - T{2}*u_0 - u_xp1_yp1 - u_xm1_ym1) / T{2};
55 return u_xm1 + u_ym1 + u_xp1 + u_yp1 - T{4}*u_0;
63 return (-T{60}*u_0 + T{16}*(u_xm1 + u_ym1 + u_xp1 + u_yp1)
64 - (u_xm2 + u_ym2 + u_xp2 + u_yp2)) / T{12};
70template<
typename T,
typename DESCRIPTOR,
71 int direction,
int orientation,
81 template <
typename CELL>
88template<
typename T,
typename DESCRIPTOR,
89 int direction,
int orientation>
97 T u0[DESCRIPTOR::d], u1[DESCRIPTOR::d], u2[DESCRIPTOR::d];
99 blockLattice.
get(iX,iY).computeU(u0);
101 iX+(direction==0 ? (-orientation):0),
102 iY+(direction==1 ? (-orientation):0) ).computeU(u1);
104 iX+(direction==0 ? (-2*orientation):0),
105 iY+(direction==1 ? (-2*orientation):0) ).computeU(u2);
107 for (
int iD=0; iD<DESCRIPTOR::d; ++iD) {
118 T rho0 = blockLattice.
get(iX,iY).computeRho();
119 T rho1 = blockLattice.
get (
120 iX+(direction==0 ? (-orientation):0),
121 iY+(direction==1 ? (-orientation):0) ).computeRho();
122 T rho2 = blockLattice.
get (
123 iX+(direction==0 ? (-2*orientation):0),
124 iY+(direction==1 ? (-2*orientation):0) ).computeRho();
130 template <
typename CELL>
136 T u0[DESCRIPTOR::d], u1[DESCRIPTOR::d], u2[DESCRIPTOR::d];
139 cell.neighbor({(direction==0 ? (-orientation):0),
140 (direction==1 ? (-orientation):0)}).computeU(u1);
141 cell.neighbor({(direction==0 ? (-2*orientation):0),
142 (direction==1 ? (-2*orientation):0)}).computeU(u2);
144 for (
int iD=0; iD<DESCRIPTOR::d; ++iD) {
153template<
typename T,
typename DESCRIPTOR,
154 int direction,
int orientation>
162 T u_p1[DESCRIPTOR::d], u_m1[DESCRIPTOR::d];
164 int deriveDirection = 1-direction;
166 iX+(deriveDirection==0 ? 1:0),
167 iY+(deriveDirection==1 ? 1:0) ).computeU(u_p1);
169 iX+(deriveDirection==0 ? (-1):0),
170 iY+(deriveDirection==1 ? (-1):0) ).computeU(u_m1);
172 for (
int iD=0; iD<DESCRIPTOR::d; ++iD) {
183 int deriveDirection = 1-direction;
184 T rho_p1 = blockLattice.
get (
185 iX+(deriveDirection==0 ? 1:0),
186 iY+(deriveDirection==1 ? 1:0) ).computeRho();
187 T rho_m1 = blockLattice.
get (
188 iX+(deriveDirection==0 ? (-1):0),
189 iY+(deriveDirection==1 ? (-1):0) ).computeRho();
195 template <
typename CELL>
201 T u_p1[DESCRIPTOR::d], u_m1[DESCRIPTOR::d];
203 int deriveDirection = 1-direction;
204 cell.neighbor({(deriveDirection==0 ? 1:0),
205 (deriveDirection==1 ? 1:0)}).computeU(u_p1);
206 cell.neighbor({(deriveDirection==0 ? (-1):0),
207 (deriveDirection==1 ? (-1):0)}).computeU(u_m1);
209 for (
int iD=0; iD<DESCRIPTOR::d; ++iD) {
Platform-abstracted block lattice for external access and inter-block interaction.
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
constexpr T centralGradient(T u_p1, T u_m1) any_platform
Second-order central gradient (u_p1 = u(x+1))
constexpr T laplacian2D(T u_xm1, T u_ym1, T u_0, T u_xp1, T u_yp1) any_platform
Second order Laplacian (u_xp1 = u(x+1,y))
constexpr T d2u_dxdy(T u_xm1_ym1, T u_xm1_yp1, T u_xp1_ym1, T u_xp1_yp1) any_platform
Second order mixed derivative (u_xp1_ym1 = u(x+1,y-1))
constexpr T boundaryGradient(T u_0, T u_1, T u_2) any_platform
Second-order asymmetric gradient (u_1 = u(x+1))
Top level namespace for all of OpenLB.
static void interpolateScalar(T &rhoDeriv, BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY)
static void interpolateVector(T velDeriv[DESCRIPTOR::d], CELL &cell) any_platform
static void interpolateVector(T velDeriv[DESCRIPTOR::d], BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY)
static void interpolateVector(T velDeriv[DESCRIPTOR::d], BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY)
static void interpolateScalar(T &rhoDeriv, BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY)
static void interpolateVector(T velDeriv[DESCRIPTOR::d], CELL &cell) any_platform
static void interpolateVector(T velDeriv[DESCRIPTOR::d], CELL &cell) any_platform
static void interpolateScalar(T &rhoDeriv, BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY)
static void interpolateVector(T velDeriv[DESCRIPTOR::d], BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY)