33 template<
class chemistryType>
37 if (writeToFile() && !prodFilePtr_)
39 prodFilePtr_ = newFileAtStartTime(
"production");
41 writeFileHeader(prodFilePtr_());
43 consFilePtr_ = newFileAtStartTime(
"consumption");
45 writeFileHeader(consFilePtr_());
47 prodIntFilePtr_ = newFileAtStartTime(
"productionInt");
49 writeFileHeader(prodIntFilePtr_());
51 consIntFilePtr_ = newFileAtStartTime(
"consumptionInt");
53 writeFileHeader(consIntFilePtr_());
58 template<
class chemistryType>
65 writeCommented(
os,
"Reaction");
76 template<
class chemistryType>
80 const basicChemistryModel& basicChemistry
86 IOobject::NO_REGISTER,
92 scalar dt = time_.deltaTValue();
96 forAll(production_, speciei)
98 forAll(production_[speciei], reactioni)
100 RR = basicChemistry.calculateRR(reactioni, speciei);
104 production_[speciei][reactioni] =
RR[0];
105 productionInt_[speciei][reactioni] += dt*
RR[0];
107 else if (
RR[0] < 0.0)
109 consumption_[speciei][reactioni] =
RR[0];
110 consumptionInt_[speciei][reactioni] += dt*
RR[0];
114 production_[speciei][reactioni] = 0.0;
115 consumption_[speciei][reactioni] = 0.0;
122 template<
class chemistryType>
128 consFilePtr_() <<
"delta T : "<< mesh_.time().deltaTValue() <<
nl <<
nl;
129 prodFilePtr_() <<
"time : " << mesh_.time().value() <<
tab <<
nl;
130 prodFilePtr_() <<
"delta T : "<< mesh_.time().deltaTValue() <<
nl <<
nl;
132 consIntFilePtr_() <<
"start time : " << startTime_ <<
tab 133 <<
"end time :" << endTime_ <<
nl;
135 prodIntFilePtr_() <<
"start time : " << startTime_ <<
tab 136 <<
"end time :" << endTime_ <<
nl;
138 for (label reactioni = 0; reactioni < nReactions_; ++reactioni)
140 consFilePtr_() << reactioni <<
tab;
141 consIntFilePtr_() << reactioni <<
tab;
142 prodFilePtr_() << reactioni <<
tab;
143 prodIntFilePtr_() << reactioni <<
tab;
147 prodFilePtr_() << production_[i][reactioni] <<
tab;
148 consFilePtr_() << consumption_[i][reactioni] <<
tab;
149 prodIntFilePtr_() << productionInt_[i][reactioni] <<
tab;
150 consIntFilePtr_() << consumptionInt_[i][reactioni] <<
tab;
151 consumptionInt_[i][reactioni] = 0.0;
152 productionInt_[i][reactioni] = 0.0;
154 consFilePtr_() <<
nl;
155 consIntFilePtr_() <<
nl;
156 prodFilePtr_() <<
nl;
157 prodIntFilePtr_() <<
nl;
159 consFilePtr_() <<
nl <<
nl;
160 consIntFilePtr_() <<
nl <<
nl;
161 prodFilePtr_() <<
nl <<
nl;
162 prodIntFilePtr_() <<
nl <<
nl;
168 template<
class chemistryType>
197 <<
"Function object only applicable to single cell cases" 201 if (foundObject<basicChemistryModel>(
"chemistryProperties"))
203 const chemistryType&
chemistry = refCast<const chemistryType>
205 lookupObject<basicChemistryModel>(
"chemistryProperties")
210 chemistry.thermo().composition().species().size()
215 speciesNames_[i] =
chemistry.thermo().composition().species()[i];
220 if (production_.
size() == 0)
229 production_[i].
setSize(nReactions_, 0.0);
230 consumption_[i].
setSize(nReactions_, 0.0);
231 productionInt_[i].
setSize(nReactions_, 0.0);
232 consumptionInt_[i].
setSize(nReactions_, 0.0);
239 <<
" No chemistry model found. " 240 <<
" Objects available are : " <<
mesh_.
names()
248 template<
class chemistryType>
261 template<
class chemistryType>
268 lookupObject<basicChemistryModel>(
"chemistryProperties");
275 template<
class chemistryType>
283 startTime_ = endTime_;
const Type & value() const noexcept
Return const reference to value.
void size(const label n)
Older name for setAddressableSize.
virtual bool write()
Calculate the reactionsSensitivityAnalysis and write.
static void writeHeader(Ostream &os, const word &fieldName)
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
wordList names() const
The unsorted names of all objects.
virtual bool read(const dictionary &)
Read the reactionsSensitivityAnalysis data.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
constexpr char tab
The tab '\t' character(0x09)
label k
Boltzmann constant.
BasicChemistryModel< psiReactionThermo > & chemistry
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
#define forAll(list, i)
Loop across all elements in list.
virtual bool execute()
Execute.
const dimensionSet dimVolume(pow3(dimLength))
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
reactionsSensitivityAnalysis(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
errorManip< error > abort(error &err)
Computes indicators for reaction rates of creation or destruction of species in each reaction...
OBJstream os(runTime.globalPath()/outputName)
virtual bool read(const dictionary &dict)
Read.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
label nCells() const noexcept
Number of mesh cells.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
virtual bool read(const dictionary &dict)
Read optional controls.
const scalar RR
Universal gas constant: default in [J/(kmol K)].
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const Time & time() const
Return time database.
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Base class for writing single files from the function objects.
const fvMesh & mesh_
Reference to the fvMesh.
Base class for chemistry models.
static constexpr const zero Zero
Global zero (0)