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

pressureDirectedInletVelocityFvPatchVectorField.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 "pressureDirectedInletVelocityFvPatchVectorField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "surfaceFields.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 pressureDirectedInletVelocityFvPatchVectorField::
00041 pressureDirectedInletVelocityFvPatchVectorField
00042 (
00043     const fvPatch& p,
00044     const DimensionedField<vector, volMesh>& iF
00045 )
00046 :
00047     fixedValueFvPatchVectorField(p, iF),
00048     phiName_("phi"),
00049     rhoName_("rho"),
00050     inletDir_(p.size())
00051 {}
00052 
00053 
00054 pressureDirectedInletVelocityFvPatchVectorField::
00055 pressureDirectedInletVelocityFvPatchVectorField
00056 (
00057     const pressureDirectedInletVelocityFvPatchVectorField& ptf,
00058     const fvPatch& p,
00059     const DimensionedField<vector, volMesh>& iF,
00060     const fvPatchFieldMapper& mapper
00061 )
00062 :
00063     fixedValueFvPatchVectorField(ptf, p, iF, mapper),
00064     phiName_(ptf.phiName_),
00065     rhoName_(ptf.rhoName_),
00066     inletDir_(ptf.inletDir_, mapper)
00067 {}
00068 
00069 
00070 pressureDirectedInletVelocityFvPatchVectorField::
00071 pressureDirectedInletVelocityFvPatchVectorField
00072 (
00073     const fvPatch& p,
00074     const DimensionedField<vector, volMesh>& iF,
00075     const dictionary& dict
00076 )
00077 :
00078     fixedValueFvPatchVectorField(p, iF),
00079     phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00080     rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
00081     inletDir_("inletDirection", dict, p.size())
00082 {
00083     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
00084 }
00085 
00086 
00087 pressureDirectedInletVelocityFvPatchVectorField::
00088 pressureDirectedInletVelocityFvPatchVectorField
00089 (
00090     const pressureDirectedInletVelocityFvPatchVectorField& pivpvf
00091 )
00092 :
00093     fixedValueFvPatchVectorField(pivpvf),
00094     phiName_(pivpvf.phiName_),
00095     rhoName_(pivpvf.rhoName_),
00096     inletDir_(pivpvf.inletDir_)
00097 {}
00098 
00099 
00100 pressureDirectedInletVelocityFvPatchVectorField::
00101 pressureDirectedInletVelocityFvPatchVectorField
00102 (
00103     const pressureDirectedInletVelocityFvPatchVectorField& pivpvf,
00104     const DimensionedField<vector, volMesh>& iF
00105 )
00106 :
00107     fixedValueFvPatchVectorField(pivpvf, iF),
00108     phiName_(pivpvf.phiName_),
00109     rhoName_(pivpvf.rhoName_),
00110     inletDir_(pivpvf.inletDir_)
00111 {}
00112 
00113 
00114 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00115 
00116 void pressureDirectedInletVelocityFvPatchVectorField::autoMap
00117 (
00118     const fvPatchFieldMapper& m
00119 )
00120 {
00121     fixedValueFvPatchVectorField::autoMap(m);
00122     inletDir_.autoMap(m);
00123 }
00124 
00125 
00126 void pressureDirectedInletVelocityFvPatchVectorField::rmap
00127 (
00128     const fvPatchVectorField& ptf,
00129     const labelList& addr
00130 )
00131 {
00132     fixedValueFvPatchVectorField::rmap(ptf, addr);
00133 
00134     const pressureDirectedInletVelocityFvPatchVectorField& tiptf =
00135         refCast<const pressureDirectedInletVelocityFvPatchVectorField>(ptf);
00136 
00137     inletDir_.rmap(tiptf.inletDir_, addr);
00138 }
00139 
00140 
00141 void pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs()
00142 {
00143     if (updated())
00144     {
00145         return;
00146     }
00147 
00148     const surfaceScalarField& phi =
00149         db().lookupObject<surfaceScalarField>(phiName_);
00150 
00151     const fvsPatchField<scalar>& phip =
00152         patch().patchField<surfaceScalarField, scalar>(phi);
00153 
00154     vectorField n = patch().nf();
00155     scalarField ndmagS = (n & inletDir_)*patch().magSf();
00156 
00157     if (phi.dimensions() == dimVelocity*dimArea)
00158     {
00159         operator==(inletDir_*phip/ndmagS);
00160     }
00161     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00162     {
00163         const fvPatchField<scalar>& rhop =
00164             patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00165 
00166         operator==(inletDir_*phip/(rhop*ndmagS));
00167     }
00168     else
00169     {
00170         FatalErrorIn
00171         (
00172             "pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs()"
00173         )   << "dimensions of phi are not correct"
00174             << "\n    on patch " << this->patch().name()
00175             << " of field " << this->dimensionedInternalField().name()
00176             << " in file " << this->dimensionedInternalField().objectPath()
00177             << exit(FatalError);
00178     }
00179 
00180     fixedValueFvPatchVectorField::updateCoeffs();
00181 }
00182 
00183 
00184 void pressureDirectedInletVelocityFvPatchVectorField::write(Ostream& os) const
00185 {
00186     fvPatchVectorField::write(os);
00187     if (phiName_ != "phi")
00188     {
00189         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00190     }
00191     if (rhoName_ != "rho")
00192     {
00193         os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
00194     }
00195     inletDir_.writeEntry("inletDirection", os);
00196     writeEntry("value", os);
00197 }
00198 
00199 
00200 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00201 
00202 void pressureDirectedInletVelocityFvPatchVectorField::operator=
00203 (
00204     const fvPatchField<vector>& pvf
00205 )
00206 {
00207     fvPatchField<vector>::operator=(inletDir_*(inletDir_ & pvf));
00208 }
00209 
00210 
00211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00212 
00213 makePatchTypeField
00214 (
00215     fvPatchVectorField,
00216     pressureDirectedInletVelocityFvPatchVectorField
00217 );
00218 
00219 
00220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00221 
00222 } // End namespace Foam
00223 
00224 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd