OpenLB 1.7
Loading...
Searching...
No Matches
extendedFiniteDifferenceBoundary3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2007 Orestis Malaspinas, Jonas Latt
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef EXTENDED_FINITE_DIFFERENCE_BOUNDARY_3D_HH
25#define EXTENDED_FINITE_DIFFERENCE_BOUNDARY_3D_HH
26
29#include "core/util.h"
30#include "dynamics/lbm.h"
31
32
33namespace olb {
34
36
37template<typename T, typename DESCRIPTOR, int direction, int orientation>
38ExtendedFdPlaneBoundaryPostProcessor3D <T,DESCRIPTOR,direction,orientation>::
39ExtendedFdPlaneBoundaryPostProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_)
40 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_)
41{
42 OLB_PRECONDITION(x0==x1 || y0==y1 || z0==z1);
43 this->getName() = "ExtendedFdPlaneBoundaryPostProcessor3D";
44}
45
46template<typename T, typename DESCRIPTOR, int direction, int orientation>
49 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_)
50{
51 typedef DESCRIPTOR L;
52 using namespace olb::util::tensorIndices3D;
53 typedef lbm<DESCRIPTOR> lbH;
54 enum {x,y,z};
55
56
57 for (int iX=x0; iX<=x1; ++iX) {
58 for (int iY=y0; iY<=y1; ++iY) {
59 for (int iZ=z0; iZ<=z1; ++iZ) {
60 Cell<T,DESCRIPTOR> cell = blockLattice.get(iX,iY,iZ);
61 T rho, u[L::d];
62 cell.computeRhoU(rho,u);
63 T dx_U[DESCRIPTOR::d], dy_U[DESCRIPTOR::d], dz_U[DESCRIPTOR::d];
64 interpolateGradients<0>(blockLattice, dx_U, iX, iY, iZ);
65 interpolateGradients<1>(blockLattice, dy_U, iX, iY, iZ);
66 interpolateGradients<2>(blockLattice, dz_U, iX, iY, iZ);
67
68 T rhoGradU[L::d][L::d];
69 rhoGradU[x][x] = rho *dx_U[x];
70 rhoGradU[x][y] = rho *dx_U[y];
71 rhoGradU[x][z] = rho *dx_U[z];
72 rhoGradU[y][x] = rho *dy_U[x];
73 rhoGradU[y][y] = rho *dy_U[y];
74 rhoGradU[y][z] = rho *dy_U[z];
75 rhoGradU[z][x] = rho *dz_U[x];
76 rhoGradU[z][y] = rho *dz_U[y];
77 rhoGradU[z][z] = rho *dz_U[z];
78
79 T omega = blockLattice.getDynamics(iX, iY, iZ) -> getOmega();
80 T sToPi = - (T)1 / descriptors::invCs2<T,DESCRIPTOR>() / omega;
82
83 pi[xx] = (T)2 * rhoGradU[x][x] * sToPi;
84 pi[yy] = (T)2 * rhoGradU[y][y] * sToPi;
85 pi[zz] = (T)2 * rhoGradU[z][z] * sToPi;
86 pi[xy] = (rhoGradU[x][y] + rhoGradU[y][x]) * sToPi;
87 pi[xz] = (rhoGradU[x][z] + rhoGradU[z][x]) * sToPi;
88 pi[yz] = (rhoGradU[y][z] + rhoGradU[z][y]) * sToPi;
89
90 // here ends the "regular" fdBoudaryCondition
91 // implemented in OpenLB
92
93 T uSqr = util::normSqr<T,DESCRIPTOR::d>(u);
94
95 // first we compute the term
96 // (c_{i\alpha} \nabla_\beta)(rho*u_\alpha*u_\beta)
97 T dx_rho, dy_rho, dz_rho;
98 interpolateGradients<0>(blockLattice, dx_rho, iX, iY, iZ);
99 interpolateGradients<1>(blockLattice, dy_rho, iX, iY, iZ);
100 interpolateGradients<2>(blockLattice, dz_rho, iX, iY, iZ);
101 for (int iPop = 0; iPop < L::q; ++iPop) {
102 T cGradRhoUU = T();
103 for (int iAlpha=0; iAlpha < L::d; ++iAlpha) {
104 cGradRhoUU += descriptors::c<L>(iPop,iAlpha) * (
105 dx_rho*u[iAlpha]*u[x] +
106 dx_U[iAlpha]*rho*u[x] +
107 dx_U[x]*rho*u[iAlpha] + //end of dx derivative
108 dy_rho*u[iAlpha]*u[y] +
109 dy_U[iAlpha]*rho*u[y] +
110 dy_U[y]*rho*u[iAlpha] +//end of dy derivative
111 dz_rho*u[iAlpha]*u[z] +
112 dz_U[iAlpha]*rho*u[z] +
113 dz_U[z]*rho*u[iAlpha]);
114 }
115
116 // then we compute the term
117 // c_{i\gamma}\nabla_{\gamma}(\rho*u_\alpha * u_\beta)
118 T cDivRhoUU[L::d][L::d]; //first step towards QcdivRhoUU
119 for (int iAlpha = 0; iAlpha < L::d; ++iAlpha) {
120 for (int iBeta = 0; iBeta < L::d; ++iBeta) {
121 cDivRhoUU[iAlpha][iBeta] = descriptors::c<L>(iPop,x)*
122 (dx_rho*u[iAlpha]*u[iBeta] +
123 dx_U[iAlpha]*rho*u[iBeta] +
124 dx_U[iBeta]*rho*u[iAlpha])
125 +descriptors::c<L>(iPop,y)*
126 (dy_rho*u[iAlpha]*u[iBeta] +
127 dy_U[iAlpha]*rho*u[iBeta] +
128 dy_U[iBeta]*rho*u[iAlpha])
129 +descriptors::c<L>(iPop,z)*
130 (dz_rho*u[iAlpha]*u[iBeta] +
131 dz_U[iAlpha]*rho*u[iBeta] +
132 dz_U[iBeta]*rho*u[iAlpha]);
133 }
134 }
135
136 //Finally we can compute
137 // Q_{i\alpha\beta}c_{i\gamma}\nabla_{\gamma}(\rho*u_\alpha * u_\beta)
138 // and Q_{i\alpha\beta}\rho\nabla_{\alpha}u_\beta
139 T qCdivRhoUU = T();
140 T qRhoGradU = T();
141 for (int iAlpha = 0; iAlpha < L::d; ++iAlpha) {
142 for (int iBeta = 0; iBeta < L::d; ++iBeta) {
143 int ci_ci = descriptors::c<L>(iPop,iAlpha)*descriptors::c<L>(iPop,iBeta);
144 qCdivRhoUU += ci_ci * cDivRhoUU[iAlpha][iBeta];
145 qRhoGradU += ci_ci * rhoGradU[iAlpha][iBeta];
146 if (iAlpha == iBeta) {
147 qCdivRhoUU -= cDivRhoUU[iAlpha][iBeta]/descriptors::invCs2<T,L>();
148 qRhoGradU -= rhoGradU[iAlpha][iBeta]/descriptors::invCs2<T,L>();
149 }
150 }
151 }
152
153 // we then can reconstruct the value of the populations
154 // according to the complete C-E expansion term
155 cell[iPop] = lbH::equilibrium(iPop,rho,u,uSqr)
156 - descriptors::t<T,L>(iPop) * descriptors::invCs2<T,L>() / omega
157 * (qRhoGradU - cGradRhoUU + 0.5*descriptors::invCs2<T,L>()*qCdivRhoUU);
158 }
159 }
160 }
161 }
162}
163
164template<typename T, typename DESCRIPTOR, int direction, int orientation>
167{
168 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
169}
170
171template<typename T, typename DESCRIPTOR, int direction, int orientation>
172template<int deriveDirection>
175 T velDeriv[DESCRIPTOR::d],
176 int iX, int iY, int iZ) const
177{
179 interpolateVector(velDeriv, blockLattice, iX, iY, iZ);
180}
181
182template<typename T, typename DESCRIPTOR, int direction, int orientation>
183template<int deriveDirection>
186 T& rhoDeriv, int iX, int iY, int iZ) const
187{
189 interpolateScalar(rhoDeriv, blockLattice, iX, iY, iZ);
190}
191
192
194
195template<typename T, typename DESCRIPTOR, int direction, int orientation>
197ExtendedFdPlaneBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_)
198 : PostProcessorGenerator3D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_, z0_, z1_)
199{ }
200
201template<typename T, typename DESCRIPTOR, int direction, int orientation>
208
209template<typename T, typename DESCRIPTOR, int direction, int orientation>
216
217
218} // namespace olb
219
220#endif
Platform-abstracted block lattice for external access and inter-block interaction.
virtual Dynamics< T, DESCRIPTOR > * getDynamics(DynamicsPromise< T, DESCRIPTOR > &&)=0
Return pointer to dynamics yielded by promise.
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
Highest-level interface to Cell data.
Definition cell.h:148
void computeRhoU(T &rho, T u[descriptors::d< DESCRIPTOR >()]) const
Compute fluid velocity and particle density on the cell.
Definition cell.hh:232
This class computes the finite difference approximation to LB boundary conditions on a plane wall in ...
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) override
Execute post-processing step on a sublattice.
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
PostProcessor3D< T, DESCRIPTOR > * generate() const override
ExtendedFdPlaneBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_)
PostProcessorGenerator3D< T, DESCRIPTOR > * clone() const override
std::string & getName()
read and write access to name
Top level namespace for all of OpenLB.
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46
static void interpolateScalar(T &rhoDeriv, BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY, int iZ)
static void interpolateVector(T velDeriv[DESCRIPTOR::d], BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY, int iZ)
Collection of common computations for LBM.
Definition lbm.h:182
Compute number of elements of a symmetric d-dimensional tensor.
Definition util.h:210
Set of functions commonly used in LB computations – header file.