[Bf-blender-cvs] [87b5b498792] fluid-mantaflow: cleanup and made multiprocessing only available for unix
Sebastián Barschkis
noreply at git.blender.org
Wed Mar 21 16:22:36 CET 2018
Commit: 87b5b498792169905752ca9da4ca4a5b27695dee
Author: Sebastián Barschkis
Date: Wed Mar 21 16:22:26 2018 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB87b5b498792169905752ca9da4ca4a5b27695dee
cleanup and made multiprocessing only available for unix
before adding multiprocessing for windows see if it is worth the effort
===================================================================
M intern/mantaflow/intern/FLUID.cpp
M intern/mantaflow/intern/manta_fluid_API.cpp
M intern/mantaflow/intern/strings/liquid_script.h
M intern/mantaflow/intern/strings/shared_script.h
M intern/mantaflow/intern/strings/smoke_script.h
M release/scripts/startup/bl_ui/properties_physics_smoke.py
M source/blender/blenkernel/BKE_smoke.h
M source/blender/blenkernel/intern/smoke.c
M source/blender/editors/physics/physics_fluid.c
M source/blender/editors/physics/physics_intern.h
M source/blender/editors/physics/physics_ops.c
===================================================================
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index f987931bd8e..3b41014ac8b 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -1002,12 +1002,14 @@ int FLUID::readCacheLow(SmokeModifierData *smd, int framenr)
if (mUsingSmoke) {
BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_DATA_LOW, NULL);
if (!BLI_exists(cacheDir)) return 0;
- printf("READCACHE 2()\n");
ss.str("");
- ss << "smoke_load_geometry_low_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+ ss << "smoke_load_data_low_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
mCommands.push_back(ss.str());
runPythonString(mCommands);
+ updatePointers();
+
+ readSuccess = true;
}
if (mUsingLiquid) {
/* First try loading the mesh */
@@ -1097,7 +1099,6 @@ int FLUID::readCacheHigh(SmokeModifierData *smd, int framenr)
if (mUsingSmoke) {
BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_DATA_LOW, NULL);
if (!BLI_exists(cacheDir)) return 0;
- printf("READCACHE 2()\n");
ss.str("");
ss << "smoke_load_geometry_low_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
@@ -1235,7 +1236,7 @@ int FLUID::bakeParticlesLow(SmokeModifierData *smd, int framenr)
if (with_debug)
std::cout << "FLUID::bakeParticlesLow()" << std::endl;
- char cacheDirData[FILE_MAX], cacheDirParticles[FILE_MAX], cacheDirGeometry[FILE_MAX];;
+ char cacheDirData[FILE_MAX], cacheDirParticles[FILE_MAX], cacheDirGeometry[FILE_MAX];
cacheDirData[0] = '\0';
cacheDirParticles[0] = '\0';
cacheDirGeometry[0] = '\0';
@@ -1259,17 +1260,19 @@ int FLUID::bakeParticlesHigh(SmokeModifierData *smd, int framenr)
if (with_debug)
std::cout << "FLUID::bakeParticlesHigh()" << std::endl;
- char cacheDirData[FILE_MAX], cacheDirParticles[FILE_MAX];
+ char cacheDirData[FILE_MAX], cacheDirParticles[FILE_MAX], cacheDirGeometry[FILE_MAX];;;
cacheDirData[0] = '\0';
cacheDirParticles[0] = '\0';
+ cacheDirGeometry[0] = '\0';
mCommands.clear();
std::ostringstream ss;
BLI_path_join(cacheDirParticles, sizeof(cacheDirParticles), smd->domain->cache_directory, FLUID_CACHE_DIR_PARTICLES_HIGH, NULL);
BLI_path_join(cacheDirData, sizeof(cacheDirData), smd->domain->cache_directory, FLUID_CACHE_DIR_DATA_HIGH, NULL);
+ BLI_path_join(cacheDirGeometry, sizeof(cacheDirGeometry), smd->domain->cache_directory, FLUID_CACHE_DIR_GEOMETRY, NULL);
- ss << "bake_particles_high_" << mCurrentID << "('" << cacheDirParticles << "', '" << cacheDirData << "', " << framenr << ")";
+ ss << "bake_particles_high_" << mCurrentID << "('" << cacheDirParticles << "', '" << cacheDirData << "', '" << cacheDirGeometry << "', " << framenr << ")";
mCommands.push_back(ss.str());
runPythonString(mCommands);
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index c2c302e7f7e..9be3048f0b2 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -850,9 +850,7 @@ extern "C" int fluid_bake_low(FLUID* fluid, SmokeModifierData *smd, int framenr)
extern "C" int fluid_bake_high(FLUID* fluid, SmokeModifierData *smd, int framenr)
{
- printf("fluid_bake_high 2\n");
if (!fluid || !smd) return 0;
- printf("fluid_bake_high 3\n");
return fluid->bakeSimulationHigh(smd, framenr);
}
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index 672e9b3b0cb..39c31926c72 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -325,6 +325,23 @@ def liquid_load_geometry_low_$ID$(path, framenr):\n\
framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
phiIn_s$ID$.load(os.path.join(path, 'phiIn_' + framenr + '.uni'))\n";
+const std::string liquid_load_data_low = "\n\
+def liquid_load_data_low_$ID$(path, framenr, withParticles):\n\
+ mantaMsg('Liquid load data low')\n\
+ framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
+ phi_s$ID$.load(os.path.join(path, 'phi_' + framenr +'.uni'))\n\
+ if withParticles:\n\
+ pp_s$ID$.load(os.path.join(path, 'pp_' + framenr +'.uni'))\n\
+ pVel_pp$ID$.load(os.path.join(path, 'pVel_' + framenr +'.uni'))\n";
+
+const std::string liquid_load_data_high = "\n\
+def liquid_load_data_high_$ID$(path, framenr, withParticles):\n\
+ mantaMsg('Liquid load data high')\n\
+ framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
+ phi_xl$ID$.load(os.path.join(path, 'phi_xl_' + framenr +'.uni'))\n\
+ if withParticles:\n\
+ pp_xl$ID$.load(os.path.join(path, 'pp_xl_' + framenr +'.uni'))\n";
+
const std::string liquid_load_mesh_low = "\n\
def liquid_load_mesh_low_$ID$(path, framenr):\n\
mantaMsg('Liquid load mesh low')\n\
@@ -350,26 +367,30 @@ def liquid_load_particles_high_$ID$(path, framenr):\n\
mantaMsg('Liquid load particles high')\n\
# Nothing to do here yet!\n";
-const std::string liquid_load_data_low = "\n\
-def liquid_load_data_low_$ID$(path, framenr, withParticles):\n\
- mantaMsg('Liquid load data low')\n\
+//////////////////////////////////////////////////////////////////////
+// EXPORT
+//////////////////////////////////////////////////////////////////////
+
+const std::string liquid_save_geometry_low = "\n\
+def liquid_save_geometry_low_$ID$(path, framenr):\n\
+ mantaMsg('Liquid save geometry')\n\
framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
- phi_s$ID$.load(os.path.join(path, 'phi_' + framenr +'.uni'))\n\
- if withParticles:\n\
- pp_s$ID$.load(os.path.join(path, 'pp_' + framenr +'.uni'))\n\
- pVel_pp$ID$.load(os.path.join(path, 'pVel_' + framenr +'.uni'))\n";
+ phiIn_s$ID$.save(os.path.join(path, 'phiIn_' + framenr + '.uni'))\n";
-const std::string liquid_load_data_high = "\n\
-def liquid_load_data_high_$ID$(path, framenr, withParticles):\n\
- mantaMsg('Liquid load data high')\n\
+const std::string liquid_save_data_low = "\n\
+def liquid_save_data_low_$ID$(path, framenr):\n\
+ mantaMsg('Liquid save data low')\n\
framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
- phi_xl$ID$.load(os.path.join(path, 'phi_xl_' + framenr +'.uni'))\n\
- if withParticles:\n\
- pp_xl$ID$.load(os.path.join(path, 'pp_xl_' + framenr +'.uni'))\n";
+ phi_s$ID$.save(os.path.join(path, 'phi_' + framenr +'.uni'))\n\
+ pp_s$ID$.save(os.path.join(path, 'pp_' + framenr +'.uni'))\n\
+ pVel_pp$ID$.save(os.path.join(path, 'pVel_' + framenr +'.uni'))\n";
-//////////////////////////////////////////////////////////////////////
-// EXPORT
-//////////////////////////////////////////////////////////////////////
+const std::string liquid_save_data_high = "\n\
+def liquid_save_data_high_$ID$(path, framenr):\n\
+ mantaMsg('Liquid save data high')\n\
+ framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
+ phi_xl$ID$.save(os.path.join(path, 'phi_xl_' + framenr +'.uni'))\n\
+ pp_s$ID$.save(os.path.join(path, 'pp_xl_' + framenr +'.uni'))\n";
const std::string liquid_save_mesh_low = "\n\
def liquid_save_mesh_low_$ID$(path, framenr):\n\
@@ -399,26 +420,10 @@ def liquid_save_particles_low_$ID$(path, framenr):\n\
pVelSnd_pp$ID$.save(os.path.join(path, 'pVelSnd_' + framenr + '.uni'))\n\
pLifeSnd_pp$ID$.save(os.path.join(path, 'pLifeSnd_' + framenr + '.uni'))\n";
-const std::string liquid_save_data_low = "\n\
-def liquid_save_data_low_$ID$(path, framenr):\n\
- mantaMsg('Liquid save data low')\n\
- framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
- phi_s$ID$.save(os.path.join(path, 'phi_' + framenr +'.uni'))\n\
- pp_s$ID$.save(os.path.join(path, 'pp_' + framenr +'.uni'))\n\
- pVel_pp$ID$.save(os.path.join(path, 'pVel_' + framenr +'.uni'))\n";
-
-const std::string liquid_save_data_high = "\n\
-def liquid_save_data_high_$ID$(path, framenr):\n\
- mantaMsg('Liquid save data high')\n\
- framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
- phi_xl$ID$.save(os.path.join(path, 'phi_xl_' + framenr +'.uni'))\n\
- pp_s$ID$.save(os.path.join(path, 'pp_xl_' + framenr +'.uni'))\n";
-
-const std::string liquid_save_geometry_low = "\n\
-def liquid_save_geometry_low_$ID$(path, framenr):\n\
- mantaMsg('Liquid save geometry')\n\
- framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
- phiIn_s$ID$.save(os.path.join(path, 'phiIn_' + framenr + '.uni'))\n";
+const std::string liquid_save_particles_high = "\n\
+def liquid_save_particles_high$ID$(path, framenr):\n\
+ mantaMsg('Liquid save particles high')\n\
+ # Nothing to do here yet!\n";
//////////////////////////////////////////////////////////////////////
// STANDALONE MODE
diff --git a/intern/mantaflow/intern/strings/shared_script.h b/intern/mantaflow/intern/strings/shared_script.h
index 8f0bc8c988e..2516f92255a 100644
--- a/intern/mantaflow/intern/strings/shared_script.h
+++ b/intern/mantaflow/intern/strings/shared_script.h
@@ -35,7 +35,19 @@
const std::string manta_import = "\
from manta import *\n\
-import os, shutil, math, sys, gc, multiprocessing, errno, bpy\n";
+import os.path, shutil, math, sys, gc, multiprocessing, platform\n\
+\n\
+# TODO (sebbas): Use this to simulate Windows multiprocessing (has default mode spawn)\n\
+debugMp = False\n\
+#try:\n\
+# multiprocessing.set_start_method('spawn')\n\
+#except:\n\
+# pass\n\
+\n\
+bpy = sys.modules.get('bpy')\n\
+if bpy is not None:\n\
+ sys.executable = bpy.app.binary_path_python\n\
+del bpy\n";
//////////////////////////////////////////////////////////////////////
// DEBUG
@@ -301,8 +313,10 @@ def bake_fluid_process_low_$ID$(framenr, path_geometry, path_data):\n\
# Load grids before stepping - because every process has its own memory space!\n\
if framenr>1:\n\
fluid_load_data_low_$ID$(path_data, framenr-1) # load data from previous frame\n\
- #if using_smoke_s$ID$:\n\
- # smoke_load_data_low_$ID$(path_geometry, framenr)\n\
+ if using_smoke_s$ID$:\n\
+ smoke_load_geometry_low_$ID$(path_geometry, framenr)\n\
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list