uniformTotalPressureFvPatchScalarField.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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
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  pressure_()
48 {}
49 
50 
53 (
54  const fvPatch& p,
56  const dictionary& dict
57 )
58 :
59  fixedValueFvPatchScalarField(p, iF),
60  UName_(dict.lookupOrDefault<word>("U", "U")),
61  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
62  rhoName_(dict.lookupOrDefault<word>("rho", "none")),
63  psiName_(dict.lookupOrDefault<word>("psi", "none")),
64  gamma_(readScalar(dict.lookup("gamma"))),
65  pressure_(DataEntry<scalar>::New("pressure", dict))
66 {
67  if (dict.found("value"))
68  {
70  (
71  scalarField("value", dict, p.size())
72  );
73  }
74  else
75  {
76  const scalar t = this->db().time().timeOutputValue();
77  fvPatchScalarField::operator==(pressure_->value(t));
78  }
79 }
80 
81 
84 (
86  const fvPatch& p,
88  const fvPatchFieldMapper& mapper
89 )
90 :
91  fixedValueFvPatchScalarField(p, iF), // Don't map
92  UName_(ptf.UName_),
93  phiName_(ptf.phiName_),
94  rhoName_(ptf.rhoName_),
95  psiName_(ptf.psiName_),
96  gamma_(ptf.gamma_),
97  pressure_(ptf.pressure_, false)
98 {
99  patchType() = ptf.patchType();
100 
101  // Set the patch pressure to the current total pressure
102  // This is not ideal but avoids problems with the creation of patch faces
103  const scalar t = this->db().time().timeOutputValue();
104  fvPatchScalarField::operator==(pressure_->value(t));
105 }
106 
107 
110 (
112 )
113 :
114  fixedValueFvPatchScalarField(ptf),
115  UName_(ptf.UName_),
116  phiName_(ptf.phiName_),
117  rhoName_(ptf.rhoName_),
118  psiName_(ptf.psiName_),
119  gamma_(ptf.gamma_),
120  pressure_(ptf.pressure_, false)
121 {}
122 
123 
126 (
129 )
130 :
131  fixedValueFvPatchScalarField(ptf, iF),
132  UName_(ptf.UName_),
133  phiName_(ptf.phiName_),
134  rhoName_(ptf.rhoName_),
135  psiName_(ptf.psiName_),
136  gamma_(ptf.gamma_),
137  pressure_(ptf.pressure_, false)
138 {}
139 
140 
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
142 
144 (
145  const vectorField& Up
146 )
147 {
148  if (updated())
149  {
150  return;
151  }
152 
153  scalar p0 = pressure_->value(this->db().time().timeOutputValue());
154 
155  const fvsPatchField<scalar>& phip =
156  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
157 
158  if (psiName_ == "none" && rhoName_ == "none")
159  {
160  operator==(p0 - 0.5*(1.0 - pos(phip))*magSqr(Up));
161  }
162  else if (rhoName_ == "none")
163  {
164  const fvPatchField<scalar>& psip =
165  patch().lookupPatchField<volScalarField, scalar>(psiName_);
166 
167  if (gamma_ > 1.0)
168  {
169  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
170 
171  operator==
172  (
173  p0
174  /pow
175  (
176  (1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)),
177  1.0/gM1ByG
178  )
179  );
180  }
181  else
182  {
183  operator==(p0/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up)));
184  }
185  }
186  else if (psiName_ == "none")
187  {
188  const fvPatchField<scalar>& rho =
189  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
190 
191  operator==(p0 - 0.5*rho*(1.0 - pos(phip))*magSqr(Up));
192  }
193  else
194  {
196  << " rho or psi set inconsitently, rho = " << rhoName_
197  << ", psi = " << psiName_ << ".\n"
198  << " Set either rho or psi or neither depending on the "
199  "definition of total pressure.\n"
200  << " Set the unused variables to 'none'.\n"
201  << " on patch " << this->patch().name()
202  << " of field " << this->dimensionedInternalField().name()
203  << " in file " << this->dimensionedInternalField().objectPath()
204  << exit(FatalError);
205  }
206 
207  fixedValueFvPatchScalarField::updateCoeffs();
208 }
209 
210 
212 {
213  updateCoeffs(patch().lookupPatchField<volVectorField, vector>(UName_));
214 }
215 
216 
218 {
220  writeEntryIfDifferent<word>(os, "U", "U", UName_);
221  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
222  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
223  os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
224  os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
225  pressure_->writeData(os);
226  writeEntry("value", os);
227 }
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 namespace Foam
233 {
235  (
238  );
239 }
240 
241 // ************************************************************************* //
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::uniformTotalPressureFvPatchScalarField::uniformTotalPressureFvPatchScalarField
uniformTotalPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: uniformTotalPressureFvPatchScalarField.C:36
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::uniformTotalPressureFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: uniformTotalPressureFvPatchScalarField.C:217
Foam::uniformTotalPressureFvPatchScalarField::phiName_
word phiName_
Name of the flux transporting the field.
Definition: uniformTotalPressureFvPatchScalarField.H:136
dimensionedInternalField
rDeltaT dimensionedInternalField()
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Foam::uniformTotalPressureFvPatchScalarField::gamma_
scalar gamma_
Heat capacity ratio.
Definition: uniformTotalPressureFvPatchScalarField.H:146
Foam::uniformTotalPressureFvPatchScalarField
This boundary condition provides a time-varying form of the uniform total pressure boundary condition...
Definition: uniformTotalPressureFvPatchScalarField.H:126
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::uniformTotalPressureFvPatchScalarField::rhoName_
word rhoName_
Name of the density field used to normalise the mass flux.
Definition: uniformTotalPressureFvPatchScalarField.H:140
Foam::uniformTotalPressureFvPatchScalarField::psiName_
word psiName_
Name of the compressibility field used to calculate the wave speed.
Definition: uniformTotalPressureFvPatchScalarField.H:143
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: uniformTotalPressureFvPatchScalarField.C:211
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
Foam::uniformTotalPressureFvPatchScalarField::UName_
word UName_
Name of the velocity field.
Definition: uniformTotalPressureFvPatchScalarField.H:133
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::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
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
uniformTotalPressureFvPatchScalarField.H
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
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::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::uniformTotalPressureFvPatchScalarField::pressure_
autoPtr< DataEntry< scalar > > pressure_
Table of time vs total pressure, including the bounding treatment.
Definition: uniformTotalPressureFvPatchScalarField.H:149
Foam::DataEntry
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: DataEntry.H:52
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::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190