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