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 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  A limited set of predefined derived fields ("rhoU", "pTotal").
34 
35  \verbatim
36  derived
37  {
38  type derivedFields;
39  libs ("libfieldFunctionObjects.so");
40 
41  fields (rhoU pTotal);
42 
43  // Optional: reference density for incompressible
44  rhoRef 1.25;
45  }
46  \endverbatim
47 
48  Entries:
49  \table
50  Property | Description | Required | Default
51  type | derivedFields | yes |
52  derived | Derived fields (pTotal/rhoU) | yes |
53  rhoRef | Reference density (incompressible) | no | 1
54  \endtable
55 
56  The known derived fields
57  \plaintable
58  rhoU | (rho * U)
59  pTotal | (p + 1/2 * rho * U)
60  \endplaintable
61 
62 SourceFiles
63  derivedFields.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef functionObjects_derivedFields_H
68 #define functionObjects_derivedFields_H
69 
70 #include "fvMeshFunctionObject.H"
71 #include "Enum.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 namespace functionObjects
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class derivedFields Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class derivedFields
85 :
86  public fvMeshFunctionObject
87 {
88 public:
89 
90  // Public Enumerations
91 
92  //- Derived/calculated field type
93  enum derivedType
94  {
95  NONE = 0,
96  MASS_FLUX,
98  UNKNOWN
99  };
100 
101  //- Known derived field types
102  static const Enum<derivedType> knownNames;
103 
104 
105 protected:
106 
107  // Read from dictionary
108 
109  //- List of derived field (types) to create
110  List<derivedType> derivedTypes_;
111 
112  //- Reference density (to convert from kinematic to static pressure)
113  scalar rhoRef_;
114 
115 
116  // Private Member Functions
117 
118  //- Hard-coded derived field (rho * U)
119  // \return true if field did not previously exist
120  bool add_rhoU(const word& derivedName);
121 
122  //- Hard-coded derived field (p + 1/2 * rho * U)
123  // \return true if field did not previously exist
124  bool add_pTotal(const word& derivedName);
125 
126 
127 public:
128 
129  //- Run-time type information
130  TypeName("derivedFields");
131 
132 
133  // Constructors
134 
135  //- Construct from Time and dictionary
137  (
138  const word& name,
139  const Time& runTime,
141  );
142 
143 
144  //- Destructor
145  virtual ~derivedFields() = default;
146 
147 
148  // Member Functions
149 
150  //- Remove (checkOut) derived fields from the object registry
151  void removeDerivedFields();
152 
153  //- Read the data
154  virtual bool read(const dictionary& dict);
155 
156  //- Calculate the derived fields
157  virtual bool execute();
158 
159  //- Write derived fields
160  virtual bool write();
161 
162  //- Update for changes of mesh
163  virtual void updateMesh(const mapPolyMesh& mpm);
164 
165  //- Update for mesh point-motion
166  virtual void movePoints(const polyMesh& m);
167 };
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace functionObjects
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
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:62
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:123
Foam::functionObjects::derivedFields::TOTAL_PRESSURE
"pTotal"
Definition: derivedFields.H:124
Foam::functionObjects::derivedFields::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: derivedFields.C:334
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:255
Foam::functionObjects::derivedFields::knownNames
static const Enum< derivedType > knownNames
Known derived field types.
Definition: derivedFields.H:129
Foam::functionObjects::derivedFields::NONE
"none"
Definition: derivedFields.H:122
Foam::functionObjects::derivedFields::write
virtual bool write()
Write derived fields.
Definition: derivedFields.C:294
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:121
Foam::functionObjects::derivedFields
A limited set of predefined derived fields ("rhoU", "pTotal").
Definition: derivedFields.H:111
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::derivedFields::read
virtual bool read(const dictionary &dict)
Read the data.
Definition: derivedFields.C:198
Foam::functionObjects::derivedFields::removeDerivedFields
void removeDerivedFields()
Remove (checkOut) derived fields from the object registry.
Definition: derivedFields.C:325
Foam::functionObjects::derivedFields::derivedFields
derivedFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: derivedFields.C:182
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::functionObjects::derivedFields::derivedType
derivedType
Derived/calculated field type.
Definition: derivedFields.H:120
Foam::List< derivedType >
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:160
Foam::functionObjects::derivedFields::UNKNOWN
Definition: derivedFields.H:125
Foam::functionObjects::derivedFields::movePoints
virtual void movePoints(const polyMesh &m)
Update for mesh point-motion.
Definition: derivedFields.C:343
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:137
Foam::functionObjects::derivedFields::rhoRef_
scalar rhoRef_
Reference density (to convert from kinematic to static pressure)
Definition: derivedFields.H:140
Enum.H