mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
lagrangian::BrownianMotionForce: Changed from a cubic to a spherical distribution
See also: StochasticDispersionRAS Resolves bug-report http://bugs.openfoam.org/view.php?id=2153
This commit is contained in:
@ -160,7 +160,7 @@ protected:
|
|||||||
const dictionary subModelProperties_;
|
const dictionary subModelProperties_;
|
||||||
|
|
||||||
//- Random number generator - used by some injection routines
|
//- Random number generator - used by some injection routines
|
||||||
cachedRandom rndGen_;
|
mutable cachedRandom rndGen_;
|
||||||
|
|
||||||
//- Cell occupancy information for each parcel, (demand driven)
|
//- Cell occupancy information for each parcel, (demand driven)
|
||||||
autoPtr<List<DynamicList<parcelType*>>> cellOccupancyPtr_;
|
autoPtr<List<DynamicList<parcelType*>>> cellOccupancyPtr_;
|
||||||
@ -363,7 +363,7 @@ public:
|
|||||||
// Cloud data
|
// Cloud data
|
||||||
|
|
||||||
//- Return reference to the random object
|
//- Return reference to the random object
|
||||||
inline cachedRandom& rndGen();
|
inline cachedRandom& rndGen() const;
|
||||||
|
|
||||||
//- Return the cell occupancy information for each
|
//- Return the cell occupancy information for each
|
||||||
// parcel, non-const access, the caller is
|
// parcel, non-const access, the caller is
|
||||||
|
|||||||
@ -356,7 +356,7 @@ inline Foam::scalar Foam::KinematicCloud<CloudType>::Dmax() const
|
|||||||
|
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
inline Foam::cachedRandom& Foam::KinematicCloud<CloudType>::rndGen()
|
inline Foam::cachedRandom& Foam::KinematicCloud<CloudType>::rndGen() const
|
||||||
{
|
{
|
||||||
return rndGen_;
|
return rndGen_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -193,13 +193,28 @@ Foam::forceSuSp Foam::BrownianMotionForce<CloudType>::calcCoupled
|
|||||||
f = mass*sqrt(mathematical::pi*s0/dt);
|
f = mass*sqrt(mathematical::pi*s0/dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
const scalar sqrt2 = sqrt(2.0);
|
|
||||||
for (direction dir = 0; dir < vector::nComponents; dir++)
|
// To generate a cubic distribution (3 independent directions) :
|
||||||
{
|
// const scalar sqrt2 = sqrt(2.0);
|
||||||
const scalar x = rndGen_.sample01<scalar>();
|
// for (direction dir = 0; dir < vector::nComponents; dir++)
|
||||||
const scalar eta = sqrt2*erfInv(2*x - 1.0);
|
// {
|
||||||
value.Su()[dir] = f*eta;
|
// const scalar x = rndGen_.sample01<scalar>();
|
||||||
}
|
// const scalar eta = sqrt2*erfInv(2*x - 1.0);
|
||||||
|
// value.Su()[dir] = f*eta;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// To generate a spherical distribution:
|
||||||
|
|
||||||
|
cachedRandom& rnd = this->owner().rndGen();
|
||||||
|
|
||||||
|
const scalar theta = rnd.sample01<scalar>()*twoPi;
|
||||||
|
const scalar u = 2*rnd.sample01<scalar>() - 1;
|
||||||
|
|
||||||
|
const scalar a = sqrt(1 - sqr(u));
|
||||||
|
const vector dir(a*cos(theta), a*sin(theta), u);
|
||||||
|
|
||||||
|
value.Su() = f*mag(rnd.GaussNormal<scalar>())*dir;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user