Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/mantaflow/preprocessed/plugin')
-rw-r--r--extern/mantaflow/preprocessed/plugin/flip.cpp16
-rw-r--r--extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp65
2 files changed, 52 insertions, 29 deletions
diff --git a/extern/mantaflow/preprocessed/plugin/flip.cpp b/extern/mantaflow/preprocessed/plugin/flip.cpp
index 1acdac1c094..eaa1ebe45d5 100644
--- a/extern/mantaflow/preprocessed/plugin/flip.cpp
+++ b/extern/mantaflow/preprocessed/plugin/flip.cpp
@@ -41,7 +41,7 @@ void sampleFlagsWithParticles(const FlagGrid &flags,
const bool is3D = flags.is3D();
const Real jlen = randomness / discretization;
const Vec3 disp(1.0 / discretization, 1.0 / discretization, 1.0 / discretization);
- RandomStream mRand(9832);
+ RandomStream rand(parts.getSeed());
FOR_IJK_BND(flags, 0)
{
@@ -53,7 +53,7 @@ void sampleFlagsWithParticles(const FlagGrid &flags,
for (int dj = 0; dj < discretization; dj++)
for (int di = 0; di < discretization; di++) {
Vec3 subpos = pos + disp * Vec3(0.5 + di, 0.5 + dj, 0.5 + dk);
- subpos += jlen * (Vec3(1, 1, 1) - 2.0 * mRand.getVec3());
+ subpos += jlen * (Vec3(1, 1, 1) - 2.0 * rand.getVec3());
if (!is3D)
subpos[2] = 0.5;
parts.addBuffered(subpos);
@@ -113,7 +113,7 @@ void sampleLevelsetWithParticles(const LevelsetGrid &phi,
const bool is3D = phi.is3D();
const Real jlen = randomness / discretization;
const Vec3 disp(1.0 / discretization, 1.0 / discretization, 1.0 / discretization);
- RandomStream mRand(9832);
+ RandomStream rand(parts.getSeed());
if (reset) {
parts.clear();
@@ -132,7 +132,7 @@ void sampleLevelsetWithParticles(const LevelsetGrid &phi,
for (int dj = 0; dj < discretization; dj++)
for (int di = 0; di < discretization; di++) {
Vec3 subpos = pos + disp * Vec3(0.5 + di, 0.5 + dj, 0.5 + dk);
- subpos += jlen * (Vec3(1, 1, 1) - 2.0 * mRand.getVec3());
+ subpos += jlen * (Vec3(1, 1, 1) - 2.0 * rand.getVec3());
if (!is3D)
subpos[2] = 0.5;
if (phi.getInterpolated(subpos) > 0.)
@@ -205,7 +205,7 @@ void sampleShapeWithParticles(const Shape &shape,
const bool is3D = flags.is3D();
const Real jlen = randomness / discretization;
const Vec3 disp(1.0 / discretization, 1.0 / discretization, 1.0 / discretization);
- RandomStream mRand(9832);
+ RandomStream rand(parts.getSeed());
if (reset) {
parts.clear();
@@ -223,7 +223,7 @@ void sampleShapeWithParticles(const Shape &shape,
for (int dj = 0; dj < discretization; dj++)
for (int di = 0; di < discretization; di++) {
Vec3 subpos = pos + disp * Vec3(0.5 + di, 0.5 + dj, 0.5 + dk);
- subpos += jlen * (Vec3(1, 1, 1) - 2.0 * mRand.getVec3());
+ subpos += jlen * (Vec3(1, 1, 1) - 2.0 * rand.getVec3());
if (!is3D)
subpos[2] = 0.5;
if (exclude && exclude->getInterpolated(subpos) <= 0.)
@@ -576,7 +576,7 @@ void adjustNumber(BasicParticleSystem &parts,
}
// seed new particles
- RandomStream mRand(9832);
+ RandomStream rand(parts.getSeed());
FOR_IJK(tmp)
{
int cnt = tmp(i, j, k);
@@ -593,7 +593,7 @@ void adjustNumber(BasicParticleSystem &parts,
if (flags.isFluid(i, j, k) && cnt < minParticles) {
for (int m = cnt; m < minParticles; m++) {
- Vec3 pos = Vec3(i, j, k) + mRand.getVec3();
+ Vec3 pos = Vec3(i, j, k) + rand.getVec3();
// Vec3 pos (i + 0.5, j + 0.5, k + 0.5); // cell center
parts.addBuffered(pos);
}
diff --git a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
index 82afe2d7ab2..8ebc239e8fc 100644
--- a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
+++ b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
@@ -479,7 +479,8 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public KernelBase {
const Real k_ta,
const Real k_wc,
const Real dt,
- const int itype = FlagGrid::TypeFluid)
+ const int itype,
+ RandomStream &rand)
: KernelBase(&flags, 0),
flags(flags),
v(v),
@@ -497,7 +498,8 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public KernelBase {
k_ta(k_ta),
k_wc(k_wc),
dt(dt),
- itype(itype)
+ itype(itype),
+ rand(rand)
{
runMessage();
run();
@@ -521,13 +523,13 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public KernelBase {
const Real k_ta,
const Real k_wc,
const Real dt,
- const int itype = FlagGrid::TypeFluid)
+ const int itype,
+ RandomStream &rand)
{
if (!(flags(i, j, k) & itype))
return;
- static RandomStream mRand(9832);
Real radius =
0.25; // diameter=0.5 => sampling with two cylinders in each dimension since cell size=1
for (Real x = i - radius; x <= i + radius; x += 2 * radius) {
@@ -549,9 +551,9 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public KernelBase {
cross(e1, dir)); // perpendicular to dir and e1, so e1 and e1 create reference plane
for (int di = 0; di < n; di++) {
- const Real r = radius * sqrt(mRand.getReal()); // distance to cylinder axis
- const Real theta = mRand.getReal() * Real(2) * M_PI; // azimuth
- const Real h = mRand.getReal() * norm(dt * vi); // distance to reference plane
+ const Real r = radius * sqrt(rand.getReal()); // distance to cylinder axis
+ const Real theta = rand.getReal() * Real(2) * M_PI; // azimuth
+ const Real h = rand.getReal() * norm(dt * vi); // distance to reference plane
Vec3 xd = xi + r * cos(theta) * e1 + r * sin(theta) * e2 + h * getNormalized(vi);
if (!flags.is3D())
xd.z = 0;
@@ -561,7 +563,7 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public KernelBase {
vi; // init velocity of new particle
Real temp = (KE + TA + WC) / 3;
l_sec[l_sec.size() - 1] = ((lMax - lMin) * temp) + lMin +
- mRand.getReal() * 0.1; // init lifetime of new particle
+ rand.getReal() * 0.1; // init lifetime of new particle
// init type of new particle
if (neighborRatio(i, j, k) < c_s) {
@@ -663,6 +665,11 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public KernelBase {
return itype;
}
typedef int type16;
+ inline RandomStream &getArg17()
+ {
+ return rand;
+ }
+ typedef RandomStream type17;
void runMessage()
{
debMsg("Executing kernel knFlipSampleSecondaryParticlesMoreCylinders ", 3);
@@ -696,7 +703,8 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public KernelBase {
k_ta,
k_wc,
dt,
- itype);
+ itype,
+ rand);
}
const FlagGrid &flags;
const MACGrid &v;
@@ -715,6 +723,7 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public KernelBase {
const Real k_wc;
const Real dt;
const int itype;
+ RandomStream &rand;
};
// adds secondary particles to &pts_sec for every fluid cell in &flags according to the potential
@@ -738,7 +747,8 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
const Real k_ta,
const Real k_wc,
const Real dt,
- const int itype = FlagGrid::TypeFluid)
+ const int itype,
+ RandomStream &rand)
: KernelBase(&flags, 0),
flags(flags),
v(v),
@@ -756,7 +766,8 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
k_ta(k_ta),
k_wc(k_wc),
dt(dt),
- itype(itype)
+ itype(itype),
+ rand(rand)
{
runMessage();
run();
@@ -780,7 +791,8 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
const Real k_ta,
const Real k_wc,
const Real dt,
- const int itype = FlagGrid::TypeFluid)
+ const int itype,
+ RandomStream &rand)
{
if (!(flags(i, j, k) & itype))
@@ -793,9 +805,8 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
const int n = KE * (k_ta * TA + k_wc * WC) * dt; // number of secondary particles
if (n == 0)
return;
- static RandomStream mRand(9832);
- Vec3 xi = Vec3(i, j, k) + mRand.getVec3(); // randomized offset uniform in cell
+ Vec3 xi = Vec3(i, j, k) + rand.getVec3(); // randomized offset uniform in cell
Vec3 vi = v.getInterpolated(xi);
Vec3 dir = dt * vi; // direction of movement of current particle
Vec3 e1 = getNormalized(Vec3(dir.z, 0, -dir.x)); // perpendicular to dir
@@ -803,9 +814,9 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
cross(e1, dir)); // perpendicular to dir and e1, so e1 and e1 create reference plane
for (int di = 0; di < n; di++) {
- const Real r = Real(0.5) * sqrt(mRand.getReal()); // distance to cylinder axis
- const Real theta = mRand.getReal() * Real(2) * M_PI; // azimuth
- const Real h = mRand.getReal() * norm(dt * vi); // distance to reference plane
+ const Real r = Real(0.5) * sqrt(rand.getReal()); // distance to cylinder axis
+ const Real theta = rand.getReal() * Real(2) * M_PI; // azimuth
+ const Real h = rand.getReal() * norm(dt * vi); // distance to reference plane
Vec3 xd = xi + r * cos(theta) * e1 + r * sin(theta) * e2 + h * getNormalized(vi);
if (!flags.is3D())
xd.z = 0;
@@ -815,7 +826,7 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
vi; // init velocity of new particle
Real temp = (KE + TA + WC) / 3;
l_sec[l_sec.size() - 1] = ((lMax - lMin) * temp) + lMin +
- mRand.getReal() * 0.1; // init lifetime of new particle
+ rand.getReal() * 0.1; // init lifetime of new particle
// init type of new particle
if (neighborRatio(i, j, k) < c_s) {
@@ -914,6 +925,11 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
return itype;
}
typedef int type16;
+ inline RandomStream &getArg17()
+ {
+ return rand;
+ }
+ typedef RandomStream type17;
void runMessage()
{
debMsg("Executing kernel knFlipSampleSecondaryParticles ", 3);
@@ -947,7 +963,8 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
k_ta,
k_wc,
dt,
- itype);
+ itype,
+ rand);
}
const FlagGrid &flags;
const MACGrid &v;
@@ -966,6 +983,7 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
const Real k_wc;
const Real dt;
const int itype;
+ RandomStream &rand;
};
void flipSampleSecondaryParticles(const std::string mode,
@@ -992,6 +1010,9 @@ void flipSampleSecondaryParticles(const std::string mode,
if (dt <= 0)
timestep = flags.getParent()->getDt();
+ /* Every particle needs to get a different random offset. */
+ RandomStream rand(pts_sec.getSeed());
+
if (mode == "single") {
knFlipSampleSecondaryParticles(flags,
v,
@@ -1009,7 +1030,8 @@ void flipSampleSecondaryParticles(const std::string mode,
k_ta,
k_wc,
timestep,
- itype);
+ itype,
+ rand);
}
else if (mode == "multiple") {
knFlipSampleSecondaryParticlesMoreCylinders(flags,
@@ -1028,7 +1050,8 @@ void flipSampleSecondaryParticles(const std::string mode,
k_ta,
k_wc,
timestep,
- itype);
+ itype,
+ rand);
}
else {
throw std::invalid_argument("Unknown mode: use \"single\" or \"multiple\" instead!");