uniformDensityHydrostaticPressureFvPatchScalarField.C
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-2019 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 \*---------------------------------------------------------------------------*/
25 
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
37 (
38  const fvPatch& p,
40 )
41 :
42  fixedValueFvPatchScalarField(p, iF),
43  rho_(0.0),
44  pRef_(0.0),
45  pRefPointSpecified_(false),
46  pRefPoint_(Zero)
47 {}
48 
49 
52 (
53  const fvPatch& p,
55  const dictionary& dict
56 )
57 :
58  fixedValueFvPatchScalarField(p, iF, dict, false),
59  rho_(readScalar(dict.lookup("rhoRef"))),
60  pRef_(readScalar(dict.lookup("pRef"))),
61  pRefPointSpecified_(dict.found("pRefPoint")),
62  pRefPoint_(dict.lookupOrDefault<vector>("pRefPoint", Zero))
63 {
64  if (dict.found("value"))
65  {
66  fvPatchScalarField::operator=
67  (
68  scalarField("value", dict, p.size())
69  );
70  }
71  else
72  {
74  }
75 }
76 
77 
80 (
82  const fvPatch& p,
84  const fvPatchFieldMapper& mapper
85 )
86 :
87  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
88  rho_(ptf.rho_),
89  pRef_(ptf.pRef_),
90  pRefPointSpecified_(ptf.pRefPointSpecified_),
91  pRefPoint_(ptf.pRefPoint_)
92 {}
93 
94 
97 (
99 )
100 :
101  fixedValueFvPatchScalarField(ptf),
102  rho_(ptf.rho_),
103  pRef_(ptf.pRef_),
104  pRefPointSpecified_(ptf.pRefPointSpecified_),
105  pRefPoint_(ptf.pRefPoint_)
106 {}
107 
108 
111 (
114 )
115 :
116  fixedValueFvPatchScalarField(ptf, iF),
117  rho_(ptf.rho_),
118  pRef_(ptf.pRef_),
119  pRefPointSpecified_(ptf.pRefPointSpecified_),
120  pRefPoint_(ptf.pRefPoint_)
121 {}
122 
123 
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 
127 {
128  if (updated())
129  {
130  return;
131  }
132 
134  db().lookupObject<uniformDimensionedVectorField>("g");
135 
136  scalar ghRef = g.value() & pRefPoint_;
137 
138  if (!pRefPointSpecified_)
139  {
140  const uniformDimensionedScalarField& hRef =
141  db().lookupObject<uniformDimensionedScalarField>("hRef");
142 
143  ghRef = - mag(g.value())*hRef.value();
144  }
145 
146  operator==
147  (
148  pRef_
149  + rho_*((g.value() & patch().Cf()) - ghRef)
150  );
151 
152  fixedValueFvPatchScalarField::updateCoeffs();
153 }
154 
155 
157 (
158  Ostream& os
159 ) const
160 {
162  writeEntry(os, "rhoRef", rho_);
163  writeEntry(os, "pRef", pRef_);
164  if (pRefPointSpecified_)
165  {
166  writeEntry(os, "pRefPoint", pRefPoint_);
167  }
168  writeEntry(os, "value", *this);
169 }
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 namespace Foam
175 {
177  (
180  );
181 }
182 
183 // ************************************************************************* //
#define readScalar
Definition: doubleScalar.C:38
Foam::surfaceFields.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:438
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
This boundary condition provides a hydrostatic pressure condition, calculated as: ...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:280
Macros for easy insertion into run-time selection tables.
Foam::fvPatchFieldMapper.
const Type & value() const
Return const reference to value.
static const zero Zero
Definition: zero.H:97
virtual label size() const
Return size.
Definition: fvPatch.H:155
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
volScalarField scalarField(fieldObject, mesh)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
uniformDensityHydrostaticPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensioned< scalar > mag(const dimensioned< Type > &)
const dimensionedVector & g
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:583