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

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