33template<
class chemistryType>
37 if (writeToFile() && !prodFilePtr_)
39 prodFilePtr_ = newFileAtStartTime(
"production");
40 writeHeader(prodFilePtr_(),
"production");
41 writeFileHeader(prodFilePtr_());
43 consFilePtr_ = newFileAtStartTime(
"consumption");
44 writeHeader(consFilePtr_(),
"consumption");
45 writeFileHeader(consFilePtr_());
47 prodIntFilePtr_ = newFileAtStartTime(
"productionInt");
48 writeHeader(prodIntFilePtr_(),
"productionInt");
49 writeFileHeader(prodIntFilePtr_());
51 consIntFilePtr_ = newFileAtStartTime(
"consumptionInt");
52 writeHeader(consIntFilePtr_(),
"consumptionInt");
53 writeFileHeader(consIntFilePtr_());
58template<
class chemistryType>
65 writeCommented(
os,
"Reaction");
76template<
class chemistryType>
80 const basicChemistryModel& basicChemistry
83 auto tRR = volScalarField::Internal::New
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;
122template<
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;
168template<
class chemistryType>
197 <<
"Function object only applicable to single cell cases"
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()
248template<
class chemistryType>
261template<
class chemistryType>
268 lookupObject<basicChemistryModel>(
"chemistryProperties");
275template<
class chemistryType>
283 startTime_ = endTime_;
void setSize(label n)
Alias for resize().
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Base class for chemistry models.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const Type & value() const noexcept
Return const reference to value.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const fvMesh & mesh_
Reference to the fvMesh.
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Computes indicators for reaction rates of creation or destruction of species in each reaction.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
reactionsSensitivityAnalysis(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
const ObjectType & lookupObject(const word &fieldName) const
Lookup and return object (eg, a field) from the (sub) objectRegistry.
bool foundObject(const word &fieldName) const
Find object (eg, a field) in the (sub) objectRegistry.
const Time & time() const
Return time database.
Base class for writing single files from the function objects.
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
virtual bool read(const dictionary &dict)
Read.
label nCells() const noexcept
Number of mesh cells.
A class for handling words, derived from Foam::string.
BasicChemistryModel< psiReactionThermo > & chemistry
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const scalar RR
Universal gas constant: default in [J/(kmol K)].
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
constexpr char tab
The tab '\t' character(0x09).
#define forAll(list, i)
Loop across all elements in list.