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

fluxCorrectedVelocityFvPatchVectorField.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 "fluxCorrectedVelocityFvPatchVectorField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "surfaceFields.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 Foam::fluxCorrectedVelocityFvPatchVectorField::
00038 fluxCorrectedVelocityFvPatchVectorField
00039 (
00040     const fvPatch& p,
00041     const DimensionedField<vector, volMesh>& iF
00042 )
00043 :
00044     zeroGradientFvPatchVectorField(p, iF),
00045     phiName_("phi"),
00046     rhoName_("rho")
00047 {}
00048 
00049 
00050 Foam::fluxCorrectedVelocityFvPatchVectorField::
00051 fluxCorrectedVelocityFvPatchVectorField
00052 (
00053     const fluxCorrectedVelocityFvPatchVectorField& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<vector, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     zeroGradientFvPatchVectorField(ptf, p, iF, mapper),
00060     phiName_(ptf.phiName_),
00061     rhoName_(ptf.rhoName_)
00062 {}
00063 
00064 
00065 Foam::fluxCorrectedVelocityFvPatchVectorField::
00066 fluxCorrectedVelocityFvPatchVectorField
00067 (
00068     const fvPatch& p,
00069     const DimensionedField<vector, volMesh>& iF,
00070     const dictionary& dict
00071 )
00072 :
00073     zeroGradientFvPatchVectorField(p, iF),
00074     phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00075     rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
00076 {
00077     fvPatchVectorField::operator=(patchInternalField());
00078 }
00079 
00080 
00081 Foam::fluxCorrectedVelocityFvPatchVectorField::
00082 fluxCorrectedVelocityFvPatchVectorField
00083 (
00084     const fluxCorrectedVelocityFvPatchVectorField& fcvpvf,
00085     const DimensionedField<vector, volMesh>& iF
00086 )
00087 :
00088     zeroGradientFvPatchVectorField(fcvpvf, iF),
00089     phiName_(fcvpvf.phiName_),
00090     rhoName_(fcvpvf.rhoName_)
00091 {}
00092 
00093 
00094 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00095 
00096 void Foam::fluxCorrectedVelocityFvPatchVectorField::evaluate
00097 (
00098     const Pstream::commsTypes
00099 )
00100 {
00101     if (!updated())
00102     {
00103         updateCoeffs();
00104     }
00105 
00106     zeroGradientFvPatchVectorField::evaluate();
00107 
00108     const surfaceScalarField& phi =
00109         db().lookupObject<surfaceScalarField>(phiName_);
00110 
00111     const fvsPatchField<scalar>& phip =
00112         patch().patchField<surfaceScalarField, scalar>(phi);
00113 
00114     vectorField n = patch().nf();
00115     const Field<scalar>& magS = patch().magSf();
00116 
00117     if (phi.dimensions() == dimVelocity*dimArea)
00118     {
00119         operator==(*this - n*(n & *this) + n*phip/magS);
00120     }
00121     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00122     {
00123         const fvPatchField<scalar>& rhop =
00124             patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00125 
00126         operator==(*this - n*(n & *this) + n*phip/(rhop*magS));
00127     }
00128     else
00129     {
00130         FatalErrorIn
00131         (
00132             "fluxCorrectedVelocityFvPatchVectorField::evaluate()"
00133         )
00134             << "dimensions of phi are incorrect\n"
00135             << "    on patch " << this->patch().name()
00136             << " of field " << this->dimensionedInternalField().name()
00137             << " in file " << this->dimensionedInternalField().objectPath()
00138             << exit(FatalError);
00139     }
00140 }
00141 
00142 
00143 void Foam::fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const
00144 {
00145     fvPatchVectorField::write(os);
00146     if (phiName_ != "phi")
00147     {
00148         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00149     }
00150     if (rhoName_ != "rho")
00151     {
00152         os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
00153     }
00154     writeEntry("value", os);
00155 }
00156 
00157 
00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00159 
00160 namespace Foam
00161 {
00162     makePatchTypeField
00163     (
00164         fvPatchVectorField,
00165         fluxCorrectedVelocityFvPatchVectorField
00166     );
00167 }
00168 
00169 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd