1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011-2011 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 "BrownianMotionForce.H"
27 #include "mathematicalConstants.H"
28 #include "demandDrivenData.H"
30 using namespace Foam::constant;
32 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
34 template<class CloudType>
35 Foam::scalar Foam::BrownianMotionForce<CloudType>::erfInv(const scalar y) const
37 const scalar a = 0.147;
38 scalar k = 2.0/(mathematical::pi*a) + 0.5*log(1.0 - y*y);
39 scalar h = log(1.0 - y*y)/a;
40 scalar x = sqrt(-k + sqrt(k*k - h));
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 template<class CloudType>
56 Foam::BrownianMotionForce<CloudType>::BrownianMotionForce
60 const dictionary& dict
63 ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
64 rndGen_(owner.rndGen()),
65 lambda_(readScalar(this->coeffs().lookup("lambda"))),
66 turbulence_(readBool(this->coeffs().lookup("turbulence"))),
67 turbulenceModelPtr_(NULL),
73 HashTable<const compressible::turbulenceModel*> models =
74 this->mesh().objectRegistry::template lookupClass
76 compressible::turbulenceModel
79 if (models.size() == 1)
81 turbulenceModelPtr_ = models.begin()();
87 "Foam::BrownianMotionForce<CloudType>::BrownianMotionForce"
93 ) << "Unable to find a valid turbulence model in mesh database"
100 template<class CloudType>
101 Foam::BrownianMotionForce<CloudType>::BrownianMotionForce
103 const BrownianMotionForce& bmf
106 ParticleForce<CloudType>(bmf),
107 rndGen_(bmf.rndGen_),
108 lambda_(bmf.lambda_),
109 turbulence_(bmf.turbulence_),
110 turbulenceModelPtr_(NULL),
116 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
118 template<class CloudType>
119 Foam::BrownianMotionForce<CloudType>::~BrownianMotionForce()
121 turbulenceModelPtr_ = NULL;
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127 template<class CloudType>
128 void Foam::BrownianMotionForce<CloudType>::cacheFields(const bool store)
134 tmp<volScalarField> tk = turbulenceModelPtr_->k();
142 kPtr_ = tk.operator->();
150 deleteDemandDrivenData(kPtr_);
158 template<class CloudType>
159 Foam::forceSuSp Foam::BrownianMotionForce<CloudType>::calcCoupled
161 const typename CloudType::parcelType& p,
168 forceSuSp value(vector::zero, 0.0);
170 const scalar dp = p.d();
171 const scalar Tc = p.Tc();
173 const scalar eta = rndGen_.sample01<scalar>();
174 const scalar alpha = 2.0*lambda_/dp;
175 const scalar cc = 1.0 + alpha*(1.257 + 0.4*exp(-1.1/alpha));
177 const scalar sigma = physicoChemical::sigma.value();
182 const label cellI = p.cell();
183 const volScalarField& k = *kPtr_;
184 const scalar kc = k[cellI];
185 const scalar Dp = sigma*Tc*cc/(3*mathematical::pi*muc*dp);
186 f = eta/mass*sqrt(2.0*sqr(kc)*sqr(Tc)/(Dp*dt));
190 const scalar rhoRatio = p.rho()/p.rhoc();
192 216*muc*sigma*Tc/(sqr(mathematical::pi)*pow5(dp)*(rhoRatio)*cc);
193 f = eta*sqrt(mathematical::pi*s0/dt);
196 const scalar sqrt2 = sqrt(2.0);
197 for (label i = 0; i < 3; i++)
199 const scalar x = rndGen_.sample01<scalar>();
200 const scalar eta = sqrt2*erfInv(2*x - 1.0);
201 value.Su()[i] = mass*f*eta;
208 // ************************************************************************* //