totalPressureFvPatchScalarField.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 | Copyright (C) 2011-2015 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 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
37  const fvPatch& p,
39 )
40 :
41  fixedValueFvPatchScalarField(p, iF),
42  UName_("U"),
43  phiName_("phi"),
44  rhoName_("none"),
45  psiName_("none"),
46  gamma_(0.0),
47  p0_(p.size(), 0.0)
48 {}
49 
50 
52 (
53  const fvPatch& p,
55  const dictionary& dict
56 )
57 :
58  fixedValueFvPatchScalarField(p, iF),
59  UName_(dict.lookupOrDefault<word>("U", "U")),
60  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
61  rhoName_(dict.lookupOrDefault<word>("rho", "none")),
62  psiName_(dict.lookupOrDefault<word>("psi", "none")),
63  gamma_(readScalar(dict.lookup("gamma"))),
64  p0_("p0", dict, p.size())
65 {
66  if (dict.found("value"))
67  {
69  (
70  scalarField("value", dict, p.size())
71  );
72  }
73  else
74  {
76  }
77 }
78 
79 
81 (
83  const fvPatch& p,
85  const fvPatchFieldMapper& mapper
86 )
87 :
88  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
89  UName_(ptf.UName_),
90  phiName_(ptf.phiName_),
91  rhoName_(ptf.rhoName_),
92  psiName_(ptf.psiName_),
93  gamma_(ptf.gamma_),
94  p0_(ptf.p0_, mapper)
95 {}
96 
97 
99 (
101 )
102 :
103  fixedValueFvPatchScalarField(tppsf),
104  UName_(tppsf.UName_),
105  phiName_(tppsf.phiName_),
106  rhoName_(tppsf.rhoName_),
107  psiName_(tppsf.psiName_),
108  gamma_(tppsf.gamma_),
109  p0_(tppsf.p0_)
110 {}
111 
112 
114 (
115  const totalPressureFvPatchScalarField& tppsf,
117 )
118 :
119  fixedValueFvPatchScalarField(tppsf, iF),
120  UName_(tppsf.UName_),
121  phiName_(tppsf.phiName_),
122  rhoName_(tppsf.rhoName_),
123  psiName_(tppsf.psiName_),
124  gamma_(tppsf.gamma_),
125  p0_(tppsf.p0_)
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 
132 (
133  const fvPatchFieldMapper& m
134 )
135 {
136  fixedValueFvPatchScalarField::autoMap(m);
137  p0_.autoMap(m);
138 }
139 
140 
142 (
143  const fvPatchScalarField& ptf,
144  const labelList& addr
145 )
146 {
147  fixedValueFvPatchScalarField::rmap(ptf, addr);
148 
149  const totalPressureFvPatchScalarField& tiptf =
150  refCast<const totalPressureFvPatchScalarField>(ptf);
151 
152  p0_.rmap(tiptf.p0_, addr);
153 }
154 
155 
157 (
158  const scalarField& p0p,
159  const vectorField& Up
160 )
161 {
162  if (updated())
163  {
164  return;
165  }
166 
167  const fvsPatchField<scalar>& phip =
168  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
169 
170  if (psiName_ == "none" && rhoName_ == "none")
171  {
172  operator==(p0p - 0.5*(1.0 - pos(phip))*magSqr(Up));
173  }
174  else if (rhoName_ == "none")
175  {
176  const fvPatchField<scalar>& psip =
177  patch().lookupPatchField<volScalarField, scalar>(psiName_);
178 
179  if (gamma_ > 1.0)
180  {
181  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
182 
183  operator==
184  (
185  p0p
186  /pow
187  (
188  (1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)),
189  1.0/gM1ByG
190  )
191  );
192  }
193  else
194  {
195  operator==(p0p/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up)));
196  }
197  }
198  else if (psiName_ == "none")
199  {
200  const fvPatchField<scalar>& rho =
201  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
202 
203  operator==(p0p - 0.5*rho*(1.0 - pos(phip))*magSqr(Up));
204  }
205  else
206  {
208  << " rho or psi set inconsistently, rho = " << rhoName_
209  << ", psi = " << psiName_ << ".\n"
210  << " Set either rho or psi or neither depending on the "
211  "definition of total pressure." << nl
212  << " Set the unused variable(s) to 'none'.\n"
213  << " on patch " << this->patch().name()
214  << " of field " << this->dimensionedInternalField().name()
215  << " in file " << this->dimensionedInternalField().objectPath()
216  << exit(FatalError);
217  }
218 
219  fixedValueFvPatchScalarField::updateCoeffs();
220 }
221 
222 
224 {
226  (
227  p0(),
228  patch().lookupPatchField<volVectorField, vector>(UName())
229  );
230 }
231 
232 
234 {
236  writeEntryIfDifferent<word>(os, "U", "U", UName_);
237  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
238  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
239  os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
240  os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
241  p0_.writeEntry("p0", os);
242  writeEntry("value", os);
243 }
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 namespace Foam
249 {
251  (
254  );
255 }
256 
257 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::totalPressureFvPatchScalarField::p0_
scalarField p0_
Total pressure.
Definition: totalPressureFvPatchScalarField.H:285
Foam::totalPressureFvPatchScalarField::gamma_
scalar gamma_
Heat capacity ratio.
Definition: totalPressureFvPatchScalarField.H:282
dimensionedInternalField
rDeltaT dimensionedInternalField()
Foam::totalPressureFvPatchScalarField::UName_
word UName_
Name of the velocity field.
Definition: totalPressureFvPatchScalarField.H:269
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
totalPressureFvPatchScalarField.H
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::totalPressureFvPatchScalarField
This boundary condition provides a total pressure condition. Four variants are possible:
Definition: totalPressureFvPatchScalarField.H:262
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::totalPressureFvPatchScalarField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: totalPressureFvPatchScalarField.C:132
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::totalPressureFvPatchScalarField::UName
const word & UName() const
Return the name of the velocity field.
Definition: totalPressureFvPatchScalarField.H:361
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:73
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::totalPressureFvPatchScalarField::p0
const scalarField & p0() const
Return the total pressure.
Definition: totalPressureFvPatchScalarField.H:425
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
readScalar
#define readScalar
Definition: doubleScalar.C:38
rho
rho
Definition: pEqn.H:3
Foam::totalPressureFvPatchScalarField::psiName_
word psiName_
Name of the compressibility field used to calculate the wave speed.
Definition: totalPressureFvPatchScalarField.H:279
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
Foam::totalPressureFvPatchScalarField::rhoName_
word rhoName_
Name of the density field used to normalise the mass flux.
Definition: totalPressureFvPatchScalarField.H:276
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
scalarField
volScalarField scalarField(fieldObject, mesh)
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::totalPressureFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: totalPressureFvPatchScalarField.C:223
Foam::totalPressureFvPatchScalarField::phiName_
word phiName_
Name of the flux transporting the field.
Definition: totalPressureFvPatchScalarField.H:272
Foam::totalPressureFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: totalPressureFvPatchScalarField.C:233
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
totalPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: totalPressureFvPatchScalarField.C:36
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::magSqr
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::totalPressureFvPatchScalarField::rmap
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: totalPressureFvPatchScalarField.C:142
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190