diff options
Diffstat (limited to 'extern/mantaflow')
-rw-r--r-- | extern/mantaflow/preprocessed/plugin/extforces.cpp | 28 | ||||
-rw-r--r-- | extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp | 38 |
2 files changed, 43 insertions, 23 deletions
diff --git a/extern/mantaflow/preprocessed/plugin/extforces.cpp b/extern/mantaflow/preprocessed/plugin/extforces.cpp index 36221fbbc10..798bb3daeee 100644 --- a/extern/mantaflow/preprocessed/plugin/extforces.cpp +++ b/extern/mantaflow/preprocessed/plugin/extforces.cpp @@ -244,13 +244,15 @@ struct KnApplyForce : public KernelBase { bool additive; }; -//! add gravity forces to all fluid cells, automatically adapts to different grid sizes +//! add gravity forces to all fluid cells, optionally adapts to different grid sizes automatically void addGravity(const FlagGrid &flags, MACGrid &vel, Vec3 gravity, - const Grid<Real> *exclude = NULL) + const Grid<Real> *exclude = NULL, + bool scale = true) { - Vec3 f = gravity * flags.getParent()->getDt() / flags.getDx(); + float gridScale = (scale) ? flags.getDx() : 1; + Vec3 f = gravity * flags.getParent()->getDt() / gridScale; KnApplyForce(flags, vel, f, exclude, true); } static PyObject *_W_0(PyObject *_self, PyObject *_linargs, PyObject *_kwds) @@ -267,8 +269,9 @@ static PyObject *_W_0(PyObject *_self, PyObject *_linargs, PyObject *_kwds) MACGrid &vel = *_args.getPtr<MACGrid>("vel", 1, &_lock); Vec3 gravity = _args.get<Vec3>("gravity", 2, &_lock); const Grid<Real> *exclude = _args.getPtrOpt<Grid<Real>>("exclude", 3, NULL, &_lock); + bool scale = _args.getOpt<bool>("scale", 4, true, &_lock); _retval = getPyNone(); - addGravity(flags, vel, gravity, exclude); + addGravity(flags, vel, gravity, exclude, scale); _args.check(); } pbFinalizePlugin(parent, "addGravity", !noTiming); @@ -287,14 +290,13 @@ void PbRegister_addGravity() } } -//! add gravity forces to all fluid cells , but dont account for changing cell size +//! Deprecated: use addGravity(scale=false) instead void addGravityNoScale(const FlagGrid &flags, MACGrid &vel, const Vec3 &gravity, const Grid<Real> *exclude = NULL) { - const Vec3 f = gravity * flags.getParent()->getDt(); - KnApplyForce(flags, vel, f, exclude, true); + addGravity(flags, vel, gravity, exclude, false); } static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds) { @@ -412,14 +414,17 @@ struct KnAddBuoyancy : public KernelBase { Vec3 strength; }; -//! add Buoyancy force based on fctor (e.g. smoke density) +//! add Buoyancy force based on factor (e.g. smoke density), optionally adapts to different grid +//! sizes automatically void addBuoyancy(const FlagGrid &flags, const Grid<Real> &density, MACGrid &vel, Vec3 gravity, - Real coefficient = 1.) + Real coefficient = 1., + bool scale = true) { - Vec3 f = -gravity * flags.getParent()->getDt() / flags.getParent()->getDx() * coefficient; + float gridScale = (scale) ? flags.getDx() : 1; + Vec3 f = -gravity * flags.getParent()->getDt() / gridScale * coefficient; KnAddBuoyancy(flags, density, vel, f); } static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds) @@ -437,8 +442,9 @@ static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds) MACGrid &vel = *_args.getPtr<MACGrid>("vel", 2, &_lock); Vec3 gravity = _args.get<Vec3>("gravity", 3, &_lock); Real coefficient = _args.getOpt<Real>("coefficient", 4, 1., &_lock); + bool scale = _args.getOpt<bool>("scale", 5, true, &_lock); _retval = getPyNone(); - addBuoyancy(flags, density, vel, gravity, coefficient); + addBuoyancy(flags, density, vel, gravity, coefficient, scale); _args.check(); } pbFinalizePlugin(parent, "addBuoyancy", !noTiming); diff --git a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp index a8913a218c1..5e24b6f28db 100644 --- a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp +++ b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp @@ -982,9 +982,14 @@ void flipSampleSecondaryParticles(const std::string mode, const Real c_b, const Real k_ta, const Real k_wc, - const Real dt, + const Real dt = 0, const int itype = FlagGrid::TypeFluid) { + + float timestep = dt; + if (dt <= 0) + timestep = flags.getParent()->getDt(); + if (mode == "single") { knFlipSampleSecondaryParticles(flags, v, @@ -1001,7 +1006,7 @@ void flipSampleSecondaryParticles(const std::string mode, c_b, k_ta, k_wc, - dt, + timestep, itype); } else if (mode == "multiple") { @@ -1020,7 +1025,7 @@ void flipSampleSecondaryParticles(const std::string mode, c_b, k_ta, k_wc, - dt, + timestep, itype); } else { @@ -1053,7 +1058,7 @@ static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds) const Real c_b = _args.get<Real>("c_b", 13, &_lock); const Real k_ta = _args.get<Real>("k_ta", 14, &_lock); const Real k_wc = _args.get<Real>("k_wc", 15, &_lock); - const Real dt = _args.get<Real>("dt", 16, &_lock); + const Real dt = _args.getOpt<Real>("dt", 16, 0, &_lock); const int itype = _args.getOpt<int>("itype", 17, FlagGrid::TypeFluid, &_lock); _retval = getPyNone(); flipSampleSecondaryParticles(mode, @@ -1691,13 +1696,20 @@ void flipUpdateSecondaryParticles(const std::string mode, const Real k_d, const Real c_s, const Real c_b, - const Real dt, + const Real dt = 0, + bool scale = true, const int exclude = ParticleBase::PTRACER, const int antitunneling = 0, const int itype = FlagGrid::TypeFluid) { - Vec3 g = gravity / flags.getDx(); + float gridScale = (scale) ? flags.getParent()->getDx() : 1; + Vec3 g = gravity / gridScale; + + float timestep = dt; + if (dt <= 0) + timestep = flags.getParent()->getDt(); + if (mode == "linear") { knFlipUpdateSecondaryParticlesLinear(pts_sec, v_sec, @@ -1711,7 +1723,7 @@ void flipUpdateSecondaryParticles(const std::string mode, k_d, c_s, c_b, - dt, + timestep, exclude, antitunneling); } @@ -1729,7 +1741,7 @@ void flipUpdateSecondaryParticles(const std::string mode, k_d, c_s, c_b, - dt, + timestep, exclude, antitunneling, itype); @@ -1764,10 +1776,11 @@ static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds) const Real k_d = _args.get<Real>("k_d", 11, &_lock); const Real c_s = _args.get<Real>("c_s", 12, &_lock); const Real c_b = _args.get<Real>("c_b", 13, &_lock); - const Real dt = _args.get<Real>("dt", 14, &_lock); - const int exclude = _args.getOpt<int>("exclude", 15, ParticleBase::PTRACER, &_lock); - const int antitunneling = _args.getOpt<int>("antitunneling", 16, 0, &_lock); - const int itype = _args.getOpt<int>("itype", 17, FlagGrid::TypeFluid, &_lock); + const Real dt = _args.getOpt<Real>("dt", 14, 0, &_lock); + bool scale = _args.getOpt<bool>("scale", 15, true, &_lock); + const int exclude = _args.getOpt<int>("exclude", 16, ParticleBase::PTRACER, &_lock); + const int antitunneling = _args.getOpt<int>("antitunneling", 17, 0, &_lock); + const int itype = _args.getOpt<int>("itype", 18, FlagGrid::TypeFluid, &_lock); _retval = getPyNone(); flipUpdateSecondaryParticles(mode, pts_sec, @@ -1784,6 +1797,7 @@ static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds) c_s, c_b, dt, + scale, exclude, antitunneling, itype); |