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

maxwellSlipUFvPatchVectorField.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 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "maxwellSlipUFvPatchVectorField.H"
00030 #include "addToRunTimeSelectionTable.H"
00031 #include "mathematicalConstants.H"
00032 #include "fvPatchFieldMapper.H"
00033 #include "volFields.H"
00034 #include "surfaceFields.H"
00035 #include "fvCFD.H"
00036 
00037 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00038 
00039 namespace Foam
00040 {
00041 
00042 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00043 
00044 maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
00045 (
00046     const fvPatch& p,
00047     const DimensionedField<vector, volMesh>& iF
00048 )
00049 :
00050     mixedFixedValueSlipFvPatchVectorField(p, iF),
00051     accommodationCoeff_(1.0),
00052     Uwall_(p.size(), vector(0.0, 0.0, 0.0)),
00053     thermalCreep_(true),
00054     curvature_(true)
00055 {}
00056 
00057 
00058 maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
00059 (
00060     const maxwellSlipUFvPatchVectorField& tdpvf,
00061     const fvPatch& p,
00062     const DimensionedField<vector, volMesh>& iF,
00063     const fvPatchFieldMapper& mapper
00064 )
00065 :
00066     mixedFixedValueSlipFvPatchVectorField(tdpvf, p, iF, mapper),
00067     accommodationCoeff_(tdpvf.accommodationCoeff_),
00068     Uwall_(tdpvf.Uwall_),
00069     thermalCreep_(tdpvf.thermalCreep_),
00070     curvature_(tdpvf.curvature_)
00071 {}
00072 
00073 
00074 maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
00075 (
00076     const fvPatch& p,
00077     const DimensionedField<vector, volMesh>& iF,
00078     const dictionary& dict
00079 )
00080 :
00081     mixedFixedValueSlipFvPatchVectorField(p, iF),
00082     accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
00083     Uwall_("Uwall", dict, p.size()),
00084     thermalCreep_(dict.lookupOrDefault("thermalCreep", true)),
00085     curvature_(dict.lookupOrDefault("curvature", true))
00086 {
00087     if
00088     (
00089         mag(accommodationCoeff_) < SMALL
00090         ||
00091         mag(accommodationCoeff_) > 2.0
00092     )
00093     {
00094         FatalIOErrorIn
00095         (
00096             "maxwellSlipUFvPatchScalarField::"
00097             "maxwellSlipUFvPatchScalarField"
00098             "(const fvPatch&, const scalarField&, const dictionary&)",
00099             dict
00100         )   << "unphysical accommodationCoeff_ specified"
00101             << "(0 < accommodationCoeff_ <= 1)" << endl
00102             << exit(FatalError);
00103     }
00104 
00105     if (dict.found("value"))
00106     {
00107         fvPatchField<vector>::operator=
00108         (
00109             vectorField("value", dict, p.size())
00110         );
00111     }
00112     else
00113     {
00114         mixedFixedValueSlipFvPatchVectorField::evaluate();
00115     }
00116 }
00117 
00118 
00119 maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
00120 (
00121     const maxwellSlipUFvPatchVectorField& tdpvf,
00122     const DimensionedField<vector, volMesh>& iF
00123 )
00124 :
00125     mixedFixedValueSlipFvPatchVectorField(tdpvf, iF),
00126     accommodationCoeff_(tdpvf.accommodationCoeff_),
00127     Uwall_(tdpvf.Uwall_),
00128     thermalCreep_(tdpvf.thermalCreep_),
00129     curvature_(tdpvf.curvature_)
00130 {}
00131 
00132 
00133 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00134 
00135 // Update the coefficients associated with the patch field
00136 void maxwellSlipUFvPatchVectorField::updateCoeffs()
00137 {
00138     if (updated())
00139     {
00140         return;
00141     }
00142 
00143     const fvPatchScalarField& pmu =
00144         patch().lookupPatchField<volScalarField, scalar>("mu");
00145     const fvPatchScalarField& prho =
00146         patch().lookupPatchField<volScalarField, scalar>("rho");
00147     const fvPatchField<scalar>& ppsi =
00148         patch().lookupPatchField<volScalarField, scalar>("psi");
00149 
00150     Field<scalar> C1 = sqrt(ppsi*mathematicalConstant::pi/2.0)
00151         *(2.0 - accommodationCoeff_)/accommodationCoeff_;
00152 
00153     Field<scalar> pnu = pmu/prho;
00154     valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C1*pnu));
00155 
00156     refValue() = Uwall_;
00157 
00158     if(thermalCreep_)
00159     {
00160         const volScalarField& vsfT =
00161             this->db().objectRegistry::lookupObject<volScalarField>("T");
00162         label patchi = this->patch().index();
00163         const fvPatchScalarField& pT = vsfT.boundaryField()[patchi];
00164         Field<vector> gradpT = fvc::grad(vsfT)().boundaryField()[patchi];
00165         vectorField n = patch().nf();
00166 
00167         refValue() -= 3.0*pnu/(4.0*pT)*transform(I - n*n, gradpT);
00168     }
00169 
00170     if(curvature_)
00171     {
00172         const fvPatchTensorField& ptauMC =
00173             patch().lookupPatchField<volTensorField, tensor>("tauMC");
00174         vectorField n = patch().nf();
00175 
00176         refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
00177     }
00178 
00179     mixedFixedValueSlipFvPatchVectorField::updateCoeffs();
00180 }
00181 
00182 
00183 // Write
00184 void maxwellSlipUFvPatchVectorField::write(Ostream& os) const
00185 {
00186     fvPatchVectorField::write(os);
00187     os.writeKeyword("accommodationCoeff")
00188         << accommodationCoeff_ << token::END_STATEMENT << nl;
00189     Uwall_.writeEntry("Uwall", os);
00190     os.writeKeyword("thermalCreep")
00191         << thermalCreep_ << token::END_STATEMENT << nl;
00192     os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl;
00193 
00194     os.writeKeyword("refValue")
00195         << refValue() << token::END_STATEMENT << nl;
00196     os.writeKeyword("valueFraction")
00197         << valueFraction() << token::END_STATEMENT << nl;
00198 
00199     writeEntry("value", os);
00200 }
00201 
00202 
00203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00204 
00205 makePatchTypeField(fvPatchVectorField, maxwellSlipUFvPatchVectorField);
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 } // End namespace Foam
00210 
00211 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd