prghPressureFvPatchScalarField.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) 2013-2016 OpenFOAM Foundation
9 Copyright (C) 2018-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
31#include "fvPatchFieldMapper.H"
32#include "volFields.H"
33#include "gravityMeshObject.H"
34
35// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36
37Foam::prghPressureFvPatchScalarField::
38prghPressureFvPatchScalarField
39(
40 const fvPatch& p,
42)
43:
44 fixedValueFvPatchScalarField(p, iF),
45 rhoName_("rho"),
46 p_(p.size(), Zero)
47{}
48
49
50Foam::prghPressureFvPatchScalarField::
51prghPressureFvPatchScalarField
52(
53 const fvPatch& p,
55 const dictionary& dict
56)
57:
58 fixedValueFvPatchScalarField(p, iF, dict, false),
59 rhoName_(dict.getOrDefault<word>("rho", "rho")),
60 p_("p", dict, p.size())
61{
62 if (dict.found("value"))
63 {
65 (
66 scalarField("value", dict, p.size())
67 );
68 }
69 else
70 {
72 }
73}
74
75
76Foam::prghPressureFvPatchScalarField::
77prghPressureFvPatchScalarField
78(
80 const fvPatch& p,
82 const fvPatchFieldMapper& mapper
83)
84:
85 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
86 rhoName_(ptf.rhoName_),
87 p_(ptf.p_, mapper)
88{}
89
90
91Foam::prghPressureFvPatchScalarField::
92prghPressureFvPatchScalarField
93(
95)
96:
97 fixedValueFvPatchScalarField(ptf),
98 rhoName_(ptf.rhoName_),
99 p_(ptf.p_)
100{}
101
102
103Foam::prghPressureFvPatchScalarField::
104prghPressureFvPatchScalarField
105(
108)
109:
110 fixedValueFvPatchScalarField(ptf, iF),
111 rhoName_(ptf.rhoName_),
112 p_(ptf.p_)
113{}
114
115
116// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117
119(
120 const fvPatchFieldMapper& m
121)
122{
123 fixedValueFvPatchScalarField::autoMap(m);
124 p_.autoMap(m);
125}
126
127
129(
130 const fvPatchScalarField& ptf,
131 const labelList& addr
132)
133{
134 fixedValueFvPatchScalarField::rmap(ptf, addr);
135
136 const prghPressureFvPatchScalarField& tiptf =
137 refCast<const prghPressureFvPatchScalarField>(ptf);
138
139 p_.rmap(tiptf.p_, addr);
140}
141
142
144{
145 if (updated())
146 {
147 return;
148 }
149
150 const scalarField& rhop = patch().lookupPatchField<volScalarField, scalar>
151 (
152 rhoName_
153 );
154
156 meshObjects::gravity::New(db().time());
157
159 db().lookupObject<uniformDimensionedScalarField>("hRef");
160
162 (
163 mag(g.value()) > SMALL
164 ? g & (cmptMag(g.value())/mag(g.value()))*hRef
165 : dimensionedScalar("ghRef", g.dimensions()*dimLength, 0)
166 );
167
168 operator==(p_ - rhop*((g.value() & patch().Cf()) - ghRef.value()));
169
170 fixedValueFvPatchScalarField::updateCoeffs();
171}
172
173
175{
177 os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
178 p_.writeEntry("p", os);
179 writeEntry("value", os);
180}
181
182
183// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184
185namespace Foam
186{
188 (
191 );
192}
193
194// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
const uniformDimensionedVectorField & g
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
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
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
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
const dimensionSet & dimensions() const
Return const reference to dimensions.
const Type & value() const
Return const reference to value.
virtual bool write()
Write the output fields.
A FieldMapper for finite-volume patch fields.
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:408
friend Ostream & operator(Ostream &, const fvPatchField< scalar > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
This boundary condition provides static pressure condition for p_rgh, calculated as:
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
const scalarField & p() const
Return the static pressure.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
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.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
dictionary dict