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-------------------------------------------------------------------------------
11License
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
35Foam::freestreamPressureFvPatchScalarField::
36freestreamPressureFvPatchScalarField
37(
38 const fvPatch& p,
40)
41:
42 mixedFvPatchScalarField(p, iF),
43 UName_("U")
44{}
45
46
47Foam::freestreamPressureFvPatchScalarField::
48freestreamPressureFvPatchScalarField
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() = scalarField("freestreamValue", dict, p.size());
59
60 if (dict.found("value"))
61 {
63 (
64 scalarField("value", dict, p.size())
65 );
66 }
67 else
68 {
70 }
71
72 refGrad() = Zero;
73 valueFraction() = 0;
74}
75
76
77Foam::freestreamPressureFvPatchScalarField::
78freestreamPressureFvPatchScalarField
79(
81 const fvPatch& p,
83 const fvPatchFieldMapper& mapper
84)
85:
86 mixedFvPatchScalarField(ptf, p, iF, mapper),
87 UName_(ptf.UName_)
88{}
89
90
91Foam::freestreamPressureFvPatchScalarField::
92freestreamPressureFvPatchScalarField
93(
95)
96:
97 mixedFvPatchScalarField(wbppsf),
98 UName_(wbppsf.UName_)
99{}
100
101
102Foam::freestreamPressureFvPatchScalarField::
103freestreamPressureFvPatchScalarField
104(
107)
108:
109 mixedFvPatchScalarField(wbppsf, iF),
110 UName_(wbppsf.UName_)
111{}
112
113
114// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115
117{
118 if (updated())
119 {
120 return;
121 }
122
123 const Field<vector>& Up =
124 patch().template lookupPatchField<volVectorField, vector>
125 (
126 UName_
127 );
128
129 valueFraction() = 0.5 + 0.5*(Up & patch().nf())/mag(Up);
130
132}
133
134
136{
138 os.writeEntryIfDifferent<word>("U", "U", UName_);
139 freestreamValue().writeEntry("freestreamValue", os);
140 writeEntry("value", os);
141}
142
143
144// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145
146namespace Foam
147{
149 (
152 );
153}
154
155// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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:251
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
This boundary condition provides a free-stream condition for pressure.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual bool write()
Write the output fields.
A FieldMapper for finite-volume patch fields.
virtual void operator=(const UList< scalar > &)
Definition: fvPatchField.C:408
friend Ostream & operator(Ostream &, const fvPatchField< scalar > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Definition: fvPatchField.H:676
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
dictionary dict