51 using std::istringstream;
53 using std::ostringstream;
60 : mCurrentID(++solverID), mMaxRes(fmd->domain->maxres)
63 cout <<
"FLUID: " << mCurrentID <<
" with res(" << res[0] <<
", " << res[1] <<
", " << res[2]
94 mTotalCells = mResX * mResY * mResZ;
95 mResGuiding = fds->
res;
101 mVelocityX =
nullptr;
102 mVelocityY =
nullptr;
103 mVelocityZ =
nullptr;
114 mDensityIn =
nullptr;
121 mEmissionIn =
nullptr;
125 mDensityHigh =
nullptr;
126 mFlameHigh =
nullptr;
128 mReactHigh =
nullptr;
129 mColorRHigh =
nullptr;
130 mColorGHigh =
nullptr;
131 mColorBHigh =
nullptr;
135 mTextureU2 =
nullptr;
136 mTextureV2 =
nullptr;
137 mTextureW2 =
nullptr;
141 mPhiStaticIn =
nullptr;
143 mPhiOutStaticIn =
nullptr;
147 mMeshNodes =
nullptr;
148 mMeshTriangles =
nullptr;
149 mMeshVelocities =
nullptr;
153 mPhiObsStaticIn =
nullptr;
154 mNumObstacle =
nullptr;
155 mObVelocityX =
nullptr;
156 mObVelocityY =
nullptr;
157 mObVelocityZ =
nullptr;
160 mPhiGuideIn =
nullptr;
162 mGuideVelocityX =
nullptr;
163 mGuideVelocityY =
nullptr;
164 mGuideVelocityZ =
nullptr;
167 mInVelocityX =
nullptr;
168 mInVelocityY =
nullptr;
169 mInVelocityZ =
nullptr;
172 mFlipParticleData =
nullptr;
173 mFlipParticleVelocity =
nullptr;
174 mParticleData =
nullptr;
175 mParticleVelocity =
nullptr;
176 mParticleLife =
nullptr;
179 mFlipFromFile =
false;
180 mMeshFromFile =
false;
181 mParticlesFromFile =
false;
184 initializeMantaflow();
187 initializeRNAMap(fmd);
189 bool initSuccess =
true;
193 initSuccess &= initDomain();
202 if (mUsingDrops || mUsingBubbles || mUsingFloats || mUsingTracers) {
204 mResXParticle = mUpresParticle * mResX;
205 mResYParticle = mUpresParticle * mResY;
206 mResZParticle = mUpresParticle * mResZ;
207 mTotalCellsParticles = mResXParticle * mResYParticle * mResZParticle;
215 mResXMesh = mUpresMesh * mResX;
216 mResYMesh = mUpresMesh * mResY;
217 mResZMesh = mUpresMesh * mResZ;
218 mTotalCellsMesh = mResXMesh * mResYMesh * mResZMesh;
221 initSuccess &= initMesh();
225 if (mUsingViscosity) {
229 if (mUsingDiffusion) {
237 if (mUsingFractions) {
244 initSuccess &= initDomain();
245 initSuccess &= initSmoke();
266 mResXNoise = amplify * mResX;
267 mResYNoise = amplify * mResY;
268 mResZNoise = amplify * mResZ;
269 mTotalCellsHigh = mResXNoise * mResYNoise * mResZNoise;
272 initSuccess &= initNoise();
273 initSuccess &= initSmokeNoise();
294 ss <<
"set_manta_debuglevel(" <<
with_debug <<
")";
295 pythonCommands.push_back(ss.str());
303 string finalString = parseScript(tmpString, fmd);
304 pythonCommands.push_back(finalString);
305 return runPythonString(pythonCommands);
312 string finalString = parseScript(tmpString, fmd);
313 pythonCommands.push_back(finalString);
315 return runPythonString(pythonCommands);
323 string finalString = parseScript(tmpString, fmd);
324 pythonCommands.push_back(finalString);
326 return runPythonString(pythonCommands);
334 string finalString = parseScript(tmpString, fmd);
335 pythonCommands.push_back(finalString);
338 return runPythonString(pythonCommands);
346 string finalString = parseScript(tmpString, fmd);
347 pythonCommands.push_back(finalString);
350 return runPythonString(pythonCommands);
360 string finalString = parseScript(tmpString, fmd);
361 pythonCommands.push_back(finalString);
364 return runPythonString(pythonCommands);
374 string finalString = parseScript(tmpString, fmd);
375 pythonCommands.push_back(finalString);
378 return runPythonString(pythonCommands);
388 string finalString = parseScript(tmpString, fmd);
389 pythonCommands.push_back(finalString);
392 return runPythonString(pythonCommands);
402 string finalString = parseScript(tmpString, fmd);
403 pythonCommands.push_back(finalString);
406 return runPythonString(pythonCommands);
417 string finalString = parseScript(tmpString, fmd);
418 pythonCommands.push_back(finalString);
421 return runPythonString(pythonCommands);
430 string finalString = parseScript(tmpString, fmd);
431 pythonCommands.push_back(finalString);
434 return runPythonString(pythonCommands);
441 string finalString = parseScript(tmpString, fmd);
442 pythonCommands.push_back(finalString);
445 return runPythonString(pythonCommands);
452 string finalString = parseScript(tmpString, fmd);
453 pythonCommands.push_back(finalString);
455 mUsingViscosity =
true;
456 return runPythonString(pythonCommands);
461 std::vector<std::string> pythonCommands;
463 pythonCommands.push_back(finalString);
465 mUsingDiffusion =
true;
466 return runPythonString(pythonCommands);
474 string finalString = parseScript(tmpString, fmd);
475 pythonCommands.push_back(finalString);
477 return (mUsingObstacle = runPythonString(pythonCommands));
488 string finalString = parseScript(tmpString, fmd);
489 pythonCommands.push_back(finalString);
491 return (mUsingGuiding = runPythonString(pythonCommands));
500 string finalString = parseScript(tmpString, fmd);
501 pythonCommands.push_back(finalString);
503 return (mUsingFractions = runPythonString(pythonCommands));
511 string finalString = parseScript(tmpString, fmd);
512 pythonCommands.push_back(finalString);
514 return (mUsingInvel = runPythonString(pythonCommands));
524 string finalString = parseScript(tmpString, fmd);
525 pythonCommands.push_back(finalString);
527 return (mUsingOutflow = runPythonString(pythonCommands));
536 string finalString = parseScript(tmpString, fmd);
537 pythonCommands.push_back(finalString);
539 return runPythonString(pythonCommands);
544 if (!mParticleData) {
549 string finalString = parseScript(tmpString, fmd);
550 pythonCommands.push_back(finalString);
552 return runPythonString(pythonCommands);
560 cout <<
"~FLUID: " << mCurrentID <<
" with res(" << mResX <<
", " << mResY <<
", " << mResZ
564 string tmpString =
"";
575 string finalString = parseScript(tmpString);
576 pythonCommands.push_back(finalString);
577 result = runPythonString(pythonCommands);
599 PyGILState_STATE gilstate = PyGILState_Ensure();
606 string command = *it;
609 PyObject *return_value = PyRun_String(
610 command.c_str(), Py_file_input, globals_dict, globals_dict);
612 if (return_value ==
nullptr) {
614 if (PyErr_Occurred()) {
619 Py_DECREF(return_value);
622 PyGILState_Release(gilstate);
628 void MANTA::initializeMantaflow()
631 cout <<
"Fluid: Initializing Mantaflow framework" << endl;
633 string filename =
"manta_scene_" +
to_string(mCurrentID) +
".py";
638 PyGILState_STATE gilstate = PyGILState_Ensure();
639 Pb::setup(filename, fill);
640 PyGILState_Release(gilstate);
643 void MANTA::terminateMantaflow()
646 cout <<
"Fluid: Releasing Mantaflow framework" << endl;
648 PyGILState_STATE gilstate = PyGILState_Ensure();
650 PyGILState_Release(gilstate);
656 cout <<
"MANTA::getCacheFileEnding()" << endl;
658 switch (cache_format) {
670 cerr <<
"Fluid Error -- Could not find file extension. Using default file extension."
678 return (value) ?
"True" :
"False";
684 cout <<
"MANTA::initializeRNAMap()" << endl;
690 cout <<
"Fluid: No modifier data given in RNA map setup - returning early" << endl;
697 string borderCollisions =
"";
699 borderCollisions +=
"x";
701 borderCollisions +=
"X";
703 borderCollisions +=
"y";
705 borderCollisions +=
"Y";
707 borderCollisions +=
"z";
709 borderCollisions +=
"Z";
711 string particleTypesStr =
"";
713 particleTypesStr +=
"PtypeSpray";
715 if (!particleTypesStr.empty())
716 particleTypesStr +=
"|";
717 particleTypesStr +=
"PtypeBubble";
720 if (!particleTypesStr.empty())
721 particleTypesStr +=
"|";
722 particleTypesStr +=
"PtypeFoam";
725 if (!particleTypesStr.empty())
726 particleTypesStr +=
"|";
727 particleTypesStr +=
"PtypeTracer";
729 if (particleTypesStr.empty())
730 particleTypesStr =
"0";
740 string vdbCompressionMethod =
"Compression_None";
742 vdbCompressionMethod =
"Compression_None";
744 vdbCompressionMethod =
"Compression_Zip";
746 vdbCompressionMethod =
"Compression_Blosc";
748 string vdbPrecisionHalf =
"Precision_Half";
750 vdbPrecisionHalf =
"Precision_Full";
752 vdbPrecisionHalf =
"Precision_Half";
754 vdbPrecisionHalf =
"Precision_Mini";
768 mRNAMap[
"DOMAIN_CLOSED"] =
getBooleanString(borderCollisions.compare(
"") == 0);
785 mRNAMap[
"BOUND_CONDITIONS"] = borderCollisions;
804 mRNAMap[
"NOISE_RESX"] =
to_string(mResXNoise);
807 mRNAMap[
"MESH_RESX"] =
to_string(mResXMesh);
810 mRNAMap[
"PARTICLE_RESX"] =
to_string(mResXParticle);
811 mRNAMap[
"PARTICLE_RESY"] = (is2D) ?
to_string(mResZParticle) :
to_string(mResYParticle);
813 mRNAMap[
"GUIDING_RESX"] =
to_string(mResGuiding[0]);
814 mRNAMap[
"GUIDING_RESY"] = (is2D) ?
to_string(mResGuiding[2]) :
to_string(mResGuiding[1]);
875 mRNAMap[
"FLUID_VISCOSITY"] =
to_string(viscosity);
876 mRNAMap[
"FLUID_DOMAIN_SIZE"] =
to_string(domainSize);
880 mRNAMap[
"SNDPARTICLE_TYPES"] = particleTypesStr;
887 mRNAMap[
"CACHE_DIR"] = cacheDirectory;
888 mRNAMap[
"COMPRESSION_OPENVDB"] = vdbCompressionMethod;
889 mRNAMap[
"PRECISION_OPENVDB"] = vdbPrecisionHalf;
1041 string MANTA::getRealValue(
const string &varName)
1043 unordered_map<string, string>::iterator it;
1044 it = mRNAMap.find(varName);
1046 if (it == mRNAMap.end()) {
1047 cerr <<
"Fluid Error -- variable " << varName <<
" not found in RNA map " << it->second
1055 string MANTA::parseLine(
const string &line)
1057 if (line.size() == 0)
1060 int currPos = 0, start_del = 0, end_del = -1;
1061 bool readingVar =
false;
1062 const char delimiter =
'$';
1063 while (currPos < line.size()) {
1064 if (line[currPos] == delimiter && !readingVar) {
1066 start_del = currPos + 1;
1067 res += line.substr(end_del + 1, currPos - end_del - 1);
1069 else if (line[currPos] == delimiter && readingVar) {
1072 res += getRealValue(line.substr(start_del, currPos - start_del));
1076 res += line.substr(end_del + 1, line.size() - end_del);
1083 cout <<
"MANTA::parseScript()" << endl;
1085 istringstream f(setup_string);
1091 initializeRNAMap(fmd);
1093 while (getline(f, line)) {
1094 res << parseLine(line) <<
"\n";
1107 else if (
c ==
'\'') {
1120 cout <<
"MANTA::writeConfiguration()" << endl;
1134 cerr <<
"Fluid Error -- Cannot open file " <<
file << endl;
1139 gzwrite(gzf, &fds->
res, 3 *
sizeof(
int));
1140 gzwrite(gzf, &fds->
dx,
sizeof(
float));
1141 gzwrite(gzf, &fds->
dt,
sizeof(
float));
1142 gzwrite(gzf, &fds->
p0, 3 *
sizeof(
float));
1143 gzwrite(gzf, &fds->
p1, 3 *
sizeof(
float));
1144 gzwrite(gzf, &fds->
dp0, 3 *
sizeof(
float));
1145 gzwrite(gzf, &fds->
shift, 3 *
sizeof(
int));
1146 gzwrite(gzf, &fds->
obj_shift_f, 3 *
sizeof(
float));
1147 gzwrite(gzf, &fds->
obmat, 16 *
sizeof(
float));
1148 gzwrite(gzf, &fds->
base_res, 3 *
sizeof(
int));
1149 gzwrite(gzf, &fds->
res_min, 3 *
sizeof(
int));
1150 gzwrite(gzf, &fds->
res_max, 3 *
sizeof(
int));
1155 return (gzclose(gzf) == Z_OK);
1161 cout <<
"MANTA::writeData()" << endl;
1173 ss <<
"smoke_save_data_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1174 <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1175 pythonCommands.push_back(ss.str());
1179 ss <<
"liquid_save_data_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1180 <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1181 pythonCommands.push_back(ss.str());
1183 return runPythonString(pythonCommands);
1189 cout <<
"MANTA::writeNoise()" << endl;
1199 if (mUsingSmoke && mUsingNoise) {
1201 ss <<
"smoke_save_noise_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1202 <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1203 pythonCommands.push_back(ss.str());
1205 return runPythonString(pythonCommands);
1211 cout <<
"MANTA::readConfiguration()" << endl;
1225 cerr <<
"Fluid Error -- Cannot open file " <<
file << endl;
1230 gzread(gzf, &fds->
res, 3 *
sizeof(
int));
1231 gzread(gzf, &fds->
dx,
sizeof(
float));
1232 gzread(gzf, &dummy,
sizeof(
float));
1233 gzread(gzf, &fds->
p0, 3 *
sizeof(
float));
1234 gzread(gzf, &fds->
p1, 3 *
sizeof(
float));
1235 gzread(gzf, &fds->
dp0, 3 *
sizeof(
float));
1236 gzread(gzf, &fds->
shift, 3 *
sizeof(
int));
1237 gzread(gzf, &fds->
obj_shift_f, 3 *
sizeof(
float));
1238 gzread(gzf, &fds->
obmat, 16 *
sizeof(
float));
1239 gzread(gzf, &fds->
base_res, 3 *
sizeof(
int));
1240 gzread(gzf, &fds->
res_min, 3 *
sizeof(
int));
1241 gzread(gzf, &fds->
res_max, 3 *
sizeof(
int));
1244 gzread(gzf, &fds->
cache_id, 4 *
sizeof(
char));
1248 return (gzclose(gzf) == Z_OK);
1254 cout <<
"MANTA::readData()" << endl;
1256 if (!mUsingSmoke && !mUsingLiquid)
1266 string resumable_cache = (!resumable) ?
"False" :
"True";
1274 ss <<
"smoke_load_data_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1275 <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1276 pythonCommands.push_back(ss.str());
1277 result &= runPythonString(pythonCommands);
1278 return (mSmokeFromFile =
result);
1282 ss <<
"liquid_load_data_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1283 <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1284 pythonCommands.push_back(ss.str());
1285 result &= runPythonString(pythonCommands);
1286 return (mFlipFromFile =
result);
1294 cout <<
"MANTA::readNoise()" << endl;
1296 if (!mUsingSmoke || !mUsingNoise)
1304 string resumable_cache = (!resumable) ?
"False" :
"True";
1316 ss <<
"smoke_load_noise_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1317 <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1318 pythonCommands.push_back(ss.str());
1320 return (mNoiseFromFile = runPythonString(pythonCommands));
1326 cout <<
"MANTA::readMesh()" << endl;
1328 if (!mUsingLiquid || !mUsingMesh)
1344 ss <<
"liquid_load_mesh_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1345 <<
", '" << mesh_format <<
"')";
1346 pythonCommands.push_back(ss.str());
1350 ss <<
"liquid_load_meshvel_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1351 <<
", '" << volume_format <<
"')";
1352 pythonCommands.push_back(ss.str());
1355 return (mMeshFromFile = runPythonString(pythonCommands));
1361 cout <<
"MANTA::readParticles()" << endl;
1365 if (!mUsingDrops && !mUsingBubbles && !mUsingFloats && !mUsingTracers)
1373 string resumable_cache = (!resumable) ?
"False" :
"True";
1385 ss <<
"liquid_load_particles_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1386 <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1387 pythonCommands.push_back(ss.str());
1389 return (mParticlesFromFile = runPythonString(pythonCommands));
1395 cout <<
"MANTA::readGuiding()" << endl;
1416 ss <<
"fluid_load_vel_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1417 <<
", '" << volume_format <<
"')";
1421 ss <<
"fluid_load_guiding_" << mCurrentID <<
"('" <<
escapePath(directory) <<
"', " << framenr
1422 <<
", '" << volume_format <<
"')";
1424 pythonCommands.push_back(ss.str());
1426 return runPythonString(pythonCommands);
1432 cout <<
"MANTA::bakeData()" << endl;
1434 string tmpString, finalString;
1440 cacheDirData[0] =
'\0';
1441 cacheDirGuiding[0] =
'\0';
1448 sizeof(cacheDirGuiding),
1456 ss <<
"bake_fluid_data_" << mCurrentID <<
"('" <<
escapePath(cacheDirData) <<
"', " << framenr
1457 <<
", '" << volume_format <<
"')";
1458 pythonCommands.push_back(ss.str());
1460 return runPythonString(pythonCommands);
1466 cout <<
"MANTA::bakeNoise()" << endl;
1473 cacheDirNoise[0] =
'\0';
1482 ss <<
"bake_noise_" << mCurrentID <<
"('" <<
escapePath(cacheDirNoise) <<
"', " << framenr
1483 <<
", '" << volume_format <<
"')";
1484 pythonCommands.push_back(ss.str());
1486 return runPythonString(pythonCommands);
1492 cout <<
"MANTA::bakeMesh()" << endl;
1499 cacheDirMesh[0] =
'\0';
1509 ss <<
"bake_mesh_" << mCurrentID <<
"('" <<
escapePath(cacheDirMesh) <<
"', " << framenr <<
", '"
1510 << volume_format <<
"', '" << mesh_format <<
"')";
1511 pythonCommands.push_back(ss.str());
1513 return runPythonString(pythonCommands);
1519 cout <<
"MANTA::bakeParticles()" << endl;
1526 cacheDirParticles[0] =
'\0';
1532 sizeof(cacheDirParticles),
1539 ss <<
"bake_particles_" << mCurrentID <<
"('" <<
escapePath(cacheDirParticles) <<
"', "
1540 << framenr <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1541 pythonCommands.push_back(ss.str());
1543 return runPythonString(pythonCommands);
1549 cout <<
"MANTA::bakeGuiding()" << endl;
1556 cacheDirGuiding[0] =
'\0';
1562 sizeof(cacheDirGuiding),
1569 ss <<
"bake_guiding_" << mCurrentID <<
"('" <<
escapePath(cacheDirGuiding) <<
"', " << framenr
1570 <<
", '" << volume_format <<
"', " << resumable_cache <<
")";
1571 pythonCommands.push_back(ss.str());
1573 return runPythonString(pythonCommands);
1578 string tmpString, finalString;
1593 if (mUsingDrops || mUsingBubbles || mUsingFloats || mUsingTracers) {
1600 finalString = parseScript(tmpString, fmd);
1601 pythonCommands.push_back(finalString);
1603 return runPythonString(pythonCommands);
1609 cout <<
"MANTA::exportSmokeScript()" << endl;
1612 char cacheDirScript[
FILE_MAX] =
"\0";
1634 string manta_script;
1705 string final_script = MANTA::parseScript(manta_script, fmd);
1709 myfile.open(cacheDirScript);
1710 myfile << final_script;
1713 cerr <<
"Fluid Error -- Could not export standalone Mantaflow smoke domain script";
1722 cout <<
"MANTA::exportLiquidScript()" << endl;
1725 char cacheDirScript[
FILE_MAX] =
"\0";
1750 string manta_script;
1759 if (drops || bubble || floater || tracer)
1770 if (drops || bubble || floater || tracer)
1781 if (drops || bubble || floater || tracer)
1806 if (drops || bubble || floater || tracer)
1818 if (drops || bubble || floater || tracer)
1825 string final_script = MANTA::parseScript(manta_script, fmd);
1829 myfile.open(cacheDirScript);
1830 myfile << final_script;
1833 cerr <<
"Fluid Error -- Could not export standalone Mantaflow liquid domain script";
1848 if ((varName ==
"") || (functionName ==
"")) {
1850 cout <<
"Fluid: Missing Python variable name and/or function name -- name is: " << varName
1851 <<
", function name is: " << functionName << endl;
1855 PyGILState_STATE gilstate = PyGILState_Ensure();
1856 PyObject *var =
nullptr, *func =
nullptr, *returnedValue =
nullptr;
1863 PyGILState_Release(gilstate);
1869 PyGILState_Release(gilstate);
1875 PyGILState_Release(gilstate);
1879 func = PyObject_GetAttrString(var, functionName.c_str());
1883 PyGILState_Release(gilstate);
1888 returnedValue = PyObject_CallObject(func,
nullptr);
1892 PyGILState_Release(gilstate);
1893 return (!isAttribute) ? returnedValue : func;
1903 PyGILState_STATE gilstate = PyGILState_Ensure();
1905 PyObject *encoded = PyUnicode_AsUTF8String(inputObject);
1906 char *
result = PyBytes_AsString(encoded);
1908 Py_DECREF(inputObject);
1911 istringstream in(
str);
1912 void *dataPointer =
nullptr;
1917 PyGILState_Release(gilstate);
1928 PyGILState_STATE gilstate = PyGILState_Ensure();
1932 double result = PyFloat_AS_DOUBLE(inputObject);
1933 Py_DECREF(inputObject);
1935 PyGILState_Release(gilstate);
1946 PyGILState_STATE gilstate = PyGILState_Ensure();
1948 long result = PyLong_AsLong(inputObject);
1949 Py_DECREF(inputObject);
1951 PyGILState_Release(gilstate);
1955 template<
class T>
static T *
getPointer(
string pyObjectName,
string pyFunctionName)
1963 cout <<
"MANTA::getFrame()" << endl;
1965 string func =
"frame";
1967 string solver =
"s" +
id;
1975 cout <<
"MANTA::getTimestep()" << endl;
1977 string func =
"timestep";
1979 string solver =
"s" +
id;
1995 cout <<
"MANTA::adaptTimestep()" << endl;
2000 ss <<
"fluid_adapt_time_step_" << mCurrentID <<
"()";
2001 pythonCommands.push_back(ss.str());
2003 runPythonString(pythonCommands);
2009 cout <<
"MANTA::updatePointers()" << endl;
2027 bool parts = !flush && liquid && (drops | bubble | floater | tracer);
2031 string func =
"getDataPointer";
2032 string funcNodes =
"getNodesDataPointer";
2033 string funcTris =
"getTrisDataPointer";
2036 string s_ext =
"_s" +
id;
2037 string pp_ext =
"_pp" +
id;
2038 string snd_ext =
"_sp" +
id;
2039 string sm_ext =
"_sm" +
id;
2040 string mesh_ext =
"_mesh" +
id;
2041 string sn_ext =
"_sn" +
id;
2043 mFlags = (smoke || liquid) ? getPointer<int>(
"flags" + s_ext, func) :
nullptr;
2044 mPhiIn = (smoke || liquid) ? getPointer<float>(
"phiIn" + s_ext, func) :
nullptr;
2045 mPhiStaticIn = (smoke || liquid) ? getPointer<float>(
"phiSIn" + s_ext, func) :
nullptr;
2046 mVelocityX = (smoke || liquid) ? getPointer<float>(
"x_vel" + s_ext, func) :
nullptr;
2047 mVelocityY = (smoke || liquid) ? getPointer<float>(
"y_vel" + s_ext, func) :
nullptr;
2048 mVelocityZ = (smoke || liquid) ? getPointer<float>(
"z_vel" + s_ext, func) :
nullptr;
2049 mForceX = (smoke || liquid) ? getPointer<float>(
"x_force" + s_ext, func) :
nullptr;
2050 mForceY = (smoke || liquid) ? getPointer<float>(
"y_force" + s_ext, func) :
nullptr;
2051 mForceZ = (smoke || liquid) ? getPointer<float>(
"z_force" + s_ext, func) :
nullptr;
2052 mPressure = (smoke || liquid) ? getPointer<float>(
"pressure" + s_ext, func) :
nullptr;
2055 mPhiOutIn = (outflow) ? getPointer<float>(
"phiOutIn" + s_ext, func) :
nullptr;
2056 mPhiOutStaticIn = (outflow) ? getPointer<float>(
"phiOutSIn" + s_ext, func) :
nullptr;
2059 mPhiObsIn = (obstacle) ? getPointer<float>(
"phiObsIn" + s_ext, func) :
nullptr;
2060 mPhiObsStaticIn = (obstacle) ? getPointer<float>(
"phiObsSIn" + s_ext, func) :
nullptr;
2061 mObVelocityX = (obstacle) ? getPointer<float>(
"x_obvel" + s_ext, func) :
nullptr;
2062 mObVelocityY = (obstacle) ? getPointer<float>(
"y_obvel" + s_ext, func) :
nullptr;
2063 mObVelocityZ = (obstacle) ? getPointer<float>(
"z_obvel" + s_ext, func) :
nullptr;
2064 mNumObstacle = (obstacle) ? getPointer<float>(
"numObs" + s_ext, func) :
nullptr;
2067 mPhiGuideIn = (guiding) ? getPointer<float>(
"phiGuideIn" + s_ext, func) :
nullptr;
2068 mGuideVelocityX = (guiding) ? getPointer<float>(
"x_guidevel" + s_ext, func) :
nullptr;
2069 mGuideVelocityY = (guiding) ? getPointer<float>(
"y_guidevel" + s_ext, func) :
nullptr;
2070 mGuideVelocityZ = (guiding) ? getPointer<float>(
"z_guidevel" + s_ext, func) :
nullptr;
2071 mNumGuide = (guiding) ? getPointer<float>(
"numGuides" + s_ext, func) :
nullptr;
2074 mInVelocityX = (invel) ? getPointer<float>(
"x_invel" + s_ext, func) :
nullptr;
2075 mInVelocityY = (invel) ? getPointer<float>(
"y_invel" + s_ext, func) :
nullptr;
2076 mInVelocityZ = (invel) ? getPointer<float>(
"z_invel" + s_ext, func) :
nullptr;
2079 mDensity = (smoke) ? getPointer<float>(
"density" + s_ext, func) :
nullptr;
2080 mDensityIn = (smoke) ? getPointer<float>(
"densityIn" + s_ext, func) :
nullptr;
2081 mShadow = (smoke) ? getPointer<float>(
"shadow" + s_ext, func) :
nullptr;
2082 mEmissionIn = (smoke) ? getPointer<float>(
"emissionIn" + s_ext, func) :
nullptr;
2085 mHeat = (heat) ? getPointer<float>(
"heat" + s_ext, func) :
nullptr;
2086 mHeatIn = (heat) ? getPointer<float>(
"heatIn" + s_ext, func) :
nullptr;
2089 mFlame = (fire) ? getPointer<float>(
"flame" + s_ext, func) :
nullptr;
2090 mFuel = (fire) ? getPointer<float>(
"fuel" + s_ext, func) :
nullptr;
2091 mReact = (fire) ? getPointer<float>(
"react" + s_ext, func) :
nullptr;
2092 mFuelIn = (fire) ? getPointer<float>(
"fuelIn" + s_ext, func) :
nullptr;
2093 mReactIn = (fire) ? getPointer<float>(
"reactIn" + s_ext, func) :
nullptr;
2096 mColorR = (colors) ? getPointer<float>(
"color_r" + s_ext, func) :
nullptr;
2097 mColorG = (colors) ? getPointer<float>(
"color_g" + s_ext, func) :
nullptr;
2098 mColorB = (colors) ? getPointer<float>(
"color_b" + s_ext, func) :
nullptr;
2099 mColorRIn = (colors) ? getPointer<float>(
"color_r_in" + s_ext, func) :
nullptr;
2100 mColorGIn = (colors) ? getPointer<float>(
"color_g_in" + s_ext, func) :
nullptr;
2101 mColorBIn = (colors) ? getPointer<float>(
"color_b_in" + s_ext, func) :
nullptr;
2104 mDensityHigh = (
noise) ? getPointer<float>(
"density" + sn_ext, func) :
nullptr;
2105 mTextureU = (
noise) ? getPointer<float>(
"texture_u" + s_ext, func) :
nullptr;
2106 mTextureV = (
noise) ? getPointer<float>(
"texture_v" + s_ext, func) :
nullptr;
2107 mTextureW = (
noise) ? getPointer<float>(
"texture_w" + s_ext, func) :
nullptr;
2108 mTextureU2 = (
noise) ? getPointer<float>(
"texture_u2" + s_ext, func) :
nullptr;
2109 mTextureV2 = (
noise) ? getPointer<float>(
"texture_v2" + s_ext, func) :
nullptr;
2110 mTextureW2 = (
noise) ? getPointer<float>(
"texture_w2" + s_ext, func) :
nullptr;
2113 mFlameHigh = (
noise && fire) ? getPointer<float>(
"flame" + sn_ext, func) :
nullptr;
2114 mFuelHigh = (
noise && fire) ? getPointer<float>(
"fuel" + sn_ext, func) :
nullptr;
2115 mReactHigh = (
noise && fire) ? getPointer<float>(
"react" + sn_ext, func) :
nullptr;
2118 mColorRHigh = (
noise && colors) ? getPointer<float>(
"color_r" + sn_ext, func) :
nullptr;
2119 mColorGHigh = (
noise && colors) ? getPointer<float>(
"color_g" + sn_ext, func) :
nullptr;
2120 mColorBHigh = (
noise && colors) ? getPointer<float>(
"color_b" + sn_ext, func) :
nullptr;
2123 mPhi = (liquid) ? getPointer<float>(
"phi" + s_ext, func) :
nullptr;
2139 mFlipFromFile =
false;
2140 mMeshFromFile =
false;
2141 mParticlesFromFile =
false;
2142 mSmokeFromFile =
false;
2143 mNoiseFromFile =
false;
2165 cout <<
"Fluid: Has Data: " << exists << endl;
2191 cout <<
"Fluid: Has Noise: " << exists << endl;
2208 cout <<
"Fluid: Has Mesh: " << exists << endl;
2234 cout <<
"Fluid: Has Particles: " << exists << endl;
2244 bool exists =
BLI_exists(getFile(fmd, subdirectory, filename, extension, framenr).c_str());
2249 exists =
BLI_exists(getFile(fmd, subdirectory, filename, extension, framenr).c_str());
2253 cout <<
"Fluid: Has Guiding: " << exists << endl;
2267 string MANTA::getFile(
2268 FluidModifierData *fmd,
string subdirectory,
string fname,
string extension,
int framenr)
2271 string path = getDirectory(fmd, subdirectory);
2272 string filename = fname +
"_####" + extension;
2273 BLI_join_dirfile(targetFile,
sizeof(targetFile), path.c_str(), filename.c_str());
File and directory operations.
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_dir_create_recursive(const char *dir) ATTR_NONNULL()
void * BLI_gzopen(const char *filename, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_path_make_safe(char *path) ATTR_NONNULL(1)
bool BLI_path_frame(char *path, int frame, int digits) ATTR_NONNULL()
void BLI_join_dirfile(char *__restrict dst, const size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
size_t BLI_path_join(char *__restrict dst, const size_t dst_len, const char *path_first,...) ATTR_NONNULL(1
#define FLUID_DOMAIN_LIQUID_SCRIPT
#define FLUID_NAME_EMISSION
#define FLUID_NAME_TRAPPEDAIR_PARTICLES
#define FLUID_CACHE_VERSION
#define FLUID_NAME_FUEL_NOISE
#define FLUID_NAME_COLORG_NOISE
#define FLUID_NAME_COLORB_NOISE
#define FLUID_NAME_FLAGS_MESH
#define FLUID_DOMAIN_DIR_DATA
@ SNDPARTICLE_BOUNDARY_DELETE
@ SNDPARTICLE_BOUNDARY_PUSHOUT
#define FLUID_NAME_PHIPARTS_MESH
#define FLUID_DOMAIN_DIR_PARTICLES
#define FLUID_NAME_TMPFLAGS
#define FLUID_NAME_PHIOBS_PARTICLES
#define FLUID_NAME_FORCES
#define FLUID_NAME_PHIIN_NOISE
#define FLUID_NAME_WAVECREST_PARTICLES
#define FLUID_NAME_VELOCITY_PARTICLES
#define FLUID_NAME_EMISSIONIN
#define FLUID_NAME_PHIGUIDEIN
#define FLUID_NAME_PLIFE_PARTICLES
#define FLUID_NAME_PFORCE_PARTICLES
#define FLUID_NAME_PHITMP
#define FLUID_NAME_VELOCITYOLD
#define FLUID_NAME_PHIOBSSIN
#define FLUID_NAME_PP_PARTICLES
#define FLUID_NAME_KINETICENERGY_PARTICLES
#define FLUID_NAME_FORCE_Y
#define FLUID_NAME_PINDEX
#define FLUID_NAME_FUELIN
#define FLUID_NAME_PARTICLES
#define FLUID_DOMAIN_EXTENSION_BINOBJ
#define FLUID_NAME_FORCE_Z
#define FLUID_DOMAIN_SMOKE_SCRIPT
#define FLUID_NAME_GUIDEVEL_Z
#define FLUID_NAME_PVEL_PARTICLES
#define FLUID_NAME_GUIDEVEL_X
#define FLUID_NAME_TEXTURE_U
#define FLUID_DOMAIN_DIR_MESH
#define FLUID_DOMAIN_DIR_GUIDE
#define FLUID_DOMAIN_DIR_SCRIPT
#define FLUID_NAME_PARTSVEL_PARTICLES
#define FLUID_NAME_TMPIN_NOISE
#define FLUID_NAME_OBVEL_X
#define FLUID_NAME_PHIOBS
#define FLUID_NAME_CONFIG
#define FLUID_NAME_COLORR_NOISE
#define FLUID_DOMAIN_EXTENSION_OPENVDB
#define FLUID_NAME_GPI_MESH
@ FLUID_DOMAIN_PARTICLE_SPRAY
@ FLUID_DOMAIN_PARTICLE_FOAM
@ FLUID_DOMAIN_PARTICLE_TRACER
@ FLUID_DOMAIN_PARTICLE_BUBBLE
#define FLUID_NAME_VELOCITYZ
#define FLUID_NAME_GUIDEVELC
#define FLUID_NAME_VELOCITYTMP
#define FLUID_NAME_VELOCITYY
@ FLUID_DOMAIN_DELETE_IN_OBSTACLE
@ FLUID_DOMAIN_USE_RESUMABLE_CACHE
@ FLUID_DOMAIN_USE_DISSOLVE_LOG
@ FLUID_DOMAIN_USE_DIFFUSION
@ FLUID_DOMAIN_USE_ADAPTIVE_TIME
@ FLUID_DOMAIN_USE_VISCOSITY
@ FLUID_DOMAIN_USE_SPEED_VECTORS
@ FLUID_DOMAIN_USE_FRACTIONS
@ FLUID_DOMAIN_USE_DISSOLVE
#define FLUID_NAME_PINDEX_MESH
#define FLUID_NAME_PHIOUT_PARTICLES
#define FLUID_NAME_CURVATURE
#define FLUID_NAME_PHISIN
#define FLUID_NAME_VELOCITY_MESH
#define FLUID_DOMAIN_EXTENSION_OBJ
#define FLUID_NAME_INVEL_Z
#define FLUID_NAME_INVELC
#define FLUID_NAME_FLAGS_NOISE
#define FLUID_NAME_PARTSLIFE_PARTICLES
#define FLUID_NAME_COLORR
@ FLUID_DOMAIN_ACTIVE_COLORS
@ FLUID_DOMAIN_ACTIVE_FIRE
@ FLUID_DOMAIN_ACTIVE_INVEL
@ FLUID_DOMAIN_ACTIVE_GUIDE
@ FLUID_DOMAIN_ACTIVE_OUTFLOW
@ FLUID_DOMAIN_ACTIVE_HEAT
@ FLUID_DOMAIN_ACTIVE_OBSTACLE
#define FLUID_NAME_TEXTURE_U2
#define FLUID_NAME_PHIOUT
#define FLUID_NAME_TEXTURE_V2
@ FLUID_DOMAIN_FILE_BIN_OBJECT
@ FLUID_DOMAIN_FILE_OBJECT
@ FLUID_DOMAIN_FILE_OPENVDB
#define FLUID_NAME_EMISSIONIN_NOISE
#define FLUID_NAME_GUIDEVEL_Y
#define FLUID_NAME_TEXTURE_W2
#define FLUID_NAME_DENSITY_NOISE
#define FLUID_NAME_PHIOUTIN
#define FLUID_NAME_NUMOBS
#define FLUID_NAME_COLORG
#define FLUID_NAME_PHIOUTSIN
#define FLUID_NAME_GUIDEVEL
#define FLUID_NAME_VELOCITYPARTS
#define FLUID_DOMAIN_DIR_CONFIG
#define FLUID_NAME_PHIOBS_NOISE
#define FLUID_NAME_INVEL_Y
#define FLUID_NAME_SHADOW
#define FLUID_NAME_PARTSVELOCITY
#define FLUID_NAME_OBVEL_Y
#define FLUID_NAME_VELOCITYVEC_MESH
#define FLUID_NAME_COLORB
@ VDB_PRECISION_MINI_FLOAT
@ VDB_PRECISION_FULL_FLOAT
@ VDB_PRECISION_HALF_FLOAT
#define FLUID_NAME_OBVELC
#define FLUID_NAME_COLORGIN
#define FLUID_NAME_VELOCITY
#define FLUID_NAME_PHIOBSIN
#define FLUID_NAME_PHI_PARTICLES
@ FLUID_DOMAIN_METHOD_APIC
#define FLUID_NAME_FORCE_X
#define FLUID_NAME_NEIGHBORRATIO_PARTICLES
#define FLUID_NAME_PARTS_PARTICLES
#define FLUID_NAME_COLORBIN
#define FLUID_NAME_GUIDING
#define FLUID_NAME_DENSITY
#define FLUID_NAME_PARTSFORCE_PARTICLES
#define FLUID_NAME_VELOCITY_GUIDE
#define FLUID_DOMAIN_EXTENSION_UNI
#define FLUID_NAME_TEMPERATUREIN
#define FLUID_NAME_INVEL_X
@ FLUID_DOMAIN_BORDER_BOTTOM
@ FLUID_DOMAIN_BORDER_LEFT
@ FLUID_DOMAIN_BORDER_RIGHT
@ FLUID_DOMAIN_BORDER_FRONT
@ FLUID_DOMAIN_BORDER_TOP
@ FLUID_DOMAIN_BORDER_BACK
#define FLUID_NAME_REACTIN
#define FLUID_NAME_PRESSURE
#define FLUID_NAME_MAPWEIGHTS
#define FLUID_NAME_FLAME_NOISE
#define FLUID_NAME_PHIOUT_NOISE
#define FLUID_NAME_VELOCITY_NOISE
#define FLUID_NAME_TEXTURE_W
#define FLUID_NAME_PP_MESH
#define FLUID_DOMAIN_DIR_NOISE
#define FLUID_NAME_OBVEL_Z
#define FLUID_NAME_PHIPARTS
#define FLUID_NAME_NUMGUIDES
#define FLUID_NAME_HEATIN
#define FLUID_NAME_FLAGS_PARTICLES
#define FLUID_NAME_TEMPERATURE
@ FLUID_DOMAIN_MESH_IMPROVED
#define FLUID_NAME_PHI_MESH
#define FLUID_NAME_FRACTIONS
#define FLUID_NAME_REACT_NOISE
#define FLUID_NAME_TEXTURE_V
#define FLUID_NAME_COLORRIN
#define FLUID_NAME_ENERGY
#define FLUID_NAME_VELOCITYX
#define FLUID_NAME_DENSITYIN
#define FLUID_NAME_NORMAL_PARTICLES
#define FLUID_NAME_WEIGHTGUIDE
#define FLUID_DOMAIN_EXTENSION_RAW
@ FLUID_DOMAIN_TYPE_LIQUID
static string getBooleanString(int value)
static string getCacheFileEnding(char cache_format)
static PyObject * manta_main_module
static string escapePath(string const &s)
static T * getPointer(string pyObjectName, string pyFunctionName)
static double pyObjectToDouble(PyObject *inputObject)
static long pyObjectToLong(PyObject *inputObject)
static void * pyObjectToPointer(PyObject *inputObject)
static PyObject * callPythonFunction(string varName, string functionName, bool isAttribute=false)
Read Guarded memory(de)allocation.
const std::string header_import
const std::string fluid_save_guiding
const std::string fluid_file_import
const std::string fluid_alloc_fractions
const std::string fluid_pre_step
const std::string header_gridinit
const std::string fluid_with_outflow
const std::string header_main
const std::string fluid_alloc
const std::string fluid_bake_data
const std::string fluid_standalone
const std::string fluid_variables_noise
const std::string fluid_with_fractions
const std::string header_steps
const std::string fluid_alloc_invel
const std::string fluid_solver_viscosity
const std::string fluid_variables_particles
const std::string fluid_with_invel
const std::string fluid_solver_particles
const std::string fluid_solver_mesh
const std::string fluid_alloc_obstacle
const std::string manta_import
const std::string fluid_load_vel
const std::string fluid_file_export
const std::string fluid_bake_noise
const std::string fluid_alloc_outflow
const std::string fluid_bake_guiding
const std::string fluid_delete_all
const std::string manta_debuglevel
const std::string header_grids
const std::string fluid_bake_multiprocessing
const std::string fluid_with_sndparts
const std::string header_time
const std::string header_libraries
const std::string fluid_variables
const std::string header_solvers
const std::string fluid_adapt_time_step
const std::string header_variables
const std::string header_prepost
const std::string fluid_solver_noise
const std::string fluid_alloc_guiding
const std::string fluid_variables_viscosity
const std::string fluid_cache_helper
const std::string fluid_time_stepping
const std::string fluid_bake_mesh
const std::string fluid_solver
const std::string fluid_bake_particles
const std::string fluid_solver_guiding
const std::string fluid_post_step
const std::string fluid_load_guiding
const std::string fluid_variables_guiding
const std::string fluid_variables_mesh
const std::string fluid_with_obstacle
const std::string liquid_load_data
const std::string liquid_save_data
const std::string liquid_alloc_viscosity
const std::string liquid_variables
const std::string liquid_save_particles
const std::string liquid_standalone
const std::string liquid_variables_particles
const std::string liquid_load_mesh
const std::string liquid_alloc_particles
const std::string liquid_step
const std::string liquid_alloc
const std::string liquid_alloc_curvature
const std::string liquid_adaptive_step
const std::string liquid_load_particles
const std::string liquid_step_mesh
const std::string liquid_step_particles
const std::string liquid_alloc_mesh
const std::string liquid_init_phi
const std::string liquid_save_mesh
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
std::string to_string(const T &n)
static float noise(int n)
const std::string smoke_alloc_noise
const std::string smoke_alloc_heat
const std::string smoke_alloc_colors
const std::string smoke_alloc_fire_noise
const std::string smoke_save_noise
const std::string smoke_adaptive_step
const std::string smoke_standalone
const std::string smoke_with_colors
const std::string smoke_load_data
const std::string smoke_with_fire
const std::string smoke_with_heat
const std::string smoke_variables
const std::string smoke_variables_noise
const std::string smoke_save_data
const std::string smoke_alloc_colors_noise
const std::string smoke_load_noise
const std::string smoke_init_colors_noise
const std::string smoke_step_noise
const std::string smoke_init_colors
const std::string smoke_wavelet_noise
const std::string smoke_alloc_fire
const std::string smoke_alloc
const std::string smoke_step
float sndparticle_tau_min_wc
int sndparticle_update_radius
char sndparticle_boundary
float fractions_threshold
char cache_particle_format
float particle_randomness
int sndparticle_potential_radius
float mesh_particle_radius
float flame_smoke_color[3]
float sndparticle_tau_max_wc
float sndparticle_tau_max_ta
float sndparticle_tau_min_ta
float particle_band_width
float sndparticle_tau_min_k
char cache_directory[1024]
struct Object * guide_parent
float sndparticle_tau_max_k
struct FluidDomainSettings * domain
bool exportSmokeScript(struct FluidModifierData *fmd)
bool bakeNoise(FluidModifierData *fmd, int framenr)
bool writeNoise(FluidModifierData *fmd, int framenr)
bool initFireHigh(struct FluidModifierData *fmd=nullptr)
bool hasNoise(FluidModifierData *fmd, int framenr)
bool exportLiquidScript(struct FluidModifierData *fmd)
bool readData(FluidModifierData *fmd, int framenr, bool resumable)
bool initOutflow(FluidModifierData *fmd=nullptr)
bool writeConfiguration(FluidModifierData *fmd, int framenr)
bool initFire(struct FluidModifierData *fmd=nullptr)
bool writeData(FluidModifierData *fmd, int framenr)
bool needsRealloc(FluidModifierData *fmd)
bool readParticles(FluidModifierData *fmd, int framenr, bool resumable)
bool readMesh(FluidModifierData *fmd, int framenr)
bool readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
bool initLiquidViscosity(FluidModifierData *fmd=nullptr)
bool bakeMesh(FluidModifierData *fmd, int framenr)
bool initLiquid(FluidModifierData *fmd=nullptr)
bool initFractions(FluidModifierData *fmd=nullptr)
bool initLiquidMesh(FluidModifierData *fmd=nullptr)
bool hasMesh(FluidModifierData *fmd, int framenr)
bool initGuiding(FluidModifierData *fmd=nullptr)
bool readConfiguration(FluidModifierData *fmd, int framenr)
bool bakeGuiding(FluidModifierData *fmd, int framenr)
static atomic< int > solverID
bool hasParticles(FluidModifierData *fmd, int framenr)
bool initColorsHigh(struct FluidModifierData *fmd=nullptr)
bool initObstacle(FluidModifierData *fmd=nullptr)
bool initColors(struct FluidModifierData *fmd=nullptr)
bool readNoise(FluidModifierData *fmd, int framenr, bool resumable)
bool initSndParts(FluidModifierData *fmd=nullptr)
bool initCurvature(FluidModifierData *fmd=nullptr)
bool hasGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
bool initHeat(struct FluidModifierData *fmd=nullptr)
bool bakeParticles(FluidModifierData *fmd, int framenr)
MANTA(int *res, struct FluidModifierData *fmd)
bool bakeData(FluidModifierData *fmd, int framenr)
bool initInVelocity(FluidModifierData *fmd=nullptr)
void updatePointers(FluidModifierData *fmd, bool flush=false)
bool hasData(FluidModifierData *fmd, int framenr)
bool updateVariables(FluidModifierData *fmd)
bool hasConfig(FluidModifierData *fmd, int framenr)
bool initLiquidSndParts(FluidModifierData *fmd=nullptr)