inletOutletTotalTemperatureFvPatchScalarField.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-2021 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"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
41  inletOutletFvPatchScalarField(p, iF),
42  UName_("U"),
43  psiName_("psi"),
44  gamma_(0.0),
45  T0_(p.size(), 0.0)
46 {
47  this->refValue() = Zero;
48  this->refGrad() = Zero;
49  this->valueFraction() = 0.0;
50 }
51 
52 
55 (
56  const fvPatch& p,
58  const dictionary& dict
59 )
60 :
61  inletOutletFvPatchScalarField(p, iF),
62  UName_(dict.lookupOrDefault<word>("U", "U")),
63  psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
64  gamma_(dict.lookup<scalar>("gamma")),
65  T0_("T0", dict, p.size())
66 {
67  this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
68 
69  this->refValue() = Zero;
70  if (dict.found("value"))
71  {
73  (
74  scalarField("value", dict, p.size())
75  );
76  }
77  else
78  {
80  }
81 
82  this->refGrad() = Zero;
83  this->valueFraction() = 0.0;
84 }
85 
86 
89 (
91  const fvPatch& p,
93  const fvPatchFieldMapper& mapper
94 )
95 :
96  inletOutletFvPatchScalarField(ptf, p, iF, mapper),
97  UName_(ptf.UName_),
98  psiName_(ptf.psiName_),
99  gamma_(ptf.gamma_),
100  T0_(mapper(ptf.T0_))
101 {}
102 
103 
106 (
109 )
110 :
111  inletOutletFvPatchScalarField(tppsf, iF),
112  UName_(tppsf.UName_),
113  psiName_(tppsf.psiName_),
114  gamma_(tppsf.gamma_),
115  T0_(tppsf.T0_)
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 
122 (
123  const fvPatchFieldMapper& m
124 )
125 {
126  inletOutletFvPatchScalarField::autoMap(m);
127  m(T0_, T0_);
128 }
129 
130 
132 (
133  const fvPatchScalarField& ptf,
134  const labelList& addr
135 )
136 {
137  inletOutletFvPatchScalarField::rmap(ptf, addr);
138 
140  refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
141 
142  T0_.rmap(tiptf.T0_, addr);
143 }
144 
145 
147 {
148  if (updated())
149  {
150  return;
151  }
152 
153  const fvPatchVectorField& Up =
154  patch().lookupPatchField<volVectorField, vector>(UName_);
155 
156  const fvsPatchField<scalar>& phip =
157  patch().lookupPatchField<surfaceScalarField, scalar>(this->phiName_);
158 
159  const fvPatchField<scalar>& psip =
160  patch().lookupPatchField<volScalarField, scalar>(psiName_);
161 
162  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
163 
164  this->refValue() =
165  T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up));
166  this->valueFraction() = 1.0 - pos0(phip);
167 
168  inletOutletFvPatchScalarField::updateCoeffs();
169 }
170 
171 
173 const
174 {
176  writeEntryIfDifferent<word>(os, "U", "U", UName_);
177  writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_);
178  writeEntryIfDifferent<word>(os, "psi", "psi", psiName_);
179  writeEntry(os, "gamma", gamma_);
180  writeEntry(os, "T0", T0_);
181  writeEntry(os, "value", *this);
182 }
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 namespace Foam
188 {
190  (
193  );
194 }
195 
196 // ************************************************************************* //
Foam::surfaceFields.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:643
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:260
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
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:57
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
static const zero Zero
Definition: zero.H:97
virtual label size() const
Return size.
Definition: fvPatch.H:156
dimensioned< scalar > magSqr(const dimensioned< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
volScalarField scalarField(fieldObject, mesh)
dimensionedScalar pos0(const dimensionedScalar &ds)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
inletOutletTotalTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
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...
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.