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 | Copyright (C) 2015 OpenCFD Ltd.
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_;
100 
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 field header information
119  template<class Type>
120  void writeFileHeader(const word& fieldName);
121 
122  //- Output file header information
123  virtual void writeFileHeader(Ostream& os) const;
124 
125 
126 public:
127 
128  //- Runtime type information
129  TypeName("residuals");
130 
131 
132  // Constructors
133 
134  //- Construct for given objectRegistry and dictionary.
135  // Allow the possibility to load fields from files
136  residuals
137  (
138  const word& name,
139  const objectRegistry&,
140  const dictionary&,
141  const bool loadFromFiles = false
142  );
143 
144 
145  //- Destructor
146  virtual ~residuals();
147 
148 
149  // Member Functions
150 
151  //- Return name of the set of field min/max
152  virtual const word& name() const
153  {
154  return name_;
155  }
156 
157  //- Read the field residuals data
158  virtual void read(const dictionary&);
159 
160  //- Execute, currently does nothing
161  virtual void execute();
162 
163  //- Execute at the final time-loop, currently does nothing
164  virtual void end();
165 
166  //- Called when time was set at the end of the Time::operator++
167  virtual void timeSet();
168 
169  //- Calculate the field residuals
170  template<class Type>
171  void writeResidual(const word& fieldName);
172 
173  //- Write the residuals
174  virtual void write();
175 
176  //- Update for changes of mesh
177  virtual void updateMesh(const mapPolyMesh&)
178  {}
179 
180  //- Update for changes of mesh
181  virtual void movePoints(const polyMesh&)
182  {}
183 };
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace Foam
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #ifdef NoRepository
193 # include "residualsTemplates.C"
194 #endif
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 #endif
199 
200 // ************************************************************************* //
Foam::residuals::TypeName
TypeName("residuals")
Runtime type information.
volFieldsFwd.H
primitiveFieldsFwd.H
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::residuals::name_
word name_
Name of this set of residuals.
Definition: residuals.H:98
NamedEnum.H
Foam::residuals::residuals
residuals(const residuals &)
Disallow default bitwise copy construct.
Foam::residuals::writeFileHeader
void writeFileHeader(const word &fieldName)
Output field header information.
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::residuals::~residuals
virtual ~residuals()
Destructor.
Definition: residuals.C:90
OFstream.H
residualsTemplates.C
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::residuals::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: residuals.C:113
Foam::residuals::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: residuals.H:180
Foam::residuals::obr_
const objectRegistry & obr_
Definition: residuals.H:100
Foam::residuals
This function object writes out the initial residual for specified fields.
Definition: residuals.H:88
Foam::residuals::read
virtual void read(const dictionary &)
Read the field residuals data.
Definition: residuals.C:96
Foam::residuals::fieldSet_
wordList fieldSet_
Fields to write residuals.
Definition: residuals.H:106
Foam::residuals::execute
virtual void execute()
Execute, currently does nothing.
Definition: residuals.C:109
Foam::residuals::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: residuals.C:117
Switch.H
solverPerformance.H
HashSet.H
Foam::residuals::writeResidual
void writeResidual(const word &fieldName)
Calculate the field residuals.
Definition: residualsTemplates.C:33
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::residuals::name
virtual const word & name() const
Return name of the set of field min/max.
Definition: residuals.H:151
Foam::residuals::active_
bool active_
on/off switch
Definition: residuals.H:103
functionObjectFile.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
Foam::residuals::operator=
void operator=(const residuals &)
Disallow default bitwise assignment.
Foam::residuals::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: residuals.H:176
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::residuals::write
virtual void write()
Write the residuals.
Definition: residuals.C:121
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53