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 "MixedDiffuseSpecular.H"
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 template <class CloudType>
31 Foam::MixedDiffuseSpecular<CloudType>::MixedDiffuseSpecular
33 const dictionary& dict,
37 WallInteractionModel<CloudType>(dict, cloud, typeName),
38 diffuseFraction_(readScalar(this->coeffDict().lookup("diffuseFraction")))
42 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
44 template <class CloudType>
45 Foam::MixedDiffuseSpecular<CloudType>::~MixedDiffuseSpecular()
49 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
51 template <class CloudType>
52 void Foam::MixedDiffuseSpecular<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 U_dot_nw = U & nw;
73 CloudType& cloud(this->owner());
75 Random& rndGen(cloud.rndGen());
77 if (diffuseFraction_ > rndGen.scalar01())
81 // Wall tangential velocity (flow direction)
82 vector Ut = U - U_dot_nw*nw;
84 while (mag(Ut) < SMALL)
86 // If the incident velocity is parallel to the face normal, no
87 // tangential direction can be chosen. Add a perturbation to the
88 // incoming velocity and recalculate.
92 U.x()*(0.8 + 0.2*rndGen.scalar01()),
93 U.y()*(0.8 + 0.2*rndGen.scalar01()),
94 U.z()*(0.8 + 0.2*rndGen.scalar01())
102 // Wall tangential unit vector
103 vector tw1 = Ut/mag(Ut);
105 // Other tangential unit vector
108 scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace];
110 scalar mass = cloud.constProps(typeId).mass();
112 scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom();
115 sqrt(CloudType::kb*T/mass)
117 rndGen.GaussNormal()*tw1
118 + rndGen.GaussNormal()*tw2
119 - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
122 U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
124 Ei = cloud.equipartitionInternalEnergy(T, iDof);
128 // Specular reflection
132 U -= 2.0*U_dot_nw*nw;
139 // ************************************************************************* //