pressure.H 9.21 KB
 andy committed Sep 24, 2012 1 2 3 4 /*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration |  OpenFOAM bot committed Oct 31, 2019 5  \\ / A nd | www.openfoam.com  OpenFOAM bot committed Feb 06, 2019 6 7  \\/ M anipulation | -------------------------------------------------------------------------------  OpenFOAM bot committed Oct 31, 2019 8  Copyright (C) 2012-2016 OpenFOAM Foundation  9  Copyright (C) 2016-2020 OpenCFD Ltd.  andy committed Sep 24, 2012 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Class  28  Foam::functionObjects::pressure  andy committed Sep 24, 2012 29   andy committed Nov 21, 2012 30 Group  Henry Weller committed May 28, 2016 31  grpFieldFunctionObjects  andy committed Nov 21, 2012 32   andy committed Sep 24, 2012 33 Description  Henry Weller committed Jun 28, 2016 34  Includes tools to manipulate the pressure into different forms.  andy committed Sep 24, 2012 35   Henry Weller committed Jun 28, 2016 36  These currently include:  andy committed Sep 24, 2012 37  - static pressure  andy committed Nov 21, 2012 38  \f[  Andrew Heather committed Jun 19, 2019 39  p_s = p_{ref} + \rho p_k  andy committed Nov 21, 2012 40  \f]  andy committed Sep 24, 2012 41  - total pressure  andy committed Nov 21, 2012 42  \f[  43  p_0 = p_{ref} + p + 0.5 \rho |U|^2  andy committed Nov 21, 2012 44  \f]  sergio committed Apr 05, 2019 45 46  - isentropic pressure \f[  Andrew Heather committed Jun 19, 2019 47  p_i = p*(1 + ((gamma-1)*M^2)/2)^(gamma/(gamma - 1))  sergio committed Apr 05, 2019 48  \f]  andy committed Sep 24, 2012 49  - static pressure coefficient  andy committed Nov 21, 2012 50  \f[  Andrew Heather committed Jun 19, 2019 51  Cp = \frac{p_s - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}  andy committed Nov 21, 2012 52  \f]  andy committed Sep 24, 2012 53  - total pressure coefficient  andy committed Nov 21, 2012 54  \f[  55  Cp_0 = \frac{p_0 - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}  andy committed Nov 21, 2012 56  \f]  andy committed Sep 24, 2012 57   andy committed Nov 23, 2012 58 59  where \vartable  60 61 62 63 64 65  \rho | Density [kg/m3] U | Velocity [m/s] \rho_{\inf} | Freestream density [kg/m3] p_{\inf} | Freestream pressure [Pa] U_{\inf} | Freestream velocity [m/s] p_k | Kinematic pressure (p/rho)[m2/s2]  Andrew Heather committed Jun 19, 2019 66  p_s | Statoc pressure [Pa]  67 68  p_0 | Total pressure [Pa] p_{ref} | Reference pressure level [Pa]  Andrew Heather committed Jun 19, 2019 69  p_i | Total isentropic pressure  70 71  Cp | Pressure coefficient Cp_0 | Total pressure coefficient  andy committed Nov 23, 2012 72 73 74  \endvartable The function object will operate on both kinematic (\f$p_k \f$) and static  75  pressure (\f$p \f$) fields, and the result is written as a  andy committed Nov 23, 2012 76 77  volScalarField.  Andrew Heather committed Oct 20, 2016 78 Usage  andy committed Nov 21, 2012 79 80  Example of function object specification to calculate pressure coefficient: \verbatim  81  pressure1  andy committed Nov 21, 2012 82  {  83  type pressure;  Henry Weller committed Jun 28, 2016 84  libs ("libfieldFunctionObjects.so");  andy committed Nov 21, 2012 85  ...  Andrew Heather committed Jun 19, 2019 86  mode staticCoeff;  andy committed Nov 21, 2012 87 88 89  } \endverbatim  Andrew Heather committed Oct 20, 2016 90  Where the entries comprise:  andy committed Nov 21, 2012 91  \table  92  Property | Description | Required | Default value  Andrew Heather committed Jun 23, 2017 93  type | type name: pressure | yes |  94 95 96 97  field | Name of the pressure field | no | p U | Name of the velocity field | no | U rho | Name of the density field | no | rho result | Name of the resulting field | no | derived from p  Andrew Heather committed Jun 19, 2019 98  mode | Calculation mode (see below) | yes |  99  pRef | Reference pressure for total pressure | no | 0  andy committed Nov 23, 2012 100 101  pInf | Freestream pressure for coefficient calculation | no | UInf | Freestream velocity for coefficient calculation | no |  102  rhoInf | Freestream density for coefficient calculation | no |  103  hydrostaticMode | Hydrostatic contributions (see below) | no | none  104 105  g | Gravity vector (see below) | no | hRef | Reference height (see below) | no |  andy committed Nov 21, 2012 106 107  \endtable  Andrew Heather committed Jun 19, 2019 108 109 110 111 112 113 114 115  The \c mode entry is used to select the type of pressure that is calculated. Selections include: - static - total - isentropic - staticCoeff - totalCoeff  116 117 118 119 120 121  The optional \c hydrostaticMode entry provides handling for the term \f$\rho (\vec{g} \dot \vec{h})\f$ where options include - \c none : not included - \c add : add the term, e.g. to convert from p_rgh to p - \c subtract : subtract the term, e.g. to convert from p to p_rgh  122 123 124 125 126 127 128 129 130  If the \c hydrostaticMode is active, values are also required for gravity, \c g, and reference height, \c hRef. By default these will be retrieved from the database. When these values are not available the user must provide them, e.g. \verbatim g (0 -9.81 0); hRef 0; \endverbatim  131   Henry Weller committed Jun 17, 2016 132 See also  133  Foam::functionObjects::fieldExpression  134 135  Foam::functionObjects::fvMeshFunctionObject  andy committed Sep 24, 2012 136 SourceFiles  137  pressure.C  andy committed Sep 24, 2012 138 139 140  \*---------------------------------------------------------------------------*/  141 142 #ifndef functionObjects_pressure_H #define functionObjects_pressure_H  andy committed Sep 24, 2012 143   144 #include "fieldExpression.H"  andy committed Sep 24, 2012 145 #include "volFieldsFwd.H"  146 #include "dimensionedVector.H"  andy committed Sep 24, 2012 147 148 149 150 151 152 #include "dimensionedScalar.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam {  153 154 155 namespace functionObjects {  andy committed Sep 24, 2012 156 /*---------------------------------------------------------------------------*\  157  Class pressure Declaration  andy committed Sep 24, 2012 158 159 \*---------------------------------------------------------------------------*/  160 class pressure  Henry Weller committed May 15, 2016 161 :  162  public fieldExpression  andy committed Sep 24, 2012 163 {  Andrew Heather committed Jun 19, 2019 164 165 166 167 168 169 170 public: // Public Data Types //- Enumeration for pressure calculation mode enum mode : unsigned {  171 172 173 174  STATIC = (1 << 0), //!< Static pressure TOTAL = (1 << 1), //!< Total pressure ISENTROPIC = (1 << 2), //!< Isentropic pressure COEFF = (1 << 3), //!< Coefficient manipulator  Andrew Heather committed Jun 19, 2019 175  STATIC_COEFF = (STATIC | COEFF),  176  TOTAL_COEFF = (TOTAL | COEFF),  Andrew Heather committed Jun 19, 2019 177 178 179 180  }; static const Enum modeNames;  181 182 183 184 185 186 187 188 189 190  //- Enumeration for hydrostatic contributions enum hydrostaticMode : unsigned { NONE = 0, ADD, SUBTRACT }; static const Enum hydrostaticModeNames;  Andrew Heather committed Jun 19, 2019 191 192 193  private:  andy committed Sep 24, 2012 194 195  // Private data  Andrew Heather committed Jun 19, 2019 196 197 198  //- Calculation mode mode mode_;  199 200 201  //- Hydrostatic constribution mode hydrostaticMode hydrostaticMode_;  andy committed Sep 24, 2012 202 203 204  //- Name of velocity field, default is "U" word UName_;  andy committed Nov 22, 2012 205 206 207  //- Name of density field, default is "rho" word rhoName_;  andy committed Sep 24, 2012 208   andy committed Nov 23, 2012 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225  // Total pressure calculation //- Reference pressure level scalar pRef_; // Pressure coefficient calculation //- Freestream pressure scalar pInf_; //- Freestream velocity vector UInf_; //- Freestream density scalar rhoInf_;  Andrew Heather committed Sep 23, 2016 226 227 228  //- Flag to show whether rhoInf has been initialised bool rhoInfInitialised_;  andy committed Nov 23, 2012 229   230 231 232 233 234 235 236 237 238 239 240 241 242 243 244  //- p +/- rgh calculation //- Gravity vector mutable dimensionedVector g_; //- Flag to show whether g has been initialised bool gInitialised_; //- Reference height mutable dimensionedScalar hRef_; //- Flag to show whether hRef has been initialised bool hRefInitialised_;  andy committed Sep 24, 2012 245 246 247  // Private Member Functions //- Return the name of the derived pressure field  248  word resultName() const;  andy committed Sep 24, 2012 249   250 251  //- Multiply the static pressure p by rhoInf if necessary and return tmp rhoScale(const volScalarField& p) const;  andy committed Nov 22, 2012 252   253 254 255 256 257 258  //- Multiply the given field by rho or rhoInf as appropriate and return tmp rhoScale ( const volScalarField& p, const tmp& tsf ) const;  andy committed Sep 24, 2012 259   260  //- Add the hydrostatic contribution  261 262 263 264 265  void addHydrostaticContribution ( const volScalarField& p, volScalarField& prgh ) const;  andy committed Sep 24, 2012 266   Andrew Heather committed Jun 19, 2019 267 268  //- Calculate and return the pressure tmp calcPressure  269 270 271 272  ( const volScalarField& p, const tmp& tp ) const;  andy committed Sep 24, 2012 273   andy committed Nov 23, 2012 274  //- Convert to coeff by applying the freestream dynamic pressure scaling  275  tmp coeff(const tmp& tp) const;  andy committed Sep 24, 2012 276   Henry Weller committed May 25, 2016 277 278 279  //- Calculate the derived pressure field and return true if successful virtual bool calc();  andy committed Sep 24, 2012 280 281 282 283  public: //- Runtime type information  284  TypeName("pressure");  andy committed Sep 24, 2012 285 286 287 288  // Constructors  Henry Weller committed May 15, 2016 289  //- Construct from Time and dictionary  290  pressure  andy committed Sep 24, 2012 291 292  ( const word& name,  Henry Weller committed May 15, 2016 293 294  const Time& runTime, const dictionary&  andy committed Sep 24, 2012 295 296 297 298  ); //- Destructor  Andrew Heather committed Jun 19, 2019 299  virtual ~pressure() = default;  andy committed Sep 24, 2012 300 301 302 303  // Member Functions  304  //- Read the pressure data  Henry Weller committed May 15, 2016 305  virtual bool read(const dictionary&);  andy committed Sep 24, 2012 306 307 308 309 310 }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //  311 } // End namespace functionObjects  andy committed Sep 24, 2012 312 313 314 315 316 317 318 } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //