1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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,
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,
61 label wppIndex = wpp.index();
63 label wppLocalFace = wpp.whichFace(faceId);
65 vector nw = wpp.faceAreas()[wppLocalFace];
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)
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.
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())
98 // Wall tangential unit vector
99 vector tw1 = Ut/mag(Ut);
101 // Other tangential unit vector
104 scalar T = cloud.T().boundaryField()[wppIndex][wppLocalFace];
106 scalar mass = cloud.constProps(typeId).mass();
108 scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom();
111 sqrt(CloudType::kb*T/mass)
113 rndGen.GaussNormal()*tw1
114 + rndGen.GaussNormal()*tw2
115 - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
118 U += cloud.U().boundaryField()[wppIndex][wppLocalFace];
120 Ei = cloud.equipartitionInternalEnergy(T, iDof);
124 // ************************************************************************* //