totalTemperatureFvPatchScalarField.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-2019 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 
35 (
36  const fvPatch& p,
38 )
39 :
40  fixedValueFvPatchScalarField(p, iF),
41  UName_("U"),
42  phiName_("phi"),
43  psiName_("thermo:psi"),
44  gamma_(0.0),
45  T0_(p.size(), 0.0)
46 {}
47 
48 
50 (
52  const fvPatch& p,
54  const fvPatchFieldMapper& mapper
55 )
56 :
57  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
58  UName_(ptf.UName_),
59  phiName_(ptf.phiName_),
60  psiName_(ptf.psiName_),
61  gamma_(ptf.gamma_),
62  T0_(mapper(ptf.T0_))
63 {}
64 
65 
67 (
68  const fvPatch& p,
70  const dictionary& dict
71 )
72 :
73  fixedValueFvPatchScalarField(p, iF, dict, false),
74  UName_(dict.lookupOrDefault<word>("U", "U")),
75  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
76  psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
77  gamma_(dict.lookup<scalar>("gamma")),
78  T0_("T0", dict, p.size())
79 {
80  if (dict.found("value"))
81  {
83  (
84  scalarField("value", dict, p.size())
85  );
86  }
87  else
88  {
90  }
91 }
92 
93 
95 (
97 )
98 :
99  fixedValueFvPatchScalarField(tppsf),
100  UName_(tppsf.UName_),
101  phiName_(tppsf.phiName_),
102  psiName_(tppsf.psiName_),
103  gamma_(tppsf.gamma_),
104  T0_(tppsf.T0_)
105 {}
106 
107 
109 (
112 )
113 :
114  fixedValueFvPatchScalarField(tppsf, iF),
115  UName_(tppsf.UName_),
116  phiName_(tppsf.phiName_),
117  psiName_(tppsf.psiName_),
118  gamma_(tppsf.gamma_),
119  T0_(tppsf.T0_)
120 {}
121 
122 
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 
126 (
127  const fvPatchFieldMapper& m
128 )
129 {
130  fixedValueFvPatchScalarField::autoMap(m);
131  m(T0_, T0_);
132 }
133 
134 
136 (
137  const fvPatchScalarField& ptf,
138  const labelList& addr
139 )
140 {
141  fixedValueFvPatchScalarField::rmap(ptf, addr);
142 
144  refCast<const totalTemperatureFvPatchScalarField>(ptf);
145 
146  T0_.rmap(tiptf.T0_, addr);
147 }
148 
149 
151 {
152  if (updated())
153  {
154  return;
155  }
156 
157  const fvPatchVectorField& Up =
158  patch().lookupPatchField<volVectorField, vector>(UName_);
159 
160  const fvsPatchField<scalar>& phip =
161  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
162 
163  const fvPatchField<scalar>& psip =
164  patch().lookupPatchField<volScalarField, scalar>(psiName_);
165 
166  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
167 
168  operator==
169  (
170  T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up))
171  );
172 
173  fixedValueFvPatchScalarField::updateCoeffs();
174 }
175 
176 
178 {
180  writeEntryIfDifferent<word>(os, "U", "U", UName_);
181  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
182  writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
183  writeEntry(os, "gamma", gamma_);
184  writeEntry(os, "T0", T0_);
185  writeEntry(os, "value", *this);
186 }
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 namespace Foam
192 {
194  (
197  );
198 }
199 
200 // ************************************************************************* //
Foam::surfaceFields.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
This boundary condition provides a total temperature condition.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
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:280
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
A class for handling words, derived from string.
Definition: word.H:59
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Foam::fvPatchFieldMapper.
virtual label size() const
Return size.
Definition: fvPatch.H:155
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)
totalTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
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:812