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

uniformDensityHydrostaticPressureFvPatchScalarField.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 "uniformDensityHydrostaticPressureFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "surfaceFields.H"
00032 #include "uniformDimensionedFields.H"
00033 
00034 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00035 
00036 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
00037 uniformDensityHydrostaticPressureFvPatchScalarField
00038 (
00039     const fvPatch& p,
00040     const DimensionedField<scalar, volMesh>& iF
00041 )
00042 :
00043     fixedValueFvPatchScalarField(p, iF),
00044     rho_(0.0),
00045     pRefValue_(0.0),
00046     pRefPoint_(vector::zero)
00047 {}
00048 
00049 
00050 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
00051 uniformDensityHydrostaticPressureFvPatchScalarField
00052 (
00053     const fvPatch& p,
00054     const DimensionedField<scalar, volMesh>& iF,
00055     const dictionary& dict
00056 )
00057 :
00058     fixedValueFvPatchScalarField(p, iF),
00059     rho_(readScalar(dict.lookup("rho"))),
00060     pRefValue_(readScalar(dict.lookup("pRefValue"))),
00061     pRefPoint_(dict.lookup("pRefPoint"))
00062 {
00063     if (dict.found("value"))
00064     {
00065         fvPatchField<scalar>::operator=
00066         (
00067             scalarField("value", dict, p.size())
00068         );
00069     }
00070     else
00071     {
00072         evaluate();
00073     }
00074 }
00075 
00076 
00077 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
00078 uniformDensityHydrostaticPressureFvPatchScalarField
00079 (
00080     const uniformDensityHydrostaticPressureFvPatchScalarField& ptf,
00081     const fvPatch& p,
00082     const DimensionedField<scalar, volMesh>& iF,
00083     const fvPatchFieldMapper& mapper
00084 )
00085 :
00086     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00087     rho_(ptf.rho_),
00088     pRefValue_(ptf.pRefValue_),
00089     pRefPoint_(ptf.pRefPoint_)
00090 {}
00091 
00092 
00093 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
00094 uniformDensityHydrostaticPressureFvPatchScalarField
00095 (
00096     const uniformDensityHydrostaticPressureFvPatchScalarField& ptf
00097 )
00098 :
00099     fixedValueFvPatchScalarField(ptf),
00100     rho_(ptf.rho_),
00101     pRefValue_(ptf.pRefValue_),
00102     pRefPoint_(ptf.pRefPoint_)
00103 {}
00104 
00105 
00106 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
00107 uniformDensityHydrostaticPressureFvPatchScalarField
00108 (
00109     const uniformDensityHydrostaticPressureFvPatchScalarField& ptf,
00110     const DimensionedField<scalar, volMesh>& iF
00111 )
00112 :
00113     fixedValueFvPatchScalarField(ptf, iF),
00114     rho_(ptf.rho_),
00115     pRefValue_(ptf.pRefValue_),
00116     pRefPoint_(ptf.pRefPoint_)
00117 {}
00118 
00119 
00120 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00121 
00122 void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs()
00123 {
00124     if (updated())
00125     {
00126         return;
00127     }
00128 
00129     const uniformDimensionedVectorField& g =
00130         db().lookupObject<uniformDimensionedVectorField>("g");
00131 
00132     operator==
00133     (
00134         pRefValue_
00135       + rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_))
00136     );
00137 
00138     fixedValueFvPatchScalarField::updateCoeffs();
00139 }
00140 
00141 
00142 void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::write
00143 (
00144     Ostream& os
00145 ) const
00146 {
00147     fvPatchScalarField::write(os);
00148     os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl;
00149     os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl;
00150     os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl;
00151     writeEntry("value", os);
00152 }
00153 
00154 
00155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00156 
00157 namespace Foam
00158 {
00159     makePatchTypeField
00160     (
00161         fvPatchScalarField,
00162         uniformDensityHydrostaticPressureFvPatchScalarField
00163     );
00164 }
00165 
00166 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd