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

smoluchowskiJumpTFvPatchScalarField.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 "smoluchowskiJumpTFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "mathematicalConstants.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<scalar, volMesh>& iF
00044 )
00045 :
00046     mixedFvPatchScalarField(p, iF),
00047     accommodationCoeff_(1.0),
00048     Twall_(p.size(), 0.0),
00049     gamma_(1.4)
00050 {
00051     refValue() = 0.0;
00052     refGrad() = 0.0;
00053     valueFraction() = 0.0;
00054 }
00055 
00056 smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
00057 (
00058     const smoluchowskiJumpTFvPatchScalarField& ptf,
00059     const fvPatch& p,
00060     const DimensionedField<scalar, volMesh>& iF,
00061     const fvPatchFieldMapper& mapper
00062 )
00063 :
00064     mixedFvPatchScalarField(ptf, p, iF, mapper),
00065     accommodationCoeff_(ptf.accommodationCoeff_),
00066     Twall_(ptf.Twall_),
00067     gamma_(ptf.gamma_)
00068 {}
00069 
00070 
00071 smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
00072 (
00073     const fvPatch& p,
00074     const DimensionedField<scalar, volMesh>& iF,
00075     const dictionary& dict
00076 )
00077 :
00078     mixedFvPatchScalarField(p, iF),
00079     accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
00080     Twall_("Twall", dict, p.size()),
00081     gamma_(dict.lookupOrDefault<scalar>("gamma", 1.4))
00082 {
00083     if
00084     (
00085         mag(accommodationCoeff_) < SMALL
00086      || mag(accommodationCoeff_) > 2.0
00087     )
00088     {
00089         FatalIOErrorIn
00090         (
00091             "smoluchowskiJumpTFvPatchScalarField::"
00092             "smoluchowskiJumpTFvPatchScalarField"
00093             "("
00094             "    const fvPatch&,"
00095             "    const DimensionedField<scalar, volMesh>&,"
00096             "    const dictionary&"
00097             ")",
00098             dict
00099         )   << "unphysical accommodationCoeff specified"
00100             << "(0 < accommodationCoeff <= 1)" << endl
00101             << exit(FatalError);
00102     }
00103 
00104     if (dict.found("value"))
00105     {
00106         fvPatchField<scalar>::operator=
00107         (
00108             scalarField("value", dict, p.size())
00109         );
00110     }
00111     else
00112     {
00113         fvPatchField<scalar>::operator=(patchInternalField());
00114     }
00115 
00116     refValue() = *this;
00117     refGrad() = 0.0;
00118     valueFraction() = 0.0;
00119 }
00120 
00121 
00122 smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
00123 (
00124     const smoluchowskiJumpTFvPatchScalarField& ptpsf,
00125     const DimensionedField<scalar, volMesh>& iF
00126 )
00127 :
00128     mixedFvPatchScalarField(ptpsf, iF),
00129     accommodationCoeff_(ptpsf.accommodationCoeff_),
00130     Twall_(ptpsf.Twall_),
00131     gamma_(ptpsf.gamma_)
00132 {}
00133 
00134 
00135 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00136 
00137 // Map from self
00138 void smoluchowskiJumpTFvPatchScalarField::autoMap
00139 (
00140     const fvPatchFieldMapper& m
00141 )
00142 {
00143     mixedFvPatchScalarField::autoMap(m);
00144 }
00145 
00146 
00147 // Reverse-map the given fvPatchField onto this fvPatchField
00148 void smoluchowskiJumpTFvPatchScalarField::rmap
00149 (
00150     const fvPatchField<scalar>& ptf,
00151     const labelList& addr
00152 )
00153 {
00154     mixedFvPatchField<scalar>::rmap(ptf, addr);
00155 }
00156 
00157 
00158 // Update the coefficients associated with the patch field
00159 void smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
00160 {
00161     if (updated())
00162     {
00163         return;
00164     }
00165 
00166     const fvPatchScalarField& pmu =
00167         patch().lookupPatchField<volScalarField, scalar>("mu");
00168     const fvPatchScalarField& prho =
00169         patch().lookupPatchField<volScalarField, scalar>("rho");
00170     const fvPatchField<scalar>& ppsi =
00171         patch().lookupPatchField<volScalarField, scalar>("psi");
00172     const fvPatchVectorField& pU =
00173         patch().lookupPatchField<volVectorField, vector>("U");
00174 
00175     // Prandtl number reading consistent with rhoCentralFoam
00176     const dictionary& thermophysicalProperties =
00177         db().lookupObject<IOdictionary>("thermophysicalProperties");
00178     dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0);
00179     if (thermophysicalProperties.found("Pr"))
00180     {
00181         Pr = thermophysicalProperties.lookup("Pr");
00182     }
00183 
00184     Field<scalar> C2 = pmu/prho
00185         *sqrt(ppsi*mathematicalConstant::pi/2.0)
00186         *2.0*gamma_/Pr.value()/(gamma_ + 1.0)
00187         *(2.0 - accommodationCoeff_)/accommodationCoeff_;
00188 
00189     Field<scalar> aCoeff = prho.snGrad() - prho/C2;
00190     Field<scalar> KEbyRho = 0.5*magSqr(pU);
00191 
00192     valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C2));
00193     refValue() = Twall_;
00194     refGrad() = 0.0;
00195 
00196     mixedFvPatchScalarField::updateCoeffs();
00197 }
00198 
00199 
00200 // Write
00201 void smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
00202 {
00203     fvPatchScalarField::write(os);
00204     os.writeKeyword("accommodationCoeff")
00205         << accommodationCoeff_ << token::END_STATEMENT << nl;
00206     Twall_.writeEntry("Twall", os);
00207     os.writeKeyword("gamma")
00208         << gamma_ << token::END_STATEMENT << nl;
00209     writeEntry("value", os);
00210 }
00211 
00212 
00213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00214 
00215 makePatchTypeField(fvPatchScalarField, smoluchowskiJumpTFvPatchScalarField);
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 } // End namespace Foam
00220 
00221 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd