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

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