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-2020 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 #include "mathematicalConstants.H"
30 #include "fvmDdt.H"
31 #include "fvcDdt.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace diameterModels
38 {
39 namespace nucleationModels
40 {
41  defineTypeNameAndDebug(reactionDriven, 0);
43  (
44  nucleationModel,
45  reactionDriven,
46  dictionary
47  );
48 }
49 }
50 }
51 
53 
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
59 (
60  const populationBalanceModel& popBal,
61  const dictionary& dict
62 )
63 :
64  nucleationModel(popBal, dict),
65  dNuc_("nucleationDiameter", dimLength, dict),
66  velGroup_
67  (
68  refCast<const velocityGroup>
69  (
70  popBal.mesh().lookupObject<phaseModel>
71  (
72  IOobject::groupName
73  (
74  "alpha",
75  dict.lookup("velocityGroup")
76  )
77  ).dPtr()()
78  )
79  ),
80  reactingPhase_
81  (
82  popBal_.mesh().lookupObject<phaseModel>
83  (
84  IOobject::groupName("alpha", dict.lookup("reactingPhase"))
85  )
86  ),
87  pair_
88  (
89  popBal_.fluid().phasePairs()
90  [
91  phasePair(velGroup_.phase(), reactingPhase_)
92  ]
93  ),
94  dmdtfName_(dict.lookup("dmdtf")),
95  specieName_(dict.lookup("specie"))
96 {
97  if
98  (
99  dNuc_.value() < velGroup_.sizeGroups().first().dSph().value()
100  || dNuc_.value() > velGroup_.sizeGroups().last().dSph().value()
101  )
102  {
104  << "Nucleation diameter " << dNuc_.value() << "m outside of range ["
105  << velGroup_.sizeGroups().first().dSph().value() << ", "
106  << velGroup_.sizeGroups().last().dSph().value() << "]." << nl
107  << exit(FatalIOError);
108  }
109 }
110 
111 
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 
114 void
116 (
117  volScalarField& nucleationRate,
118  const label i
119 )
120 {
121  const sizeGroup& fi = popBal_.sizeGroups()[i];
122  const volScalarField& rho = fi.phase().rho();
123 
124  const volScalarField& dmidtf =
125  popBal_.mesh().lookupObject<volScalarField>
126  (
128  (
130  (
131  dmdtfName_,
132  specieName_
133  ),
134  pair_.name()
135  )
136  );
137 
138  const scalar dmidtfSign =
139  velGroup_.phase().name() == pair_.first() ? +1 : -1;
140 
141  nucleationRate +=
142  popBal_.eta(i, pi/6.0*pow3(dNuc_))*dmidtfSign*dmidtf/rho/fi.x();
143 }
144 
145 
146 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
reactionDriven(const populationBalanceModel &popBal, const dictionary &dict)
const phasePair & pair_
Phase pair.
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:106
virtual word name() const
Pair name.
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Calculate the first temporal derivative.
stressControl lookup("compactNormalStress") >> compactNormalStress
dynamicFvMesh & mesh
static word groupName(Name name, const word &group)
Calculate the matrix for the first temporal derivative.
phaseSystem & fluid
Definition: createFields.H:11
virtual void addToNucleationRate(volScalarField &nucleationRate, const label i)
Add to nucleationRate.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:260
const Mesh & mesh() const
Return mesh.
defineTypeNameAndDebug(combustionModel, 0)
dimensionedScalar pow3(const dimensionedScalar &ds)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
const Type & first() const
Return first.
Definition: Pair.H:87
Namespace for OpenFOAM.
IOerror FatalIOError