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-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 \*---------------------------------------------------------------------------*/
25 
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class PressureFvPatchScalarField>
37 (
38  const fvPatch& p,
40 )
41 :
42  PressureFvPatchScalarField(p, iF),
43  rhoName_("rho")
44 {}
45 
46 
47 template<class PressureFvPatchScalarField>
50 (
51  const fvPatch& p,
53  const dictionary& dict
54 )
55 :
56  PressureFvPatchScalarField(p, iF, dict),
57  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
58 {}
59 
60 
61 template<class PressureFvPatchScalarField>
64 (
66  const fvPatch& p,
68  const fvPatchFieldMapper& mapper
69 )
70 :
71  PressureFvPatchScalarField(ptf, p, iF, mapper),
72  rhoName_(ptf.rhoName_)
73 {}
74 
75 
76 template<class PressureFvPatchScalarField>
79 (
82 )
83 :
84  PressureFvPatchScalarField(ptf, iF),
85  rhoName_(ptf.rhoName_)
86 {}
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
91 template<class PressureFvPatchScalarField>
94 {
95  if (PressureFvPatchScalarField::updated())
96  {
97  return;
98  }
99 
100  PressureFvPatchScalarField::updateCoeffs();
101 
102  const scalarField& rhop = this->patch().template
103  lookupPatchField<volScalarField, scalar>
104  (
105  rhoName_
106  );
107 
109  this->db().template lookupObject<uniformDimensionedVectorField>("g");
110 
111  const uniformDimensionedScalarField& hRef =
112  this->db().template lookupObject<uniformDimensionedScalarField>("hRef");
113 
114  const dimensionedScalar ghRef(- mag(g)*hRef);
115 
116  this->operator==
117  (
118  *this - rhop*((g.value() & this->patch().Cf()) - ghRef.value())
119  );
120 }
121 
122 
123 template<class PressureFvPatchScalarField>
125 write(Ostream& os) const
126 {
128  writeEntry(os, "rho", rhoName_);
129 }
130 
131 
132 // ************************************************************************* //
PrghPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
virtual void write(Ostream &) const
Write.
Macros for easy insertion into run-time selection tables.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for handling words, derived from string.
Definition: word.H:59
This boundary condition provides the p_rgh equivalent of a pressure boundary condition calculated as:...
Foam::fvPatchFieldMapper.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
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,.
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