residuals.H
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) 2015-2022 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 Class
25  Foam::functionObjects::residuals
26 
27 Description
28  Writes out the initial residual for specified fields.
29 
30  Example of function object specification:
31  \verbatim
32  residuals
33  {
34  type residuals;
35 
36  libs ("libutilityFunctionObjects.so");
37 
38  writeControl timeStep;
39  writeInterval 1;
40  fields
41  (
42  U
43  p
44  );
45  }
46  \endverbatim
47 
48  Output data is written to the dir postProcessing/residuals/<timeDir>/
49  For vector/tensor fields, e.g. U, where an equation is solved for each
50  component, the largest residual of each component is written out.
51 
52 See also
53  Foam::functionObject
54  Foam::functionObjects::fvMeshFunctionObject
55  Foam::functionObjects::logFiles
56  Foam::functionObjects::timeControl
57 
58 SourceFiles
59  residuals.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef functionObjects_residuals_H
64 #define functionObjects_residuals_H
65 
66 #include "fvMeshFunctionObject.H"
67 #include "logFiles.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 namespace functionObjects
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class residuals Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 class residuals
81 :
82  public fvMeshFunctionObject,
83  public logFiles
84 {
85 protected:
86 
87  // Protected data
88 
89  //- Fields to write residuals
91 
92 
93  // Protected Member Functions
94 
95  //- Output field header information
96  template<class Type>
97  void writeFileHeader(const word& fieldName);
98 
99  //- Output file header information
100  virtual void writeFileHeader(const label i);
101 
102  //- Calculate the field min/max
103  template<class Type>
104  void writeResidual(const word& fieldName);
105 
106 
107 public:
108 
109  //- Runtime type information
110  TypeName("residuals");
111 
112 
113  // Constructors
114 
115  //- Construct from Time and dictionary
116  residuals
117  (
118  const word& name,
119  const Time& runTime,
120  const dictionary& dict
121  );
122 
123  //- Disallow default bitwise copy construction
124  residuals(const residuals&) = delete;
125 
126 
127  //- Destructor
128  virtual ~residuals();
129 
130 
131  // Member Functions
132 
133  //- Read the controls
134  virtual bool read(const dictionary&);
135 
136  //- Return the list of fields required
137  virtual wordList fields() const
138  {
139  return wordList::null();
140  }
141 
142  //- Execute, currently does nothing
143  virtual bool execute();
144 
145  //- Write the residuals
146  virtual bool write();
147 
148 
149  // Member Operators
150 
151  //- Disallow default bitwise assignment
152  void operator=(const residuals&) = delete;
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace functionObjects
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #ifdef NoRepository
164  #include "residualsTemplates.C"
165 #endif
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
void writeResidual(const word &fieldName)
Calculate the field min/max.
dictionary dict
virtual bool write()
Write the residuals.
Definition: residuals.C:113
const word & name() const
Return the name of this functionObject.
virtual bool execute()
Execute, currently does nothing.
Definition: residuals.C:107
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void writeFileHeader(const word &fieldName)
Output field header information.
virtual bool read(const dictionary &)
Read the controls.
Definition: residuals.C:72
TypeName("residuals")
Runtime type information.
static const List< T > & null()
Return a null List.
Definition: ListI.H:118
void operator=(const residuals &)=delete
Disallow default bitwise assignment.
wordList fieldSet_
Fields to write residuals.
Definition: residuals.H:89
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual wordList fields() const
Return the list of fields required.
Definition: residuals.H:136
Writes out the initial residual for specified fields.
Definition: residuals.H:79
A class for handling words, derived from string.
Definition: word.H:59
virtual ~residuals()
Destructor.
Definition: residuals.C:66
residuals(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: residuals.C:50
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Namespace for OpenFOAM.
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:57