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-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 
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 (
51  const fvPatch& p,
53  const dictionary& dict
54 )
55 :
56  fixedValueFvPatchScalarField(p, iF, dict, false),
57  UName_(dict.lookupOrDefault<word>("U", "U")),
58  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
59  psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
60  gamma_(dict.lookup<scalar>("gamma")),
61  T0_("T0", dict, p.size())
62 {
63  if (dict.found("value"))
64  {
66  (
67  scalarField("value", dict, p.size())
68  );
69  }
70  else
71  {
73  }
74 }
75 
76 
78 (
80  const fvPatch& p,
82  const fvPatchFieldMapper& mapper
83 )
84 :
85  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
86  UName_(ptf.UName_),
87  phiName_(ptf.phiName_),
88  psiName_(ptf.psiName_),
89  gamma_(ptf.gamma_),
90  T0_(mapper(ptf.T0_))
91 {}
92 
93 
95 (
98 )
99 :
100  fixedValueFvPatchScalarField(tppsf, iF),
101  UName_(tppsf.UName_),
102  phiName_(tppsf.phiName_),
103  psiName_(tppsf.psiName_),
104  gamma_(tppsf.gamma_),
105  T0_(tppsf.T0_)
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
112 (
113  const fvPatchFieldMapper& m
114 )
115 {
116  fixedValueFvPatchScalarField::autoMap(m);
117  m(T0_, T0_);
118 }
119 
120 
122 (
123  const fvPatchScalarField& ptf,
124  const labelList& addr
125 )
126 {
127  fixedValueFvPatchScalarField::rmap(ptf, addr);
128 
130  refCast<const totalTemperatureFvPatchScalarField>(ptf);
131 
132  T0_.rmap(tiptf.T0_, addr);
133 }
134 
135 
137 {
138  if (updated())
139  {
140  return;
141  }
142 
143  const fvPatchVectorField& Up =
144  patch().lookupPatchField<volVectorField, vector>(UName_);
145 
146  const fvsPatchField<scalar>& phip =
147  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
148 
149  const fvPatchField<scalar>& psip =
150  patch().lookupPatchField<volScalarField, scalar>(psiName_);
151 
152  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
153 
154  operator==
155  (
156  T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up))
157  );
158 
159  fixedValueFvPatchScalarField::updateCoeffs();
160 }
161 
162 
164 {
166  writeEntryIfDifferent<word>(os, "U", "U", UName_);
167  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
168  writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
169  writeEntry(os, "gamma", gamma_);
170  writeEntry(os, "T0", T0_);
171  writeEntry(os, "value", *this);
172 }
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 namespace Foam
178 {
180  (
183  );
184 }
185 
186 // ************************************************************************* //
Foam::surfaceFields.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:643
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:156
This boundary condition provides a total temperature condition.
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.
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: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)
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:844