1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "buoyantPressureFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "uniformDimensionedFields.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 buoyantPressureFvPatchScalarField::
40 buoyantPressureFvPatchScalarField
43 const DimensionedField<scalar, volMesh>& iF
46 fixedGradientFvPatchScalarField(p, iF),
51 buoyantPressureFvPatchScalarField::
52 buoyantPressureFvPatchScalarField
55 const DimensionedField<scalar, volMesh>& iF,
56 const dictionary& dict
59 fixedGradientFvPatchScalarField(p, iF),
60 rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
62 fvPatchField<scalar>::operator=(patchInternalField());
67 buoyantPressureFvPatchScalarField::
68 buoyantPressureFvPatchScalarField
70 const buoyantPressureFvPatchScalarField& ptf,
72 const DimensionedField<scalar, volMesh>& iF,
73 const fvPatchFieldMapper& mapper
76 fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
77 rhoName_(ptf.rhoName_)
81 buoyantPressureFvPatchScalarField::
82 buoyantPressureFvPatchScalarField
84 const buoyantPressureFvPatchScalarField& ptf
87 fixedGradientFvPatchScalarField(ptf),
88 rhoName_(ptf.rhoName_)
92 buoyantPressureFvPatchScalarField::
93 buoyantPressureFvPatchScalarField
95 const buoyantPressureFvPatchScalarField& ptf,
96 const DimensionedField<scalar, volMesh>& iF
99 fixedGradientFvPatchScalarField(ptf, iF),
100 rhoName_(ptf.rhoName_)
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 void buoyantPressureFvPatchScalarField::updateCoeffs()
113 // If variables are not found, evaluate as zero gradient
117 !db().foundObject<uniformDimensionedVectorField>("g")
118 || !db().foundObject<volScalarField>(rhoName_)
123 "void buoyantPressureFvPatchScalarField::updateCoeffs()"
124 ) << "Fields required for evaluation not found for patch "
125 << patch().name() << endl;
128 fixedGradientFvPatchScalarField::updateCoeffs();
133 const uniformDimensionedVectorField& g =
134 db().lookupObject<uniformDimensionedVectorField>("g");
136 const fvPatchField<scalar>& rho =
137 lookupPatchField<volScalarField, scalar>(rhoName_);
139 // If the variable name is "p_rgh" or "pd" assume it is p - rho*g.h
140 // and set the gradient appropriately.
141 // Otherwise assume the variable is the static pressure.
144 dimensionedInternalField().name() == "p_rgh"
145 || dimensionedInternalField().name() == "pd"
148 gradient() = -rho.snGrad()*(g.value() & patch().Cf());
152 gradient() = rho*(g.value() & patch().nf());
155 fixedGradientFvPatchScalarField::updateCoeffs();
159 void buoyantPressureFvPatchScalarField::write(Ostream& os) const
161 fixedGradientFvPatchScalarField::write(os);
162 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
163 writeEntry("value", os);
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 buoyantPressureFvPatchScalarField
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 } // End namespace Foam
179 // ************************************************************************* //