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

inviscidWallPFvPatchScalarField.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 "inviscidWallPFvPatchScalarField.H"
00028 #include "fvPatchFieldMapper.H"
00029 #include "volFields.H"
00030 #include "surfaceFields.H"
00031 #include "addToRunTimeSelectionTable.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 inviscidWallPFvPatchScalarField::inviscidWallPFvPatchScalarField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<scalar, volMesh>& iF
00044 )
00045 :
00046     fixedGradientFvPatchScalarField(p, iF),
00047     fluxFraction_(1)
00048 {}
00049 
00050 
00051 inviscidWallPFvPatchScalarField::inviscidWallPFvPatchScalarField
00052 (
00053     const inviscidWallPFvPatchScalarField& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<scalar, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
00060     fluxFraction_(ptf.fluxFraction_)
00061 {}
00062 
00063 
00064 inviscidWallPFvPatchScalarField::inviscidWallPFvPatchScalarField
00065 (
00066     const fvPatch& p,
00067     const DimensionedField<scalar, volMesh>& iF,
00068     const dictionary& dict
00069 )
00070 :
00071     fixedGradientFvPatchScalarField(p, iF),
00072     fluxFraction_(readScalar(dict.lookup("fluxFraction")))
00073 {
00074     if (dict.found("gradient"))
00075     {
00076         gradient() = scalarField("gradient", dict, p.size());
00077         fixedGradientFvPatchScalarField::updateCoeffs();
00078         fixedGradientFvPatchScalarField::evaluate();
00079     }
00080     else
00081     {
00082         fvPatchField<scalar>::operator=(patchInternalField());
00083         gradient() = 0.0;
00084     }
00085 
00086     if (fluxFraction_<0.0 || fluxFraction_ > 1.0)
00087     {
00088         FatalIOErrorIn
00089         (
00090             "inviscidWallPFvPatchScalarField::"
00091             "supersonicFreeStreamFvPatchVectorField"
00092             "(const fvPatch&, const scalarField&, const dictionary&)",
00093             dict
00094         )   << "    unphysical fluxFraction specified (< 0.0 or > 1.0)"
00095             << exit(FatalIOError);
00096     }
00097 
00098 }
00099 
00100 
00101 inviscidWallPFvPatchScalarField::inviscidWallPFvPatchScalarField
00102 (
00103     const inviscidWallPFvPatchScalarField& wbppsf
00104 )
00105 :
00106     fixedGradientFvPatchScalarField(wbppsf),
00107     fluxFraction_(wbppsf.fluxFraction_)
00108 {}
00109 
00110 
00111 inviscidWallPFvPatchScalarField::inviscidWallPFvPatchScalarField
00112 (
00113     const inviscidWallPFvPatchScalarField& wbppsf,
00114     const DimensionedField<scalar, volMesh>& iF
00115 )
00116 :
00117     fixedGradientFvPatchScalarField(wbppsf, iF),
00118     fluxFraction_(wbppsf.fluxFraction_)
00119 {}
00120 
00121 
00122 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00123 
00124 void inviscidWallPFvPatchScalarField::updateCoeffs()
00125 {
00126     if (updated())
00127     {
00128         return;
00129     }
00130 
00131     const fvPatchField<vector>& rhoUp =
00132         patch().lookupPatchField<volVectorField, vector>("rhoU");
00133 
00134     const fvsPatchField<scalar>& phip = 
00135         patch().lookupPatchField<surfaceScalarField, scalar>("phi");
00136 
00137     const fvsPatchField<scalar>& rAp =
00138         patch().lookupPatchField<surfaceScalarField, scalar>("rrhoUAf");
00139 
00140     gradient() = (fluxFraction_*phip - (patch().Sf() & rhoUp))/
00141                  (rAp*patch().magSf());
00142 
00143     fixedGradientFvPatchScalarField::updateCoeffs();
00144 }
00145 
00146 
00147 void inviscidWallPFvPatchScalarField::write(Ostream& os) const
00148 {
00149     fixedGradientFvPatchScalarField::write(os);
00150     os.writeKeyword("fluxFraction") 
00151         << fluxFraction_ << token::END_STATEMENT << nl;
00152     writeEntry("value", os);
00153 }
00154 
00155 
00156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00157 
00158 makePatchTypeField(fvPatchScalarField, inviscidWallPFvPatchScalarField);
00159 
00160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00161 
00162 } // End namespace Foam
00163 
00164 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd