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-2024 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 "fieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
37 (
38  const fvPatch& p,
40  const dictionary& dict
41 )
42 :
43  fixedValueFvPatchScalarField(p, iF, dict, false),
44  rho_(dict.lookup<scalar>("rhoRef", dimDensity)),
45  pRef_(dict.lookup<scalar>("pRef", dimPressure)),
46  pRefPointSpecified_(dict.found("pRefPoint")),
47  pRefPoint_(dict.lookupOrDefault<vector>("pRefPoint", dimLength, Zero))
48 {
49  if (dict.found("value"))
50  {
52  (
53  scalarField("value", iF.dimensions(), dict, p.size())
54  );
55  }
56  else
57  {
59  }
60 }
61 
62 
65 (
67  const fvPatch& p,
69  const fieldMapper& mapper
70 )
71 :
72  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
73  rho_(ptf.rho_),
74  pRef_(ptf.pRef_),
75  pRefPointSpecified_(ptf.pRefPointSpecified_),
76  pRefPoint_(ptf.pRefPoint_)
77 {}
78 
79 
82 (
85 )
86 :
87  fixedValueFvPatchScalarField(ptf, iF),
88  rho_(ptf.rho_),
89  pRef_(ptf.pRef_),
90  pRefPointSpecified_(ptf.pRefPointSpecified_),
91  pRefPoint_(ptf.pRefPoint_)
92 {}
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
98 {
99  if (updated())
100  {
101  return;
102  }
103 
105  db().lookupObject<uniformDimensionedVectorField>("g");
106 
107  scalar ghRef = g.value() & pRefPoint_;
108 
109  if (!pRefPointSpecified_)
110  {
111  const uniformDimensionedScalarField& hRef =
112  db().lookupObject<uniformDimensionedScalarField>("hRef");
113 
114  ghRef = - mag(g.value())*hRef.value();
115  }
116 
117  operator==
118  (
119  pRef_
120  + rho_*((g.value() & patch().Cf()) - ghRef)
121  );
122 
123  fixedValueFvPatchScalarField::updateCoeffs();
124 }
125 
126 
128 (
129  Ostream& os
130 ) const
131 {
133  writeEntry(os, "rhoRef", rho_);
134  writeEntry(os, "pRef", pRef_);
135  if (pRefPointSpecified_)
136  {
137  writeEntry(os, "pRefPoint", pRefPoint_);
138  }
139  writeEntry(os, "value", *this);
140 }
141 
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 namespace Foam
146 {
148  (
151  );
152 }
153 
154 // ************************************************************************* //
bool found
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Type & value()
Return a reference to the value.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:229
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:249
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
This boundary condition provides a hydrostatic pressure condition, calculated as:
uniformDensityHydrostaticPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
const dimensionSet dimPressure
const dimensionSet dimLength
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
const dimensionSet dimDensity
dimensioned< scalar > mag(const dimensioned< Type > &)
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
dictionary dict
volScalarField & p
Foam::surfaceFields.