FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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