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

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