1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "MaxwellianThermal.H"
27 #include "constants.H"
29 using namespace Foam::constant;
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 template <class CloudType>
34 Foam::MaxwellianThermal<CloudType>::MaxwellianThermal
36 const dictionary& dict,
40 WallInteractionModel<CloudType>(cloud)
44 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
46 template <class CloudType>
47 Foam::MaxwellianThermal<CloudType>::~MaxwellianThermal()
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53 template <class CloudType>
54 void Foam::MaxwellianThermal<CloudType>::correct
56 typename CloudType::parcelType& p,
57 const wallPolyPatch& wpp
64 label typeId = p.typeId();
66 label wppIndex = wpp.index();
68 label wppLocalFace = wpp.whichFace(p.face());
70 vector nw = p.normal();
73 // Normal velocity magnitude
74 scalar U_dot_nw = U & nw;
76 // Wall tangential velocity (flow direction)
77 vector Ut = U - U_dot_nw*nw;
79 CloudType& cloud(this->owner());
81 Random& rndGen(cloud.rndGen());
83 while (mag(Ut) < SMALL)
85 // If the incident velocity is parallel to the face normal, no
86 // tangential direction can be chosen. Add a perturbation to the
87 // incoming velocity and recalculate.
91 U.x()*(0.8 + 0.2*rndGen.scalar01()),
92 U.y()*(0.8 + 0.2*rndGen.scalar01()),
93 U.z()*(0.8 + 0.2*rndGen.scalar01())
101 // Wall tangential unit vector
102 vector tw1 = Ut/mag(Ut);
104 // Other tangential unit vector
107 scalar T = cloud.boundaryT().boundaryField()[wppIndex][wppLocalFace];
109 scalar mass = cloud.constProps(typeId).mass();
111 scalar iDof = cloud.constProps(typeId).internalDegreesOfFreedom();
114 sqrt(physicoChemical::k.value()*T/mass)
116 rndGen.GaussNormal()*tw1
117 + rndGen.GaussNormal()*tw2
118 - sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
121 U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
123 Ei = cloud.equipartitionInternalEnergy(T, iDof);
127 // ************************************************************************* //