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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::functionObjects::derivedFields
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
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 
49 Usage
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 
83 See also
84  - Foam::functionObject
85  - Foam::functionObjects::fvMeshFunctionObject
86  - ExtendedCodeGuide::functionObjects::field::derivedFields
87 
88 SourceFiles
89  derivedFields.C
90 
91 \*---------------------------------------------------------------------------*/
92 
93 #ifndef functionObjects_derivedFields_H
94 #define functionObjects_derivedFields_H
95 
96 #include "fvMeshFunctionObject.H"
97 #include "Enum.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 namespace functionObjects
104 {
105 
106 /*---------------------------------------------------------------------------*\
107  Class derivedFields Declaration
108 \*---------------------------------------------------------------------------*/
109 
110 class derivedFields
111 :
112  public fvMeshFunctionObject
113 {
114 public:
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 
131 protected:
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 
153 public:
154 
155  //- Run-time type information
156  TypeName("derivedFields");
157 
158 
159  // Constructors
160 
161  //- Construct from Time and dictionary
163  (
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;
174 
175 
176  //- Destructor
177  virtual ~derivedFields() = default;
178 
179 
180  // Member Functions
181 
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);
199 };
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace functionObjects
205 } // End namespace Foam
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #endif
210 
211 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Enum< derivedType >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::derivedFields::add_rhoU
bool add_rhoU(const word &derivedName)
Hard-coded derived field (rho * U)
fvMeshFunctionObject.H
Foam::functionObjects::derivedFields::TypeName
TypeName("derivedFields")
Run-time type information.
Foam::functionObjects::derivedFields::MASS_FLUX
"rhoU"
Definition: derivedFields.H:175
Foam::functionObjects::derivedFields::TOTAL_PRESSURE
"pTotal"
Definition: derivedFields.H:176
Foam::functionObjects::derivedFields::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: derivedFields.C:327
Foam::functionObjects::derivedFields::operator=
void operator=(const derivedFields &)=delete
No copy assignment.
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::functionObjects::derivedFields::~derivedFields
virtual ~derivedFields()=default
Destructor.
Foam::functionObjects::derivedFields::execute
virtual bool execute()
Calculate the derived fields.
Definition: derivedFields.C:248
Foam::functionObjects::derivedFields::knownNames
static const Enum< derivedType > knownNames
Names for derivedType.
Definition: derivedFields.H:181
Foam::functionObjects::derivedFields::NONE
"none"
Definition: derivedFields.H:174
Foam::functionObjects::derivedFields::write
virtual bool write()
Write derived fields.
Definition: derivedFields.C:287
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::derivedFields
Computes two predefined derived fields, i.e. rhoU, and pTotal, where the defined fields are hard-code...
Definition: derivedFields.H:163
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::derivedFields::read
virtual bool read(const dictionary &dict)
Read the data.
Definition: derivedFields.C:191
Foam::functionObjects::derivedFields::removeDerivedFields
void removeDerivedFields()
Remove (checkOut) derived fields from the object registry.
Definition: derivedFields.C:318
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::derivedFields::derivedFields
derivedFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: derivedFields.C:175
Foam::functionObjects::derivedFields::derivedType
derivedType
Options for the derived/calculated field type.
Definition: derivedFields.H:172
Foam::List< derivedType >
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::functionObjects::derivedFields::UNKNOWN
Definition: derivedFields.H:177
Foam::functionObjects::derivedFields::movePoints
virtual void movePoints(const polyMesh &m)
Update for mesh point-motion.
Definition: derivedFields.C:336
Foam::functionObjects::derivedFields::add_pTotal
bool add_pTotal(const word &derivedName)
Hard-coded derived field (p + 1/2 * rho * U)
Foam::functionObjects::derivedFields::derivedTypes_
List< derivedType > derivedTypes_
List of derived field (types) to create.
Definition: derivedFields.H:189
Foam::functionObjects::derivedFields::rhoRef_
scalar rhoRef_
Reference density (to convert from kinematic to static pressure)
Definition: derivedFields.H:192
Enum.H