reactionDriven.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2019-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "reactionDriven.H"
27 #include "phaseSystem.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace phaseTransferModels
35 {
38 }
39 }
40 
41 
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 
44 template<bool Index>
45 Foam::word Foam::phaseTransferModels::reactionDriven::speciesKey() const
46 {
47  return
49  (
50  "species",
51  (!Index ? interface_.phase1() : interface_.phase2()).name()
52  );
53 }
54 
55 
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57 
59 (
60  const dictionary& dict,
61  const phaseInterface& interface
62 )
63 :
64  phaseTransferModel(dict, interface),
65  interface_(interface),
66  species1_(dict.lookupOrDefault<wordList>(speciesKey<0>(), wordList())),
67  species2_(dict.lookupOrDefault<wordList>(speciesKey<1>(), wordList())),
68  species_()
69 {
70  if (!dict.found(speciesKey<0>()) && !dict.found(speciesKey<1>()))
71  {
73  << "No transferring species specified. Specify either "
74  << speciesKey<0>() << " or " << speciesKey<1>() << " or both."
75  << exit(FatalIOError);
76  }
77 
78  wordList species(species1_);
79  species.append(species2_);
80  species_.transfer(species);
81 }
82 
83 
84 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
85 
87 {}
88 
89 
90 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91 
94 {
95  return species_;
96 }
97 
98 
101 {
103 
104  const phaseModel& phase1 = interface_.phase1();
105  const phaseModel& phase2 = interface_.phase2();
106 
107  forAll(species1_, i)
108  {
109  volScalarField& Y1 =
110  const_cast<volScalarField&>(phase1.Y(species1_[i]));
111  result.set(species1_[i], (- phase1*phase1.R(Y1) & Y1).ptr());
112  }
113 
114  forAll(species2_, i)
115  {
116  volScalarField& Y2 =
117  const_cast<volScalarField&>(phase2.Y(species2_[i]));
118  result.set(species2_[i], (phase2*phase2.R(Y2) & Y2).ptr());
119  }
120 
121  return result;
122 };
123 
124 
125 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:67
bool set(const Key &, const T &newElmt)
Set a new hashedEntry, overwriting existing entries.
Definition: HashTableI.H:91
static word groupName(Name name, const word &group)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A wordList with hashed indices for faster lookup by name.
void append(const word &)
Append an element at the end of the list.
void transfer(List< word > &)
Transfer the contents of the argument List into this list.
Class to represent an interface between phases. Derivations can further specify the configuration of ...
const phaseModel & phase1() const
Return phase 1.
const phaseModel & phase2() const
Return phase 2.
virtual const PtrList< volScalarField > & Y() const =0
Return the species mass fractions.
virtual tmp< fvScalarMatrix > R(volScalarField &Yi) const =0
Return the fuel consumption rate matrix.
Phase transfer model representing change from one phase to another due to reactions....
reactionDriven(const dictionary &dict, const phaseInterface &interface)
Construct from a dictionary and an interface.
virtual HashPtrTable< volScalarField > dmidtf() const
The mass transfer rate for individual species.
virtual const hashedWordList & species() const
The list of individual species that are transferred.
A class for handling words, derived from string.
Definition: word.H:62
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
defineTypeNameAndDebug(cavitation, 0)
addToRunTimeSelectionTable(phaseTransferModel, cavitation, dictionary)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
IOerror FatalIOError
dictionary dict