solverInfo.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::solverInfo
29 
30 Group
31  grpUtilitiesFunctionObjects
32 
33 Description
34  Writes solver information for a list of user-specified fields
35 
36  Information written to file includes:
37  - residual fields
38  - solver type
39  - initial residual
40  - final residual
41  - number of solver iterations
42  - convergecnce flag
43 
44 Usage
45  Example of function object specification:
46  \verbatim
47  solverInfo
48  {
49  type solverInfo;
50  libs (utilityFunctionObjects);
51  ...
52  fields (U p);
53  writeResidualFields yes;
54  }
55  \endverbatim
56 
57  Where the entries comprise:
58  \table
59  Property | Description | Required | Default value
60  type | Type name: solverInfo | yes |
61  fields | List of fields to process | yes |
62  writeResidualFields | Write the residual fields | no | no
63  \endtable
64 
65  Output data is written to the dir postProcessing/solverInfo/<timeDir>/
66 
67 See also
68  Foam::functionObject
69  Foam::functionObjects::fvMeshFunctionObject
70  Foam::functionObjects::writeFile
71  Foam::functionObjects::timeControl
72 
73 SourceFiles
74  solverInfo.C
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef functionObjects_solverInfo_H
79 #define functionObjects_solverInfo_H
80 
81 #include "fvMeshFunctionObject.H"
82 #include "writeFile.H"
83 #include "solverFieldSelection.H"
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 namespace Foam
88 {
89 namespace functionObjects
90 {
91 
92 /*---------------------------------------------------------------------------*\
93  Class solverInfo Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 class solverInfo
97 :
98  public fvMeshFunctionObject,
99  public writeFile
100 {
101 protected:
102 
103  // Protected data
104 
105  //- Fields to process
106  solverFieldSelection fieldSet_;
107 
108  //- Flag to write the residual as a vol field
110 
111  //- Names of (result) residual fields
113 
114  //- Initialisation flag
116 
117 
118  // Protected Member Functions
119 
120  //- Output file header information
121  void writeFileHeader(Ostream& os);
122 
123  //- Create and store a residual field on the mesh database
124  void createResidualField(const word& fieldName);
125 
126  //- Output file header information per primitive type value
127  template<class Type>
128  void writeFileHeader(Ostream& os, const word& fileName) const;
129 
130  //- Initialise a residual field
131  template<class Type>
132  void initialiseResidualField(const word& fieldName);
133 
134  //- Calculate the solver information
135  template<class Type>
136  void updateSolverInfo(const word& fieldName);
137 
138 
139 private:
140 
141  // Private member functions
142 
143  //- No copy construct
144  solverInfo(const solverInfo&) = delete;
145 
146  //- No copy assignment
147  void operator=(const solverInfo&) = delete;
148 
149 
150 public:
151 
152  //- Runtime type information
153  TypeName("solverInfo");
154 
155 
156  // Constructors
157 
158  //- Construct from Time and dictionary
159  solverInfo
160  (
161  const word& name,
162  const Time& runTime,
163  const dictionary& dict
164  );
165 
166 
167  //- Destructor
168  virtual ~solverInfo() = default;
169 
170 
171  // Member Functions
172 
173  //- Read the controls
174  virtual bool read(const dictionary&);
175 
176  //- Execute, currently does nothing
177  virtual bool execute();
178 
179  //- Write the solverInfo
180  virtual bool write();
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace functionObjects
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #ifdef NoRepository
192  #include "solverInfoTemplates.C"
193 #endif
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
writeFile.H
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjects::solverInfo::read
virtual bool read(const dictionary &)
Read the controls.
Definition: solverInfo.C:142
solverInfoTemplates.C
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
fvMeshFunctionObject.H
Foam::functionObjects::solverInfo::initialiseResidualField
void initialiseResidualField(const word &fieldName)
Initialise a residual field.
Definition: solverInfoTemplates.C:74
solverFieldSelection.H
Foam::functionObjects::solverFieldSelection
Definition: solverFieldSelection.H:52
Foam::functionObjects::solverInfo::updateSolverInfo
void updateSolverInfo(const word &fieldName)
Calculate the solver information.
Definition: solverInfoTemplates.C:109
Foam::HashSet< word >
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::solverInfo
Writes solver information for a list of user-specified fields.
Definition: solverInfo.H:115
Foam::functionObjects::solverInfo::execute
virtual bool execute()
Execute, currently does nothing.
Definition: solverInfo.C:162
Foam::functionObjects::solverInfo::writeResidualFields_
bool writeResidualFields_
Flag to write the residual as a vol field.
Definition: solverInfo.H:128
Foam::functionObjects::solverInfo::TypeName
TypeName("solverInfo")
Runtime type information.
Foam::functionObjects::solverInfo::residualFieldNames_
wordHashSet residualFieldNames_
Names of (result) residual fields.
Definition: solverInfo.H:131
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::solverInfo::writeFileHeader
void writeFileHeader(Ostream &os)
Output file header information.
Definition: solverInfo.C:52
Foam::functionObjects::solverInfo::initialised_
bool initialised_
Initialisation flag.
Definition: solverInfo.H:134
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::functionObjects::solverInfo::write
virtual bool write()
Write the solverInfo.
Definition: solverInfo.C:202
Foam::functionObjects::solverInfo::~solverInfo
virtual ~solverInfo()=default
Destructor.
Foam::functionObjects::solverInfo::fieldSet_
solverFieldSelection fieldSet_
Fields to process.
Definition: solverInfo.H:125
Foam::wordHashSet
HashSet< word > wordHashSet
A HashSet with word keys.
Definition: HashSet.H:406
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::functionObjects::solverInfo::createResidualField
void createResidualField(const word &fieldName)
Create and store a residual field on the mesh database.
Definition: solverInfo.C:86