OpenLB 1.7
Loading...
Searching...
No Matches
advectionDiffusionReactionCouplingPostProcessor3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2022 Johanna Moedl
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 ADVECTION_DIFFUSSION_REACTION_COUPLING_POST_PROCESSOR_3D_H
25#define ADVECTION_DIFFUSSION_REACTION_COUPLING_POST_PROCESSOR_3D_H
26
27#include "core/blockStructure.h"
28#include "core/postProcessing.h"
29#include "core/util.h"
30#include "latticeDescriptors.h"
31#include "utilities/omath.h"
32
33
34namespace olb {
35
36
41//======================================================================
42// ======== AD coupling with Concentration 3D ====================//
43//======================================================================
44template<typename T, typename DESCRIPTOR>
46 : public LocalPostProcessor3D<T,DESCRIPTOR> {
47
48public:
50 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_,
51 const std::vector<T>& stoichiometricCoeff_,
52 const std::vector<T> latticeReactionCoeff_,
53 const std::vector<T>& react_order_,
54 std::vector<BlockStructureD<3>* > partners_)
55 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_), stoichiometricCoeff(stoichiometricCoeff_), latticeReactionCoeff(latticeReactionCoeff_),
56 react_order(react_order_), partners(partners_) {
57 this->getName() = "ConcentrationAdvectionDiffusionCouplingPostProcessor3D";
58 reaction_number = static_cast<int>(latticeReactionCoeff.size());
59 component_number = static_cast<int>(partners.size())+1;
60 for (int i = 0; i<component_number;i++){
61 tpartners.emplace_back(
62 static_cast<BlockLattice<T,DESCRIPTOR> *>(partners[i]));
63 }
64 }
65
66 int extent() const override {
67 return 0;
68 }
69
70 int extent(int whichDirection) const override {
71 return 0;
72 }
73
74 void process(BlockLattice<T,DESCRIPTOR>& blockLattice) override {
75 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
76 }
77
79 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) override {
80
81 int newX0, newX1, newY0, newY1, newZ0, newZ1;
82 if ( util::intersect (
83 x0, x1, y0, y1, z0, z1,
84 x0_, x1_, y0_, y1_, z0_, z1_,
85 newX0, newX1, newY0, newY1, newZ0, newZ1) ) {
86
87 for (int iX=newX0; iX<=newX1; ++iX) {
88 for (int iY=newY0; iY<=newY1; ++iY) {
89 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
90
91 std::vector<T> conc;
92 conc.emplace_back(blockLattice.get(iX,iY, iZ).computeRho());
93 for (int iter_component = 0; iter_component<component_number-1; ++ iter_component){
94 conc.emplace_back(tpartners[iter_component]->get(iX,iY,iZ).computeRho());
95 }
96
97 T lambda[reaction_number];
98 T reaction_rate;
99 for (int iter_reaction = 0; iter_reaction<reaction_number; ++ iter_reaction){
100 lambda[iter_reaction] = 0;
101 reaction_rate = 1;
102 for(int iter_component = 0; iter_component <component_number; ++ iter_component){
103
104 reaction_rate = reaction_rate*(util::pow(conc[iter_component],react_order[iter_reaction*component_number+iter_component]));
105 }
106
107 lambda[iter_reaction] = reaction_rate*latticeReactionCoeff[iter_reaction];
108 }
109 T temp_source;
110 for (int iter_component = 0; iter_component<component_number; ++ iter_component){
111 temp_source = 0;
112 for (int iter_reaction = 0; iter_reaction<reaction_number; ++ iter_reaction){
113 temp_source = temp_source + stoichiometricCoeff[iter_reaction*component_number+iter_component]*lambda[iter_reaction];
114 }
115 if (iter_component == 0){
116 blockLattice.get(iX,iY,iZ).template setField<descriptors::SOURCE>(
117 temp_source);
118 }
119 else {
120 tpartners[iter_component-1]->get(iX,iY,iZ).template setField<descriptors::SOURCE>(
121 temp_source);
122 }
123 }
124 }
125 }
126 }
127 }
128 }
129
130private:
131 int x0, x1, y0, y1, z0, z1;
132 int reaction_number;
133 int component_number;
134 const std::vector<T>& stoichiometricCoeff;
135 const std::vector<T> latticeReactionCoeff;
136 const std::vector<T>& react_order;
137 std::vector<BlockLattice<T,DESCRIPTOR>*> tpartners;
138 std::vector<BlockStructureD<3>* > partners;
139};
140
141template<typename T, typename DESCRIPTOR>
143 : public LatticeCouplingGenerator3D<T,DESCRIPTOR> {
144
145public:
147 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_,
148 const std::vector<T>& stoichiometricCoeff_,
149 const std::vector<T> latticeReactionCoeff_,
150 const std::vector<T>& react_order_)
151 : LatticeCouplingGenerator3D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_, z0_, z1_),
152 stoichiometricCoeff(stoichiometricCoeff_), latticeReactionCoeff(latticeReactionCoeff_), react_order(react_order_)
153 { }
154
156 std::vector<BlockStructureD<3>* > partners) const override {
158 this->x0,this->x1,this->y0,this->y1, this->z0, this->z1, stoichiometricCoeff, latticeReactionCoeff, react_order, partners);
159 }
160
164
165private:
166 const std::vector<T>& stoichiometricCoeff;
167 const std::vector<T> latticeReactionCoeff;
168 const std::vector<T>& react_order;
169};
170
171
172
173
174}
175
176#endif
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.
LatticeCouplingGenerator3D< T, DESCRIPTOR > * clone() const override
ConcentrationAdvectionDiffusionCouplingGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, const std::vector< T > &stoichiometricCoeff_, const std::vector< T > latticeReactionCoeff_, const std::vector< T > &react_order_)
PostProcessor3D< T, DESCRIPTOR > * generate(std::vector< BlockStructureD< 3 > * > partners) const override
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
int extent(int whichDirection) const override
Extent of application area along a direction (0 or 1)
int extent() const override
Extent of application area (0 for purely local operations)
ConcentrationAdvectionDiffusionCouplingPostProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, const std::vector< T > &stoichiometricCoeff_, const std::vector< T > latticeReactionCoeff_, const std::vector< T > &react_order_, std::vector< BlockStructureD< 3 > * > partners_)
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) override
Execute post-processing step on a sublattice.
std::string & getName()
read and write access to name
Descriptor for all types of 2D and 3D lattices.
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112
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.
Interface for post-processing steps – header file.
Set of functions commonly used in LB computations – header file.