PrghPressureFvPatchScalarField.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) 2018-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 \*---------------------------------------------------------------------------*/
25 
28 #include "fieldMapper.H"
29 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class PressureFvPatchScalarField>
37 (
38  const fvPatch& p,
40  const dictionary& dict
41 )
42 :
43  PressureFvPatchScalarField(p, iF, dict),
44  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
45 {}
46 
47 
48 template<class PressureFvPatchScalarField>
51 (
53  const fvPatch& p,
55  const fieldMapper& mapper
56 )
57 :
58  PressureFvPatchScalarField(ptf, p, iF, mapper),
59  rhoName_(ptf.rhoName_)
60 {}
61 
62 
63 template<class PressureFvPatchScalarField>
66 (
69 )
70 :
71  PressureFvPatchScalarField(ptf, iF),
72  rhoName_(ptf.rhoName_)
73 {}
74 
75 
76 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
77 
78 template<class PressureFvPatchScalarField>
81 {
82  if (PressureFvPatchScalarField::updated())
83  {
84  return;
85  }
86 
87  PressureFvPatchScalarField::updateCoeffs();
88 
89  const scalarField& rhop = this->patch().template
90  lookupPatchField<volScalarField, scalar>
91  (
92  rhoName_
93  );
94 
96  this->db().template lookupObject<uniformDimensionedVectorField>("g");
97 
98  const uniformDimensionedScalarField& hRef =
99  this->db().template lookupObject<uniformDimensionedScalarField>("hRef");
100 
101  const dimensionedScalar ghRef(- mag(g)*hRef);
102 
103  this->operator==
104  (
105  *this - rhop*((g.value() & this->patch().Cf()) - ghRef.value())
106  );
107 }
108 
109 
110 template<class PressureFvPatchScalarField>
112 write(Ostream& os) const
113 {
115  writeEntry(os, "rho", rhoName_);
116 }
117 
118 
119 // ************************************************************************* //
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...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
This boundary condition provides the p_rgh equivalent of a pressure boundary condition calculated as:
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
PrghPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
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
const Type & value() const
Return const reference to value.
Abstract base class for field mapping.
Definition: fieldMapper.H:48
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
A class for handling words, derived from string.
Definition: word.H:62
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dimensioned< scalar > mag(const dimensioned< Type > &)
dictionary dict
volScalarField & p