Loading...
Searching...
No Matches
momentum.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2018-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::functionObjects::momentum
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Computes linear/angular momentum, reporting integral values and optionally
34 writing the fields.
35
36 Operands:
37 \table
38 Operand | Type | Location
39 input | - | -
40 output file | dat | postProcessing/<FO>/<time>/file
41 output field | - | -
42 \endtable
43
44Usage
45 Minimal example by using \c system/controlDict.functions:
46 \verbatim
47 momentumFO
48 {
49 // Mandatory entries
50 type momentum;
51 libs (fieldFunctionObjects);
52
53 // Optional entries
54 regionType <word>;;
55 writeMomentum <bool>;
56 writePosition <bool>;
57 writeVelocity <bool>;
58 p <word>;
59 U <word>;
60 rho <word>;
61 rhoRef <scalar>;
62 cylindrical <bool>;
63
64 // Conditional entries
65
66 // when 'cylindrical' is 'true'
67 origin (0 0 0);
68 e1 (1 0 0);
69 e3 (0 0 1);
70
71 // Inherited entries
72 ...
73 }
74 \endverbatim
75
76 where the entries mean:
77 \table
78 Property | Description | Type | Reqd | Deflt
79 type | Type name: momentum | word | yes | -
80 libs | Library name: fieldFunctionObjects | word | yes | -
81 regionType | Selection type: all/cellSet/cellZone | word | no | all
82 writeMomentum | Write (linear, angular) momentum fields | bool | no | no
83 writePosition | Write angular position component fields | bool | no | no
84 writeVelocity | Write angular velocity fields | bool | no | no
85 p | Pressure field name | word | no | p
86 U | Velocity field name | word | no | U
87 rho | Density field name | word | no | rho
88 rhoRef | Reference density (incompressible) | scalar | no | 1.0
89 cylindrical | Use cylindrical coordinates | bool | no | no
90 origin | Origin for cylindrical coordinates | vector | conditional | -
91 name | Name of cellSet/cellZone if required | word | conditional | -
92 \endtable
93
94 The inherited entries are elaborated in:
95 - \link functionObject.H \endlink
96 - \link writeFile.H \endlink
97
98Note
99 - For incompressible cases, the value of \c rhoRef is used.
100 - When specifying the cylindrical coordinate system, the rotation
101 can be specified directly with e1/e2/e3 axes, or via a \c rotation
102 sub-dictionary
103 For example,
104 \verbatim
105 origin (0 0 0);
106 rotation
107 {
108 type cylindrical;
109 axis (0 0 1);
110 }
111 \endverbatim
112
113SourceFiles
114 momentum.C
115
116\*---------------------------------------------------------------------------*/
117
118#ifndef Foam_functionObjects_momentum_H
119#define Foam_functionObjects_momentum_H
120
121#include "fvMeshFunctionObject.H"
122#include "writeFile.H"
123#include "cylindricalCS.H"
124#include "volFieldsFwd.H"
125#include "volRegion.H"
126
127// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128
129namespace Foam
130{
131
132// Forward Declarations
133class dimensionSet;
134
135namespace functionObjects
136{
137
138/*---------------------------------------------------------------------------*\
139 Class momentum Declaration
140\*---------------------------------------------------------------------------*/
141
142class momentum
143:
145 public volRegion,
146 public writeFile
147{
148 // Private Member Functions
149
150 //- Remove calculated fields from the registry
151 void purgeFields();
152
153 //- Calculate the fields and integral values
154 void calc();
155
156 //- Allocate a new zero geometric field
157 template<class GeoField>
158 autoPtr<GeoField> newField
159 (
160 const word& baseName,
161 const dimensionSet& dims,
162 bool registerObject=true
163 ) const;
164
165
166protected:
167
168 // Protected Data
169
170 //- Integral (linear) momentum
172
173 //- Integral angular momentum
175
176
177 // Read from dictionary
178
179 //- The velocity field name (optional)
180 word UName_;
181
182 //- The pressure field name (optional)
183 // Only used to determine incompressible/compressible
184 word pName_;
185
186 //- The density field name (optional)
187 word rhoName_;
188
189 //- Reference density (for incompressible)
190 scalar rhoRef_;
191
192 //- Coordinate system for evaluating angular momentum
193 coordSystem::cylindrical csys_;
194
195 //- Are we using the cylindrical coordinate system?
196 bool hasCsys_;
197
198 //- Write fields flag
199 bool writeMomentum_;
200
201 //- Write fields flag
202 bool writeVelocity_;
203
204 //- Write fields flag
205 bool writePosition_;
206
207 //- Initialised flag
208 bool initialised_;
209
210
211 // Protected Member Functions
212
213 //- Initialise the fields
214 void initialise();
215
216 //- Output file header information
217 virtual void writeFileHeader(Ostream& os);
218
219 //- Write momentum data
220 void writeValues(Ostream& os);
221
222
223public:
224
225 //- Runtime type information
226 TypeName("momentum");
227
228
229 // Constructors
230
231 //- Construct from name, Time and dictionary
233 (
234 const word& name,
235 const Time& runTime,
236 const dictionary& dict,
237 const bool readFields = true
238 );
239
240 //- Construct from objectRegistry and dictionary
242 (
243 const word& name,
244 const objectRegistry& obr,
245 const dictionary& dict,
246 const bool readFields = true
247 );
248
249 //- No copy construct
250 momentum(const momentum&) = delete;
251
252 //- No copy assignment
253 void operator=(const momentum&) = delete;
254
255
256 //- Destructor
257 virtual ~momentum() = default;
258
259
260 // Member Functions
261
262 //- Read the function-object dictionary
263 virtual bool read(const dictionary& dict);
264
265 //- Execute the function-object operations
266 virtual bool execute();
267
268 //- Write the function-object results
269 virtual bool write();
270
271 //- Update for changes of mesh
272 virtual void updateMesh(const mapPolyMesh&);
273
274 //- Update for mesh point-motion
275 virtual void movePoints(const polyMesh&);
276};
277
278
279// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280
281} // End namespace functionObjects
282} // End namespace Foam
283
284// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285
286#endif
288// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A cylindrical coordinate system (r-theta-z). The coordinate system angle theta is always in radians.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Computes linear/angular momentum, reporting integral values and optionally writing the fields.
Definition momentum.H:242
word pName_
The pressure field name (optional).
Definition momentum.H:294
scalar rhoRef_
Reference density (for incompressible).
Definition momentum.H:304
void initialise()
Initialise the fields.
Definition momentum.C:266
void operator=(const momentum &)=delete
No copy assignment.
word UName_
The velocity field name (optional).
Definition momentum.H:287
bool hasCsys_
Are we using the cylindrical coordinate system?
Definition momentum.H:314
momentum(const momentum &)=delete
No copy construct.
bool writePosition_
Write fields flag.
Definition momentum.H:329
bool writeMomentum_
Write fields flag.
Definition momentum.H:319
bool initialised_
Initialised flag.
Definition momentum.H:334
void writeValues(Ostream &os)
Write momentum data.
Definition momentum.C:299
momentum(const word &name, const Time &runTime, const dictionary &dict, const bool readFields=true)
Construct from name, Time and dictionary.
Definition momentum.C:343
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition momentum.C:408
vector sumMomentum_
Integral (linear) momentum.
Definition momentum.H:274
virtual ~momentum()=default
Destructor.
TypeName("momentum")
Runtime type information.
word rhoName_
The density field name (optional).
Definition momentum.H:299
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition momentum.C:593
vector sumAngularMom_
Integral angular momentum.
Definition momentum.H:279
virtual void writeFileHeader(Ostream &os)
Output file header information.
Definition momentum.C:222
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition momentum.C:586
virtual bool execute()
Execute the function-object operations.
Definition momentum.C:478
virtual bool write()
Write the function-object results.
Definition momentum.C:504
coordSystem::cylindrical csys_
Coordinate system for evaluating angular momentum.
Definition momentum.H:309
bool writeVelocity_
Write fields flag.
Definition momentum.H:324
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition readFields.H:146
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Volume (cell) region selection class.
Definition volRegion.H:112
volRegion(const fvMesh &mesh, const dictionary &dict)
Construct from fvMesh and dictionary.
Definition volRegion.C:143
Base class for writing single files from the function objects.
Definition writeFile.H:113
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
Definition writeFile.C:200
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
OBJstream os(runTime.globalPath()/outputName)
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
Vector< scalar > vector
Definition vector.H:57
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68
Forwards and collection of common volume field types.