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

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