initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / dsmc / submodels / WallInteractionModel / MaxwellianThermal / MaxwellianThermal.C
blobe7213561c0d2a2f2dacd103daeee8a74676c7aaf
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "MaxwellianThermal.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 template <class CloudType>
32 Foam::MaxwellianThermal<CloudType>::MaxwellianThermal
34     const dictionary& dict,
35     CloudType& cloud
38     WallInteractionModel<CloudType>(dict, cloud, typeName)
42 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
44 template <class CloudType>
45 Foam::MaxwellianThermal<CloudType>::~MaxwellianThermal()
49 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
51 template <class CloudType>
52 void Foam::MaxwellianThermal<CloudType>::correct
54     const wallPolyPatch& wpp,
55     const label faceId,
56     vector& U,
57     scalar& Ei,
58     label typeId
61     label wppIndex = wpp.index();
63     label wppLocalFace = wpp.whichFace(faceId);
65     vector nw = wpp.faceAreas()[wppLocalFace];
67     // Normal unit vector
68     nw /= mag(nw);
70     // Normal velocity magnitude
71     scalar magUn = U & nw;
73     // Wall tangential velocity (flow direction)
74     vector Ut = U - magUn*nw;
76     CloudType& cloud(this->owner());
78     Random& rndGen(cloud.rndGen());
80     while (mag(Ut) < SMALL)
81     {
82         // If the incident velocity is parallel to the face normal, no
83         // tangential direction can be chosen.  Add a perturbation to the
84         // incoming velocity and recalculate.
86         U = vector
87         (
88             U.x()*(0.8 + 0.2*rndGen.scalar01()),
89             U.y()*(0.8 + 0.2*rndGen.scalar01()),
90             U.z()*(0.8 + 0.2*rndGen.scalar01())
91         );
93         magUn = U & nw;
95         Ut = U - magUn*nw;
96     }
98     // Wall tangential unit vector
99     vector tw1 = Ut/mag(Ut);
101     // Other tangential unit vector
102     vector tw2 = nw^tw1;
104     scalar T = cloud.T().boundaryField()[wppIndex][wppLocalFace];
106     scalar mass = cloud.constProps(typeId).mass();
108     scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom();
110     U =
111         sqrt(CloudType::kb*T/mass)
112        *(
113             rndGen.GaussNormal()*tw1
114           + rndGen.GaussNormal()*tw2
115           - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
116         );
118     U += cloud.U().boundaryField()[wppIndex][wppLocalFace];
120     Ei = cloud.equipartitionInternalEnergy(T, iDof);
124 // ************************************************************************* //