FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

buoyantPressureFvPatchScalarField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "buoyantPressureFvPatchScalarField.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/fvPatchFieldMapper.H>
00029 #include <finiteVolume/volFields.H>
00030 #include <OpenFOAM/uniformDimensionedFields.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00038 
00039 buoyantPressureFvPatchScalarField::
00040 buoyantPressureFvPatchScalarField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<scalar, volMesh>& iF
00044 )
00045 :
00046     fixedGradientFvPatchScalarField(p, iF),
00047     rhoName_("rho")
00048 {}
00049 
00050 
00051 buoyantPressureFvPatchScalarField::
00052 buoyantPressureFvPatchScalarField
00053 (
00054     const fvPatch& p,
00055     const DimensionedField<scalar, volMesh>& iF,
00056     const dictionary& dict
00057 )
00058 :
00059     fixedGradientFvPatchScalarField(p, iF),
00060     rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
00061 {
00062     fvPatchField<scalar>::operator=(patchInternalField());
00063     gradient() = 0.0;
00064 }
00065 
00066 
00067 buoyantPressureFvPatchScalarField::
00068 buoyantPressureFvPatchScalarField
00069 (
00070     const buoyantPressureFvPatchScalarField& ptf,
00071     const fvPatch& p,
00072     const DimensionedField<scalar, volMesh>& iF,
00073     const fvPatchFieldMapper& mapper
00074 )
00075 :
00076     fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
00077     rhoName_(ptf.rhoName_)
00078 {}
00079 
00080 
00081 buoyantPressureFvPatchScalarField::
00082 buoyantPressureFvPatchScalarField
00083 (
00084     const buoyantPressureFvPatchScalarField& ptf
00085 )
00086 :
00087     fixedGradientFvPatchScalarField(ptf),
00088     rhoName_(ptf.rhoName_)
00089 {}
00090 
00091 
00092 buoyantPressureFvPatchScalarField::
00093 buoyantPressureFvPatchScalarField
00094 (
00095     const buoyantPressureFvPatchScalarField& ptf,
00096     const DimensionedField<scalar, volMesh>& iF
00097 )
00098 :
00099     fixedGradientFvPatchScalarField(ptf, iF),
00100     rhoName_(ptf.rhoName_)
00101 {}
00102 
00103 
00104 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00105 
00106 void buoyantPressureFvPatchScalarField::updateCoeffs()
00107 {
00108     if (updated())
00109     {
00110         return;
00111     }
00112 
00113     const uniformDimensionedVectorField& g =
00114         db().lookupObject<uniformDimensionedVectorField>("g");
00115 
00116     const fvPatchField<scalar>& rho =
00117         patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00118 
00119     // If the variable name is "p_rgh", "ph_rgh" or "pd"
00120     // assume it is p? - rho*g.h and set the gradient appropriately.
00121     // Otherwise assume the variable is the static pressure.
00122     if
00123     (
00124         dimensionedInternalField().name() == "p_rgh"
00125      || dimensionedInternalField().name() == "ph_rgh"
00126      || dimensionedInternalField().name() == "pd"
00127     )
00128     {
00129         gradient() = -rho.snGrad()*(g.value() & patch().Cf());
00130     }
00131     else
00132     {
00133         gradient() = rho*(g.value() & patch().nf());
00134     }
00135 
00136     fixedGradientFvPatchScalarField::updateCoeffs();
00137 }
00138 
00139 
00140 void buoyantPressureFvPatchScalarField::write(Ostream& os) const
00141 {
00142     fixedGradientFvPatchScalarField::write(os);
00143     os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
00144     writeEntry("value", os);
00145 }
00146 
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 makePatchTypeField
00151 (
00152     fvPatchScalarField,
00153     buoyantPressureFvPatchScalarField
00154 );
00155 
00156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00157 
00158 } // End namespace Foam
00159 
00160 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines