[Bf-blender-cvs] [a1ddb633297] master: Fluid: Update Mantaflow source files
Sebastián Barschkis
noreply at git.blender.org
Wed Apr 8 13:43:17 CEST 2020
Commit: a1ddb633297a603ed19a37340be5f27c1c439d36
Author: Sebastián Barschkis
Date: Wed Apr 8 13:25:16 2020 +0200
Branches: master
https://developer.blender.org/rBa1ddb633297a603ed19a37340be5f27c1c439d36
Fluid: Update Mantaflow source files
Update includes new grid helper functions and some cleanups.
===================================================================
M extern/mantaflow/preprocessed/gitinfo.h
M extern/mantaflow/preprocessed/grid.cpp
M extern/mantaflow/preprocessed/grid.h
M extern/mantaflow/preprocessed/grid.h.reg.cpp
M extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
===================================================================
diff --git a/extern/mantaflow/preprocessed/gitinfo.h b/extern/mantaflow/preprocessed/gitinfo.h
index 208d8008a7e..6a26c480392 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
-#define MANTA_GIT_VERSION "commit 5fbd3d04381b21afce4a593d1fe2d9bc7bef5424"
+#define MANTA_GIT_VERSION "commit f3d32c45934fd08c40096fb3510e9cc403730977"
diff --git a/extern/mantaflow/preprocessed/grid.cpp b/extern/mantaflow/preprocessed/grid.cpp
index f10052349d5..0ea3afb91f4 100644
--- a/extern/mantaflow/preprocessed/grid.cpp
+++ b/extern/mantaflow/preprocessed/grid.cpp
@@ -853,6 +853,147 @@ template<class T> struct knPermuteAxes : public KernelBase {
int axis2;
};
+struct knJoinVec : public KernelBase {
+ knJoinVec(Grid<Vec3> &a, const Grid<Vec3> &b, bool keepMax)
+ : KernelBase(&a, 0), a(a), b(b), keepMax(keepMax)
+ {
+ runMessage();
+ run();
+ }
+ inline void op(IndexInt idx, Grid<Vec3> &a, const Grid<Vec3> &b, bool keepMax) const
+ {
+ Real a1 = normSquare(a[idx]);
+ Real b1 = normSquare(b[idx]);
+ a[idx] = (keepMax) ? max(a1, b1) : min(a1, b1);
+ }
+ inline Grid<Vec3> &getArg0()
+ {
+ return a;
+ }
+ typedef Grid<Vec3> type0;
+ inline const Grid<Vec3> &getArg1()
+ {
+ return b;
+ }
+ typedef Grid<Vec3> type1;
+ inline bool &getArg2()
+ {
+ return keepMax;
+ }
+ typedef bool type2;
+ void runMessage()
+ {
+ debMsg("Executing kernel knJoinVec ", 3);
+ debMsg("Kernel range"
+ << " x " << maxX << " y " << maxY << " z " << minZ << " - " << maxZ << " ",
+ 4);
+ };
+ void operator()(const tbb::blocked_range<IndexInt> &__r) const
+ {
+ for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++)
+ op(idx, a, b, keepMax);
+ }
+ void run()
+ {
+ tbb::parallel_for(tbb::blocked_range<IndexInt>(0, size), *this);
+ }
+ Grid<Vec3> &a;
+ const Grid<Vec3> &b;
+ bool keepMax;
+};
+struct knJoinInt : public KernelBase {
+ knJoinInt(Grid<int> &a, const Grid<int> &b, bool keepMax)
+ : KernelBase(&a, 0), a(a), b(b), keepMax(keepMax)
+ {
+ runMessage();
+ run();
+ }
+ inline void op(IndexInt idx, Grid<int> &a, const Grid<int> &b, bool keepMax) const
+ {
+ a[idx] = (keepMax) ? max(a[idx], b[idx]) : min(a[idx], b[idx]);
+ }
+ inline Grid<int> &getArg0()
+ {
+ return a;
+ }
+ typedef Grid<int> type0;
+ inline const Grid<int> &getArg1()
+ {
+ return b;
+ }
+ typedef Grid<int> type1;
+ inline bool &getArg2()
+ {
+ return keepMax;
+ }
+ typedef bool type2;
+ void runMessage()
+ {
+ debMsg("Executing kernel knJoinInt ", 3);
+ debMsg("Kernel range"
+ << " x " << maxX << " y " << maxY << " z " << minZ << " - " << maxZ << " ",
+ 4);
+ };
+ void operator()(const tbb::blocked_range<IndexInt> &__r) const
+ {
+ for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++)
+ op(idx, a, b, keepMax);
+ }
+ void run()
+ {
+ tbb::parallel_for(tbb::blocked_range<IndexInt>(0, size), *this);
+ }
+ Grid<int> &a;
+ const Grid<int> &b;
+ bool keepMax;
+};
+struct knJoinReal : public KernelBase {
+ knJoinReal(Grid<Real> &a, const Grid<Real> &b, bool keepMax)
+ : KernelBase(&a, 0), a(a), b(b), keepMax(keepMax)
+ {
+ runMessage();
+ run();
+ }
+ inline void op(IndexInt idx, Grid<Real> &a, const Grid<Real> &b, bool keepMax) const
+ {
+ a[idx] = (keepMax) ? max(a[idx], b[idx]) : min(a[idx], b[idx]);
+ }
+ inline Grid<Real> &getArg0()
+ {
+ return a;
+ }
+ typedef Grid<Real> type0;
+ inline const Grid<Real> &getArg1()
+ {
+ return b;
+ }
+ typedef Grid<Real> type1;
+ inline bool &getArg2()
+ {
+ return keepMax;
+ }
+ typedef bool type2;
+ void runMessage()
+ {
+ debMsg("Executing kernel knJoinReal ", 3);
+ debMsg("Kernel range"
+ << " x " << maxX << " y " << maxY << " z " << minZ << " - " << maxZ << " ",
+ 4);
+ };
+ void operator()(const tbb::blocked_range<IndexInt> &__r) const
+ {
+ for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++)
+ op(idx, a, b, keepMax);
+ }
+ void run()
+ {
+ tbb::parallel_for(tbb::blocked_range<IndexInt>(0, size), *this);
+ }
+ Grid<Real> &a;
+ const Grid<Real> &b;
+ bool keepMax;
+};
+
template<class T> Grid<T> &Grid<T>::safeDivide(const Grid<T> &a)
{
knGridSafeDiv<T>(*this, a);
@@ -928,6 +1069,18 @@ void Grid<T>::permuteAxesCopyToGrid(int axis0, int axis1, int axis2, Grid<T> &ou
"Permuted grids must have the same dimensions!");
knPermuteAxes<T>(*this, out, axis0, axis1, axis2);
}
+template<> void Grid<Vec3>::join(const Grid<Vec3> &a, bool keepMax)
+{
+ knJoinVec(*this, a, keepMax);
+}
+template<> void Grid<int>::join(const Grid<int> &a, bool keepMax)
+{
+ knJoinInt(*this, a, keepMax);
+}
+template<> void Grid<Real>::join(const Grid<Real> &a, bool keepMax)
+{
+ knJoinReal(*this, a, keepMax);
+}
template<> Real Grid<Real>::getMax() const
{
diff --git a/extern/mantaflow/preprocessed/grid.h b/extern/mantaflow/preprocessed/grid.h
index 6abe3a2b08a..fe386cfc269 100644
--- a/extern/mantaflow/preprocessed/grid.h
+++ b/extern/mantaflow/preprocessed/grid.h
@@ -966,10 +966,38 @@ template<class T> class Grid : public GridBase {
}
}
+ //! join other grid by either keeping min or max value at cell
+ void join(const Grid<T> &a, bool keepMax = true);
+ static PyObject *_W_27(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ {
+ try {
+ PbArgs _args(_linargs, _kwds);
+ Grid *pbo = dynamic_cast<Grid *>(Pb::objFromPy(_self));
+ bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
+ pbPreparePlugin(pbo->getParent(), "Grid::join", !noTiming);
+ PyObject *_retval = 0;
+ {
+ ArgLocker _lock;
+ const Grid<T> &a = *_args.getPtr<Grid<T>>("a", 0, &_lock);
+ bool keepMax = _args.getOpt<bool>("keepMax", 1, true, &_lock);
+ pbo->_args.copy(_args);
+ _retval = getPyNone();
+ pbo->join(a, keepMax);
+ pbo->_args.check();
+ }
+ pbFinalizePlugin(pbo->getParent(), "Grid::join", !noTiming);
+ return _retval;
+ }
+ catch (std::exception &e) {
+ pbSetError("Grid::join", e.what());
+ return 0;
+ }
+ }
+
// common compound operators
//! get absolute max value in grid
Real getMaxAbs() const;
- static PyObject *_W_27(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_28(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -994,7 +1022,7 @@ template<class T> class Grid : public GridBase {
//! get max value in grid
Real getMax() const;
- static PyObject *_W_28(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_29(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1019,7 +1047,7 @@ template<class T> class Grid : public GridBase {
//! get min value in grid
Real getMin() const;
- static PyObject *_W_29(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_30(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1044,7 +1072,7 @@ template<class T> class Grid : public GridBase {
//! calculate L1 norm of grid content
Real getL1(int bnd = 0);
- static PyObject *_W_30(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_31(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1070,7 +1098,7 @@ template<class T> class Grid : public GridBase {
//! calculate L2 norm of grid content
Real getL2(int bnd = 0);
- static PyObject *_W_31(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_32(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1096,7 +1124,7 @@ template<class T> class Grid : public GridBase {
//! set all boundary cells to constant value (Dirichlet)
void setBound(T value, int boundaryWidth = 1);
- static PyObject *_W_32(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_33(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1124,7 +1152,7 @@ template<class T> class Grid : public GridBase {
//! set all boundary cells to last inner value (Neumann)
void setBoundNeumann(int boundaryWidth = 1);
- static PyObject *_W_33(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_34(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1151,7 +1179,7 @@ template<class T> class Grid : public GridBase {
//! get data pointer of grid
std::string getDataPointer();
- static PyObject *_W_34(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_35(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1176,7 +1204,7 @@ template<class T> class Grid : public GridBase {
//! debugging helper, print grid from python. skip boundary of width bnd
void printGrid(int zSlice = -1, bool printIndex = false, int bnd = 1);
- static PyObject *_W_35(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_36(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1244,7 +1272,7 @@ class MACGrid : public Grid<Vec3> {
{
mType = (GridType)(TypeMAC | TypeVec3);
}
- static int _W_36(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static int _W_37(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
PbClass *obj = Pb::objFromPy(_self);
if (obj)
@@ -1326,7 +1354,7 @@ class MACGrid : public Grid<Vec3> {
//! set all boundary cells of a MAC grid to certain value (Dirchlet). Respects staggered grid
//! locations optionally, only set normal components
void setBoundMAC(Vec3 value, int boundaryWidth, bool normalOnly = false);
- static PyObject *_W_37(PyObject *_self, PyObject *_linargs
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list