calcFvcDiv.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::calcFvcDiv
26 
27 Group
28  grpFVFunctionObjects
29 
30 Description
31  This function object calculates the divergence of a field. The operation
32  is limited to surfaceScalarFields and volumeVector fields, and the output
33  is a volume scalar field.
34 
35  Example of function object specification:
36  \verbatim
37  calcFvcDiv1
38  {
39  type calcFvcDiv;
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: calcFvcDiv | yes |
50  fieldName | Name of field to process | yes |
51  resultName | Name of divergence field | no | fvc::div(fieldName)
52  log | Log to standard output | no | yes
53  \endtable
54 
55 SourceFiles
56  calcFvcDiv.C
57  IOcalcFvcDiv.H
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef calcFvcDiv_H
62 #define calcFvcDiv_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 calcFvcDiv Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 class calcFvcDiv
87 {
88  // Private data
89 
90  //- Name of this calcFvcDiv 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 divergence field
113  (
114  const word& gradName,
115  const dimensionSet& dims
116  );
117 
118  //- Helper function to calculate the divergence of different field types
119  template<class FieldType>
120  void calcDiv
121  (
122  const word& fieldName,
123  const word& resultName,
124  bool& processed
125  );
126 
127  //- Disallow default bitwise copy construct
128  calcFvcDiv(const calcFvcDiv&);
129 
130  //- Disallow default bitwise assignment
131  void operator=(const calcFvcDiv&);
132 
133 
134 public:
135 
136  //- Runtime type information
137  TypeName("calcFvcDiv");
138 
139 
140  // Constructors
141 
142  //- Construct for given objectRegistry and dictionary.
143  // Allow the possibility to load fields from files
144  calcFvcDiv
145  (
146  const word& name,
147  const objectRegistry&,
148  const dictionary&,
149  const bool loadFromFiles = false
150  );
151 
152 
153  //- Destructor
154  virtual ~calcFvcDiv();
155 
156 
157  // Member Functions
158 
159  //- Return name of the set of calcFvcDiv
160  virtual const word& name() const
161  {
162  return name_;
163  }
164 
165  //- Read the calcFvcDiv data
166  virtual void read(const dictionary&);
167 
168  //- Execute, currently does nothing
169  virtual void execute();
170 
171  //- Execute at the final time-loop, currently does nothing
172  virtual void end();
173 
174  //- Called when time was set at the end of the Time::operator++
175  virtual void timeSet();
176 
177  //- Calculate the calcFvcDiv and write
178  virtual void write();
179 
180  //- Update for changes of mesh
181  virtual void updateMesh(const mapPolyMesh&)
182  {}
183 
184  //- Update for changes of mesh
185  virtual void movePoints(const polyMesh&)
186  {}
187 };
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #ifdef NoRepository
197  #include "calcFvcDivTemplates.C"
198 #endif
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
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::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::calcFvcDiv::resultName_
word resultName_
Name of result field.
Definition: calcFvcDiv.H:127
Foam::calcFvcDiv::obr_
const objectRegistry & obr_
Reference to the database.
Definition: calcFvcDiv.H:118
Foam::calcFvcDiv::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: calcFvcDiv.H:209
Foam::dimensionSet
Dimension set for the base types.
Definition: dimensionSet.H:116
Foam::calcFvcDiv::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: calcFvcDiv.C:150
Foam::calcFvcDiv
This function object calculates the divergence of a field. The operation is limited to surfaceScalarF...
Definition: calcFvcDiv.H:110
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::calcFvcDiv::calcDiv
void calcDiv(const word &fieldName, const word &resultName, bool &processed)
Helper function to calculate the divergence of different field types.
Definition: calcFvcDivTemplates.C:33
OFstream.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::calcFvcDiv::active_
bool active_
On/off switch.
Definition: calcFvcDiv.H:121
Foam::calcFvcDiv::calcFvcDiv
calcFvcDiv(const calcFvcDiv &)
Disallow default bitwise copy construct.
pointFieldFwd.H
Foam::calcFvcDiv::write
virtual void write()
Calculate the calcFvcDiv and write.
Definition: calcFvcDiv.C:162
Switch.H
Foam::calcFvcDiv::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: calcFvcDiv.C:156
Foam::calcFvcDiv::divField
volScalarField & divField(const word &gradName, const dimensionSet &dims)
Helper function to create/store/return the divergence field.
Definition: calcFvcDiv.C:42
calcFvcDivTemplates.C
Foam::calcFvcDiv::TypeName
TypeName("calcFvcDiv")
Runtime type information.
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::calcFvcDiv::name_
word name_
Name of this calcFvcDiv object.
Definition: calcFvcDiv.H:115
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::calcFvcDiv::fieldName_
word fieldName_
Name of field to process.
Definition: calcFvcDiv.H:124
Foam::calcFvcDiv::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: calcFvcDiv.H:205
Foam::calcFvcDiv::operator=
void operator=(const calcFvcDiv &)
Disallow default bitwise assignment.
surfaceFieldsFwd.H
Foam::calcFvcDiv::execute
virtual void execute()
Execute, currently does nothing.
Definition: calcFvcDiv.C:132
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::calcFvcDiv::~calcFvcDiv
virtual ~calcFvcDiv()
Destructor.
Definition: calcFvcDiv.C:109
Foam::calcFvcDiv::name
virtual const word & name() const
Return name of the set of calcFvcDiv.
Definition: calcFvcDiv.H:184
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::calcFvcDiv::read
virtual void read(const dictionary &)
Read the calcFvcDiv data.
Definition: calcFvcDiv.C:115
Foam::calcFvcDiv::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: calcFvcDiv.H:130