OpenLB 1.8.1
Loading...
Searching...
No Matches
extendedFiniteDifferenceBoundary2D.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_2D_HH
25#define EXTENDED_FINITE_DIFFERENCE_BOUNDARY_2D_HH
26
29#include "core/util.h"
30#include "dynamics/lbm.h"
31
32
33namespace olb {
34
35
37template<typename T, typename DESCRIPTOR, int direction, int orientation>
39ExtendedStraightFdBoundaryPostProcessor2D(int x0_, int x1_, int y0_, int y1_)
40 : x0(x0_), x1(x1_), y0(y0_), y1(y1_)
41{
42 OLB_PRECONDITION(x0==x1 || y0==y1);
43 this->getName() = "ExtendedStraightFdBoundaryPostProcessor2D";
44}
45
46template<typename T, typename DESCRIPTOR, int direction, int orientation>
48processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_, int y1_)
49{
50 using namespace olb::util::tensorIndices2D;
51 typedef lbm<DESCRIPTOR> lbH;
52 typedef DESCRIPTOR L;
53 enum {x,y};
54
55 for (int iX=x0; iX<=x1; ++iX) {
56 for (int iY=y0; iY<=y1; ++iY) {
57 Cell<T,DESCRIPTOR> cell = blockLattice.get(iX,iY);
58 T rho, u[L::d];
59 cell.computeRhoU(rho,u);
60
62
63 T dx_U[L::d], dy_U[L::d];
64 interpolateGradients<0>(blockLattice, dx_U, iX, iY);
65 interpolateGradients<1>(blockLattice, dy_U, iX, iY);
66
67 T rhoGradU[L::d][L::d];
68 rhoGradU[x][x] = rho * dx_U[x];
69 rhoGradU[x][y] = rho * dx_U[y];
70 rhoGradU[y][x] = rho * dy_U[x];
71 rhoGradU[y][y] = rho * dy_U[y];
72
73 T omega = blockLattice.getDynamics(iX, iY) -> getOmega();
74 T sToPi = - (T)1 / descriptors::invCs2<T,DESCRIPTOR>() / omega;
75
77 pi[xx] = (T)2 * rhoGradU[x][x] * sToPi;
78 pi[yy] = (T)2 * rhoGradU[y][y] * sToPi;
79 pi[xy] = (rhoGradU[x][y] + rhoGradU[y][x]) * sToPi;
80 // here ends the "regular" fdBoudaryCondition
81 // implemented in OpenLB
82
83 // first we compute the term
84 // (c_{i\alpha} \nabla_\beta)(rho*u_\alpha*u_\beta)
85 T dx_rho, dy_rho;
86 interpolateGradients<0>(blockLattice, dx_rho, iX, iY);
87 interpolateGradients<1>(blockLattice, dy_rho, iX, iY);
88 for (int iPop = 0; iPop < L::q; ++iPop) {
89 T cGradRhoUU = T();
90 for (int iAlpha=0; iAlpha < L::d; ++iAlpha) {
91 cGradRhoUU += descriptors::c<L>(iPop,iAlpha) * (
92 dx_rho*u[iAlpha]*u[x] +
93 dx_U[iAlpha]*rho*u[x] +
94 dx_U[x]*rho*u[iAlpha] + //end of dx derivatice
95 dy_rho*u[iAlpha]*u[y] +
96 dy_U[iAlpha]*rho*u[y] +
97 dy_U[y]*rho*u[iAlpha]);
98 }
99
100 // then we compute the term
101 // c_{i\gamma}\nabla_{\gamma}(\rho*u_\alpha * u_\beta)
102 T cDivRhoUU[L::d][L::d]; //first step towards QcdivRhoUU
103 for (int iAlpha = 0; iAlpha < L::d; ++iAlpha) {
104 for (int iBeta = 0; iBeta < L::d; ++iBeta) {
105 cDivRhoUU[iAlpha][iBeta] = descriptors::c<L>(iPop,x) *
106 (dx_rho*u[iAlpha]*u[iBeta] +
107 dx_U[iAlpha]*rho*u[iBeta] +
108 dx_U[iBeta]*rho*u[iAlpha])
109 + descriptors::c<L>(iPop,y) *
110 (dy_rho*u[iAlpha]*u[iBeta] +
111 dy_U[iAlpha]*rho*u[iBeta] +
112 dy_U[iBeta]*rho*u[iAlpha]);
113 }
114 }
115
116 //Finally we can compute
117 // Q_{i\alpha\beta}c_{i\gamma}\nabla_{\gamma}(\rho*u_\alpha * u_\beta)
118 // and Q_{i\alpha\beta}\rho\nabla_{\alpha}u_\beta
119 T qCdivRhoUU = T();
120 T qRhoGradU = T();
121 for (int iAlpha = 0; iAlpha < L::d; ++iAlpha) {
122 for (int iBeta = 0; iBeta < L::d; ++iBeta) {
123 int ci_ci = descriptors::c<L>(iPop,iAlpha)*descriptors::c<L>(iPop,iBeta);
124 qCdivRhoUU += ci_ci * cDivRhoUU[iAlpha][iBeta];
125 qRhoGradU += ci_ci * rhoGradU[iAlpha][iBeta];
126 if (iAlpha == iBeta) {
127 qCdivRhoUU -= cDivRhoUU[iAlpha][iBeta]/descriptors::invCs2<T,L>();
128 qRhoGradU -= rhoGradU[iAlpha][iBeta]/descriptors::invCs2<T,L>();
129 }
130 }
131 }
132
133 // we then can reconstruct the value of the populations
134 // according to the complete C-E expansion term
135 cell[iPop] = lbH::equilibrium(iPop,rho,u,uSqr)
137 * (qRhoGradU - cGradRhoUU + 0.5*descriptors::invCs2<T,L>()*qCdivRhoUU);
138 }
139 }
140 }
141}
142
143template<typename T, typename DESCRIPTOR, int direction, int orientation>
146{
147 processSubDomain(blockLattice, x0, x1, y0, y1);
148}
149
150template<typename T, typename DESCRIPTOR, int direction, int orientation>
151template<int deriveDirection>
154 T velDeriv[DESCRIPTOR::d], int iX, int iY) const
155{
157 interpolateVector(velDeriv, blockLattice, iX, iY);
158}
159
160template<typename T, typename DESCRIPTOR, int direction, int orientation>
161template<int deriveDirection>
163interpolateGradients(BlockLattice<T,DESCRIPTOR> const& blockLattice, T& rhoDeriv, int iX, int iY) const
164{
166 interpolateScalar(rhoDeriv, blockLattice, iX, iY);
167}
168
169
171
172template<typename T, typename DESCRIPTOR, int direction, int orientation>
177
178template<typename T, typename DESCRIPTOR, int direction, int orientation>
185
186template<typename T, typename DESCRIPTOR, int direction, int orientation>
193
194} // namespace olb
195
196#endif
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.
ExtendedStraightFdBoundaryPostProcessor2D(int x0_, int x1_, int y0_, int y1_)
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
PostProcessor2D< T, DESCRIPTOR > * generate() const override
PostProcessorGenerator2D< T, DESCRIPTOR > * clone() const override
Interface of 2D post-processing steps.
Definition aliases.h:43
std::string & getName()
read and write access to name
constexpr T invCs2() any_platform
Definition functions.h:107
constexpr T t(unsigned iPop, tag::CUM) any_platform
Definition cum.h:108
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83
auto normSqr(const ARRAY_LIKE &u) any_platform
Compute norm square of a d-dimensional vector.
Definition util.h:145
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)
static void interpolateVector(T velDeriv[DESCRIPTOR::d], BlockLattice< T, DESCRIPTOR > const &blockLattice, int iX, int iY)
Collection of common computations for LBM.
Definition lbm.h:264
Compute number of elements of a symmetric d-dimensional tensor.
Definition util.h:216
Set of functions commonly used in LB computations – header file.