OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "buoyantPressureFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "uniformDimensionedFields.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 buoyantPressureFvPatchScalarField::
00041 buoyantPressureFvPatchScalarField
00042 (
00043     const fvPatch& p,
00044     const DimensionedField<scalar, volMesh>& iF
00045 )
00046 :
00047     fixedGradientFvPatchScalarField(p, iF),
00048     rhoName_("rho")
00049 {}
00050 
00051 
00052 buoyantPressureFvPatchScalarField::
00053 buoyantPressureFvPatchScalarField
00054 (
00055     const fvPatch& p,
00056     const DimensionedField<scalar, volMesh>& iF,
00057     const dictionary& dict
00058 )
00059 :
00060     fixedGradientFvPatchScalarField(p, iF),
00061     rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
00062 {
00063     fvPatchField<scalar>::operator=(patchInternalField());
00064     gradient() = 0.0;
00065 }
00066 
00067 
00068 buoyantPressureFvPatchScalarField::
00069 buoyantPressureFvPatchScalarField
00070 (
00071     const buoyantPressureFvPatchScalarField& ptf,
00072     const fvPatch& p,
00073     const DimensionedField<scalar, volMesh>& iF,
00074     const fvPatchFieldMapper& mapper
00075 )
00076 :
00077     fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
00078     rhoName_(ptf.rhoName_)
00079 {}
00080 
00081 
00082 buoyantPressureFvPatchScalarField::
00083 buoyantPressureFvPatchScalarField
00084 (
00085     const buoyantPressureFvPatchScalarField& ptf
00086 )
00087 :
00088     fixedGradientFvPatchScalarField(ptf),
00089     rhoName_(ptf.rhoName_)
00090 {}
00091 
00092 
00093 buoyantPressureFvPatchScalarField::
00094 buoyantPressureFvPatchScalarField
00095 (
00096     const buoyantPressureFvPatchScalarField& ptf,
00097     const DimensionedField<scalar, volMesh>& iF
00098 )
00099 :
00100     fixedGradientFvPatchScalarField(ptf, iF),
00101     rhoName_(ptf.rhoName_)
00102 {}
00103 
00104 
00105 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00106 
00107 void buoyantPressureFvPatchScalarField::updateCoeffs()
00108 {
00109     if (updated())
00110     {
00111         return;
00112     }
00113 
00114     const uniformDimensionedVectorField& g =
00115         db().lookupObject<uniformDimensionedVectorField>("g");
00116 
00117     const fvPatchField<scalar>& rho =
00118         patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00119 
00120     // If the variable name is "pd" assume it is p - rho*g.h
00121     // and set the gradient appropriately.
00122     // Otherwise assume the variable is the static pressure.
00123     if (dimensionedInternalField().name() == "pd")
00124     {
00125         gradient() = -rho.snGrad()*(g.value() & patch().Cf());
00126     }
00127     else
00128     {
00129         gradient() = rho*(g.value() & patch().nf());
00130     }
00131 
00132     fixedGradientFvPatchScalarField::updateCoeffs();
00133 }
00134 
00135 
00136 void buoyantPressureFvPatchScalarField::write(Ostream& os) const
00137 {
00138     fixedGradientFvPatchScalarField::write(os);
00139     os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
00140     writeEntry("value", os);
00141 }
00142 
00143 
00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00145 
00146 makePatchTypeField
00147 (
00148     fvPatchScalarField,
00149     buoyantPressureFvPatchScalarField
00150 );
00151 
00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00153 
00154 } // End namespace Foam
00155 
00156 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd