OpenLB 1.7
Loading...
Searching...
No Matches
reactingSpecies2D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 Davide Dapelo
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
28#ifndef REACTING_SPECIES_2D_H
29#define REACTING_SPECIES_2D_H
30
31namespace olb {
32
33/*
34 * This class provides a unified set of reading-writing methods to reacting specie fields.
35 * The methods work the same to the user regardless of whether the specie field is solved through explicit Finite-Difference
36 * (thereby being defined as an external field), or through Lattice-Boltzmann (thereby being defined as the 0-th momenum of
37 * Lattice-Boltzmann one-particle density functions). This is achieved through CRTP.
38 * The Finite-Difference implementation is flexible enough to allow the external field being defined on both the main lattice,
39 * and on a coupled lattice. Conversely, the Lattice-Boltzmann implementation allows only a coupled lattice.
40 */
41template <typename T, typename DESCRIPTOR, typename SOURCE, typename IMPL>
43public:
44 ReactingSpecies2D(T stoichioCoeff);
45 // Get the stoichiometric coefficient
47 // Read the field value at a input lattice site within the input BlockStructure.
48 T getField(BlockStructureD<2>* blockStructure, int iX, int iY);
49 // Read the source value at a input lattice site within the input BlockStructure.
50 T getSource(BlockStructureD<2>* blockStructure, int iX, int iY);
51 // Increment the source value at a input lattice site within the input BlockStructure.
52 void incrementSource(BlockStructureD<2>* blockStructure, T val, int iX, int iY);
53 // Resets the source value at a input lattice site within the input BlockStructure.
54 void resetSource(BlockStructureD<2>* blockStructure, int iX, int iY);
55protected:
56 // Stoichiometric coefficient. If negative, the species is a reagent; if positive, a product.
58};
59
60template <typename T, typename DESCRIPTOR, typename SOURCE, typename FIELD>
61class FiniteDifferenceReactingSpecies2D final : public ReactingSpecies2D<T,DESCRIPTOR,SOURCE,FiniteDifferenceReactingSpecies2D<T,DESCRIPTOR,SOURCE,FIELD>> {
62public:
63 FiniteDifferenceReactingSpecies2D(T stoichioCoeff, std::size_t& iT);
64 // Read the field value at a input lattice site within the input BlockLattice.
65 T getField(BlockStructureD<2>* blockStructure, int iX, int iY);
66protected:
67 std::size_t& _iT;
68};
69
70template <typename T, typename DESCRIPTOR, typename SOURCE>
71class LatticeBoltzmannReactingSpecies2D final : public ReactingSpecies2D<T,DESCRIPTOR,SOURCE,LatticeBoltzmannReactingSpecies2D<T,DESCRIPTOR,SOURCE>> {
72public:
73 LatticeBoltzmannReactingSpecies2D(T stoichioCoeff);
74 // Read the field value at a input lattice site within the input BlockLattice.
75 T getField(BlockStructureD<2>* blockStructure, int iX, int iY);
76};
77
78}; // namespace olb
79
80#endif
Base of a regular block.
T getField(BlockStructureD< 2 > *blockStructure, int iX, int iY)
FiniteDifferenceReactingSpecies2D(T stoichioCoeff, std::size_t &iT)
T getField(BlockStructureD< 2 > *blockStructure, int iX, int iY)
ReactingSpecies2D(T stoichioCoeff)
void incrementSource(BlockStructureD< 2 > *blockStructure, T val, int iX, int iY)
T getField(BlockStructureD< 2 > *blockStructure, int iX, int iY)
T getSource(BlockStructureD< 2 > *blockStructure, int iX, int iY)
void resetSource(BlockStructureD< 2 > *blockStructure, int iX, int iY)
Top level namespace for all of OpenLB.