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

freestreamPressureFvPatchScalarField.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 "freestreamPressureFvPatchScalarField.H"
00028 #include "freestreamFvPatchFields.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "surfaceFields.H"
00032 #include "addToRunTimeSelectionTable.H"
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00040 
00041 freestreamPressureFvPatchScalarField::freestreamPressureFvPatchScalarField
00042 (
00043     const fvPatch& p,
00044     const DimensionedField<scalar, volMesh>& iF
00045 )
00046 :
00047     zeroGradientFvPatchScalarField(p, iF)
00048 {}
00049 
00050 
00051 freestreamPressureFvPatchScalarField::freestreamPressureFvPatchScalarField
00052 (
00053     const freestreamPressureFvPatchScalarField& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<scalar, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     zeroGradientFvPatchScalarField(ptf, p, iF, mapper)
00060 {}
00061 
00062 
00063 freestreamPressureFvPatchScalarField::freestreamPressureFvPatchScalarField
00064 (
00065     const fvPatch& p,
00066     const DimensionedField<scalar, volMesh>& iF,
00067     const dictionary& dict
00068 )
00069 :
00070     zeroGradientFvPatchScalarField(p, iF, dict)
00071 {}
00072 
00073 
00074 freestreamPressureFvPatchScalarField::freestreamPressureFvPatchScalarField
00075 (
00076     const freestreamPressureFvPatchScalarField& wbppsf
00077 )
00078 :
00079     zeroGradientFvPatchScalarField(wbppsf)
00080 {}
00081 
00082 
00083 freestreamPressureFvPatchScalarField::freestreamPressureFvPatchScalarField
00084 (
00085     const freestreamPressureFvPatchScalarField& wbppsf,
00086     const DimensionedField<scalar, volMesh>& iF
00087 )
00088 :
00089     zeroGradientFvPatchScalarField(wbppsf, iF)
00090 {}
00091 
00092 
00093 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00094 
00095 void freestreamPressureFvPatchScalarField::updateCoeffs()
00096 {
00097     if (updated())
00098     {
00099         return;
00100     }
00101 
00102     const freestreamFvPatchVectorField& Up = 
00103         refCast<const freestreamFvPatchVectorField>
00104         (
00105             patch().lookupPatchField<volVectorField, vector>("U")
00106         );
00107 
00108     const surfaceScalarField& phi = 
00109         db().lookupObject<surfaceScalarField>("phi");
00110 
00111     fvsPatchField<scalar>& phip =
00112         const_cast<fvsPatchField<scalar>&>
00113         (
00114             patch().patchField<surfaceScalarField, scalar>(phi)
00115         );
00116 
00117     if (phi.dimensions() == dimVelocity*dimArea)
00118     {
00119         phip = patch().Sf() & Up.freestreamValue();
00120     }
00121     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00122     {
00123         const fvPatchField<scalar>& rhop =
00124             patch().lookupPatchField<volScalarField, scalar>("rho");
00125 
00126         phip = rhop*(patch().Sf() & Up.freestreamValue());
00127     }
00128     else
00129     {
00130         FatalErrorIn("freestreamPressureFvPatchScalarField::updateCoeffs()")
00131             << "dimensions of phi are not correct"
00132             << "\n    on patch " << this->patch().name()
00133             << " of field " << this->dimensionedInternalField().name()
00134             << " in file " << this->dimensionedInternalField().objectPath()
00135             << exit(FatalError);
00136     }
00137 
00138     zeroGradientFvPatchScalarField::updateCoeffs();
00139 }
00140 
00141 
00142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00143 
00144 makePatchTypeField(fvPatchScalarField, freestreamPressureFvPatchScalarField);
00145 
00146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00147 
00148 } // End namespace Foam
00149 
00150 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd