Generalised to support static pressure as well as "pd".
[OpenFOAM-1.5.x.git] / src / finiteVolume / fields / fvPatchFields / derived / fixedFluxBuoyantPressure / fixedFluxBuoyantPressureFvPatchScalarField.C
blobb6f48ff6ada8e214e41f83c848bafabdb32de46e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "fixedFluxBuoyantPressureFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
37 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
39 fixedFluxBuoyantPressureFvPatchScalarField::
40 fixedFluxBuoyantPressureFvPatchScalarField
42     const fvPatch& p,
43     const DimensionedField<scalar, volMesh>& iF
46     fixedGradientFvPatchScalarField(p, iF)
50 fixedFluxBuoyantPressureFvPatchScalarField::
51 fixedFluxBuoyantPressureFvPatchScalarField
53     const fixedFluxBuoyantPressureFvPatchScalarField& ptf,
54     const fvPatch& p,
55     const DimensionedField<scalar, volMesh>& iF,
56     const fvPatchFieldMapper& mapper
59     fixedGradientFvPatchScalarField(ptf, p, iF, mapper)
63 fixedFluxBuoyantPressureFvPatchScalarField::
64 fixedFluxBuoyantPressureFvPatchScalarField
66     const fvPatch& p,
67     const DimensionedField<scalar, volMesh>& iF,
68     const dictionary&
71     fixedGradientFvPatchScalarField(p, iF)
73     fvPatchField<scalar>::operator=(patchInternalField());
74     gradient() = 0.0;
78 fixedFluxBuoyantPressureFvPatchScalarField::
79 fixedFluxBuoyantPressureFvPatchScalarField
81     const fixedFluxBuoyantPressureFvPatchScalarField& wbppsf
84     fixedGradientFvPatchScalarField(wbppsf)
88 fixedFluxBuoyantPressureFvPatchScalarField::
89 fixedFluxBuoyantPressureFvPatchScalarField
91     const fixedFluxBuoyantPressureFvPatchScalarField& wbppsf,
92     const DimensionedField<scalar, volMesh>& iF
95     fixedGradientFvPatchScalarField(wbppsf, iF)
99 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
101 void fixedFluxBuoyantPressureFvPatchScalarField::updateCoeffs()
103     if (updated())
104     {
105         return;
106     }
108     const dictionary& environmentalProperties
109         = db().lookupObject<IOdictionary>("environmentalProperties");
111     dimensionedVector g(environmentalProperties.lookup("g"));
113     const fvPatchField<scalar>& rho =
114         patch().lookupPatchField<volScalarField, scalar>("rho");
116     // If the variable name is "pd" assume it is p - rho*g.h
117     // and set the gradient appropriately.
118     // Otherwise assume the variable is the static pressure.
119     if (dimensionedInternalField().name() == "pd")
120     {
121         gradient() = -rho.snGrad()*(g.value() & patch().Cf());
122     }
123     else
124     {
125         gradient() = rho*(g.value() & patch().nf());
126     }
128     fixedGradientFvPatchScalarField::updateCoeffs();
132 void fixedFluxBuoyantPressureFvPatchScalarField::write(Ostream& os) const
134     fixedGradientFvPatchScalarField::write(os);
135     writeEntry("value", os);
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 makePatchTypeField
143     fvPatchScalarField,
144     fixedFluxBuoyantPressureFvPatchScalarField
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 } // End namespace Foam
151 // ************************************************************************* //