calcFvcGrad.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) 2012-2014 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::calcFvcGrad
26 
27 Group
28  grpFVFunctionObjects
29 
30 Description
31  This function object calculates the gradient of a field. The operation
32  is limited to scalar and vector volume or surface fields, and the output
33  is a volume vector or tensor field.
34 
35  Example of function object specification:
36  \verbatim
37  calcFvcGrad1
38  {
39  type calcFvcGrad;
40  functionObjectLibs ("libFVFunctionObjects.so");
41  ...
42  fieldName U;
43  }
44  \endverbatim
45 
46  \heading Function object usage
47  \table
48  Property | Description | Required | Default value
49  type | type name: calcFvcGrad | yes |
50  fieldName | Name of field to process | yes |
51  resultName | Name of gradient field | no | fvc::grad(fieldName)
52  log | Log to standard output | no | yes
53  \endtable
54 
55 SourceFiles
56  calcFvcGrad.C
57  IOcalcFvcGrad.H
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef calcFvcGrad_H
62 #define calcFvcGrad_H
63 
64 #include "volFieldsFwd.H"
65 #include "surfaceFieldsFwd.H"
66 #include "pointFieldFwd.H"
67 #include "OFstream.H"
68 #include "Switch.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 
75 // Forward declaration of classes
76 class objectRegistry;
77 class dictionary;
78 class polyMesh;
79 class mapPolyMesh;
80 class dimensionSet;
81 
82 /*---------------------------------------------------------------------------*\
83  Class calcFvcGrad Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 class calcFvcGrad
87 {
88  // Private data
89 
90  //- Name of this calcFvcGrad object
91  word name_;
92 
93  //- Reference to the database
94  const objectRegistry& obr_;
95 
96  //- On/off switch
97  bool active_;
98 
99  //- Name of field to process
100  word fieldName_;
101 
102  //- Name of result field
103  word resultName_;
104 
105  //- Switch to send output to Info as well as to file
106  Switch log_;
107 
108 
109  // Private Member Functions
110 
111  //- Helper function to create/store/return the gradient field
112  template<class Type>
114  <
116  fvPatchField,
117  volMesh
118  >&
119  gradField(const word& gradName, const dimensionSet& dims);
120 
121  //- Helper function to calculate the gradient of different field types
122  template<class Type>
123  void calcGrad
124  (
125  const word& fieldName,
126  const word& resultName,
127  bool& processed
128  );
129 
130  //- Disallow default bitwise copy construct
131  calcFvcGrad(const calcFvcGrad&);
132 
133  //- Disallow default bitwise assignment
134  void operator=(const calcFvcGrad&);
135 
136 
137 public:
138 
139  //- Runtime type information
140  TypeName("calcFvcGrad");
141 
142 
143  // Constructors
144 
145  //- Construct for given objectRegistry and dictionary.
146  // Allow the possibility to load fields from files
148  (
149  const word& name,
150  const objectRegistry&,
151  const dictionary&,
152  const bool loadFromFiles = false
153  );
154 
155 
156  //- Destructor
157  virtual ~calcFvcGrad();
158 
159 
160  // Member Functions
161 
162  //- Return name of the set of calcFvcGrad
163  virtual const word& name() const
164  {
165  return name_;
166  }
167 
168  //- Read the calcFvcGrad data
169  virtual void read(const dictionary&);
170 
171  //- Execute, currently does nothing
172  virtual void execute();
173 
174  //- Execute at the final time-loop, currently does nothing
175  virtual void end();
176 
177  //- Called when time was set at the end of the Time::operator++
178  virtual void timeSet();
179 
180  //- Calculate the calcFvcGrad and write
181  virtual void write();
182 
183  //- Update for changes of mesh
184  virtual void updateMesh(const mapPolyMesh&)
185  {}
186 
187  //- Update for changes of mesh
188  virtual void movePoints(const polyMesh&)
189  {}
190 };
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #ifdef NoRepository
200  #include "calcFvcGradTemplates.C"
201 #endif
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
volFieldsFwd.H
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::calcFvcGrad::calcFvcGrad
calcFvcGrad(const calcFvcGrad &)
Disallow default bitwise copy construct.
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::calcFvcGrad::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: calcFvcGrad.C:112
Foam::calcFvcGrad::calcGrad
void calcGrad(const word &fieldName, const word &resultName, bool &processed)
Helper function to calculate the gradient of different field types.
Definition: calcFvcGradTemplates.C:82
Foam::calcFvcGrad::~calcFvcGrad
virtual ~calcFvcGrad()
Destructor.
Definition: calcFvcGrad.C:71
Foam::volMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:47
Foam::calcFvcGrad::operator=
void operator=(const calcFvcGrad &)
Disallow default bitwise assignment.
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, int(pTraits< arg1 >::rank)+int(pTraits< arg2 >::rank) >::type type
Definition: products.H:72
Foam::calcFvcGrad::read
virtual void read(const dictionary &)
Read the calcFvcGrad data.
Definition: calcFvcGrad.C:77
Foam::calcFvcGrad::name
virtual const word & name() const
Return name of the set of calcFvcGrad.
Definition: calcFvcGrad.H:187
Foam::dimensionSet
Dimension set for the base types.
Definition: dimensionSet.H:116
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
OFstream.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::calcFvcGrad::write
virtual void write()
Calculate the calcFvcGrad and write.
Definition: calcFvcGrad.C:124
Foam::calcFvcGrad::active_
bool active_
On/off switch.
Definition: calcFvcGrad.H:121
pointFieldFwd.H
Foam::calcFvcGrad::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: calcFvcGrad.H:212
Foam::calcFvcGrad::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: calcFvcGrad.C:118
Switch.H
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::calcFvcGrad::obr_
const objectRegistry & obr_
Reference to the database.
Definition: calcFvcGrad.H:118
Foam::calcFvcGrad::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: calcFvcGrad.H:208
Foam::calcFvcGrad
This function object calculates the gradient of a field. The operation is limited to scalar and vecto...
Definition: calcFvcGrad.H:110
Foam::calcFvcGrad::fieldName_
word fieldName_
Name of field to process.
Definition: calcFvcGrad.H:124
Foam::calcFvcGrad::resultName_
word resultName_
Name of result field.
Definition: calcFvcGrad.H:127
Foam::calcFvcGrad::TypeName
TypeName("calcFvcGrad")
Runtime type information.
surfaceFieldsFwd.H
Foam::calcFvcGrad::execute
virtual void execute()
Execute, currently does nothing.
Definition: calcFvcGrad.C:94
calcFvcGradTemplates.C
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::calcFvcGrad::gradField
GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > & gradField(const word &gradName, const dimensionSet &dims)
Helper function to create/store/return the gradient field.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::calcFvcGrad::name_
word name_
Name of this calcFvcGrad object.
Definition: calcFvcGrad.H:115
Foam::calcFvcGrad::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: calcFvcGrad.H:130