residuals.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 | Copyright (C) 2015 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::residuals
26 
27 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  This function object writes out the initial residual for specified fields.
32 
33  Example of function object specification:
34  \verbatim
35  residuals
36  {
37  type residuals;
38  outputControl timeStep;
39  outputInterval 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 SeeAlso
53  Foam::functionObject
54  Foam::OutputFilterFunctionObject
55 
56 SourceFiles
57  residuals.C
58  IOresiduals.H
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef residuals_H
63 #define residuals_H
64 
65 #include "functionObjectFile.H"
66 #include "primitiveFieldsFwd.H"
67 #include "volFieldsFwd.H"
68 #include "HashSet.H"
69 #include "OFstream.H"
70 #include "Switch.H"
71 #include "NamedEnum.H"
72 #include "solverPerformance.H"
73 
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 
76 namespace Foam
77 {
78 
79 // Forward declaration of classes
80 class objectRegistry;
81 class dictionary;
82 class polyMesh;
83 class mapPolyMesh;
84 
85 /*---------------------------------------------------------------------------*\
86  Class residuals Declaration
87 \*---------------------------------------------------------------------------*/
88 
89 class residuals
90 :
91  public functionObjectFile
92 {
93 protected:
94 
95  // Protected data
96 
97  //- Name of this set of residuals
98  // Also used as the name of the output directory
99  word name_;
101  const objectRegistry& obr_;
102 
103  //- on/off switch
104  bool active_;
105 
106  //- Fields to write residuals
108 
109 
110  // Private Member Functions
111 
112  //- Disallow default bitwise copy construct
113  residuals(const residuals&);
114 
115  //- Disallow default bitwise assignment
116  void operator=(const residuals&);
117 
118  //- Output file header information
119  virtual void writeFileHeader(const label i);
120 
121 
122 public:
123 
124  //- Runtime type information
125  TypeName("residuals");
126 
127 
128  // Constructors
129 
130  //- Construct for given objectRegistry and dictionary.
131  // Allow the possibility to load fields from files
132  residuals
133  (
134  const word& name,
135  const objectRegistry&,
136  const dictionary&,
137  const bool loadFromFiles = false
138  );
139 
140 
141  //- Destructor
142  virtual ~residuals();
143 
144 
145  // Member Functions
146 
147  //- Return name of the set of field min/max
148  virtual const word& name() const
149  {
150  return name_;
151  }
152 
153  //- Read the field min/max data
154  virtual void read(const dictionary&);
155 
156  //- Execute, currently does nothing
157  virtual void execute();
158 
159  //- Execute at the final time-loop, currently does nothing
160  virtual void end();
161 
162  //- Called when time was set at the end of the Time::operator++
163  virtual void timeSet();
164 
165  //- Calculate the field min/max
166  template<class Type>
167  void writeResidual(const word& fieldName);
168 
169  //- Write the residuals
170  virtual void write();
171 
172  //- Update for changes of mesh
173  virtual void updateMesh(const mapPolyMesh&)
174  {}
175 
176  //- Update for changes of mesh
177  virtual void movePoints(const polyMesh&)
178  {}
179 };
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace Foam
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #ifdef NoRepository
189 # include "residualsTemplates.C"
190 #endif
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #endif
195 
196 // ************************************************************************* //
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: residuals.H:172
This function object writes out the initial residual for specified fields.
Definition: residuals.H:88
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: residuals.C:121
virtual ~residuals()
Destructor.
Definition: residuals.C:77
A class for handling words, derived from string.
Definition: word.H:59
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
TypeName("residuals")
Runtime type information.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: residuals.H:176
virtual void writeFileHeader(const label i)
Output file header information.
Definition: residuals.C:92
wordList fieldSet_
Fields to write residuals.
Definition: residuals.H:106
residuals(const residuals &)
Disallow default bitwise copy construct.
bool active_
on/off switch
Definition: residuals.H:103
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual void execute()
Execute, currently does nothing.
Definition: residuals.C:109
virtual void write()
Write the residuals.
Definition: residuals.C:127
Registry of regIOobjects.
const objectRegistry & obr_
Definition: residuals.H:100
virtual const word & name() const
Return name of the set of field min/max.
Definition: residuals.H:147
Base class for output file data handling.
void writeResidual(const word &fieldName)
Calculate the field min/max.
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: residuals.C:115
virtual void read(const dictionary &)
Read the field min/max data.
Definition: residuals.C:83
word name_
Name of this set of residuals.
Definition: residuals.H:98
void operator=(const residuals &)
Disallow default bitwise assignment.