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 
31 #include "fvPatchFieldMapper.H"
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, false),
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 (dict.found("value"))
84  {
86  (
87  scalarField("value", dict, p.size())
88  );
89  }
90  else
91  {
93  }
94 }
95 
96 
98 (
100 )
101 :
102  fixedValueFvPatchScalarField(tppsf),
103  UName_(tppsf.UName_),
104  phiName_(tppsf.phiName_),
105  psiName_(tppsf.psiName_),
106  gamma_(tppsf.gamma_),
107  T0_(tppsf.T0_)
108 {}
109 
110 
112 (
115 )
116 :
117  fixedValueFvPatchScalarField(tppsf, iF),
118  UName_(tppsf.UName_),
119  phiName_(tppsf.phiName_),
120  psiName_(tppsf.psiName_),
121  gamma_(tppsf.gamma_),
122  T0_(tppsf.T0_)
123 {}
124 
125 
126 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127 
129 (
130  const fvPatchFieldMapper& m
131 )
132 {
133  fixedValueFvPatchScalarField::autoMap(m);
134  T0_.autoMap(m);
135 }
136 
137 
139 (
140  const fvPatchScalarField& ptf,
141  const labelList& addr
142 )
143 {
144  fixedValueFvPatchScalarField::rmap(ptf, addr);
145 
147  refCast<const totalTemperatureFvPatchScalarField>(ptf);
148 
149  T0_.rmap(tiptf.T0_, addr);
150 }
151 
152 
154 {
155  if (updated())
156  {
157  return;
158  }
159 
160  const fvPatchVectorField& Up =
161  patch().lookupPatchField<volVectorField, vector>(UName_);
162 
163  const fvsPatchField<scalar>& phip =
164  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
165 
166  const fvPatchField<scalar>& psip =
167  patch().lookupPatchField<volScalarField, scalar>(psiName_);
168 
169  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
170 
171  operator==
172  (
173  T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up))
174  );
175 
176  fixedValueFvPatchScalarField::updateCoeffs();
177 }
178 
179 
181 {
183  os.writeEntryIfDifferent<word>("U", "U", UName_);
184  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
185  os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
186  os.writeEntry("gamma", gamma_);
187  T0_.writeEntry("T0", os);
188  writeEntry("value", os);
189 }
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 namespace Foam
195 {
197  (
200  );
201 }
202 
203 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
totalTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: totalTemperatureFvPatchScalarField.C:38
volFields.H
Foam::fvPatchField< scalar >::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:384
Foam::Ostream::writeEntryIfDifferent
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:248
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:188
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::totalTemperatureFvPatchScalarField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: totalTemperatureFvPatchScalarField.C:129
Foam::totalTemperatureFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: totalTemperatureFvPatchScalarField.C:180
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::totalTemperatureFvPatchScalarField::rmap
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: totalTemperatureFvPatchScalarField.C:139
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
totalTemperatureFvPatchScalarField.H
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:62
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::List< label >
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::totalTemperatureFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: totalTemperatureFvPatchScalarField.C:153
Foam::totalTemperatureFvPatchScalarField
This boundary condition provides a total temperature condition.
Definition: totalTemperatureFvPatchScalarField.H:106
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54