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-2020 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 and internal field
124  (
125  const fvPatch&,
126  const DimensionedField<scalar, volMesh>&
127  );
128 
129  //- Construct from patch, internal field and dictionary
131  (
132  const fvPatch&,
133  const DimensionedField<scalar, volMesh>&,
134  const dictionary&
135  );
137  //- Construct by mapping given
138  // phaseHydrostaticPressureFvPatchScalarField onto a new patch
140  (
142  const fvPatch&,
144  const fvPatchFieldMapper&
145  );
147  //- Disallow copy without setting internal field reference
149  (
151  ) = delete;
153  //- Copy constructor setting internal field reference
155  (
158  );
159 
160  //- Construct and return a clone setting internal field reference
162  (
164  ) const
165  {
167  (
169  );
170  }
171 
172 
173  // Member Functions
174 
175  // Attributes
176 
177  //- Return true: this patch field is altered by assignment
178  virtual bool assignable() const
179  {
180  return true;
181  }
182 
183 
184  // Access
185 
186  //- Return the phaseFraction
187  const word& phaseFraction() const
188  {
189  return phaseFraction_;
190  }
191 
192  //- Return reference to the phaseFraction to allow adjustment
194  {
195  return phaseFraction_;
196  }
197 
198  //- Return the constant density in the far-field
199  scalar rho() const
200  {
201  return rho_;
202  }
203 
204  //- Return reference to the constant density in the far-field
205  // to allow adjustment
206  scalar& rho()
207  {
208  return rho_;
209  }
210 
211  //- Return the reference pressure
212  scalar pRefValue() const
213  {
214  return pRefValue_;
215  }
216 
217  //- Return reference to the reference pressure to allow adjustment
218  scalar& pRefValue()
219  {
220  return pRefValue_;
221  }
223  //- Return the pressure reference location
224  const vector& pRefPoint() const
225  {
226  return pRefPoint_;
227  }
228 
229  //- Return reference to the pressure reference location
230  // to allow adjustment
232  {
233  return pRefPoint_;
234  }
235 
236 
237  //- Update the coefficients associated with the patch field
238  virtual void updateCoeffs();
239 
240  //- Write
241  virtual void write(Ostream&) const;
242 
244  // Member Operators
245 
246  virtual void operator=(const fvPatchScalarField& pvf);
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
TypeName("phaseHydrostaticPressure")
Runtime type information.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
scalar rho() const
Return the constant density in the far-field.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
const vector & pRefPoint() const
Return the pressure reference location.
This boundary condition provides a phase-based hydrostatic pressure condition, calculated as: ...
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
virtual tmp< fvPatchScalarField > clone(const DimensionedField< scalar, volMesh > &iF) const
Construct and return a clone setting internal field reference.
phaseHydrostaticPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
virtual bool assignable() const
Return true: this patch field is altered by assignment.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.