totalTemperatureFvPatchScalarField.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) 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 
32 #include "volFields.H"
33 #include "surfaceFields.H"
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
38 (
39  const fvPatch& p,
41 )
42 :
43  fixedValueFvPatchScalarField(p, iF),
44  UName_("U"),
45  phiName_("phi"),
46  psiName_("thermo:psi"),
47  gamma_(0.0),
48  T0_(p.size(), Zero)
49 {}
50 
51 
53 (
55  const fvPatch& p,
57  const fvPatchFieldMapper& mapper
58 )
59 :
60  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
61  UName_(ptf.UName_),
62  phiName_(ptf.phiName_),
63  psiName_(ptf.psiName_),
64  gamma_(ptf.gamma_),
65  T0_(ptf.T0_, mapper)
66 {}
67 
68 
70 (
71  const fvPatch& p,
73  const dictionary& dict
74 )
75 :
76  fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
77  UName_(dict.getOrDefault<word>("U", "U")),
78  phiName_(dict.getOrDefault<word>("phi", "phi")),
79  psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
80  gamma_(dict.get<scalar>("gamma")),
81  T0_("T0", dict, p.size())
82 {
83  if (!this->readValueEntry(dict))
84  {
86  }
87 }
88 
89 
91 (
92  const totalTemperatureFvPatchScalarField& tppsf
93 )
94 :
95  fixedValueFvPatchScalarField(tppsf),
96  UName_(tppsf.UName_),
97  phiName_(tppsf.phiName_),
98  psiName_(tppsf.psiName_),
99  gamma_(tppsf.gamma_),
100  T0_(tppsf.T0_)
101 {}
102 
103 
105 (
108 )
109 :
110  fixedValueFvPatchScalarField(tppsf, iF),
111  UName_(tppsf.UName_),
112  phiName_(tppsf.phiName_),
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  fixedValueFvPatchScalarField::autoMap(m);
127  T0_.autoMap(m);
128 }
129 
130 
132 (
133  const fvPatchScalarField& ptf,
134  const labelList& addr
135 )
136 {
137  fixedValueFvPatchScalarField::rmap(ptf, addr);
138 
140  refCast<const totalTemperatureFvPatchScalarField>(ptf);
141 
142  T0_.rmap(tiptf.T0_, addr);
143 }
144 
145 
147 {
148  if (updated())
149  {
150  return;
151  }
152 
153  const auto& Up =
154  patch().lookupPatchField<volVectorField>(UName_);
155 
156  const auto& phip =
157  patch().lookupPatchField<surfaceScalarField>(phiName_);
158 
159  const auto& psip =
160  patch().lookupPatchField<volScalarField>(psiName_);
161 
162  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
163 
164  operator==
165  (
166  T0_/(1.0 + 0.5*psip*gM1ByG*(neg(phip))*magSqr(Up))
167  );
168 
169  fixedValueFvPatchScalarField::updateCoeffs();
170 }
171 
172 
174 {
176  os.writeEntryIfDifferent<word>("U", "U", UName_);
177  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
178  os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
179  os.writeEntry("gamma", gamma_);
180  T0_.writeEntry("T0", os);
182 }
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 namespace Foam
188 {
190  (
192  totalTemperatureFvPatchScalarField
193  );
194 }
195 
196 // ************************************************************************* //
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.
dictionary dict
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
This boundary condition provides a total temperature condition.
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
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:82
dimensionedScalar neg(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
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
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
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)
totalTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:391
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
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