derivedFields.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) 2019-2020 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::derivedFields
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Computes two predefined derived fields, i.e. \c rhoU, and \c pTotal, where
34 the defined fields are hard-coded as follows:
35
36 \vartable
37 rhoU | \f$ \rho \vec U \f$
38 pTotal | \f$ p + 1/2 \rho \, mag(\vec U)^2 \f$
39 \endvartable
40
41 Operands:
42 \table
43 Operand | Type | Location
44 input | vol{Scalar,Vector}Field | $FOAM_CASE/<time>/<inpField>
45 output file | - | -
46 output field | vol{Scalar,Vector}Field | $FOAM_CASE/<time>/<outField>
47 \endtable
48
49Usage
50 Minimal example by using \c system/controlDict.functions:
51 \verbatim
52 derivedFields1
53 {
54 // Mandatory entries (unmodifiable)
55 type derivedFields;
56 libs (fieldFunctionObjects);
57
58 // Mandatory entries (runtime modifiable)
59 derived (rhoU pTotal);
60
61 // Optional entries (runtime modifiable)
62 rhoRef 1.0;
63
64 // Optional (inherited) entries
65 ...
66 }
67 \endverbatim
68
69 where the entries mean:
70 \table
71 Property | Description | Type | Req'd | Dflt
72 type | Type name: derivedFields | word | yes | -
73 libs | Library name: fieldFunctionObjects | word | yes | -
74 derived | Names of operand fields (rhoU/pTotal) | word | yes | -
75 rhoRef | Reference density for incompressible flows | scalar | no | 1.0
76 \endtable
77
78 The inherited entries are elaborated in:
79 - \link functionObject.H \endlink
80
81 Usage by the \c postProcess utility is not available.
82
83See also
84 - Foam::functionObject
85 - Foam::functionObjects::fvMeshFunctionObject
86 - ExtendedCodeGuide::functionObjects::field::derivedFields
87
88SourceFiles
89 derivedFields.C
90
91\*---------------------------------------------------------------------------*/
92
93#ifndef functionObjects_derivedFields_H
94#define functionObjects_derivedFields_H
95
97#include "Enum.H"
98
99// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100
101namespace Foam
102{
103namespace functionObjects
104{
105
106/*---------------------------------------------------------------------------*\
107 Class derivedFields Declaration
108\*---------------------------------------------------------------------------*/
109
110class derivedFields
111:
112 public fvMeshFunctionObject
113{
114public:
115
116 // Public Enumerations
117
118 //- Options for the derived/calculated field type
119 enum derivedType
120 {
121 NONE = 0,
122 MASS_FLUX,
124 UNKNOWN
125 };
126
127 //- Names for derivedType
128 static const Enum<derivedType> knownNames;
129
130
131protected:
132
133 // Read from dictionary
134
135 //- List of derived field (types) to create
136 List<derivedType> derivedTypes_;
137
138 //- Reference density (to convert from kinematic to static pressure)
139 scalar rhoRef_;
140
141
142 // Protected Member Functions
143
144 //- Hard-coded derived field (rho * U)
145 // \return true if field did not previously exist
146 bool add_rhoU(const word& derivedName);
147
148 //- Hard-coded derived field (p + 1/2 * rho * U)
149 // \return true if field did not previously exist
150 bool add_pTotal(const word& derivedName);
151
152
153public:
154
155 //- Run-time type information
156 TypeName("derivedFields");
157
158
159 // Constructors
160
161 //- Construct from Time and dictionary
164 const word& name,
165 const Time& runTime,
166 const dictionary& dict
167 );
168
169 //- No copy construct
170 derivedFields(const derivedFields&) = delete;
171
172 //- No copy assignment
173 void operator=(const derivedFields&) = delete;
176 //- Destructor
177 virtual ~derivedFields() = default;
179
180 // Member Functions
182 //- Remove (checkOut) derived fields from the object registry
183 void removeDerivedFields();
184
185 //- Read the data
186 virtual bool read(const dictionary& dict);
187
188 //- Calculate the derived fields
189 virtual bool execute();
190
191 //- Write derived fields
192 virtual bool write();
193
194 //- Update for changes of mesh
195 virtual void updateMesh(const mapPolyMesh& mpm);
196
197 //- Update for mesh point-motion
198 virtual void movePoints(const polyMesh& m);
200
201
202// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204} // End namespace functionObjects
205} // End namespace Foam
206
207// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208
209#endif
210
211// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Computes two predefined derived fields, i.e. rhoU, and pTotal, where the defined fields are hard-code...
scalar rhoRef_
Reference density (to convert from kinematic to static pressure)
derivedType
Options for the derived/calculated field type.
virtual void movePoints(const polyMesh &m)
Update for mesh point-motion.
void operator=(const derivedFields &)=delete
No copy assignment.
virtual bool read(const dictionary &dict)
Read the data.
bool add_rhoU(const word &derivedName)
Hard-coded derived field (rho * U)
static const Enum< derivedType > knownNames
Names for derivedType.
derivedFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
bool add_pTotal(const word &derivedName)
Hard-coded derived field (p + 1/2 * rho * U)
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
void removeDerivedFields()
Remove (checkOut) derived fields from the object registry.
TypeName("derivedFields")
Run-time type information.
List< derivedType > derivedTypes_
List of derived field (types) to create.
virtual bool execute()
Calculate the derived fields.
virtual bool write()
Write derived fields.
derivedFields(const derivedFields &)=delete
No copy construct.
virtual ~derivedFields()=default
Destructor.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73