OpenLB 1.7
Loading...
Searching...
No Matches
shanChenForcedSingleComponentPostProcessor2D.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_FORCED_SINGLE_COMPONENT_POST_PROCESSOR_2D_HH
25#define SHAN_CHEN_FORCED_SINGLE_COMPONENT_POST_PROCESSOR_2D_HH
26
29#include "core/util.h"
31
32namespace olb {
33
35
36
37template<typename T, typename DESCRIPTOR>
38ShanChenForcedSingleComponentPostProcessor2D <T,DESCRIPTOR>::
39ShanChenForcedSingleComponentPostProcessor2D(int x0_, int x1_, int y0_, int y1_, T G_,
40 std::vector<T> rho0_,
42 std::vector<BlockStructureD<2>*> partners_)
43 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), G(G_), rho0(rho0_), interactionPotential(iP_), partners(partners_)
44{
45 this->getName() = "ShanChenForcedSingleComponentPostProcessor2D";
46}
47
48template<typename T, typename DESCRIPTOR>
49ShanChenForcedSingleComponentPostProcessor2D <T,DESCRIPTOR>::
50ShanChenForcedSingleComponentPostProcessor2D(T G_,
51 std::vector<T> rho0_,
53 std::vector<BlockStructureD<2>*> partners_)
54 : x0(0), x1(0), y0(0), y1(0), G(G_), rho0(rho0_), interactionPotential(iP_), partners(partners_)
55{
56 this->getName() = "ShanChenForcedSingleComponentPostProcessor2D";
57}
58
59template<typename T, typename DESCRIPTOR>
62 int x0_, int x1_, int y0_, int y1_ )
63{
64 typedef DESCRIPTOR L;
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>()[0];
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[cell.getCellId()] = cell.computeRho()*rho0[0];
80 }
81 }
82
83 for (int iX=newX0; iX<=newX1; ++iX) {
84 for (int iY=newY0; iY<=newY1; ++iY) {
85 Cell<T,DESCRIPTOR> blockCell = blockLattice.get(iX,iY);
86
87 auto j = blockCell.template getField<descriptors::VELOCITY>();
88 lbm<DESCRIPTOR>::computeJ(blockCell,j);
89 blockCell.template setField<descriptors::VELOCITY>(j);
90
91 T blockOmega = blockCell.getDynamics()->getParameters(blockLattice).template getOrFallback<descriptors::OMEGA>(0);
92
93 // Computation of the common velocity, shared among the two populations
94 T rhoTot = rhoField[blockCell.getCellId()]*blockOmega;
95
96 Vector<T, 2> uTot;
97 auto blockU = blockCell.template getField<descriptors::VELOCITY>(); // contains precomputed value rho*u
98 uTot = (blockU*rho0[0]*blockOmega) / rhoTot;
99
100 // Computation of the interaction potential
101 Vector<T, 2> rhoBlockContribution;
102 T psi;
103 interactionPotential(&psi, &rhoField[blockCell.getCellId()]);
104 for (int iPop = 0; iPop < L::q; ++iPop) {
105 int nextX = iX + descriptors::c<L>(iPop,0);
106 int nextY = iY + descriptors::c<L>(iPop,1);
107 T blockRho;
108 interactionPotential(&blockRho, &rhoField[blockLattice.getCellId(nextX, nextY)]);//rho0[0];
109 rhoBlockContribution += psi * blockRho * descriptors::c<L>(iPop)* descriptors::t<T,L>(iPop);
110 }
111
112 // Computation and storage of the final velocity, consisting
113 // of u and the momentum difference due to interaction
114 // potential plus external force
115 auto externalBlockForce = blockCell.template getField<descriptors::EXTERNAL_FORCE>();
116
117 blockCell.template setField<descriptors::VELOCITY>(uTot);
118 blockCell.template setField<descriptors::FORCE>(externalBlockForce
119 - G*rhoBlockContribution/rhoField[blockCell.getCellId()]);
120 }
121 }
122 }
123}
124
125template<typename T, typename DESCRIPTOR>
128{
129 processSubDomain(blockLattice, x0, x1, y0, y1);
130}
131
132
134
135template<typename T, typename DESCRIPTOR>
137 int x0_, int x1_, int y0_, int y1_, T G_, std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_ )
138 : LatticeCouplingGenerator2D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_), G(G_), rho0(rho0_), interactionPotential(iP_)
139{ }
140
141template<typename T, typename DESCRIPTOR>
143 T G_, std::vector<T> rho0_, AnalyticalF<1,T,T>& iP_ )
144 : LatticeCouplingGenerator2D<T,DESCRIPTOR>(0, 0, 0, 0), G(G_), rho0(rho0_), interactionPotential(iP_)
145{ }
146
147template<typename T, typename DESCRIPTOR>
149 std::vector<BlockStructureD<2>*> partners) const
150{
152 this->x0,this->x1,this->y0,this->y1,G, rho0, interactionPotential, partners);
153}
154
155template<typename T, typename DESCRIPTOR>
160
161
162
163} // namespace olb
164
165#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
Dynamics< T, DESCRIPTOR > * getDynamics()
Get a pointer to the dynamics.
Definition cell.hh:174
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
ShanChenForcedSingleComponentGenerator2D(int x0_, int x1_, int y0_, int y1_, T G_, std::vector< T > rho0_, AnalyticalF< 1, T, T > &iP_)
LatticeCouplingGenerator for NS coupling.
LatticeCouplingGenerator2D< T, DESCRIPTOR > * clone() const override
PostProcessor2D< T, DESCRIPTOR > * generate(std::vector< BlockStructureD< 2 > * > partners) const override
Multiphysics class for coupling between different lattices.
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
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.