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

MaxwellianThermal.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) 2009-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 "MaxwellianThermal.H"
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 template <class CloudType>
00032 Foam::MaxwellianThermal<CloudType>::MaxwellianThermal
00033 (
00034     const dictionary& dict,
00035     CloudType& cloud
00036 )
00037 :
00038     WallInteractionModel<CloudType>(dict, cloud, typeName)
00039 {}
00040 
00041 
00042 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00043 
00044 template <class CloudType>
00045 Foam::MaxwellianThermal<CloudType>::~MaxwellianThermal()
00046 {}
00047 
00048 
00049 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00050 
00051 template <class CloudType>
00052 void Foam::MaxwellianThermal<CloudType>::correct
00053 (
00054     const wallPolyPatch& wpp,
00055     const label faceId,
00056     vector& U,
00057     scalar& Ei,
00058     label typeId
00059 )
00060 {
00061     label wppIndex = wpp.index();
00062 
00063     label wppLocalFace = wpp.whichFace(faceId);
00064 
00065     vector nw = wpp.faceAreas()[wppLocalFace];
00066 
00067     // Normal unit vector
00068     nw /= mag(nw);
00069 
00070     // Normal velocity magnitude
00071     scalar magUn = U & nw;
00072 
00073     // Wall tangential velocity (flow direction)
00074     vector Ut = U - magUn*nw;
00075 
00076     CloudType& cloud(this->owner());
00077 
00078     Random& rndGen(cloud.rndGen());
00079 
00080     while (mag(Ut) < SMALL)
00081     {
00082         // If the incident velocity is parallel to the face normal, no
00083         // tangential direction can be chosen.  Add a perturbation to the
00084         // incoming velocity and recalculate.
00085 
00086         U = vector
00087         (
00088             U.x()*(0.8 + 0.2*rndGen.scalar01()),
00089             U.y()*(0.8 + 0.2*rndGen.scalar01()),
00090             U.z()*(0.8 + 0.2*rndGen.scalar01())
00091         );
00092 
00093         magUn = U & nw;
00094 
00095         Ut = U - magUn*nw;
00096     }
00097 
00098     // Wall tangential unit vector
00099     vector tw1 = Ut/mag(Ut);
00100 
00101     // Other tangential unit vector
00102     vector tw2 = nw^tw1;
00103 
00104     scalar T = cloud.T().boundaryField()[wppIndex][wppLocalFace];
00105 
00106     scalar mass = cloud.constProps(typeId).mass();
00107 
00108     scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom();
00109 
00110     U =
00111         sqrt(CloudType::kb*T/mass)
00112        *(
00113             rndGen.GaussNormal()*tw1
00114           + rndGen.GaussNormal()*tw2
00115           - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
00116         );
00117 
00118     U += cloud.U().boundaryField()[wppIndex][wppLocalFace];
00119 
00120     Ei = cloud.equipartitionInternalEnergy(T, iDof);
00121 }
00122 
00123 
00124 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd