Loading...
Searching...
No Matches
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 | <time>/inputField
45 output file | - | -
46 output field | vol{Scalar,Vector}Field | <time>/outputField
47 \endtable
48
49Usage
50 Minimal example by using \c system/controlDict.functions:
51 \verbatim
52 derivedFieldsFO
53 {
54 // Mandatory entries
55 type derivedFields;
56 libs (fieldFunctionObjects);
57 derived (rhoU pTotal);
58
59 // Optional entries
60 rhoRef <scalar>;
61
62 // Inherited entries
63 ...
64 }
65 \endverbatim
66
67 where the entries mean:
68 \table
69 Property | Description | Type | Reqd | Deflt
70 type | Type name: derivedFields | word | yes | -
71 libs | Library name: fieldFunctionObjects | word | yes | -
72 derived | Names of operand fields (rhoU/pTotal) | word | yes | -
73 rhoRef | Reference density for incompressible flows | scalar | no | 1.0
74 \endtable
75
76 The inherited entries are elaborated in:
77 - \link functionObject.H \endlink
78
79SourceFiles
80 derivedFields.C
81
82\*---------------------------------------------------------------------------*/
83
84#ifndef Foam_functionObjects_derivedFields_H
85#define Foam_functionObjects_derivedFields_H
86
88#include "Enum.H"
89
90// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91
92namespace Foam
93{
94namespace functionObjects
95{
96
97/*---------------------------------------------------------------------------*\
98 Class derivedFields Declaration
99\*---------------------------------------------------------------------------*/
100
101class derivedFields
102:
104{
105public:
106
107 // Public Enumerations
108
109 //- Options for the derived/calculated field type
110 enum derivedType
111 {
112 NONE = 0,
113 MASS_FLUX,
115 UNKNOWN
116 };
117
118 //- Names for derivedType
119 static const Enum<derivedType> knownNames;
120
121
122protected:
123
124 // Read from dictionary
125
126 //- List of derived field (types) to create
127 List<derivedType> derivedTypes_;
128
129 //- Reference density (to convert from kinematic to static pressure)
130 scalar rhoRef_;
131
132
133 // Protected Member Functions
134
135 //- Hard-coded derived field (rho * U)
136 // \return true if field did not previously exist
137 bool add_rhoU(const word& derivedName);
138
139 //- Hard-coded derived field (p + 1/2 * rho * U)
140 // \return true if field did not previously exist
141 bool add_pTotal(const word& derivedName);
142
143
144public:
145
146 //- Run-time type information
147 TypeName("derivedFields");
148
149
150 // Constructors
151
152 //- Construct from name, Time and dictionary
154 (
155 const word& name,
156 const Time& runTime,
157 const dictionary& dict
158 );
159
160 //- No copy construct
161 derivedFields(const derivedFields&) = delete;
162
163 //- No copy assignment
164 void operator=(const derivedFields&) = delete;
167 //- Destructor
168 virtual ~derivedFields() = default;
169
170
171 // Member Functions
173 //- Remove (checkOut) derived fields from the object registry
174 void removeDerivedFields();
175
176 //- Read the function-object dictionary
177 virtual bool read(const dictionary& dict);
178
179 //- Execute the function-object operations
180 virtual bool execute();
181
182 //- Write the function-object results
183 virtual bool write();
184
185 //- Update for changes of mesh
186 virtual void updateMesh(const mapPolyMesh& mpm);
188 //- Update for mesh point-motion
189 virtual void movePoints(const polyMesh& m);
190};
191
192
193// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194
195} // End namespace functionObjects
196} // End namespace Foam
198// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199
200#endif
201
202// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
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 function-object dictionary.
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 name, 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()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
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...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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
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
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68