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
This commit is contained in:
1
extern/mantaflow/CMakeLists.txt
vendored
1
extern/mantaflow/CMakeLists.txt
vendored
@@ -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
|
||||
|
18
extern/mantaflow/preprocessed/fileio/iogrids.cpp
vendored
18
extern/mantaflow/preprocessed/fileio/iogrids.cpp
vendored
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
||||
|
45
extern/mantaflow/preprocessed/fileio/ioutil.cpp
vendored
Normal file
45
extern/mantaflow/preprocessed/fileio/ioutil.cpp
vendored
Normal file
@@ -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
|
@@ -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
|
||||
|
2
extern/mantaflow/preprocessed/gitinfo.h
vendored
2
extern/mantaflow/preprocessed/gitinfo.h
vendored
@@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
#define MANTA_GIT_VERSION "commit abfff159b5ea8cee93d858f4b8be2a308b58b51d"
|
||||
#define MANTA_GIT_VERSION "commit 7b9e0d841274c65dce911ec578bd0b4779971422"
|
||||
|
4
extern/mantaflow/preprocessed/particle.cpp
vendored
4
extern/mantaflow/preprocessed/particle.cpp
vendored
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -359,7 +359,7 @@ def smoke_step_$ID$():\n\
|
||||
if using_fire_s$ID$:\n\
|
||||
flame_s$ID$.copyFrom(fuel_s$ID$) # temporarily misuse flame grid as vorticity storage\n\
|
||||
flame_s$ID$.multConst(flameVorticity_s$ID$)\n\
|
||||
vorticityConfinement(vel=vel_s$ID$, flags=flags_s$ID$, strengthGlobal=vorticity_s$ID$, strengthCell=flame_s$ID$ if using_fire_s$ID$ else None)\n\
|
||||
vorticityConfinement(vel=vel_s$ID$, flags=flags_s$ID$, strength=vorticity_s$ID$, strengthCell=flame_s$ID$ if using_fire_s$ID$ else None)\n\
|
||||
\n\
|
||||
if using_heat_s$ID$:\n\
|
||||
mantaMsg('Adding heat buoyancy')\n\
|
||||
|
Reference in New Issue
Block a user