[Bf-blender-cvs] [a4a825e0fcf] fluid-mantaflow: Mantaflow: Updated manta pp files
Sebastián Barschkis
noreply at git.blender.org
Wed Oct 9 19:02:46 CEST 2019
Commit: a4a825e0fcf39b13d905110bc72b5370bbb20492
Author: Sebastián Barschkis
Date: Wed Oct 9 18:53:27 2019 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBa4a825e0fcf39b13d905110bc72b5370bbb20492
Mantaflow: Updated manta pp files
===================================================================
M intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.cpp
M intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.h
M intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h
M intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.h
M intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.h.reg
M intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.h.reg.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/omp/levelset.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/omp/levelset.h
M intern/mantaflow/intern/manta_develop/preprocessed/omp/mesh.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/omp/mesh.h
A intern/mantaflow/intern/manta_develop/preprocessed/omp/plugin/sndparticles.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/gitinfo.h
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/grid.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/grid.h
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/grid.h.reg
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/grid.h.reg.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/levelset.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/levelset.h
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/mesh.cpp
M intern/mantaflow/intern/manta_develop/preprocessed/tbb/mesh.h
A intern/mantaflow/intern/manta_develop/preprocessed/tbb/plugin/sndparticles.cpp
===================================================================
diff --git a/intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.cpp b/intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.cpp
index 2b8ea9793c1..d2ddb21be70 100644
--- a/intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.cpp
+++ b/intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.cpp
@@ -64,8 +64,12 @@ void PyArrayContainer::ExtractData(void *_pParentPyArray)
{
PyArrayObject *pParent = reinterpret_cast<PyArrayObject *>(pParentPyArray);
+ int numDims = PyArray_NDIM(pParent);
+ long *pDims = (long *)PyArray_DIMS(pParent);
+
pData = PyArray_DATA(pParent);
TotalSize = PyArray_SIZE(pParent);
+ Dims = std::vector<long>(&pDims[0], &pDims[numDims]);
int iDataType = PyArray_TYPE(pParent);
switch (iDataType) {
diff --git a/intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.h b/intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.h
index e06f5300dc7..67e7e2851d2 100644
--- a/intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.h
+++ b/intern/mantaflow/intern/manta_develop/helper/pwrapper/numpyWrap.h
@@ -71,6 +71,7 @@ class PyArrayContainer {
void *pData;
NumpyTypes DataType;
unsigned int TotalSize;
+ std::vector<long> Dims;
private:
void *pParentPyArray;
diff --git a/intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h b/intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h
index 36b661a3f00..8c1a007650f 100644
--- a/intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h
+++ b/intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h
@@ -1,3 +1,3 @@
-#define MANTA_GIT_VERSION "commit d2f1eee1562925547b0467aa1edbfb1d63c966dc"
+#define MANTA_GIT_VERSION "commit 9b5f026ea0362355499c4734bf5a9fda959e66a9"
diff --git a/intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.cpp b/intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.cpp
index c01289dd44c..ae448776365 100644
--- a/intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.cpp
+++ b/intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.cpp
@@ -775,6 +775,88 @@ template<class T> struct knGridStomp : public KernelBase {
const T &threshold;
};
+template<class T> struct knPermuteAxes : public KernelBase {
+ knPermuteAxes(Grid<T> &self, Grid<T> &target, int axis0, int axis1, int axis2)
+ : KernelBase(&self, 0), self(self), target(target), axis0(axis0), axis1(axis1), axis2(axis2)
+ {
+ runMessage();
+ run();
+ }
+ inline void op(
+ int i, int j, int k, Grid<T> &self, Grid<T> &target, int axis0, int axis1, int axis2)
+ {
+ int i0 = axis0 == 0 ? i : (axis0 == 1 ? j : k);
+ int i1 = axis1 == 0 ? i : (axis1 == 1 ? j : k);
+ int i2 = axis2 == 0 ? i : (axis2 == 1 ? j : k);
+ target(i, j, k) = self(i0, i1, i2);
+ }
+ inline Grid<T> &getArg0()
+ {
+ return self;
+ }
+ typedef Grid<T> type0;
+ inline Grid<T> &getArg1()
+ {
+ return target;
+ }
+ typedef Grid<T> type1;
+ inline int &getArg2()
+ {
+ return axis0;
+ }
+ typedef int type2;
+ inline int &getArg3()
+ {
+ return axis1;
+ }
+ typedef int type3;
+ inline int &getArg4()
+ {
+ return axis2;
+ }
+ typedef int type4;
+ void runMessage()
+ {
+ debMsg("Executing kernel knPermuteAxes ", 3);
+ debMsg("Kernel range"
+ << " x " << maxX << " y " << maxY << " z " << minZ << " - " << maxZ << " ",
+ 4);
+ };
+ void run()
+ {
+ const int _maxX = maxX;
+ const int _maxY = maxY;
+ if (maxZ > 1) {
+
+#pragma omp parallel
+ {
+
+#pragma omp for
+ for (int k = minZ; k < maxZ; k++)
+ for (int j = 0; j < _maxY; j++)
+ for (int i = 0; i < _maxX; i++)
+ op(i, j, k, self, target, axis0, axis1, axis2);
+ }
+ }
+ else {
+ const int k = 0;
+#pragma omp parallel
+ {
+
+#pragma omp for
+ for (int j = 0; j < _maxY; j++)
+ for (int i = 0; i < _maxX; i++)
+ op(i, j, k, self, target, axis0, axis1, axis2);
+ }
+ }
+ }
+ Grid<T> &self;
+ Grid<T> ⌖
+ int axis0;
+ int axis1;
+ int axis2;
+};
+
template<class T> Grid<T> &Grid<T>::safeDivide(const Grid<T> &a)
{
knGridSafeDiv<T>(*this, a);
@@ -824,6 +906,18 @@ template<class T> void Grid<T>::stomp(const T &threshold)
{
knGridStomp<T>(*this, threshold);
}
+template<class T> void Grid<T>::permuteAxes(int axis0, int axis1, int axis2)
+{
+ if (axis0 == axis1 || axis0 == axis2 || axis1 == axis2 || axis0 > 2 || axis1 > 2 || axis2 > 2 ||
+ axis0 < 0 || axis1 < 0 || axis2 < 0)
+ return;
+ Vec3i size = mParent->getGridSize();
+ assertMsg(mParent->is2D() ? size.x == size.y : size.x == size.y && size.y == size.z,
+ "Grid must be cubic!");
+ Grid<T> tmp(mParent);
+ knPermuteAxes<T>(*this, tmp, axis0, axis1, axis2);
+ this->swap(tmp);
+}
template<> Real Grid<Real>::getMax() const
{
@@ -921,7 +1015,7 @@ struct knCountCells : public KernelBase {
{
if (mask)
(*mask)(i, j, k) = 0.;
- if (bnd > 0 && (!flags.isInBounds(Vec3i(i, j, k))))
+ if (bnd > 0 && (!flags.isInBounds(Vec3i(i, j, k), bnd)))
return;
if (flags(i, j, k) & flag) {
cnt++;
diff --git a/intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.h b/intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.h
index 735295fe4f6..3a9b21b73f0 100644
--- a/intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.h
+++ b/intern/mantaflow/intern/manta_develop/preprocessed/omp/grid.h
@@ -881,10 +881,39 @@ template<class T> class Grid : public GridBase {
}
}
+ //! permute grid axes, e.g. switch y with z (0,2,1)
+ void permuteAxes(int axis0, int axis1, int axis2);
+ static PyObject *_W_24(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::permuteAxes", !noTiming);
+ PyObject *_retval = 0;
+ {
+ ArgLocker _lock;
+ int axis0 = _args.get<int>("axis0", 0, &_lock);
+ int axis1 = _args.get<int>("axis1", 1, &_lock);
+ int axis2 = _args.get<int>("axis2", 2, &_lock);
+ pbo->_args.copy(_args);
+ _retval = getPyNone();
+ pbo->permuteAxes(axis0, axis1, axis2);
+ pbo->_args.check();
+ }
+ pbFinalizePlugin(pbo->getParent(), "Grid::permuteAxes", !noTiming);
+ return _retval;
+ }
+ catch (std::exception &e) {
+ pbSetError("Grid::permuteAxes", e.what());
+ return 0;
+ }
+ }
+
// common compound operators
//! get absolute max value in grid
Real getMaxAbs() const;
- static PyObject *_W_24(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_25(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -909,7 +938,7 @@ template<class T> class Grid : public GridBase {
//! get max value in grid
Real getMax() const;
- static PyObject *_W_25(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_26(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -934,7 +963,7 @@ template<class T> class Grid : public GridBase {
//! get min value in grid
Real getMin() const;
- static PyObject *_W_26(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_27(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -959,7 +988,7 @@ template<class T> class Grid : public GridBase {
//! calculate L1 norm of grid content
Real getL1(int bnd = 0);
- 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);
@@ -985,7 +1014,7 @@ template<class T> class Grid : public GridBase {
//! calculate L2 norm of grid content
Real getL2(int bnd = 0);
- 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);
@@ -1011,7 +1040,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_29(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_30(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1039,7 +1068,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_30(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_31(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1066,7 +1095,7 @@ template<class T> class Grid : public GridBase {
//! get data pointer of grid
std::string getDataPointer();
- 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);
@@ -1091,7 +1120,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_32(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_33(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1160,7 +1189,7 @@ class MACGrid : public Grid<Vec3> {
{
mType = (GridType)(TypeMAC | TypeVec3);
}
- static int _W_33(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static int _W_34(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
PbClass *obj = Pb::objFromPy(_self);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list