TrajectoryCollision.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "TrajectoryCollision.H"
29
30// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
31
32template<class CloudType>
34(
36 const scalar dt
37)
38{
40}
41
42
43template<class CloudType>
45(
46 const scalar dt,
47 parcelType& p1,
48 parcelType& p2,
49 scalar& m1,
50 scalar& m2
51)
52{
53 bool coalescence = false;
54
55 const vector pos1(p1.position());
56 const vector pos2(p2.position());
57
58 const vector& U1 = p1.U();
59 const vector& U2 = p2.U();
60
61 vector URel(U1 - U2);
62
63 vector d(pos2 - pos1);
64 scalar magd = mag(d);
65
66 scalar vAlign = URel & (d/(magd + ROOTVSMALL));
67
68 if (vAlign > 0)
69 {
70 const scalar d1 = p1.d();
71 const scalar d2 = p2.d();
72
73 scalar sumD = d1 + d2;
74
75 if (vAlign*dt > magd - 0.5*sumD)
76 {
77 scalar magU1 = mag(U1) + ROOTVSMALL;
78 scalar magU2 = mag(U2) + ROOTVSMALL;
79 vector n1 = U1/magU1;
80 vector n2 = U2/magU2;
81
82 scalar n1n2 = n1 & n2;
83 scalar n1d = n1 & d;
84 scalar n2d = n2 & d;
85
86 scalar det = 1.0 - sqr(n1n2);
87
88 scalar alpha = GREAT;
89 scalar beta = GREAT;
90
91 if (mag(det) > 1.0e-4)
92 {
93 beta = -(n2d - n1n2*n1d)/det;
94 alpha = n1d + n1n2*beta;
95 }
96
97 alpha /= magU1*dt;
98 beta /= magU2*dt;
99
100 // is collision possible within this timestep
101 if ((alpha > 0) && (alpha < 1.0) && (beta > 0) && (beta < 1.0))
102 {
103 vector p1c = pos1 + alpha*U1*dt;
104 vector p2c = pos2 + beta*U2*dt;
105
106 scalar closestDist = mag(p1c - p2c);
107
108 scalar collProb =
109 pow(0.5*sumD/max(0.5*sumD, closestDist), cSpace_)
110 *exp(-cTime_*mag(alpha - beta));
111
112 scalar xx = this->owner().rndGen().template sample01<scalar>();
113
114 // collision occurs
115 if (xx > collProb)
116 {
117 if (d1 > d2)
118 {
119 coalescence = this->collideSorted(dt, p1, p2, m1, m2);
120 }
121 else
122 {
123 coalescence = this->collideSorted(dt, p2, p1, m2, m1);
124 }
125 }
126 }
127 }
128 }
129
130 return coalescence;
131}
132
133
134// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
135
136template<class CloudType>
138(
139 const dictionary& dict,
140 CloudType& owner
141)
142:
143 ORourkeCollision<CloudType>(dict, owner, typeName),
144 cSpace_(this->coeffDict().getScalar("cSpace")),
145 cTime_(this->coeffDict().getScalar("cTime"))
146{}
147
148
149template<class CloudType>
151(
153)
154:
156 cSpace_(cm.cSpace_),
157 cTime_(cm.cTime_)
158{}
159
160
161// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
162
163template<class CloudType>
165{}
166
167
168// ************************************************************************* //
Y[inertIndex] max(0.0)
volVectorField & U1
volVectorField & U2
virtual void collide()=0
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
Collision model by P.J. O'Rourke.
Trajectory collision model by N. Nordin, based on O'Rourke's collision model.
virtual ~TrajectoryCollision()
Destructor.
virtual bool collideParcels(const scalar dt, parcelType &p1, parcelType &p2, scalar &m1, scalar &m2)
Collide parcels and return true if mass has changed.
CloudType::parcelType parcelType
Convenience typedef to the cloud's parcel type.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Class used to pass data into container.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
dimensionedScalar exp(const dimensionedScalar &ds)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
volScalarField & alpha
dictionary dict
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)