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 -------------------------------------------------------------------------------
10 License
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 
32 template<class CloudType>
34 (
35  typename CloudType::parcelType::trackingData& td,
36  const scalar dt
37 )
38 {
40 }
41 
42 
43 template<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 
136 template<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 
149 template<class CloudType>
151 (
153 )
154 :
156  cSpace_(cm.cSpace_),
157  cTime_(cm.cTime_)
158 {}
159 
160 
161 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
162 
163 template<class CloudType>
165 {}
166 
167 
168 // ************************************************************************* //
U1
volVectorField & U1
Definition: setRegionFluidFields.H:11
Foam::TrajectoryCollision::collideParcels
virtual bool collideParcels(const scalar dt, parcelType &p1, parcelType &p2, scalar &m1, scalar &m2)
Collide parcels and return true if mass has changed.
Definition: TrajectoryCollision.C:45
Foam::TrajectoryCollision::cTime_
scalar cTime_
Time coefficient.
Definition: TrajectoryCollision.H:63
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::exp
dimensionedScalar exp(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:261
TrajectoryCollision.H
Foam::ORourkeCollision
Collision model by P.J. O'Rourke.
Definition: ORourkeCollision.H:49
Foam::DSMCCloud::rndGen
Random & rndGen()
Return reference to the random object.
Definition: DSMCCloudI.H:124
Foam::TrajectoryCollision::~TrajectoryCollision
virtual ~TrajectoryCollision()
Destructor.
Definition: TrajectoryCollision.C:164
Foam::TrajectoryCollision::collide
virtual void collide(typename CloudType::parcelType::trackingData &td, const scalar dt)
Main collision routine.
Definition: TrajectoryCollision.C:34
beta
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
Foam::TrajectoryCollision::TrajectoryCollision
TrajectoryCollision(const dictionary &dict, CloudType &cloud)
Construct from dictionary.
Definition: TrajectoryCollision.C:138
Foam::TrajectoryCollision
Trajectory collision model by N. Nordin, based on O'Rourke's collision model.
Definition: TrajectoryCollision.H:48
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
U2
volVectorField & U2
Definition: setRegionFluidFields.H:15
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::ORourkeCollision::parcelType
CloudType::parcelType parcelType
Convenience typedef to the cloud's parcel type.
Definition: ORourkeCollision.H:58
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::TrajectoryCollision::cSpace_
scalar cSpace_
Space coefficient.
Definition: TrajectoryCollision.H:60
Foam::det
dimensionedScalar det(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:62