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
83 auto RRt = tmp<DimensionedField<scalar, volMesh>>
::New 98 scalar dt = time_.deltaTValue();
102 forAll(production_, speciei)
104 forAll(production_[speciei], reactioni)
106 RR = basicChemistry.calculateRR(reactioni, speciei);
110 production_[speciei][reactioni] =
RR[0];
111 productionInt_[speciei][reactioni] += dt*
RR[0];
113 else if (
RR[0] < 0.0)
115 consumption_[speciei][reactioni] =
RR[0];
116 consumptionInt_[speciei][reactioni] += dt*
RR[0];
120 production_[speciei][reactioni] = 0.0;
121 consumption_[speciei][reactioni] = 0.0;
128 template<
class chemistryType>
134 consFilePtr_() <<
"delta T : "<< mesh_.time().deltaTValue() <<
nl <<
nl;
135 prodFilePtr_() <<
"time : " << mesh_.time().value() <<
tab <<
nl;
136 prodFilePtr_() <<
"delta T : "<< mesh_.time().deltaTValue() <<
nl <<
nl;
138 consIntFilePtr_() <<
"start time : " << startTime_ <<
tab 139 <<
"end time :" << endTime_ <<
nl;
141 prodIntFilePtr_() <<
"start time : " << startTime_ <<
tab 142 <<
"end time :" << endTime_ <<
nl;
144 for (label reactioni = 0; reactioni < nReactions_; ++reactioni)
146 consFilePtr_() << reactioni <<
tab;
147 consIntFilePtr_() << reactioni <<
tab;
148 prodFilePtr_() << reactioni <<
tab;
149 prodIntFilePtr_() << reactioni <<
tab;
153 prodFilePtr_() << production_[i][reactioni] <<
tab;
154 consFilePtr_() << consumption_[i][reactioni] <<
tab;
155 prodIntFilePtr_() << productionInt_[i][reactioni] <<
tab;
156 consIntFilePtr_() << consumptionInt_[i][reactioni] <<
tab;
157 consumptionInt_[i][reactioni] = 0.0;
158 productionInt_[i][reactioni] = 0.0;
160 consFilePtr_() <<
nl;
161 consIntFilePtr_() <<
nl;
162 prodFilePtr_() <<
nl;
163 prodIntFilePtr_() <<
nl;
165 consFilePtr_() <<
nl <<
nl;
166 consIntFilePtr_() <<
nl <<
nl;
167 prodFilePtr_() <<
nl <<
nl;
168 prodIntFilePtr_() <<
nl <<
nl;
174 template<
class chemistryType>
203 <<
"Function object only applicable to single cell cases" 207 if (foundObject<basicChemistryModel>(
"chemistryProperties"))
209 const chemistryType&
chemistry = refCast<const chemistryType>
211 lookupObject<basicChemistryModel>(
"chemistryProperties")
216 chemistry.thermo().composition().species().size()
221 speciesNames_[i] =
chemistry.thermo().composition().species()[i];
226 if (production_.
size() == 0)
235 production_[i].
setSize(nReactions_, 0.0);
236 consumption_[i].
setSize(nReactions_, 0.0);
237 productionInt_[i].
setSize(nReactions_, 0.0);
238 consumptionInt_[i].
setSize(nReactions_, 0.0);
245 <<
" No chemistry model found. " 246 <<
" Objects available are : " <<
mesh_.
names()
254 template<
class chemistryType>
267 template<
class chemistryType>
274 lookupObject<basicChemistryModel>(
"chemistryProperties");
281 template<
class chemistryType>
289 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)