BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / dsmc / submodels / BinaryCollisionModel / VariableHardSphere / VariableHardSphere.C
blob1aa69335e1ea36c10bc496266ef0854adbba29f0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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 "VariableHardSphere.H"
27 #include "constants.H"
29 using namespace Foam::constant::mathematical;
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 template <class CloudType>
34 Foam::VariableHardSphere<CloudType>::VariableHardSphere
36     const dictionary& dict,
37     CloudType& cloud
40     BinaryCollisionModel<CloudType>(dict, cloud, typeName),
41     Tref_(readScalar(this->coeffDict().lookup("Tref")))
45 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
47 template <class CloudType>
48 Foam::VariableHardSphere<CloudType>::~VariableHardSphere()
52 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
54 template<class CloudType>
55 bool Foam::VariableHardSphere<CloudType>::active() const
57     return true;
61 template <class CloudType>
62 Foam::scalar Foam::VariableHardSphere<CloudType>::sigmaTcR
64     const typename CloudType::parcelType& pP,
65     const typename CloudType::parcelType& pQ
66 ) const
68     const CloudType& cloud(this->owner());
70     label typeIdP = pP.typeId();
71     label typeIdQ = pQ.typeId();
73     scalar dPQ =
74         0.5
75        *(
76             cloud.constProps(typeIdP).d()
77           + cloud.constProps(typeIdQ).d()
78         );
80     scalar omegaPQ =
81         0.5
82        *(
83             cloud.constProps(typeIdP).omega()
84           + cloud.constProps(typeIdQ).omega()
85         );
87     scalar cR = mag(pP.U() - pQ.U());
89     if (cR < VSMALL)
90     {
91         return 0;
92     }
94     scalar mP = cloud.constProps(typeIdP).mass();
96     scalar mQ = cloud.constProps(typeIdQ).mass();
98     scalar mR = mP*mQ/(mP + mQ);
100     // calculating cross section = pi*dPQ^2, where dPQ is from Bird, eq. 4.79
101     scalar sigmaTPQ =
102         pi*dPQ*dPQ
103        *pow(2.0*physicoChemical::k.value()*Tref_/(mR*cR*cR), omegaPQ - 0.5)
104        /exp(Foam::lgamma(2.5 - omegaPQ));
106     return sigmaTPQ*cR;
110 template <class CloudType>
111 void Foam::VariableHardSphere<CloudType>::collide
113     typename CloudType::parcelType& pP,
114     typename CloudType::parcelType& pQ
117     CloudType& cloud(this->owner());
119     label typeIdP = pP.typeId();
120     label typeIdQ = pQ.typeId();
121     vector& UP = pP.U();
122     vector& UQ = pQ.U();
124     Random& rndGen(cloud.rndGen());
126     scalar mP = cloud.constProps(typeIdP).mass();
128     scalar mQ = cloud.constProps(typeIdQ).mass();
130     vector Ucm = (mP*UP + mQ*UQ)/(mP + mQ);
132     scalar cR = mag(UP - UQ);
134     scalar cosTheta = 2.0*rndGen.scalar01() - 1.0;
136     scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
138     scalar phi = twoPi*rndGen.scalar01();
140     vector postCollisionRelU =
141         cR
142        *vector
143         (
144             cosTheta,
145             sinTheta*cos(phi),
146             sinTheta*sin(phi)
147         );
149     UP = Ucm + postCollisionRelU*mQ/(mP + mQ);
151     UQ = Ucm - postCollisionRelU*mP/(mP + mQ);
155 // ************************************************************************* //