freestreamPressureFvPatchScalarField.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-2016 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"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
37 (
38  const fvPatch& p,
40 )
41 :
42  zeroGradientFvPatchScalarField(p, iF),
43  UName_("U"),
44  phiName_("phi"),
45  rhoName_("rho")
46 {}
47 
48 
51 (
52  const fvPatch& p,
54  const dictionary& dict
55 )
56 :
57  zeroGradientFvPatchScalarField(p, iF, dict),
58  UName_(dict.lookupOrDefault<word>("U", "U")),
59  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
60  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
61 {}
62 
63 
66 (
68  const fvPatch& p,
70  const fvPatchFieldMapper& mapper
71 )
72 :
73  zeroGradientFvPatchScalarField(ptf, p, iF, mapper),
74  UName_(ptf.UName_),
75  phiName_(ptf.phiName_),
76  rhoName_(ptf.rhoName_)
77 {}
78 
79 
82 (
84 )
85 :
86  zeroGradientFvPatchScalarField(wbppsf),
87  UName_(wbppsf.UName_),
88  phiName_(wbppsf.phiName_),
89  rhoName_(wbppsf.rhoName_)
90 {}
91 
92 
95 (
98 )
99 :
100  zeroGradientFvPatchScalarField(wbppsf, iF),
101  UName_(wbppsf.UName_),
102  phiName_(wbppsf.phiName_),
103  rhoName_(wbppsf.rhoName_)
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
110 {
111  if (updated())
112  {
113  return;
114  }
115 
116  const freestreamFvPatchVectorField& Up =
117  refCast<const freestreamFvPatchVectorField>
118  (
119  patch().lookupPatchField<volVectorField, vector>(UName_)
120  );
121 
122  const surfaceScalarField& phi =
123  db().lookupObject<surfaceScalarField>(phiName_);
124 
125  fvsPatchField<scalar>& phip =
126  const_cast<fvsPatchField<scalar>&>
127  (
128  patch().patchField<surfaceScalarField, scalar>(phi)
129  );
130 
131  if (phi.dimensions() == dimVelocity*dimArea)
132  {
133  phip = patch().Sf() & Up.freestreamValue();
134  }
135  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
136  {
137  const fvPatchField<scalar>& rhop =
138  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
139 
140  phip = rhop*(patch().Sf() & Up.freestreamValue());
141  }
142  else
143  {
145  << "dimensions of phi are not correct"
146  << "\n on patch " << this->patch().name()
147  << " of field " << this->internalField().name()
148  << " in file " << this->internalField().objectPath()
149  << exit(FatalError);
150  }
151 
152  zeroGradientFvPatchScalarField::updateCoeffs();
153 }
154 
155 
157 {
159  writeEntryIfDifferent<word>(os, "U", "U", UName_);
160  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
161  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
162  writeEntry("value", os);
163 }
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 namespace Foam
169 {
171  (
174  );
175 }
176 
177 // ************************************************************************* //
Foam::surfaceFields.
surfaceScalarField & phi
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
freestreamPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
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:65
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
const dimensionSet & dimensions() const
Return dimensions.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const dimensionSet dimDensity
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
This boundary condition provides a free-stream condition for pressure. It is a zero-gradient conditio...
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Namespace for OpenFOAM.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:363
const dimensionSet dimVelocity