inletOutletTotalTemperatureFvPatchScalarField.C
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-2017 OpenFOAM Foundation
9  Copyright (C) 2017-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "fvPatchFieldMapper.H"
32 #include "volFields.H"
33 #include "surfaceFields.H"
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
39 (
40  const fvPatch& p,
42 )
43 :
44  inletOutletFvPatchScalarField(p, iF),
45  UName_("U"),
46  psiName_("psi"),
47  gamma_(0.0),
48  T0_(p.size(), Zero)
49 {
50  this->refValue() = Zero;
51  this->refGrad() = Zero;
52  this->valueFraction() = 0.0;
53 }
54 
55 
58 (
60  const fvPatch& p,
62  const fvPatchFieldMapper& mapper
63 )
64 :
65  inletOutletFvPatchScalarField(ptf, p, iF, mapper),
66  UName_(ptf.UName_),
67  psiName_(ptf.psiName_),
68  gamma_(ptf.gamma_),
69  T0_(ptf.T0_, mapper)
70 {}
71 
72 
75 (
76  const fvPatch& p,
78  const dictionary& dict
79 )
80 :
81  inletOutletFvPatchScalarField(p, iF),
82  UName_(dict.getOrDefault<word>("U", "U")),
83  psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
84  gamma_(dict.get<scalar>("gamma")),
85  T0_("T0", dict, p.size())
86 {
88 
89  this->phiName_ = dict.getOrDefault<word>("phi", "phi");
90 
91  this->refValue() = Zero;
92 
93  if (!this->readValueEntry(dict))
94  {
96  }
97 
98  this->refGrad() = Zero;
99  this->valueFraction() = 0.0;
100 }
101 
102 
105 (
107 )
108 :
109  inletOutletFvPatchScalarField(tppsf),
110  UName_(tppsf.UName_),
111  psiName_(tppsf.psiName_),
112  gamma_(tppsf.gamma_),
113  T0_(tppsf.T0_)
114 {}
115 
116 
119 (
122 )
123 :
124  inletOutletFvPatchScalarField(tppsf, iF),
125  UName_(tppsf.UName_),
126  psiName_(tppsf.psiName_),
127  gamma_(tppsf.gamma_),
128  T0_(tppsf.T0_)
129 {}
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
135 (
136  const fvPatchFieldMapper& m
137 )
138 {
139  inletOutletFvPatchScalarField::autoMap(m);
140  T0_.autoMap(m);
141 }
142 
143 
145 (
146  const fvPatchScalarField& ptf,
147  const labelList& addr
148 )
149 {
150  inletOutletFvPatchScalarField::rmap(ptf, addr);
151 
153  refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
154 
155  T0_.rmap(tiptf.T0_, addr);
156 }
157 
158 
160 {
161  if (updated())
162  {
163  return;
164  }
165 
166  const auto& Up =
167  patch().lookupPatchField<volVectorField>(UName_);
168 
169  const auto& phip =
170  patch().lookupPatchField<surfaceScalarField>(this->phiName_);
171 
172  const auto& psip =
173  patch().lookupPatchField<volScalarField>(psiName_);
174 
175  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
176 
177  this->refValue() =
178  T0_/(1.0 + 0.5*psip*gM1ByG*(neg(phip))*magSqr(Up));
179  this->valueFraction() = neg(phip);
180 
181  inletOutletFvPatchScalarField::updateCoeffs();
182 }
183 
184 
186 const
187 {
189  os.writeEntryIfDifferent<word>("U", "U", UName_);
190  os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
191  os.writeEntryIfDifferent<word>("psi", "psi", psiName_);
192  os.writeEntry("gamma", gamma_);
193  T0_.writeEntry("T0", os);
195 }
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 namespace Foam
201 {
203  (
205  inletOutletTotalTemperatureFvPatchScalarField
206  );
207 }
208 
209 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Foam::surfaceFields.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:321
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
Definition: fvPatchField.H:375
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:372
virtual void readDict(const dictionary &dict)
Read dictionary entries.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:82
dimensionedScalar neg(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
This boundary condition provides an outflow condition for total temperature for use with supersonic c...
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
Definition: word.H:63
A FieldMapper for finite-volume patch fields.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:336
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
inletOutletTotalTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:391
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const std::string patch
OpenFOAM patch number as a std::string.
volScalarField & p
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.