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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2018 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 
30 #include "volFields.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
37 (
38  const fvPatch& p,
40 )
41 :
42  mixedFvPatchScalarField(p, iF),
43  UName_("U")
44 {}
45 
46 
49 (
50  const fvPatch& p,
52  const dictionary& dict
53 )
54 :
55  mixedFvPatchScalarField(p, iF),
56  UName_(dict.getOrDefault<word>("U", "U"))
57 {
58  // freestreamValue() and refValue() are identical
59  freestreamValue().assign("freestreamValue", dict, p.size());
60  refGrad() = Zero;
61  valueFraction() = 0;
62 
63  if (!this->readValueEntry(dict))
64  {
66  }
67 }
68 
69 
72 (
73  const freestreamPressureFvPatchScalarField& ptf,
74  const fvPatch& p,
75  const DimensionedField<scalar, volMesh>& iF,
76  const fvPatchFieldMapper& mapper
77 )
78 :
79  mixedFvPatchScalarField(ptf, p, iF, mapper),
80  UName_(ptf.UName_)
81 {}
82 
83 
86 (
88 )
89 :
90  mixedFvPatchScalarField(wbppsf),
91  UName_(wbppsf.UName_)
92 {}
93 
94 
97 (
100 )
101 :
102  mixedFvPatchScalarField(wbppsf, iF),
103  UName_(wbppsf.UName_)
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
110 {
111  if (updated())
112  {
113  return;
114  }
115 
116  const Field<vector>& Up =
117  patch().template lookupPatchField<volVectorField>(UName_);
119  valueFraction() = 0.5 + 0.5*(Up & patch().nf())/mag(Up);
120 
122 }
123 
124 
126 {
128  os.writeEntryIfDifferent<word>("U", "U", UName_);
129  freestreamValue().writeEntry("freestreamValue", os);
131 }
132 
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 namespace Foam
137 {
139  (
141  freestreamPressureFvPatchScalarField
142  );
143 }
144 
145 // ************************************************************************* //
dictionary dict
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
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:70
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
Definition: fvPatchField.H:375
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:372
Macros for easy insertion into run-time selection tables.
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
Definition: word.H:63
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:336
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
void assign(const entry &e, const label len)
Assign from a primitive dictionary entry with the following behaviour:
Definition: Field.C:207
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:309
virtual void operator=(const UList< scalar > &)
Definition: fvPatchField.C:391
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const std::string patch
OpenFOAM patch number as a std::string.
volScalarField & p
This boundary condition provides a free-stream condition for pressure.
const scalarField & freestreamValue() const
Same as refValue()
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127