phaseHydrostaticPressureFvPatchScalarField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::phaseHydrostaticPressureFvPatchScalarField
26 
27 Description
28  This boundary condition provides a phase-based hydrostatic pressure
29  condition, calculated as:
30 
31  \f[
32  p_{hyd} = p_{ref} + \rho g (x - x_{ref})
33  \f]
34 
35  where
36  \vartable
37  p_{hyd} | hyrostatic pressure [Pa]
38  p_{ref} | reference pressure [Pa]
39  x_{ref} | reference point in Cartesian co-ordinates
40  \rho | density (assumed uniform)
41  g | acceleration due to gravity [m/s^2]
42  \endtable
43 
44  The values are assigned according to the phase-fraction field:
45  - 1: apply \$fp_{hyd}\$f
46  - 0: apply a zero-gradient condition
47 
48 Usage
49  \table
50  Property | Description | Required | Default value
51  phaseFraction | phase-fraction field name | no | alpha
52  rho | density field name | no | rho
53  pRefValue | reference pressure [Pa] | yes |
54  pRefPoint | reference pressure location | yes |
55  \endtable
56 
57  Example of the boundary condition specification:
58  \verbatim
59  <patchName>
60  {
61  type phaseHydrostaticPressure;
62  phaseFraction alpha1;
63  rho rho;
64  pRefValue 1e5;
65  pRefPoint (0 0 0);
66  value uniform 0; // optional initial value
67  }
68  \endverbatim
69 
70 See also
71  Foam::mixedFvPatchScalarField
72 
73 SourceFiles
74  phaseHydrostaticPressureFvPatchScalarField.C
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef phaseHydrostaticPressureFvPatchScalarField_H
79 #define phaseHydrostaticPressureFvPatchScalarField_H
80 
81 #include "mixedFvPatchFields.H"
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 namespace Foam
86 {
87 
88 /*---------------------------------------------------------------------------*\
89  Class phaseHydrostaticPressureFvPatchScalarField Declaration
90 \*---------------------------------------------------------------------------*/
91 
92 class phaseHydrostaticPressureFvPatchScalarField
93 :
94  public mixedFvPatchScalarField
95 {
96 
97 protected:
98 
99  // Protected data
100 
101  //- Name of phase-fraction field
102  word phaseFraction_;
103 
104  //- Constant density in the far-field
105  scalar rho_;
106 
107  //- Reference pressure
108  scalar pRefValue_;
109 
110  //- Reference pressure location
112 
113 
114 public:
115 
116  //- Runtime type information
117  TypeName("phaseHydrostaticPressure");
118 
119 
120  // Constructors
121 
122  //- Construct from patch, internal field and dictionary
124  (
125  const fvPatch&,
126  const DimensionedField<scalar, volMesh>&,
127  const dictionary&
128  );
129 
130  //- Construct by mapping given
131  // phaseHydrostaticPressureFvPatchScalarField onto a new patch
133  (
135  const fvPatch&,
137  const fvPatchFieldMapper&
138  );
139 
140  //- Disallow copy without setting internal field reference
142  (
144  ) = delete;
145 
146  //- Copy constructor setting internal field reference
148  (
151  );
152 
153  //- Construct and return a clone setting internal field reference
155  (
157  ) const
158  {
160  (
162  );
163  }
164 
165 
166  // Member Functions
167 
168  // Attributes
169 
170  //- Return true: this patch field is altered by assignment
171  virtual bool assignable() const
172  {
173  return true;
174  }
175 
176 
177  // Access
178 
179  //- Return the phaseFraction
180  const word& phaseFraction() const
181  {
182  return phaseFraction_;
183  }
184 
185  //- Return reference to the phaseFraction to allow adjustment
187  {
188  return phaseFraction_;
189  }
190 
191  //- Return the constant density in the far-field
192  scalar rho() const
193  {
194  return rho_;
195  }
196 
197  //- Return reference to the constant density in the far-field
198  // to allow adjustment
199  scalar& rho()
200  {
201  return rho_;
202  }
203 
204  //- Return the reference pressure
205  scalar pRefValue() const
206  {
207  return pRefValue_;
208  }
209 
210  //- Return reference to the reference pressure to allow adjustment
211  scalar& pRefValue()
212  {
213  return pRefValue_;
214  }
215 
216  //- Return the pressure reference location
217  const vector& pRefPoint() const
218  {
219  return pRefPoint_;
220  }
221 
222  //- Return reference to the pressure reference location
223  // to allow adjustment
225  {
226  return pRefPoint_;
227  }
228 
229 
230  //- Update the coefficients associated with the patch field
231  virtual void updateCoeffs();
232 
233  //- Write
234  virtual void write(Ostream&) const;
235 
236 
237  // Member Operators
238 
239  virtual void operator=(const fvPatchScalarField& pvf);
240 };
241 
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 } // End namespace Foam
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 #endif
250 
251 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
This boundary condition provides a phase-based hydrostatic pressure condition, calculated as:
phaseHydrostaticPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
TypeName("phaseHydrostaticPressure")
Runtime type information.
virtual tmp< fvPatchScalarField > clone(const DimensionedField< scalar, volMesh > &iF) const
Construct and return a clone setting internal field reference.
scalar rho() const
Return the constant density in the far-field.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual bool assignable() const
Return true: this patch field is altered by assignment.
const vector & pRefPoint() const
Return the pressure reference location.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49