From 888d180164004d121511609da044ea86c3aa9cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Barschkis?= Date: Wed, 19 Feb 2020 18:58:09 +0100 Subject: 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 --- extern/mantaflow/preprocessed/fileio/iogrids.cpp | 18 ++++----- extern/mantaflow/preprocessed/fileio/iomeshes.cpp | 8 ++-- .../mantaflow/preprocessed/fileio/ioparticles.cpp | 8 ++-- extern/mantaflow/preprocessed/fileio/ioutil.cpp | 45 ++++++++++++++++++++++ extern/mantaflow/preprocessed/fileio/mantaio.h | 2 + 5 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 extern/mantaflow/preprocessed/fileio/ioutil.cpp (limited to 'extern/mantaflow/preprocessed/fileio') 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 void writeGridRaw(const string &name, Grid *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 void readGridRaw(const string &name, Grid *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 void writeGridUni(const string &name, Grid *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 void readGridUni(const string &name, Grid *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 void writeGrid4dUni(const string &name, Grid4d *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 void writeGrid4dRaw(const string &name, Grid4d *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 void readGrid4dRaw(const string &name, Grid4d *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 void readMdataUni(const std::string &name, MeshDataImpl *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 void writeMdataUni(const std::string &name, MeshDataImpl *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 void writePdataUni(const std::string &name, ParticleDataImpl void readPdataUni(const std::string &name, ParticleDataImpl 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 +} + +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 void readMdataUni(const std::string &name, MeshDataImpl *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 -- cgit v1.2.3