phaseHydrostaticPressureFvPatchScalarField.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) 2011-2016 OpenFOAM Foundation
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::phaseHydrostaticPressureFvPatchScalarField
28 
29 Group
30  grpGenericBoundaryConditions
31 
32 Description
33  This boundary condition provides a phase-based hydrostatic pressure
34  condition, calculated as:
35 
36  \f[
37  p_{hyd} = p_{ref} + \rho g (x - x_{ref})
38  \f]
39 
40  where
41  \vartable
42  p_{hyd} | hyrostatic pressure [Pa]
43  p_{ref} | reference pressure [Pa]
44  x_{ref} | reference point in Cartesian coordinates
45  \rho | density (assumed uniform)
46  g | acceleration due to gravity [m/s2]
47  \endtable
48 
49  The values are assigned according to the phase-fraction field:
50  - 1: apply \f$p_{hyd}\f$
51  - 0: apply a zero-gradient condition
52 
53 Usage
54  \table
55  Property | Description | Required | Default value
56  phaseFraction | phase-fraction field name | no | alpha
57  rho | density field name | no | rho
58  pRefValue | reference pressure [Pa] | yes |
59  pRefPoint | reference pressure location | yes |
60  \endtable
61 
62  Example of the boundary condition specification:
63  \verbatim
64  <patchName>
65  {
66  type phaseHydrostaticPressure;
67  phaseFraction alpha1;
68  rho rho;
69  pRefValue 1e5;
70  pRefPoint (0 0 0);
71  value uniform 0; // optional initial value
72  }
73  \endverbatim
74 
75 See also
76  Foam::mixedFvPatchScalarField
77 
78 SourceFiles
79  phaseHydrostaticPressureFvPatchScalarField.C
80 
81 \*---------------------------------------------------------------------------*/
82 
83 #ifndef phaseHydrostaticPressureFvPatchScalarField_H
84 #define phaseHydrostaticPressureFvPatchScalarField_H
85 
86 #include "mixedFvPatchFields.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 /*---------------------------------------------------------------------------*\
94  Class phaseHydrostaticPressureFvPatchScalarField Declaration
95 \*---------------------------------------------------------------------------*/
96 
97 class phaseHydrostaticPressureFvPatchScalarField
98 :
99  public mixedFvPatchScalarField
100 {
101 
102 protected:
103 
104  // Protected data
105 
106  //- Name of phase-fraction field
107  word phaseFraction_;
108 
109  //- Constant density in the far-field
110  scalar rho_;
111 
112  //- Reference pressure
113  scalar pRefValue_;
114 
115  //- Reference pressure location
117 
118 
119 public:
120 
121  //- Runtime type information
122  TypeName("phaseHydrostaticPressure");
123 
124 
125  // Constructors
126 
127  //- Construct from patch and internal field
129  (
130  const fvPatch&,
131  const DimensionedField<scalar, volMesh>&
132  );
133 
134  //- Construct from patch, internal field and dictionary
136  (
137  const fvPatch&,
139  const dictionary&
140  );
141 
142  //- Construct by mapping given
143  // phaseHydrostaticPressureFvPatchScalarField onto a new patch
145  (
147  const fvPatch&,
150  );
151 
152  //- Construct as copy
154  (
156  );
157 
158  //- Construct and return a clone
160  {
162  (
164  );
165  }
166 
167  //- Construct as copy setting internal field reference
169  (
172  );
173 
174  //- Construct and return a clone setting internal field reference
176  (
178  ) const
179  {
181  (
183  );
184  }
185 
186 
187  // Member Functions
188 
189  //- True: this patch field is altered by assignment
190  virtual bool assignable() const { return true; }
191 
192 
193  // Access
194 
195  //- Return the phaseFraction
196  const word& phaseFraction() const
197  {
198  return phaseFraction_;
199  }
200 
201  //- Return reference to the phaseFraction to allow adjustment
202  word& phaseFraction()
203  {
204  return phaseFraction_;
205  }
206 
207  //- Return the constant density in the far-field
208  scalar rho() const
209  {
210  return rho_;
211  }
212 
213  //- Return reference to the constant density in the far-field
214  // to allow adjustment
215  scalar& rho()
216  {
217  return rho_;
218  }
219 
220  //- Return the reference pressure
221  scalar pRefValue() const
222  {
223  return pRefValue_;
224  }
225 
226  //- Return reference to the reference pressure to allow adjustment
227  scalar& pRefValue()
228  {
229  return pRefValue_;
230  }
231 
232  //- Return the pressure reference location
233  const vector& pRefPoint() const
234  {
235  return pRefPoint_;
236  }
237 
238  //- Return reference to the pressure reference location
239  // to allow adjustment
240  vector& pRefPoint()
241  {
242  return pRefPoint_;
243  }
244 
245 
246  //- Update the coefficients associated with the patch field
247  virtual void updateCoeffs();
248 
249  //- Write
250  virtual void write(Ostream&) const;
251 
252 
253  // Member operators
254 
255  virtual void operator=(const fvPatchScalarField& pvf);
256 };
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 } // End namespace Foam
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 #endif
266 
267 // ************************************************************************* //
TypeName("phaseHydrostaticPressure")
Runtime type information.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
scalar rho() const
Return the constant density in the far-field.
const vector & pRefPoint() const
Return the pressure reference location.
This boundary condition provides a phase-based hydrostatic pressure condition, calculated as: ...
A FieldMapper for finite-volume patch fields.
phaseHydrostaticPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Vector< scalar > vector
Definition: vector.H:57
virtual bool assignable() const
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:55
virtual tmp< fvPatchScalarField > clone() const
Construct and return a clone.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.