OpenLB 1.7
Loading...
Searching...
No Matches
inamuroAnalyticalDynamics.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2006, Orestis Malaspinas and 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 INAMURO_ANALYTICAL_DYNAMICS_HH
25#define INAMURO_ANALYTICAL_DYNAMICS_HH
26
29#include "core/util.h"
30#include "dynamics/lbm.h"
31#include "utilities/omath.h"
32
33namespace olb {
34
35template<typename T, typename DESCRIPTOR, typename Dynamics, typename MOMENTA, int direction, int orientation>
37 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>(),
38 boundaryDynamics(omega_)
39{
40 this->getName() = "InamuroAnalyticalDynamics";
41}
42
43template<typename T, typename DESCRIPTOR, typename Dynamics, typename MOMENTA, int direction, int orientation>
45computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const
46{
47 return boundaryDynamics.computeEquilibrium(iPop, rho, u, uSqr);
48}
49
50template<typename T, typename DESCRIPTOR, typename Dynamics, typename MOMENTA, int direction, int orientation>
53 LatticeStatistics<T>& statistics )
54{
55 typedef DESCRIPTOR L;
56
57 // Along all the commented parts of this code there will be an example based
58 // on the situation where the wall's normal vector if (0,1) and the
59 // numerotation of the velocites are done according to the D2Q9
60 // lattice of the OpenLB library.
61
62 // Find all the missing populations
63 // (directions 3,4,5)
64 std::vector<int> missInd =
65 util::subIndexOutgoing<L,direction,orientation>();
66
67 // Will contain the missing poputations that are not normal to the wall.
68 // (directions 3,5)
69 std::vector<int> missDiagInd = missInd;
70
71 for (unsigned iPop = 0; iPop < missInd.size(); ++iPop) {
72 int numOfNonNullComp = 0;
73 for (int iDim = 0; iDim < L::d; ++iDim) {
74 numOfNonNullComp += util::abs(descriptors::c<L>(missInd[iPop],iDim));
75 }
76
77 if (numOfNonNullComp == 1) {
78 missDiagInd.erase(missDiagInd.begin()+iPop);
79 break;
80 }
81 }
82
83 // Will contain the populations normal to the wall's normal vector.
84 // (directions 2,6)
85 std::vector<std::size_t> perpInd = util::populationsContributingToVelocity<L,direction,0>();
86 for (unsigned iPop = 0; iPop < perpInd.size(); ++iPop) {
87 if (descriptors::c<L>(perpInd[iPop],0) == 0 && descriptors::c<L>(perpInd[iPop],1) == 0) {
88 perpInd.erase(perpInd.begin() + iPop);
89 break;
90 }
91 }
92
93 T rho, u[L::d];
94 MOMENTA().computeRhoU(cell, rho, u);
95
96 T rhoCs = T();
97 T uCs[L::d];
98 for (int iDim = 0; iDim < L::d; ++iDim) {
99 uCs[iDim] = T();
100 }
101
102 T fSum = T();
103 for (unsigned iPop = 0; iPop < missInd.size(); ++iPop) {
104 fSum += cell[descriptors::opposite<L>(missInd[iPop])];
105 }
106 // do not forget the "+1" in the rhoCs equation in the numerator (it's
107 // here because fEq = usualfEq - t[i]
108 rhoCs = ((T)6 * (-orientation * rho * u[direction] + fSum) + (T)1) /
109 ((T)3 * u[direction] * u[direction] - orientation * (T)3 * u[direction] + (T)1);
110
111 T fDiffPerp = T();
112 for (unsigned iPop = 0; iPop < perpInd.size(); ++iPop) {
113 fDiffPerp += descriptors::c<L>(perpInd[iPop],(direction + 1)%2) * cell[perpInd[iPop]];
114 }
115 fDiffPerp *= orientation;
116
117 T fDiffDiag = T();
118 for (unsigned iPop = 0; iPop < missDiagInd.size(); ++iPop)
119 fDiffDiag += descriptors::c<L>(descriptors::opposite<L>(missDiagInd[iPop]),(direction + 1)%2)
120 * cell[descriptors::opposite<L>(missDiagInd[iPop])];
121 fDiffDiag *= orientation;
122
123 uCs[(direction + 1)%L::d] = (
124 - orientation * (T)6 * rho * u[(direction+1)%L::d]
125 + orientation * rhoCs * u[(direction+1)%L::d]
126 - (T)3 * rhoCs * u[direction]*u[(direction+1)%L::d]
127 + (T)6*(fDiffPerp + fDiffDiag))
128 / (
129 rhoCs * (-orientation + (T)3 * u[direction]));
130
131 for (int iDim = 0; iDim < L::d; ++iDim) {
132 uCs[iDim] += u[iDim];
133 }
134
135 T uSqr = util::normSqr<T,L::d>(uCs);
136
137 for (unsigned iPop = 0; iPop < missInd.size(); ++iPop) {
138 cell[missInd[iPop]] = computeEquilibrium(missInd[iPop], rhoCs, uCs, uSqr);
139 }
140
141 boundaryDynamics.collide(cell, statistics);
142}
143
144template<typename T, typename DESCRIPTOR, typename Dynamics, typename MOMENTA, int direction, int orientation>
149
150template<typename T, typename DESCRIPTOR, typename Dynamics, typename MOMENTA, int direction, int orientation>
152{
153 boundaryDynamics.setOmega(omega_);
154}
155
156
157} // namespace olb
158
159
160#endif
Highest-level interface to Cell data.
Definition cell.h:148
T getOmega() const
Get local relaxation parameter of the dynamics.
void setOmega(T omega_)
Set local relaxation parameter of the dynamics.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const override
Compute equilibrium distribution function.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell, LatticeStatistics< T > &statistics) override
Collision step.
Descriptor for all types of 2D and 3D lattices.
ADf< T, DIM > abs(const ADf< T, DIM > &a)
Definition aDiff.h:1019
Top level namespace for all of OpenLB.
Return value of any collision.
Definition interface.h:43
virtual std::string getName() const
Return human-readable name.
Definition interface.h:63
Set of functions commonly used in LB computations – header file.