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 {
87  this->patchType() = dict.getOrDefault<word>("patchType", word::null);
88 
89  this->phiName_ = dict.getOrDefault<word>("phi", "phi");
90 
91  this->refValue() = Zero;
92  if (dict.found("value"))
93  {
95  (
96  scalarField("value", dict, p.size())
97  );
98  }
99  else
100  {
102  }
103 
104  this->refGrad() = Zero;
105  this->valueFraction() = 0.0;
106 }
107 
108 
111 (
113 )
114 :
115  inletOutletFvPatchScalarField(tppsf),
116  UName_(tppsf.UName_),
117  psiName_(tppsf.psiName_),
118  gamma_(tppsf.gamma_),
119  T0_(tppsf.T0_)
120 {}
121 
122 
125 (
128 )
129 :
130  inletOutletFvPatchScalarField(tppsf, iF),
131  UName_(tppsf.UName_),
132  psiName_(tppsf.psiName_),
133  gamma_(tppsf.gamma_),
134  T0_(tppsf.T0_)
135 {}
136 
137 
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 
141 (
142  const fvPatchFieldMapper& m
143 )
144 {
145  inletOutletFvPatchScalarField::autoMap(m);
146  T0_.autoMap(m);
147 }
148 
149 
151 (
152  const fvPatchScalarField& ptf,
153  const labelList& addr
154 )
155 {
156  inletOutletFvPatchScalarField::rmap(ptf, addr);
157 
159  refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
160 
161  T0_.rmap(tiptf.T0_, addr);
162 }
163 
164 
166 {
167  if (updated())
168  {
169  return;
170  }
171 
172  const fvPatchVectorField& Up =
173  patch().lookupPatchField<volVectorField, vector>(UName_);
174 
175  const fvsPatchField<scalar>& phip =
176  patch().lookupPatchField<surfaceScalarField, scalar>(this->phiName_);
177 
178  const fvPatchField<scalar>& psip =
179  patch().lookupPatchField<volScalarField, scalar>(psiName_);
180 
181  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
182 
183  this->refValue() =
184  T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up));
185  this->valueFraction() = 1.0 - pos0(phip);
186 
187  inletOutletFvPatchScalarField::updateCoeffs();
188 }
189 
190 
192 const
193 {
195  os.writeEntryIfDifferent<word>("U", "U", UName_);
196  os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
197  os.writeEntryIfDifferent<word>("psi", "psi", psiName_);
198  os.writeEntry("gamma", gamma_);
199  T0_.writeEntry("T0", os);
200  writeEntry("value", os);
201 }
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 namespace Foam
207 {
209  (
211  inletOutletTotalTemperatureFvPatchScalarField
212  );
213 }
214 
215 // ************************************************************************* //
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
fvPatchField< vector > fvPatchVectorField
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:68
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:312
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:333
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:85
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:84
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
Definition: word.H:63
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A FieldMapper for finite-volume patch fields.
static const word null
An empty word.
Definition: word.H:84
Vector< scalar > vector
Definition: vector.H:57
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:327
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
dimensionedScalar pos0(const dimensionedScalar &ds)
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:352
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:157
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.