OpenLB 1.7
Loading...
Searching...
No Matches
shanChenDynOmegaForcedPostProcessor2D.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, 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 SHAN_CHEN_DYN_OMEGA_FORCED_POST_PROCESSOR_2D_HH
25#define SHAN_CHEN_DYN_OMEGA_FORCED_POST_PROCESSOR_2D_HH
26
29#include "core/util.h"
31
32namespace olb {
33
35
36
37template<typename T, typename DESCRIPTOR>
38ShanChenDynOmegaForcedPostProcessor2D <T,DESCRIPTOR>::
39ShanChenDynOmegaForcedPostProcessor2D(int x0_, int x1_, int y0_, int y1_, T G_,
40 std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_,
41 std::vector<BlockStructureD<2>*> partners_)
42 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), G(G_), rho0(rho0_), interactionPotential(iP_), partners(partners_)
43{
44 this->getName() = "ShanChenDynOmegaForcedPostProcessor2D";
45}
46
47template<typename T, typename DESCRIPTOR>
48ShanChenDynOmegaForcedPostProcessor2D <T,DESCRIPTOR>::
49ShanChenDynOmegaForcedPostProcessor2D(T G_,
50 std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_,
51 std::vector<BlockStructureD<2>*> partners_)
52 : x0(0), x1(0), y0(0), y1(0), G(G_), rho0(rho0_), interactionPotential(iP_), partners(partners_)
53{
54 this->getName() = "ShanChenDynOmegaForcedPostProcessor2D";
55}
56
57template<typename T, typename DESCRIPTOR>
60 int x0_, int x1_, int y0_, int y1_ )
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;
67 if ( util::intersect ( x0, x1, y0, y1,
68 x0_, x1_, y0_, y1_,
69 newX0, newX1, newY0, newY1 ) ) {
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 Cell<T,DESCRIPTOR> cell = blockLattice.get(iX,iY);
79 rhoField[0][cell.getCellId()] = cell.computeRho()*rho0[0];
80 }
81 }
82
83 // Compute density and velocity on every site of second lattice, and store result
84 // in external scalars; envelope cells are included, because they are needed
85 // to compute the interaction potential in what follows.
86 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
87 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
88 Cell<T,DESCRIPTOR> cell = partnerLattice->get(iX,iY);
89 rhoField[1][cell.getCellId()] = cell.computeRho()*rho0[1];
90 }
91 }
92
93 for (int iX=newX0; iX<=newX1; ++iX) {
94 for (int iY=newY0; iY<=newY1; ++iY) {
95 Cell<T,DESCRIPTOR> blockCell = blockLattice.get(iX,iY);
96 Cell<T,DESCRIPTOR> partnerCell = partnerLattice->get(iX,iY);
97
99
100 lbm<DESCRIPTOR>::computeJ(blockCell,j);
101 blockCell.template setField<descriptors::VELOCITY>(j);
102
103 lbm<DESCRIPTOR>::computeJ(partnerCell,j);
104 partnerCell.template setField<descriptors::VELOCITY>(j);
105
106 T blockOmega = blockCell.template getField<descriptors::OMEGA>(); //blockCell.getDynamics()->getOmega();
107 T partnerOmega = partnerCell.template getField<descriptors::OMEGA>(); //partnerCell.getDynamics()->getOmega();
108 // Computation of the common velocity, shared among the two populations
109 T rhoTot = rhoField[0][blockCell.getCellId()]*blockOmega +
110 rhoField[1][blockCell.getCellId()]*partnerOmega;
111
112 Vector<T, 2> uTot;
113 auto blockU = blockCell.template getField<descriptors::VELOCITY>(); // contains precomputed value rho*u
114 auto partnerU = partnerCell.template getField<descriptors::VELOCITY>(); // contains precomputed value rho*u
115 uTot = (blockU*rho0[0]*blockOmega + partnerU*rho0[1]*partnerOmega) / rhoTot;
116
117
118 // Computation of the interaction potential
119 Vector<T, 2> rhoBlockContribution;
120 Vector<T, 2> rhoPartnerContribution;
121 T psi2;
122 T psi1;
123 interactionPotential(&psi2, &rhoField[1][blockCell.getCellId()]);
124 interactionPotential(&psi1, &rhoField[0][blockCell.getCellId()]);
125 for (int iPop = 0; iPop < L::q; ++iPop) {
126 int nextX = iX + descriptors::c<L>(iPop,0);
127 int nextY = iY + descriptors::c<L>(iPop,1);
128 T blockRho;
129 T partnerRho;
130 interactionPotential(&blockRho, &rhoField[0][blockLattice.getCellId(nextX, nextY)]);//rho0[0];
131 interactionPotential(&partnerRho, &rhoField[1][blockLattice.getCellId(nextX, nextY)]);
132 rhoBlockContribution += psi2 * blockRho * descriptors::c<L>(iPop)* descriptors::t<T,L>(iPop);
133 rhoPartnerContribution += psi1 * partnerRho * descriptors::c<L>(iPop)* descriptors::t<T,L>(iPop);
134 }
135
136 // Computation and storage of the final velocity, consisting
137 // of u and the momentum difference due to interaction
138 // potential plus external force
139 auto externalBlockForce = blockCell.template getField<descriptors::EXTERNAL_FORCE>();
140 auto externalPartnerForce = partnerCell.template getField<descriptors::EXTERNAL_FORCE>();
141
142 blockCell.template setField<descriptors::VELOCITY>(uTot);
143 partnerCell.template setField<descriptors::VELOCITY>(uTot);
144 blockCell.template setField<descriptors::FORCE>(externalBlockForce
145 - G*rhoPartnerContribution/rhoField[0][blockCell.getCellId()]);
146 partnerCell.template setField<descriptors::FORCE>(externalPartnerForce
147 - G*rhoBlockContribution/rhoField[1][blockCell.getCellId()]);
148 }
149 }
150 }
151}
152
153template<typename T, typename DESCRIPTOR>
156{
157 processSubDomain(blockLattice, x0, x1, y0, y1);
158}
159
160
162
163template<typename T, typename DESCRIPTOR>
165 int x0_, int x1_, int y0_, int y1_, T G_, std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_ )
166 : LatticeCouplingGenerator2D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_), G(G_), rho0(rho0_), interactionPotential(iP_)
167{ }
168
169template<typename T, typename DESCRIPTOR>
171 T G_, std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_ )
172 : LatticeCouplingGenerator2D<T,DESCRIPTOR>(0, 0, 0, 0), G(G_), rho0(rho0_), interactionPotential(iP_)
173{ }
174
175template<typename T, typename DESCRIPTOR>
177 std::vector<BlockStructureD<2>*> partners) const
178{
180 this->x0,this->x1,this->y0,this->y1,G, rho0, interactionPotential, partners);
181}
182
183template<typename T, typename DESCRIPTOR>
188
189
190
191} // namespace olb
192
193#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
Interface of 2D post-processing steps.
std::string & getName()
read and write access to name
virtual PostProcessor2D< T, DESCRIPTOR > * generate(std::vector< BlockStructureD< 2 > * > partners) const
ShanChenDynOmegaForcedGenerator2D(int x0_, int x1_, int y0_, int y1_, T G_, std::vector< T > rho0_, AnalyticalF< 1, T, T > &iP_)
LatticeCouplingGenerator for NS coupling.
virtual LatticeCouplingGenerator2D< T, DESCRIPTOR > * clone() const
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_)
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.