hydrostaticPressure.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-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::hydrostaticPressure
28 
29 Group
30  grpInitialisationFunctionObjects
31 
32 Description
33  Calculates and outputs the pressure fields p_rgh and ph_rgh
34 
35 Usage
36  Example of function object specification to calculate hydrostatic pressure:
37  \verbatim
38  hydrostaticPressure1
39  {
40  type hydrostaticPressure;
41  libs (initialisationFunctionObjects);
42  ...
43  }
44  \endverbatim
45 
46  Where the entries comprise:
47  \table
48  Property | Description | Required | Default value
49  log | Log to standard output | no | yes
50  p_rgh | Name of p_rgh field | no | p_rgh
51  ph_rgh | Name of ph_rgh field | no | ph_rgh
52  pRef | Name of pressure ref field | no | pRef
53  pRefValue | Value of pressure ref | when pRef set to pInf | 0
54  rho | Name of density field | no | rho
55  U | Name of velocity field | no | U
56  gh | Name of gravity*height volume field | no | gh
57  ghf | Name of gravity*height surface field | no | ghf
58  nCorrectors | Number of correctors when solving ph_rgh | no | 5
59  \endtable
60 
61 Note
62  Calculates the hydrostatic pressure on construction/re-initialisation;
63  the execute and write functions are not used.
64 
65 SourceFiles
66  hydrostaticPressure.C
67 
68 \*---------------------------------------------------------------------------*/
69 
70 #ifndef functionObjects_hydrostaticPressure_H
71 #define functionObjects_hydrostaticPressure_H
72 
73 #include "fvMeshFunctionObject.H"
75 
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 
78 namespace Foam
79 {
80 
81 namespace functionObjects
82 {
83 
84 /*---------------------------------------------------------------------------*\
85  Class hydrostaticPressure Declaration
86 \*---------------------------------------------------------------------------*/
87 
88 class hydrostaticPressure
89 :
90  public fvMeshFunctionObject
91 {
92 protected:
93 
94  // Protected data
95 
96  //- Name of p - rho*g*h field, default is "p_rgh"
97  word p_rghName_;
98 
99  //- Name of p_hydrostatic - rho*g*h field, default is "ph_rgh"
100  word ph_rghName_;
101 
102  //- Name of uniform pressure reference field, default is "pRef"
103  // Set to "none" to set to zero or pInf to set according to pRefValue
104  word pRefName_;
105 
106  //- Reference pressure if pRefName is set to "pInf"
107  scalar pRefValue_;
108 
109  //- Name of density field, default is "rho"
110  word rhoName_;
111 
112  //- Name of velocity field, default is "ph_rgh"
113  word UName_;
114 
115  //- Name of g*h volume field, default is "gh"
116  word ghName_;
117 
118  //- Name of g*h surface field, default is "ghf"
119  word ghfName_;
120 
121  //- Number of correctors when solving for ph_rgh
122  label nCorrectors_;
123 
124 
125  // Protected Member Functions
126 
127  //- Helper function to return the reference pressure
128  // Returns zero if pRefName = none; otherwise returns the value
129  // from the mesh database
130  dimensionedScalar pRef() const;
131 
132  //- Calculate the fields and write
133  void calculateAndWrite();
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("hydrostaticPressure");
140 
141 
142  // Constructors
143 
144  //- Construct from Time and dictionary
146  (
147  const word& name,
148  const Time& runTime,
149  const dictionary& dict
150  );
151 
152 
153  //- Destructor
154  virtual ~hydrostaticPressure() = default;
155 
156 
157  // Member Functions
158 
159  //- Read the hydrostaticPressure data
160  virtual bool read(const dictionary& dict);
161 
162  //- Calculate the p_rgh field
163  virtual bool execute();
164 
165  //- Write the p_rgh and derived fields
166  virtual bool write();
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::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjects::hydrostaticPressure::hydrostaticPressure
hydrostaticPressure(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: hydrostaticPressure.C:165
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fvMeshFunctionObject.H
Foam::functionObjects::hydrostaticPressure::UName_
word UName_
Name of velocity field, default is "ph_rgh".
Definition: hydrostaticPressure.H:167
Foam::functionObjects::hydrostaticPressure::calculateAndWrite
void calculateAndWrite()
Calculate the fields and write.
Definition: hydrostaticPressure.C:76
Foam::functionObjects::hydrostaticPressure::TypeName
TypeName("hydrostaticPressure")
Runtime type information.
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::hydrostaticPressure::read
virtual bool read(const dictionary &dict)
Read the hydrostaticPressure data.
Definition: hydrostaticPressure.C:213
Foam::functionObjects::hydrostaticPressure::pRef
dimensionedScalar pRef() const
Helper function to return the reference pressure.
Definition: hydrostaticPressure.C:59
Foam::functionObjects::hydrostaticPressure::p_rghName_
word p_rghName_
Name of p - rho*g*h field, default is "p_rgh".
Definition: hydrostaticPressure.H:151
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::functionObjects::hydrostaticPressure::write
virtual bool write()
Write the p_rgh and derived fields.
Definition: hydrostaticPressure.C:245
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::dimensioned< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::hydrostaticPressure::ghName_
word ghName_
Name of g*h volume field, default is "gh".
Definition: hydrostaticPressure.H:170
Foam::functionObjects::hydrostaticPressure::pRefName_
word pRefName_
Name of uniform pressure reference field, default is "pRef".
Definition: hydrostaticPressure.H:158
uniformDimensionedFields.H
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::hydrostaticPressure::nCorrectors_
label nCorrectors_
Number of correctors when solving for ph_rgh.
Definition: hydrostaticPressure.H:176
Foam::functionObjects::hydrostaticPressure::pRefValue_
scalar pRefValue_
Reference pressure if pRefName is set to "pInf".
Definition: hydrostaticPressure.H:161
Foam::functionObjects::hydrostaticPressure::execute
virtual bool execute()
Calculate the p_rgh field.
Definition: hydrostaticPressure.C:239
Foam::functionObjects::hydrostaticPressure::rhoName_
word rhoName_
Name of density field, default is "rho".
Definition: hydrostaticPressure.H:164
Foam::functionObjects::hydrostaticPressure::ph_rghName_
word ph_rghName_
Name of p_hydrostatic - rho*g*h field, default is "ph_rgh".
Definition: hydrostaticPressure.H:154
Foam::functionObjects::hydrostaticPressure::ghfName_
word ghfName_
Name of g*h surface field, default is "ghf".
Definition: hydrostaticPressure.H:173
Foam::functionObjects::hydrostaticPressure
Calculates and outputs the pressure fields p_rgh and ph_rgh.
Definition: hydrostaticPressure.H:142
Foam::functionObjects::hydrostaticPressure::~hydrostaticPressure
virtual ~hydrostaticPressure()=default
Destructor.