OpenLB 1.7
Loading...
Searching...
No Matches
shanChenDynOmegaForcedPostProcessor3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2008 Orestis Malaspinas, Andrea Parmigiani,
4 * Jonas Latt, 2013 Mathias J. Krause
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#ifndef SHAN_CHEN_DYN_OMEGA_FORCED_POST_PROCESSOR_3D_HH
26#define SHAN_CHEN_DYN_OMEGA_FORCED_POST_PROCESSOR_3D_HH
27
30#include "core/util.h"
32
33namespace olb {
34
36
37
38template<typename T, typename DESCRIPTOR>
39ShanChenDynOmegaForcedPostProcessor3D <T,DESCRIPTOR>::
40ShanChenDynOmegaForcedPostProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_,
41 T G_, std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_,
42 std::vector<BlockStructureD<3>*> partners_)
43 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_), G(G_), rho0(rho0_), interactionPotential(iP_), partners(partners_)
44{
45 this->getName() = "ShanChenDynOmegaForcedPostProcessor3D";
46}
47
48template<typename T, typename DESCRIPTOR>
49ShanChenDynOmegaForcedPostProcessor3D <T,DESCRIPTOR>::
50ShanChenDynOmegaForcedPostProcessor3D(T G_, std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_,
51 std::vector<BlockStructureD<3>*> partners_)
52 : x0(0), x1(0), y0(0), y1(0), z0(0), z1(0), G(G_), rho0(rho0_), interactionPotential(iP_), partners(partners_)
53{
54 this->getName() = "ShanChenDynOmegaForcedPostProcessor3D";
55}
56
57template<typename T, typename DESCRIPTOR>
60 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_ )
61{
62 typedef DESCRIPTOR L;
63
64 BlockLattice<T,DESCRIPTOR> *partnerLattice = static_cast<BlockLattice<T,DESCRIPTOR> *>(partners[0]);
65
66 int newX0, newX1, newY0, newY1, newZ0, newZ1;
67 if ( util::intersect ( x0, x1, y0, y1, z0, z1,
68 x0_, x1_, y0_, y1_, z0_, z1_,
69 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
70
71 auto& rhoField = blockLattice.template getField<RHO_CACHE>();
72
73 // Compute density and velocity on every site of first lattice, and store result
74 // in external scalars; envelope cells are included, because they are needed
75 // to compute the interaction potential in what follows.
76 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
77 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
78 for (int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
79 Cell<T,DESCRIPTOR> cell = blockLattice.get(iX,iY,iZ);
80 rhoField[0][cell.getCellId()] = cell.computeRho()*rho0[0];
81 }
82 }
83 }
84
85 // Compute density and velocity on every site of second lattice, and store result
86 // in external scalars; envelope cells are included, because they are needed
87 // to compute the interaction potential in what follows.
88 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
89 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
90 for (int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
91 Cell<T,DESCRIPTOR> cell = partnerLattice->get(iX,iY,iZ);
92 rhoField[1][cell.getCellId()] = cell.computeRho()*rho0[1];
93 }
94 }
95 }
96
97 for (int iX=newX0; iX<=newX1; ++iX) {
98 for (int iY=newY0; iY<=newY1; ++iY) {
99 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
100 Cell<T,DESCRIPTOR> blockCell = blockLattice.get(iX,iY,iZ);
101 Cell<T,DESCRIPTOR> partnerCell = partnerLattice->get(iX,iY,iZ);
102
104
105 lbm<DESCRIPTOR>::computeJ(blockCell,j);
106 blockCell.template setField<descriptors::VELOCITY>(j);
107
108 lbm<DESCRIPTOR>::computeJ(partnerCell,j);
109 partnerCell.template setField<descriptors::VELOCITY>(j);
110
111
112 T blockOmega = blockCell.template getField<descriptors::OMEGA>(); //blockLattice.getDynamics(iX, iY, iZ)->getOmega();
113 T partnerOmega = partnerCell.template getField<descriptors::OMEGA>(); //partnerLattice.getDynamics(iX, iY, iZ)->getOmega();
114 // Computation of the common velocity, shared among the two populations
115 T rhoTot = rhoField[0][blockCell.getCellId()]*blockOmega +
116 rhoField[1][blockCell.getCellId()]*partnerOmega;
117
118 Vector<T, 3> uTot;
119 auto blockU = blockCell.template getField<descriptors::VELOCITY>(); // contains precomputed value rho*u
120 auto partnerU = partnerCell.template getField<descriptors::VELOCITY>(); // contains precomputed value rho*u
121 uTot = (blockU*rho0[0]*blockOmega + partnerU*rho0[1]*partnerOmega) / rhoTot;
122
123 // Computation of the interaction potential
124 Vector<T, 3> rhoBlockContribution = {T(), T(), T()};
125 Vector<T, 3> rhoPartnerContribution = {T(), T(), T()};
126 T psi2;
127 T psi1;
128 interactionPotential(&psi2, &rhoField[1][blockCell.getCellId()]);
129 interactionPotential(&psi1, &rhoField[0][blockCell.getCellId()]);
130 for (int iPop = 0; iPop < L::q; ++iPop) {
131 int nextX = iX + descriptors::c<L>(iPop,0);
132 int nextY = iY + descriptors::c<L>(iPop,1);
133 int nextZ = iZ + descriptors::c<L>(iPop,2);
134 T blockRho;
135 T partnerRho;
136 interactionPotential(&blockRho, &rhoField[0][blockLattice.getCellId(nextX, nextY, nextZ)]);
137 interactionPotential(&partnerRho, &rhoField[1][blockLattice.getCellId(nextX, nextY, nextZ)]);
138 rhoBlockContribution += psi2 * blockRho * descriptors::c<L>(iPop) * descriptors::t<T, L>(iPop);
139 rhoPartnerContribution += psi1 * partnerRho * descriptors::c<L>(iPop) * descriptors::t<T, L>(iPop);
140 }
141
142 // Computation and storage of the final velocity, consisting
143 // of u and the momentum difference due to interaction
144 // potential plus external force
145 auto externalBlockForce = blockCell.template getField<descriptors::EXTERNAL_FORCE>();
146 auto externalPartnerForce = partnerCell.template getField<descriptors::EXTERNAL_FORCE>();
147
148 blockCell.template setField<descriptors::VELOCITY>(uTot);
149 partnerCell.template setField<descriptors::VELOCITY>(uTot);
150 blockCell.template setField<descriptors::FORCE>(externalBlockForce
151 - G*rhoPartnerContribution/rhoField[0][blockCell.getCellId()]);
152 partnerCell.template setField<descriptors::FORCE>(externalPartnerForce
153 - G*rhoBlockContribution/rhoField[1][blockCell.getCellId()]);
154 }
155 }
156 }
157 }
158}
159
160template<typename T, typename DESCRIPTOR>
163{
164 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
165}
166
167
169
170template<typename T, typename DESCRIPTOR>
172 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, T G_, std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_)
173 : LatticeCouplingGenerator3D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_, z0_, z1_), G(G_), interactionPotential(iP_), rho0(rho0_)
174{ }
175
176template<typename T, typename DESCRIPTOR>
178 T G_, std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_)
179 : LatticeCouplingGenerator3D<T,DESCRIPTOR>(0, 0, 0, 0, 0, 0), G(G_), interactionPotential(iP_), rho0(rho0_)
180{ }
181
182template<typename T, typename DESCRIPTOR>
184 std::vector<BlockStructureD<3>*> partners) const
185{
187 this->x0,this->x1,this->y0,this->y1,this->z0,this->z1, G, rho0, interactionPotential, partners);
188}
189
190template<typename T, typename DESCRIPTOR>
195
196
197
198} // namespace olb
199
200#endif
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Platform-abstracted block lattice for external access and inter-block interaction.
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
Base of a regular block.
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.
Highest-level interface to Cell data.
Definition cell.h:148
T computeRho() const
Compute particle density on the cell.
Definition cell.hh:206
std::size_t getCellId() const
Return memory ID of the currently represented cell.
Definition cell.hh:51
std::string & getName()
read and write access to name
virtual PostProcessor3D< T, DESCRIPTOR > * generate(std::vector< BlockStructureD< 3 > * > partners) const
virtual LatticeCouplingGenerator3D< T, DESCRIPTOR > * clone() const
ShanChenDynOmegaForcedGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, T G_, std::vector< T > rho0_, AnalyticalF< 1, T, T > &iP_)
LatticeCouplingGenerator for NS coupling.
Multiphysics class for coupling between different lattices.
virtual void process(BlockLattice< T, DESCRIPTOR > &blockLattice)
Execute post-processing step.
virtual void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_)
Execute post-processing step on a sublattice.
Plain old scalar vector.
Definition vector.h:47
bool intersect(int x0, int x1, int y0, int y1, int x0_, int x1_, int y0_, int y1_, int &newX0, int &newX1, int &newY0, int &newY1)
Definition util.h:89
Top level namespace for all of OpenLB.
static void computeJ(CELL &cell, J &j) any_platform
Computation of momentum.
Definition lbm.h:197
Set of functions commonly used in LB computations – header file.