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

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