OpenLB 1.7
Loading...
Searching...
No Matches
adsorptionCoupling3D.hh
Go to the documentation of this file.
1/* Lattice Boltzmann sample, written in C++, using the OpenLB
2 * library
3 *
4 * Copyright (C) 2022 Florian Raichle
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 ADSORPTION_COUPLING_POST_PROCESSOR_3D_HH
26#define ADSORPTION_COUPLING_POST_PROCESSOR_3D_HH
27
31namespace olb {
34template<typename T, typename NSDESCRIPTOR, typename ADEDESCRIPTOR>
36 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int iC_,
37 std::vector<BlockStructureD<3> *> partners_,
38 AdsorptionReaction<T, ADEDESCRIPTOR> *adsorptionReaction_,
39 std::vector<std::reference_wrapper<AdvectionDiffusionForce3D<T,NSDESCRIPTOR,ADEDESCRIPTOR>>> forces_)
40 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_), iC(iC_),
41 particleLattice(static_cast<BlockLattice<T, ADEDESCRIPTOR> *>(partners_[0])),
42 soluteLattice(static_cast<BlockLattice<T, ADEDESCRIPTOR> *>(partners_[1])),
43 loadingLattice(static_cast<BlockLattice<T, ADEDESCRIPTOR> *>(partners_[2])),
44 adsorptionReaction(adsorptionReaction_),
45 forces(forces_) {
46 this->getName() = "AdsorptionFullCouplingPostProcessor3D";
47 }
48
49template<typename T, typename NSDESCRIPTOR, typename ADEDESCRIPTOR>
51 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
52 }
53
54template<typename T, typename NSDESCRIPTOR, typename ADEDESCRIPTOR>
56 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) {
57
58 int newX0, newX1, newY0, newY1, newZ0, newZ1;
60 x0, x1, y0, y1, z0, z1,
61 x0_, x1_, y0_, y1_, z0_, z1_,
62 newX0, newX1, newY0, newY1, newZ0, newZ1)) {
63 for (int iX = newX0; iX <= newX1; ++iX) {
64 for (int iY = newY0; iY <= newY1; ++iY) {
65 for (int iZ = newZ0; iZ <= newZ1; ++iZ) {
66 //computation of particle velocity for particle and load lattices
67 auto vel = blockLattice.get(iX, iY, iZ).template getField<descriptors::VELOCITY>();
68 T forceValue[3] = {0.,0.,0.};
69 if (forces.begin() != forces.end()) {
70 auto velXp = blockLattice.get(iX+1, iY, iZ).template getField<descriptors::VELOCITY>();
71 auto velXn = blockLattice.get(iX-1, iY, iZ).template getField<descriptors::VELOCITY>();
72 auto velYp = blockLattice.get(iX, iY+1, iZ).template getField<descriptors::VELOCITY>();
73 auto velYn = blockLattice.get(iX, iY-1, iZ).template getField<descriptors::VELOCITY>();
74 auto velZp = blockLattice.get(iX, iY, iZ+1).template getField<descriptors::VELOCITY>();
75 auto velZn = blockLattice.get(iX, iY, iZ-1).template getField<descriptors::VELOCITY>();
76 T velGrad[3] = {0., 0., 0.};
77 velGrad[0] = 0.5*(vel[0]*(velXp[0] - velXn[0]) + vel[1]*(velYp[0] - velYn[0]) + vel[2]*(velZp[0] - velZn[0]));
78 velGrad[1] = 0.5*(vel[0]*(velXp[1] - velXn[1]) + vel[1]*(velYp[1] - velYn[1]) + vel[2]*(velZp[1] - velZn[1]));
79 velGrad[2] = 0.5*(vel[0]*(velXp[2] - velXn[2]) + vel[1]*(velYp[2] - velYn[2]) + vel[2]*(velZp[2] - velZn[2]));
80
81 int latticeR[4] = {iC, iX, iY, iZ};
82 auto nsCell = blockLattice.get(iX, iY, iZ);
83 auto adCell = particleLattice->get(iX, iY, iZ);
85 f.applyForce(forceValue, &nsCell, &adCell, vel.data(), latticeR);
86 }
87
88 // compute new particle velocity under action of forces
90 for (int i=0; i < ADEDESCRIPTOR::d; i++) {
91 newVel[i] = vel[i] + forceValue[i] - velGrad[i];
92 }
93 particleLattice->get(iX, iY, iZ).template setField<descriptors::VELOCITY>(newVel);
94 loadingLattice->get(iX, iY, iZ).template setField<descriptors::VELOCITY>(newVel);
95 }
96 else { // set particle velocity to the carrier fluid velocity
97 particleLattice->get(iX, iY, iZ).template setField<descriptors::VELOCITY>(vel);
98 loadingLattice->get(iX, iY, iZ).template setField<descriptors::VELOCITY>(vel);
99 }
100
101 //setting of the solute velocity to the carrier fluid velocity
102 soluteLattice->get(iX, iY, iZ).template setField<descriptors::VELOCITY>(vel);
103
104 //computation of the adsorption source terms for solute and load lattices
105 T soluteConcentration = soluteLattice->get(iX, iY, iZ).computeRho();
106 T particleConcentration = particleLattice->get(iX, iY, iZ).computeRho();
107 T particleLoading = loadingLattice->get(iX, iY, iZ).computeRho();
108 Vector<T, 2> reactionRates = adsorptionReaction->getReactionRate(soluteConcentration, particleLoading, particleConcentration);
109 loadingLattice->get(iX, iY, iZ).template setField<descriptors::SOURCE>(reactionRates[1]);
110 soluteLattice->get(iX, iY, iZ).template setField<descriptors::SOURCE>(-reactionRates[0]);
111 }
112 }
113 }
114 }
115}
116
117template<typename T, typename NSDESCRIPTOR, typename ADEDESCRIPTOR>
120 int x0, int x1, int y0, int y1, int z0, int z1)
121 : LatticeCouplingGenerator3D<T, NSDESCRIPTOR>(x0, x1, y0, y1, z0, z1), reaction(reaction)
122 {}
123template<typename T, typename NSDESCRIPTOR, typename ADEDESCRIPTOR>
125 std::vector<BlockStructureD<3> *> partners) const {
127 this->x0, this->x1, this->y0, this->y1, this->z0, this->z1, this->iC, partners, reaction, ADforces);
128}
129
130template<typename T, typename NSDESCRIPTOR, typename ADEDESCRIPTOR>
134
135template<typename T, typename NSDESCRIPTOR, typename ADEDESCRIPTOR>
141}
142#endif
void process(BlockLattice< T, NSDESCRIPTOR > &blockLattice) override
AdsorptionFullCouplingPostProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int iC, std::vector< BlockStructureD< 3 > * > partners_, AdsorptionReaction< T, ADEDESCRIPTOR > *adsorptionReaction_, std::vector< std::reference_wrapper< AdvectionDiffusionForce3D< T, NSDESCRIPTOR, ADEDESCRIPTOR > > > forces_)
All in one adsorption coupling.
void processSubDomain(BlockLattice< T, NSDESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_)
AdsorptionFullCouplingPostProcessorGenerator3D(AdsorptionReaction< T, ADEDESCRIPTOR > *reaction, int x0=0, int x1=0, int y0=0, int y1=0, int z0=0, int z1=0)
LatticeCouplingGenerator3D< T, NSDESCRIPTOR > * clone() const override
PostProcessor3D< T, NSDESCRIPTOR > * generate(std::vector< BlockStructureD< 3 > * > partners) const
void addForce(AdvectionDiffusionForce3D< T, NSDESCRIPTOR, ADEDESCRIPTOR > &force)
Describes adsorption reactions in conjunction with a Isotherm class.
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.
std::string & getName()
read and write access to name
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.