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-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::solverInfo
29
30Group
31 grpUtilitiesFunctionObjects
32
33Description
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 - convergence flag
43
44 Operands:
45 \table
46 Operand | Type | Location
47 input | - | -
48 output file | dat <!--
49 --> | postProcessing/<FO>/<time>/<file>(s)
50 output field | volScalarField(s) <!--
51 --> | <time>/initialResiduals:<outField>(s)
52 \endtable
53
54Usage
55 Minimal example by using \c system/controlDict.functions:
56 \verbatim
57 solverInfo1
58 {
59 // Mandatory entries (unmodifiable)
60 type solverInfo;
61 libs (utilityFunctionObjects);
62
63 // Mandatory entries (runtime modifiable)
64 fields (<field1> <field2> ... <fieldN>);
65
66 // Optional entries (runtime modifiable)
67 writeResidualFields true;
68
69 // Inherited entries
70 ...
71 }
72 \endverbatim
73
74 where the entries mean:
75 \table
76 Property | Description | Type | Reqd | Deflt
77 type | Type name: solverInfo | word | yes | -
78 libs | Library name: utilityFunctionObjects | word | yes | -
79 fields | Names of operand fields | wordList | yes | -
80 writeResidualFields | Flag to write the initial-residual fields <!--
81 --> | bool | no | false
82 \endtable
83
84 The inherited entries are elaborated in:
85 - \link functionObject.H \endlink
86 - \link writeFile.H \endlink
87
88See also
89 - Foam::functionObject
90 - Foam::functionObjects::fvMeshFunctionObject
91 - Foam::functionObjects::writeFile
92
93SourceFiles
94 solverInfo.C
95 solverInfoTemplates.C
96
97\*---------------------------------------------------------------------------*/
98
99#ifndef functionObjects_solverInfo_H
100#define functionObjects_solverInfo_H
101
102#include "fvMeshFunctionObject.H"
103#include "writeFile.H"
104#include "solverFieldSelection.H"
105
106// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107
108namespace Foam
109{
110namespace functionObjects
111{
112
113/*---------------------------------------------------------------------------*\
114 Class solverInfo Declaration
115\*---------------------------------------------------------------------------*/
116
117class solverInfo
118:
119 public fvMeshFunctionObject,
120 public writeFile
121{
122protected:
123
124 // Protected Data
125
126 //- Names of operand fields
127 solverFieldSelection fieldSet_;
128
129 //- Names of (result) residual fields
131
132 //- Flag to write the initial-residual as a vol field
134
135 //- Initialisation flag
136 bool initialised_;
137
138
139 // Protected Member Functions
140
141 //- Output file header information
142 void writeFileHeader(Ostream& os);
143
144 //- Create and store a residual field on the mesh database
145 void createResidualField(const word& fieldName);
146
147 //- Output file header information per primitive type value
148 template<class Type>
149 void writeFileHeader(Ostream& os, const word& fileName) const;
150
151 //- Initialise a residual field
152 template<class Type>
153 void initialiseResidualField(const word& fieldName);
154
155 //- Calculate the solver information
156 template<class Type>
157 void updateSolverInfo(const word& fieldName);
158
159
160 // Generated Methods
161
162 //- No copy construct
163 solverInfo(const solverInfo&) = delete;
164
165 //- No copy assignment
166 void operator=(const solverInfo&) = delete;
167
169public:
170
171 //- Runtime type information
172 TypeName("solverInfo");
173
174
175 // Constructors
176
177 //- Construct from Time and dictionary
179 (
180 const word& name,
181 const Time& runTime,
182 const dictionary& dict
183 );
185
186 //- Destructor
187 virtual ~solverInfo() = default;
188
189
190 // Member Functions
191
192 //- Read solverInfo settings
193 virtual bool read(const dictionary&);
194
195 //- Execute solverInfo
196 virtual bool execute();
197
198 //- Write solverInfo results
199 virtual bool write();
200};
201
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205} // End namespace functionObjects
206} // End namespace Foam
207
208// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209
210#ifdef NoRepository
211 #include "solverInfoTemplates.C"
212#endif
213
214// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215
216#endif
218// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Writes solver information for a list of user-specified fields.
Definition: solverInfo.H:172
virtual ~solverInfo()=default
Destructor.
TypeName("solverInfo")
Runtime type information.
bool initialised_
Initialisation flag.
Definition: solverInfo.H:187
void updateSolverInfo(const word &fieldName)
Calculate the solver information.
wordHashSet residualFieldNames_
Names of (result) residual fields.
Definition: solverInfo.H:181
void createResidualField(const word &fieldName)
Create and store a residual field on the mesh database.
Definition: solverInfo.C:80
void initialiseResidualField(const word &fieldName)
Initialise a residual field.
void operator=(const solverInfo &)=delete
No copy assignment.
bool writeResidualFields_
Flag to write the initial-residual as a vol field.
Definition: solverInfo.H:184
void writeFileHeader(Ostream &os)
Output file header information.
Definition: solverInfo.C:46
solverInfo(const solverInfo &)=delete
No copy construct.
virtual bool execute()
Execute solverInfo.
Definition: solverInfo.C:158
virtual bool write()
Write solverInfo results.
Definition: solverInfo.C:198
solverFieldSelection fieldSet_
Names of operand fields.
Definition: solverInfo.H:178
virtual bool read(const dictionary &)
Read solverInfo settings.
Definition: solverInfo.C:139
Base class for writing single files from the function objects.
Definition: writeFile.H:120
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Definition: HashSet.H:82
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73