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-2022 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  const fvPatchScalarField& ptf
149 )
150 {
151  inletOutletFvPatchScalarField::reset(ptf);
152 
154  refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
155 
156  T0_.reset(tiptf.T0_);
157 }
158 
159 
161 {
162  if (updated())
163  {
164  return;
165  }
166 
167  const fvPatchVectorField& Up =
168  patch().lookupPatchField<volVectorField, vector>(UName_);
169 
170  const fvsPatchField<scalar>& phip =
171  patch().lookupPatchField<surfaceScalarField, scalar>(this->phiName_);
172 
173  const fvPatchField<scalar>& psip =
174  patch().lookupPatchField<volScalarField, scalar>(psiName_);
175 
176  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
177 
178  this->refValue() =
179  T0_/(1.0 + 0.5*psip*gM1ByG*neg(phip)*magSqr(Up));
180  this->valueFraction() = neg(phip);
181 
182  inletOutletFvPatchScalarField::updateCoeffs();
183 }
184 
185 
187 const
188 {
190  writeEntryIfDifferent<word>(os, "U", "U", UName_);
191  writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_);
192  writeEntryIfDifferent<word>(os, "psi", "psi", psiName_);
193  writeEntry(os, "gamma", gamma_);
194  writeEntry(os, "T0", T0_);
195  writeEntry(os, "value", *this);
196 }
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 namespace Foam
202 {
204  (
207  );
208 }
209 
210 // ************************************************************************* //
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:663
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:63
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:243
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:59
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:58
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
static const zero Zero
Definition: zero.H:97
virtual void reset(const fvPatchScalarField &)
Reset the fvPatchField to the given fvPatchField.
virtual label size() const
Return size.
Definition: fvPatch.H:157
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)
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:864
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.