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
path: root/extern
diff options
context:
space:
mode:
authorSebastián Barschkis <sebbas@sebbas.org>2020-02-19 20:58:09 +0300
committerSebastián Barschkis <sebbas@sebbas.org>2020-02-19 20:58:48 +0300
commit888d180164004d121511609da044ea86c3aa9cb0 (patch)
tree217442311b8023be7aa609344fbd312e28d0c2e7 /extern
parent04b7f052e14ee6ff09b5cc4c85a76c4c5a1b0383 (diff)
Fluid: Updated manta pp files
Updates in the files include: - New manta files now use an platform independent gzopen function - Adjusted argument name for vorticity
Diffstat (limited to 'extern')
-rw-r--r--extern/mantaflow/CMakeLists.txt1
-rw-r--r--extern/mantaflow/preprocessed/fileio/iogrids.cpp18
-rw-r--r--extern/mantaflow/preprocessed/fileio/iomeshes.cpp8
-rw-r--r--extern/mantaflow/preprocessed/fileio/ioparticles.cpp8
-rw-r--r--extern/mantaflow/preprocessed/fileio/ioutil.cpp45
-rw-r--r--extern/mantaflow/preprocessed/fileio/mantaio.h2
-rw-r--r--extern/mantaflow/preprocessed/gitinfo.h2
-rw-r--r--extern/mantaflow/preprocessed/particle.cpp4
-rw-r--r--extern/mantaflow/preprocessed/plugin/extforces.cpp8
-rw-r--r--extern/mantaflow/preprocessed/plugin/flip.cpp7
10 files changed, 76 insertions, 27 deletions
diff --git a/extern/mantaflow/CMakeLists.txt b/extern/mantaflow/CMakeLists.txt
index 99d985578bd..7486f123666 100644
--- a/extern/mantaflow/CMakeLists.txt
+++ b/extern/mantaflow/CMakeLists.txt
@@ -117,6 +117,7 @@ set(SRC
${MANTA_PP}/fastmarch.cpp
${MANTA_PP}/fastmarch.h
${MANTA_PP}/fastmarch.h.reg.cpp
+ ${MANTA_PP}/fileio/ioutil.cpp
${MANTA_PP}/fileio/iogrids.cpp
${MANTA_PP}/fileio/iomeshes.cpp
${MANTA_PP}/fileio/ioparticles.cpp
diff --git a/extern/mantaflow/preprocessed/fileio/iogrids.cpp b/extern/mantaflow/preprocessed/fileio/iogrids.cpp
index 2b8ee905f99..acd1bda5174 100644
--- a/extern/mantaflow/preprocessed/fileio/iogrids.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iogrids.cpp
@@ -298,7 +298,7 @@ template<class T> void writeGridRaw(const string &name, Grid<T> *grid)
debMsg("writing grid " << grid->getName() << " to raw file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeGridRaw: can't open file " << name);
gzwrite(gzf, &((*grid)[0]), sizeof(T) * grid->getSizeX() * grid->getSizeY() * grid->getSizeZ());
@@ -313,7 +313,7 @@ template<class T> void readGridRaw(const string &name, Grid<T> *grid)
debMsg("reading grid " << grid->getName() << " from raw file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("readGridRaw: can't open file " << name);
@@ -350,7 +350,7 @@ void getUniFileSize(const string &name, int &x, int &y, int &z, int *t, std::str
{
x = y = z = 0;
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (gzf) {
char ID[5] = {0, 0, 0, 0, 0};
gzread(gzf, ID, 4);
@@ -499,7 +499,7 @@ template<class T> void writeGridUni(const string &name, Grid<T> *grid)
else
errMsg("writeGridUni: unknown element type");
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeGridUni: can't open file " << name);
@@ -527,7 +527,7 @@ template<class T> void readGridUni(const string &name, Grid<T> *grid)
debMsg("Reading grid " << grid->getName() << " from uni file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("readGridUni: can't open file " << name);
@@ -736,7 +736,7 @@ template<class T> void writeGrid4dUni(const string &name, Grid4d<T> *grid)
else
errMsg("writeGrid4dUni: unknown element type");
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeGrid4dUni: can't open file " << name);
@@ -778,7 +778,7 @@ void readGrid4dUni(
// optionally - reuse file handle, if valid one is passed in fileHandle pointer...
if ((!fileHandle) || (fileHandle && (*fileHandle == NULL))) {
- gzf = gzopen(name.c_str(), "rb");
+ gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("readGrid4dUni: can't open file " << name);
@@ -905,7 +905,7 @@ template<class T> void writeGrid4dRaw(const string &name, Grid4d<T> *grid)
debMsg("writing grid4d " << grid->getName() << " to raw file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeGrid4dRaw: can't open file " << name);
gzwrite(gzf,
@@ -922,7 +922,7 @@ template<class T> void readGrid4dRaw(const string &name, Grid4d<T> *grid)
debMsg("reading grid4d " << grid->getName() << " from raw file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("readGrid4dRaw: can't open file " << name);
diff --git a/extern/mantaflow/preprocessed/fileio/iomeshes.cpp b/extern/mantaflow/preprocessed/fileio/iomeshes.cpp
index 79a9e76da3f..906b849fffb 100644
--- a/extern/mantaflow/preprocessed/fileio/iomeshes.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iomeshes.cpp
@@ -158,7 +158,7 @@ void readBobjFile(const string &name, Mesh *mesh, bool append)
const Real dx = mesh->getParent()->getDx();
const Vec3 gs = toVec3(mesh->getParent()->getGridSize());
- gzFile gzf = gzopen(name.c_str(), "rb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb1"); // do some compression
if (!gzf)
errMsg("readBobj: unable to open file");
@@ -213,7 +213,7 @@ void writeBobjFile(const string &name, Mesh *mesh)
const Real dx = mesh->getParent()->getDx();
const Vec3i gs = mesh->getParent()->getGridSize();
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("writeBobj: unable to open file");
@@ -412,7 +412,7 @@ template<class T> void readMdataUni(const std::string &name, MeshDataImpl<T> *md
debMsg("reading mesh data " << mdata->getName() << " from uni file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("can't open file " << name);
@@ -460,7 +460,7 @@ template<class T> void writeMdataUni(const std::string &name, MeshDataImpl<T> *m
MuTime stamp;
head.timestamp = stamp.time;
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("can't open file " << name);
gzwrite(gzf, ID, 4);
diff --git a/extern/mantaflow/preprocessed/fileio/ioparticles.cpp b/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
index a6cc7583327..2eab485beb3 100644
--- a/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
+++ b/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
@@ -176,7 +176,7 @@ void writeParticlesUni(const std::string &name, const BasicParticleSystem *parts
MuTime stamp;
head.timestamp = stamp.time;
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("can't open file " << name);
@@ -206,7 +206,7 @@ void readParticlesUni(const std::string &name, BasicParticleSystem *parts)
debMsg("reading particles " << parts->getName() << " from uni file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("can't open file " << name);
@@ -273,7 +273,7 @@ template<class T> void writePdataUni(const std::string &name, ParticleDataImpl<T
MuTime stamp;
head.timestamp = stamp.time;
- gzFile gzf = gzopen(name.c_str(), "wb1"); // do some compression
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1"); // do some compression
if (!gzf)
errMsg("can't open file " << name);
gzwrite(gzf, ID, 4);
@@ -299,7 +299,7 @@ template<class T> void readPdataUni(const std::string &name, ParticleDataImpl<T>
debMsg("reading particle data " << pdata->getName() << " from uni file " << name, 1);
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "rb");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "rb");
if (!gzf)
errMsg("can't open file " << name);
diff --git a/extern/mantaflow/preprocessed/fileio/ioutil.cpp b/extern/mantaflow/preprocessed/fileio/ioutil.cpp
new file mode 100644
index 00000000000..7c1682dfc5e
--- /dev/null
+++ b/extern/mantaflow/preprocessed/fileio/ioutil.cpp
@@ -0,0 +1,45 @@
+
+
+// DO NOT EDIT !
+// This file is generated using the MantaFlow preprocessor (prep generate).
+
+/******************************************************************************
+ *
+ * MantaFlow fluid solver framework
+ * Copyright 2011-2020 Tobias Pfaff, Nils Thuerey
+ *
+ * This program is free software, distributed under the terms of the
+ * Apache License, Version 2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Helper functions to handle file IO
+ *
+ ******************************************************************************/
+
+#include "mantaio.h"
+
+#if NO_ZLIB != 1
+extern "C" {
+# include <zlib.h>
+}
+
+namespace Manta {
+
+//! helper to handle non ascii filenames correctly, mainly problematic on windows
+void *safeGzopen(const char *filename, const char *mode)
+{
+ gzFile gzfile;
+# if defined(WIN32) || defined(_WIN32)
+ UTF16_ENCODE(filename);
+
+ // gzopen_w() is supported since zlib v1.2.7
+ gzfile = gzopen_w(filename_16, mode);
+ UTF16_UN_ENCODE(filename);
+# else
+ gzfile = gzopen(filename, mode);
+# endif
+ return gzfile;
+}
+#endif
+
+} // namespace
diff --git a/extern/mantaflow/preprocessed/fileio/mantaio.h b/extern/mantaflow/preprocessed/fileio/mantaio.h
index 8bb0a5af6a4..fbfe4bdd5d4 100644
--- a/extern/mantaflow/preprocessed/fileio/mantaio.h
+++ b/extern/mantaflow/preprocessed/fileio/mantaio.h
@@ -76,6 +76,8 @@ template<class T> void readMdataUni(const std::string &name, MeshDataImpl<T> *md
void getUniFileSize(
const std::string &name, int &x, int &y, int &z, int *t = NULL, std::string *info = NULL);
+void *safeGzopen(const char *filename, const char *mode);
+
} // namespace Manta
#endif
diff --git a/extern/mantaflow/preprocessed/gitinfo.h b/extern/mantaflow/preprocessed/gitinfo.h
index 943840958f6..0e84563eae3 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
-#define MANTA_GIT_VERSION "commit abfff159b5ea8cee93d858f4b8be2a308b58b51d"
+#define MANTA_GIT_VERSION "commit 7b9e0d841274c65dce911ec578bd0b4779971422"
diff --git a/extern/mantaflow/preprocessed/particle.cpp b/extern/mantaflow/preprocessed/particle.cpp
index 478f1417109..41af5d3ba81 100644
--- a/extern/mantaflow/preprocessed/particle.cpp
+++ b/extern/mantaflow/preprocessed/particle.cpp
@@ -182,7 +182,7 @@ void BasicParticleSystem::writeParticlesText(const string name) const
void BasicParticleSystem::writeParticlesRawPositionsGz(const string name) const
{
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "wb1");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1");
if (!gzf)
errMsg("can't open file " << name);
for (IndexInt i = 0; i < this->size(); ++i) {
@@ -198,7 +198,7 @@ void BasicParticleSystem::writeParticlesRawPositionsGz(const string name) const
void BasicParticleSystem::writeParticlesRawVelocityGz(const string name) const
{
#if NO_ZLIB != 1
- gzFile gzf = gzopen(name.c_str(), "wb1");
+ gzFile gzf = (gzFile)safeGzopen(name.c_str(), "wb1");
if (!gzf)
errMsg("can't open file " << name);
if (mPdataVec3.size() < 1)
diff --git a/extern/mantaflow/preprocessed/plugin/extforces.cpp b/extern/mantaflow/preprocessed/plugin/extforces.cpp
index df0ddb15b33..36221fbbc10 100644
--- a/extern/mantaflow/preprocessed/plugin/extforces.cpp
+++ b/extern/mantaflow/preprocessed/plugin/extforces.cpp
@@ -1335,7 +1335,7 @@ struct KnConfForce : public KernelBase {
void vorticityConfinement(MACGrid &vel,
const FlagGrid &flags,
- Real strengthGlobal = 0,
+ Real strength = 0,
const Grid<Real> *strengthCell = NULL)
{
Grid<Vec3> velCenter(flags.getParent()), curl(flags.getParent()), force(flags.getParent());
@@ -1344,7 +1344,7 @@ void vorticityConfinement(MACGrid &vel,
GetCentered(velCenter, vel);
CurlOp(velCenter, curl);
GridNorm(norm, curl);
- KnConfForce(force, norm, curl, strengthGlobal, strengthCell);
+ KnConfForce(force, norm, curl, strength, strengthCell);
KnApplyForceField(flags, vel, force, NULL, true, false);
}
static PyObject *_W_8(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
@@ -1359,11 +1359,11 @@ static PyObject *_W_8(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
ArgLocker _lock;
MACGrid &vel = *_args.getPtr<MACGrid>("vel", 0, &_lock);
const FlagGrid &flags = *_args.getPtr<FlagGrid>("flags", 1, &_lock);
- Real strengthGlobal = _args.getOpt<Real>("strengthGlobal", 2, 0, &_lock);
+ Real strength = _args.getOpt<Real>("strength", 2, 0, &_lock);
const Grid<Real> *strengthCell = _args.getPtrOpt<Grid<Real>>(
"strengthCell", 3, NULL, &_lock);
_retval = getPyNone();
- vorticityConfinement(vel, flags, strengthGlobal, strengthCell);
+ vorticityConfinement(vel, flags, strength, strengthCell);
_args.check();
}
pbFinalizePlugin(parent, "vorticityConfinement", !noTiming);
diff --git a/extern/mantaflow/preprocessed/plugin/flip.cpp b/extern/mantaflow/preprocessed/plugin/flip.cpp
index 4dfeff1d0ac..8ac167c1166 100644
--- a/extern/mantaflow/preprocessed/plugin/flip.cpp
+++ b/extern/mantaflow/preprocessed/plugin/flip.cpp
@@ -18,6 +18,7 @@
******************************************************************************/
#include "particle.h"
+#include "general.h"
#include "grid.h"
#include "commonkernels.h"
#include "randomstream.h"
@@ -1429,9 +1430,9 @@ struct correctLevelset : public KernelBase {
Real t = (t_high - maxEV) / (t_high - t_low);
correction = t * t * t - 3 * t * t + 3 * t;
}
- correction = (correction < 0) ?
- 0 :
- correction; // enforce correction factor to [0,1] (not explicitly in paper)
+ correction = clamp(correction,
+ Real(0),
+ Real(1)); // enforce correction factor to [0,1] (not explicitly in paper)
const Vec3 gridPos = Vec3(i, j, k) + Vec3(0.5); // shifted by half cell
const Real correctedPhi = fabs(norm(gridPos - pAcc(i, j, k))) - rAcc(i, j, k) * correction;