bXiProgress.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) 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 "bXiProgress.H"
27 #include "volFields.H"
28 #include "fvcGrad.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace functionObjects
36 {
39 }
40 }
41 
42 
43 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44 
46 {
47  if (Pstream::master())
48  {
49  writeHeader(file(), "Combustion progress");
50  writeCommented(file(), "Time");
51 
52  file() << tab << "progress";
53 
54  file() << endl;
55  }
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
62 (
63  const word& name,
64  const Time& runTime,
65  const dictionary& dict
66 )
67 :
68  fvMeshFunctionObject(name, runTime, dict),
69  logFiles(obr_, name)
70 {
71  read(dict);
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 {
86 
87  resetName(typeName);
88 
89  return true;
90 }
91 
92 
94 {
95  return wordList{"b"};
96 }
97 
98 
100 {
101  return true;
102 }
103 
104 
106 {
107  const volScalarField& b =
108  mesh_.lookupObject<volScalarField>("b");
109 
110  const scalar progress((scalar(1) - b)().weightedAverage(mesh_.V()).value());
111 
112  logFiles::write();
113 
114  if (Pstream::master())
115  {
116  writeTime(file());
117 
118  file() << tab << progress;
119 
120  file() << endl;
121  }
122 
123  return true;
124 }
125 
126 
127 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:423
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base-class for Time/database functionObjects.
virtual bool read(const dictionary &)
Read and set the functionObject if its data have changed.
Writes the combustion progress of the Weller b-Xi combustion models.
Definition: bXiProgress.H:88
virtual wordList fields() const
Return the list of fields required.
Definition: bXiProgress.C:93
virtual ~bXiProgress()
Destructor.
Definition: bXiProgress.C:77
bXiProgress(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: bXiProgress.C:62
virtual void writeFileHeader(const label i)
Output file header information.
Definition: bXiProgress.C:45
virtual bool execute()
Do nothing.
Definition: bXiProgress.C:99
virtual bool write()
Write the cell-centre fields.
Definition: bXiProgress.C:105
virtual bool read(const dictionary &)
Read the controls.
Definition: bXiProgress.C:83
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:60
OFstream & file()
Return access to the file (if only 1)
Definition: logFiles.C:113
virtual bool write()
Write function.
Definition: logFiles.C:173
void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
Definition: writeFile.C:131
void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
Definition: writeFile.C:110
A class for handling words, derived from string.
Definition: word.H:62
Calculate the gradient of the given field.
volScalarField & b
Definition: createFields.H:27
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
Namespace for OpenFOAM.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
static const char tab
Definition: Ostream.H:266
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict