1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "MaxwellianThermal.H"
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 template <class CloudType>
31 Foam::MaxwellianThermal<CloudType>::MaxwellianThermal
33 const dictionary& dict,
37 WallInteractionModel<CloudType>(dict, cloud, typeName)
41 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
43 template <class CloudType>
44 Foam::MaxwellianThermal<CloudType>::~MaxwellianThermal()
48 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
50 template <class CloudType>
51 void Foam::MaxwellianThermal<CloudType>::correct
53 const wallPolyPatch& wpp,
60 label wppIndex = wpp.index();
62 label wppLocalFace = wpp.whichFace(faceId);
64 vector nw = wpp.faceAreas()[wppLocalFace];
69 // Normal velocity magnitude
70 scalar magUn = U & nw;
72 // Wall tangential velocity (flow direction)
73 vector Ut = U - magUn*nw;
75 CloudType& cloud(this->owner());
77 Random& rndGen(cloud.rndGen());
79 while (mag(Ut) < SMALL)
81 // If the incident velocity is parallel to the face normal, no
82 // tangential direction can be chosen. Add a perturbation to the
83 // incoming velocity and recalculate.
87 U.x()*(0.8 + 0.2*rndGen.scalar01()),
88 U.y()*(0.8 + 0.2*rndGen.scalar01()),
89 U.z()*(0.8 + 0.2*rndGen.scalar01())
97 // Wall tangential unit vector
98 vector tw1 = Ut/mag(Ut);
100 // Other tangential unit vector
103 scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace];
105 scalar mass = cloud.constProps(typeId).mass();
107 scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom();
110 sqrt(CloudType::kb*T/mass)
112 rndGen.GaussNormal()*tw1
113 + rndGen.GaussNormal()*tw2
114 - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
117 U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
119 Ei = cloud.equipartitionInternalEnergy(T, iDof);
123 // ************************************************************************* //