Blender V5.3
MANTA_main.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2016 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10#include <fstream>
11#include <iostream>
12#include <sstream>
13#include <zlib.h>
14
15#include <Python.h>
16
17#include <manta.h>
18
19#include "MANTA_main.h"
20#include "fluid_script.h"
21#include "liquid_script.h"
22#include "smoke_script.h"
23
24#include "BLI_fileops.hh"
25#include "BLI_path_utils.hh"
26#include "BLI_utildefines.hh"
27
28#include "DNA_fluid_types.h"
29#include "DNA_modifier_types.h"
30
31using std::cerr;
32using std::cout;
33using std::endl;
34using std::ifstream;
35using std::istringstream;
36using std::ofstream;
37using std::ostringstream;
38using std::to_string;
39
40namespace blender {
41
42atomic<int> MANTA::solverID(0);
44
46 : mCurrentID(++solverID), mMaxRes(fmd->domain->maxres)
47{
48 using namespace blender;
49 if (with_debug) {
50 cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << res[1] << ", " << res[2]
51 << ")" << endl;
52 }
53
54 FluidDomainSettings *fds = fmd->domain;
55 fds->fluid = this;
56
57 mUsingLiquid = (fds->type == FLUID_DOMAIN_TYPE_LIQUID);
58 mUsingSmoke = (fds->type == FLUID_DOMAIN_TYPE_GAS);
59 mUsingNoise = (fds->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke;
60 mUsingFractions = (fds->flags & FLUID_DOMAIN_USE_FRACTIONS) && mUsingLiquid;
61 mUsingMesh = (fds->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
62 mUsingDiffusion = (fds->flags & FLUID_DOMAIN_USE_DIFFUSION) && mUsingLiquid;
63 mUsingViscosity = (fds->flags & FLUID_DOMAIN_USE_VISCOSITY) && mUsingLiquid;
64 mUsingMVel = (fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid;
65 mUsingGuiding = (fds->flags & FLUID_DOMAIN_USE_GUIDE);
66 mUsingDrops = (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && mUsingLiquid;
67 mUsingBubbles = (fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && mUsingLiquid;
68 mUsingFloats = (fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && mUsingLiquid;
69 mUsingTracers = (fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) && mUsingLiquid;
70
71 mUsingHeat = (fds->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && mUsingSmoke;
72 mUsingFire = (fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && mUsingSmoke;
73 mUsingColors = (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && mUsingSmoke;
74 mUsingObstacle = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
75 mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
76 mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
77
78 /* Simulation constants */
79 mResX = res[0]; /* Current size of domain (will adjust with adaptive domain). */
80 mResY = res[1];
81 mResZ = res[2];
82 mTotalCells = mResX * mResY * mResZ;
83 mResGuiding = fds->res;
84
85 /* Smoke low res grids. */
86 mDensity = nullptr;
87 mShadow = nullptr;
88 mHeat = nullptr;
89 mVelocityX = nullptr;
90 mVelocityY = nullptr;
91 mVelocityZ = nullptr;
92 mForceX = nullptr;
93 mForceY = nullptr;
94 mForceZ = nullptr;
95 mFlame = nullptr;
96 mFuel = nullptr;
97 mReact = nullptr;
98 mColorR = nullptr;
99 mColorG = nullptr;
100 mColorB = nullptr;
101 mFlags = nullptr;
102 mDensityIn = nullptr;
103 mHeatIn = nullptr;
104 mColorRIn = nullptr;
105 mColorGIn = nullptr;
106 mColorBIn = nullptr;
107 mFuelIn = nullptr;
108 mReactIn = nullptr;
109 mEmissionIn = nullptr;
110 mPressure = nullptr;
111
112 /* Smoke high res grids. */
113 mDensityHigh = nullptr;
114 mFlameHigh = nullptr;
115 mFuelHigh = nullptr;
116 mReactHigh = nullptr;
117 mColorRHigh = nullptr;
118 mColorGHigh = nullptr;
119 mColorBHigh = nullptr;
120 mTextureU = nullptr;
121 mTextureV = nullptr;
122 mTextureW = nullptr;
123 mTextureU2 = nullptr;
124 mTextureV2 = nullptr;
125 mTextureW2 = nullptr;
126
127 /* Fluid low res grids. */
128 mPhiIn = nullptr;
129 mPhiStaticIn = nullptr;
130 mPhiOutIn = nullptr;
131 mPhiOutStaticIn = nullptr;
132 mPhi = nullptr;
133
134 /* Mesh. */
135 mMeshNodes = nullptr;
136 mMeshTriangles = nullptr;
137 mMeshVelocities = nullptr;
138
139 /* Fluid obstacle. */
140 mPhiObsIn = nullptr;
141 mPhiObsStaticIn = nullptr;
142 mNumObstacle = nullptr;
143 mObVelocityX = nullptr;
144 mObVelocityY = nullptr;
145 mObVelocityZ = nullptr;
146
147 /* Fluid guiding. */
148 mPhiGuideIn = nullptr;
149 mNumGuide = nullptr;
150 mGuideVelocityX = nullptr;
151 mGuideVelocityY = nullptr;
152 mGuideVelocityZ = nullptr;
153
154 /* Fluid initial velocity. */
155 mInVelocityX = nullptr;
156 mInVelocityY = nullptr;
157 mInVelocityZ = nullptr;
158
159 /* Secondary particles. */
160 mFlipParticleData = nullptr;
161 mFlipParticleVelocity = nullptr;
162 mParticleData = nullptr;
163 mParticleVelocity = nullptr;
164 mParticleLife = nullptr;
165
166 /* Cache read success indicators. */
167 mFlipFromFile = false;
168 mMeshFromFile = false;
169 mParticlesFromFile = false;
170
171 /* Setup Mantaflow in Python. */
172 initializeMantaflow();
173
174 /* Initialize RNA map with values that Python will need. */
175 initializeRNAMap(fmd);
176
177 bool initSuccess = true;
178 /* Initialize Mantaflow variables in Python. */
179 /* Liquid. */
180 if (mUsingLiquid) {
181 initSuccess &= initDomain();
182 initSuccess &= initLiquid();
183 if (mUsingObstacle) {
184 initSuccess &= initObstacle();
185 }
186 if (mUsingInvel) {
187 initSuccess &= initInVelocity();
188 }
189 if (mUsingOutflow) {
190 initSuccess &= initOutflow();
191 }
192
193 if (mUsingDrops || mUsingBubbles || mUsingFloats || mUsingTracers) {
194 mUpresParticle = fds->particle_scale;
195 mResXParticle = mUpresParticle * mResX;
196 mResYParticle = mUpresParticle * mResY;
197 mResZParticle = mUpresParticle * mResZ;
198 mTotalCellsParticles = mResXParticle * mResYParticle * mResZParticle;
199
200 initSuccess &= initSndParts();
201 initSuccess &= initLiquidSndParts();
202 }
203
204 if (mUsingMesh) {
205 mUpresMesh = fds->mesh_scale;
206 mResXMesh = mUpresMesh * mResX;
207 mResYMesh = mUpresMesh * mResY;
208 mResZMesh = mUpresMesh * mResZ;
209 mTotalCellsMesh = mResXMesh * mResYMesh * mResZMesh;
210
211 /* Initialize Mantaflow variables in Python. */
212 initSuccess &= initMesh();
213 initSuccess &= initLiquidMesh();
214 }
215
216 if (mUsingViscosity) {
217 initSuccess &= initLiquidViscosity();
218 }
219
220 if (mUsingDiffusion) {
221 initSuccess &= initCurvature();
222 }
223
224 if (mUsingGuiding) {
225 mResGuiding = (fds->guide_parent) ? fds->guide_res : fds->res;
226 initSuccess &= initGuiding();
227 }
228 if (mUsingFractions) {
229 initSuccess &= initFractions();
230 }
231 }
232
233 /* Smoke. */
234 if (mUsingSmoke) {
235 initSuccess &= initDomain();
236 initSuccess &= initSmoke();
237 if (mUsingHeat) {
238 initSuccess &= initHeat();
239 }
240 if (mUsingFire) {
241 initSuccess &= initFire();
242 }
243 if (mUsingColors) {
244 initSuccess &= initColors();
245 }
246 if (mUsingObstacle) {
247 initSuccess &= initObstacle();
248 }
249 if (mUsingInvel) {
250 initSuccess &= initInVelocity();
251 }
252 if (mUsingOutflow) {
253 initSuccess &= initOutflow();
254 }
255
256 if (mUsingGuiding) {
257 mResGuiding = (fds->guide_parent) ? fds->guide_res : fds->res;
258 initSuccess &= initGuiding();
259 }
260
261 if (mUsingNoise) {
262 int amplify = fds->noise_scale;
263 mResXNoise = amplify * mResX;
264 mResYNoise = amplify * mResY;
265 mResZNoise = amplify * mResZ;
266 mTotalCellsHigh = mResXNoise * mResYNoise * mResZNoise;
267
268 /* Initialize Mantaflow variables in Python. */
269 initSuccess &= initNoise();
270 initSuccess &= initSmokeNoise();
271 if (mUsingFire) {
272 initSuccess &= initFireHigh();
273 }
274 if (mUsingColors) {
275 initSuccess &= initColorsHigh();
276 }
277 }
278 }
279 /* All requested initializations must not fail in constructor. */
280 BLI_assert(initSuccess);
281 (void)initSuccess; /* Ignored in release. */
282
283 updatePointers(fmd);
284}
285
286bool MANTA::initDomain(FluidModifierData *fmd)
287{
288 /* Vector will hold all python commands that are to be executed. */
289 vector<string> pythonCommands;
290
291 /* Set manta debug level first. */
292 pythonCommands.push_back(manta_import + manta_debuglevel);
293
294 ostringstream ss;
295 ss << "set_manta_debuglevel(" << with_debug << ")";
296 pythonCommands.push_back(ss.str());
297
298 /* Now init basic fluid domain. */
299 string tmpString = fluid_variables + fluid_solver + fluid_alloc + fluid_cache_helper +
300 fluid_bake_multiprocessing + fluid_bake_data + fluid_bake_noise +
301 fluid_bake_mesh + fluid_bake_particles + fluid_bake_guiding +
302 fluid_file_import + fluid_file_export + fluid_pre_step + fluid_post_step +
303 fluid_adapt_time_step + fluid_time_stepping;
304 string finalString = parseScript(tmpString, fmd);
305 pythonCommands.push_back(finalString);
306 return runPythonString(pythonCommands);
307}
308
309bool MANTA::initNoise(FluidModifierData *fmd)
310{
311 vector<string> pythonCommands;
312 string tmpString = fluid_variables_noise + fluid_solver_noise;
313 string finalString = parseScript(tmpString, fmd);
314 pythonCommands.push_back(finalString);
315
316 return runPythonString(pythonCommands);
317}
318
319bool MANTA::initSmoke(FluidModifierData *fmd)
320{
321 vector<string> pythonCommands;
322 string tmpString = smoke_variables + smoke_alloc + smoke_adaptive_step + smoke_save_data +
323 smoke_load_data + smoke_step;
324 string finalString = parseScript(tmpString, fmd);
325 pythonCommands.push_back(finalString);
326
327 return runPythonString(pythonCommands);
328}
329
330bool MANTA::initSmokeNoise(FluidModifierData *fmd)
331{
332 vector<string> pythonCommands;
334 smoke_save_noise + smoke_load_noise + smoke_step_noise;
335 string finalString = parseScript(tmpString, fmd);
336 pythonCommands.push_back(finalString);
337
338 mUsingNoise = true;
339 return runPythonString(pythonCommands);
340}
341
343{
344 if (!mHeat) {
345 vector<string> pythonCommands;
346 string tmpString = smoke_alloc_heat + smoke_with_heat;
347 string finalString = parseScript(tmpString, fmd);
348 pythonCommands.push_back(finalString);
349
350 mUsingHeat = true;
351 return runPythonString(pythonCommands);
352 }
353 return false;
354}
355
357{
358 if (!mFuel) {
359 vector<string> pythonCommands;
360 string tmpString = smoke_alloc_fire + smoke_with_fire;
361 string finalString = parseScript(tmpString, fmd);
362 pythonCommands.push_back(finalString);
363
364 mUsingFire = true;
365 return runPythonString(pythonCommands);
366 }
367 return false;
368}
369
371{
372 if (!mFuelHigh) {
373 vector<string> pythonCommands;
374 string tmpString = smoke_alloc_fire_noise + smoke_with_fire;
375 string finalString = parseScript(tmpString, fmd);
376 pythonCommands.push_back(finalString);
377
378 mUsingFire = true;
379 return runPythonString(pythonCommands);
380 }
381 return false;
382}
383
385{
386 if (!mColorR) {
387 vector<string> pythonCommands;
389 string finalString = parseScript(tmpString, fmd);
390 pythonCommands.push_back(finalString);
391
392 mUsingColors = true;
393 return runPythonString(pythonCommands);
394 }
395 return false;
396}
397
399{
400 if (!mColorRHigh) {
401 vector<string> pythonCommands;
403 string finalString = parseScript(tmpString, fmd);
404 pythonCommands.push_back(finalString);
405
406 mUsingColors = true;
407 return runPythonString(pythonCommands);
408 }
409 return false;
410}
411
413{
414 if (!mPhiIn) {
415 vector<string> pythonCommands;
416 string tmpString = liquid_variables + liquid_alloc + liquid_init_phi + liquid_save_data +
417 liquid_load_data + liquid_adaptive_step + liquid_step;
418 string finalString = parseScript(tmpString, fmd);
419 pythonCommands.push_back(finalString);
420
421 mUsingLiquid = true;
422 return runPythonString(pythonCommands);
423 }
424 return false;
425}
426
427bool MANTA::initMesh(FluidModifierData *fmd)
428{
429 vector<string> pythonCommands;
430 string tmpString = fluid_variables_mesh + fluid_solver_mesh + liquid_load_mesh;
431 string finalString = parseScript(tmpString, fmd);
432 pythonCommands.push_back(finalString);
433
434 mUsingMesh = true;
435 return runPythonString(pythonCommands);
436}
437
439{
440 vector<string> pythonCommands;
441 string tmpString = liquid_alloc_mesh + liquid_step_mesh + liquid_save_mesh;
442 string finalString = parseScript(tmpString, fmd);
443 pythonCommands.push_back(finalString);
444
445 mUsingMesh = true;
446 return runPythonString(pythonCommands);
447}
448
450{
451 vector<string> pythonCommands;
453 string finalString = parseScript(tmpString, fmd);
454 pythonCommands.push_back(finalString);
455
456 mUsingViscosity = true;
457 return runPythonString(pythonCommands);
458}
459
461{
462 std::vector<std::string> pythonCommands;
463 std::string finalString = parseScript(liquid_alloc_curvature, fmd);
464 pythonCommands.push_back(finalString);
465
466 mUsingDiffusion = true;
467 return runPythonString(pythonCommands);
468}
469
471{
472 if (!mPhiObsIn) {
473 vector<string> pythonCommands;
474 string tmpString = fluid_alloc_obstacle + fluid_with_obstacle;
475 string finalString = parseScript(tmpString, fmd);
476 pythonCommands.push_back(finalString);
477
478 return (mUsingObstacle = runPythonString(pythonCommands));
479 }
480 return false;
481}
482
484{
485 if (!mPhiGuideIn) {
486 vector<string> pythonCommands;
487 string tmpString = fluid_variables_guiding + fluid_solver_guiding + fluid_alloc_guiding +
488 fluid_save_guiding + fluid_load_vel + fluid_load_guiding;
489 string finalString = parseScript(tmpString, fmd);
490 pythonCommands.push_back(finalString);
491
492 return (mUsingGuiding = runPythonString(pythonCommands));
493 }
494 return false;
495}
496
498{
499 vector<string> pythonCommands;
500 string tmpString = fluid_alloc_fractions + fluid_with_fractions;
501 string finalString = parseScript(tmpString, fmd);
502 pythonCommands.push_back(finalString);
503
504 return (mUsingFractions = runPythonString(pythonCommands));
505}
506
508{
509 if (!mInVelocityX) {
510 vector<string> pythonCommands;
511 string tmpString = fluid_alloc_invel + fluid_with_invel;
512 string finalString = parseScript(tmpString, fmd);
513 pythonCommands.push_back(finalString);
514
515 return (mUsingInvel = runPythonString(pythonCommands));
516 }
517 return false;
518}
519
521{
522 if (!mPhiOutIn) {
523 vector<string> pythonCommands;
524 string tmpString = fluid_alloc_outflow + fluid_with_outflow;
525 string finalString = parseScript(tmpString, fmd);
526 pythonCommands.push_back(finalString);
527
528 return (mUsingOutflow = runPythonString(pythonCommands));
529 }
530 return false;
531}
532
534{
535 vector<string> pythonCommands;
537 string finalString = parseScript(tmpString, fmd);
538 pythonCommands.push_back(finalString);
539
540 return runPythonString(pythonCommands);
541}
542
544{
545 if (!mParticleData) {
546 vector<string> pythonCommands;
548 liquid_step_particles + fluid_with_sndparts + liquid_load_particles +
549 liquid_save_particles;
550 string finalString = parseScript(tmpString, fmd);
551 pythonCommands.push_back(finalString);
552
553 return runPythonString(pythonCommands);
554 }
555 return false;
556}
557
559{
560 if (with_debug) {
561 cout << "~FLUID: " << mCurrentID << " with res(" << mResX << ", " << mResY << ", " << mResZ
562 << ")" << endl;
563 }
564
565 /* Destruction string for Python. */
566 string tmpString;
567 vector<string> pythonCommands;
568 bool result = false;
569
570 tmpString += manta_import;
571 tmpString += fluid_delete_all;
572
573 /* Initialize RNA map with values that Python will need. */
574 initializeRNAMap();
575
576 /* Leave out fmd argument in parseScript since only looking up IDs. */
577 string finalString = parseScript(tmpString);
578 pythonCommands.push_back(finalString);
579 result = runPythonString(pythonCommands);
580
581 /* WARNING: this causes crash on exit in the `cycles_volume_cpu/smoke_color` test,
582 * freeing a single modifier ends up clearing the shared module.
583 * For this to be handled properly there would need to be a initialize/free
584 * function for global data. */
585#if 0
586 MANTA::terminateMantaflow();
587#endif
588
591}
592
599static PyObject *manta_python_main_module_create(const char *filename)
600{
601 PyObject *builtins = PyEval_GetBuiltins();
602 PyObject *mod_main = PyModule_New("__main__");
603 PyModule_AddStringConstant(mod_main, "__name__", "__main__");
604 if (filename) {
605 /* __file__ mainly for nice UI'ness
606 * NOTE: this won't map to a real file when executing text-blocks and buttons. */
607 PyModule_AddObject(mod_main, "__file__", PyUnicode_InternFromString(filename));
608 }
609 PyModule_AddObjectRef(mod_main, "__builtins__", builtins);
610 return mod_main;
611}
612
613static void manta_python_main_module_activate(PyObject *mod_main)
614{
615 PyObject *modules = PyImport_GetModuleDict();
616 PyObject *main_mod_cmp = PyDict_GetItemString(modules, "__main__");
617 if (mod_main == main_mod_cmp) {
618 return;
619 }
620 /* NOTE: we could remove the reference to `mod_main` here, but as it's know to be removed
621 * accept that there is temporarily an extra reference. */
622 PyDict_SetItemString(modules, "__main__", mod_main);
623}
624
625static void manta_python_main_module_backup(PyObject **r_main_mod)
626{
627 PyObject *modules = PyImport_GetModuleDict();
628 *r_main_mod = PyDict_GetItemString(modules, "__main__");
629 Py_XINCREF(*r_main_mod); /* don't free */
630}
631
632static void manta_python_main_module_restore(PyObject *main_mod)
633{
634 PyObject *modules = PyImport_GetModuleDict();
635 PyDict_SetItemString(modules, "__main__", main_mod);
636 Py_XDECREF(main_mod);
637}
638
646static PyObject *manta_main_module = nullptr;
647
649{
650 if (manta_main_module) {
651 Py_DECREF(manta_main_module);
652 manta_main_module = nullptr;
653 }
654}
655
657{
658 if (!manta_main_module) {
660 }
661 return manta_main_module;
662}
663
664bool MANTA::runPythonString(vector<string> commands)
665{
666 bool success = true;
667 PyGILState_STATE gilstate = PyGILState_Ensure();
668
669 /* Temporarily set `sys.modules["__main__"]` as some Python modules expect this. */
670 PyObject *main_mod_backup;
671 manta_python_main_module_backup(&main_mod_backup);
672
673 /* If we never want to run this when the module isn't initialize,
674 * assign with `manta_python_main_module_ensure()`. */
675 BLI_assert(manta_main_module != nullptr);
677
678 for (vector<string>::iterator it = commands.begin(); it != commands.end(); ++it) {
679 string command = *it;
680
681 PyObject *globals_dict = PyModule_GetDict(manta_main_module);
682 PyObject *return_value = PyRun_String(
683 command.c_str(), Py_file_input, globals_dict, globals_dict);
684
685 if (return_value == nullptr) {
686 success = false;
687 if (PyErr_Occurred()) {
688 PyErr_Print();
689 }
690 }
691 else {
692 Py_DECREF(return_value);
693 }
694 }
695
696 manta_python_main_module_restore(main_mod_backup);
697
698 PyGILState_Release(gilstate);
699
700 BLI_assert(success);
701 return success;
702}
703
704void MANTA::initializeMantaflow()
705{
706 if (with_debug) {
707 cout << "Fluid: Initializing Mantaflow framework" << endl;
708 }
709
710 string filename = "manta_scene_" + to_string(mCurrentID) + ".py";
711 vector<string> fill = vector<string>();
712
713 /* Initialize extension classes and wrappers. */
714 srand(0);
715 PyGILState_STATE gilstate = PyGILState_Ensure();
716
718 PyObject *globals_dict = PyModule_GetDict(manta_main_module);
719 Pb::setup(false, filename, fill, globals_dict); /* Namespace from Mantaflow (registry). */
720 PyGILState_Release(gilstate);
721}
722
723void MANTA::terminateMantaflow()
724{
725 if (with_debug) {
726 cout << "Fluid: Releasing Mantaflow framework" << endl;
727 }
728
729 PyGILState_STATE gilstate = PyGILState_Ensure();
730 Pb::finalize(false); /* Namespace from Mantaflow (registry). */
732 PyGILState_Release(gilstate);
733}
734
735static string getCacheFileEnding(char cache_format)
736{
737 if (MANTA::with_debug) {
738 cout << "MANTA::getCacheFileEnding()" << endl;
739 }
740
741 switch (cache_format) {
752 default:
753 cerr << "Fluid Error -- Could not find file extension. Using default file extension."
754 << endl;
756 }
757}
758
759static string getBooleanString(int value)
760{
761 return (value) ? "True" : "False";
762}
763
764void MANTA::initializeRNAMap(FluidModifierData *fmd)
765{
766 if (with_debug) {
767 cout << "MANTA::initializeRNAMap()" << endl;
768 }
769
770 mRNAMap["ID"] = to_string(mCurrentID);
771
772 if (!fmd) {
773 if (with_debug) {
774 cout << "Fluid: No modifier data given in RNA map setup - returning early" << endl;
775 }
776 return;
777 }
778
779 FluidDomainSettings *fds = fmd->domain;
780 bool is2D = (fds->solver_res == 2);
781
782 string borderCollisions;
784 borderCollisions += "x";
785 }
787 borderCollisions += "X";
788 }
790 borderCollisions += "y";
791 }
793 borderCollisions += "Y";
794 }
796 borderCollisions += "z";
797 }
798 if ((fds->border_collisions & FLUID_DOMAIN_BORDER_TOP) == 0) {
799 borderCollisions += "Z";
800 }
801
802 string particleTypesStr;
804 particleTypesStr += "PtypeSpray";
805 }
807 if (!particleTypesStr.empty()) {
808 particleTypesStr += "|";
809 }
810 particleTypesStr += "PtypeBubble";
811 }
813 if (!particleTypesStr.empty()) {
814 particleTypesStr += "|";
815 }
816 particleTypesStr += "PtypeFoam";
817 }
819 if (!particleTypesStr.empty()) {
820 particleTypesStr += "|";
821 }
822 particleTypesStr += "PtypeTracer";
823 }
824 if (particleTypesStr.empty()) {
825 particleTypesStr = "0";
826 }
827
830
831 string cacheDirectory(fds->cache_directory);
832
833 float viscosity = fds->viscosity_base * pow(10.0f, -fds->viscosity_exponent);
834 float domainSize = std::max({fds->global_size[0], fds->global_size[1], fds->global_size[2]});
835
836 string vdbCompressionMethod = "Compression_None";
838 vdbCompressionMethod = "Compression_None";
839 }
840 else if (fds->openvdb_compression == VDB_COMPRESSION_ZIP) {
841 vdbCompressionMethod = "Compression_Zip";
842 }
844 vdbCompressionMethod = "Compression_Blosc";
845 }
846
847 string vdbPrecisionHalf = "Precision_Half";
849 vdbPrecisionHalf = "Precision_Full";
850 }
852 vdbPrecisionHalf = "Precision_Half";
853 }
855 vdbPrecisionHalf = "Precision_Mini";
856 }
857
858 mRNAMap["USING_SMOKE"] = getBooleanString(fds->type == FLUID_DOMAIN_TYPE_GAS);
859 mRNAMap["USING_LIQUID"] = getBooleanString(fds->type == FLUID_DOMAIN_TYPE_LIQUID);
860 mRNAMap["USING_COLORS"] = getBooleanString(fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS);
861 mRNAMap["USING_HEAT"] = getBooleanString(fds->active_fields & FLUID_DOMAIN_ACTIVE_HEAT);
862 mRNAMap["USING_FIRE"] = getBooleanString(fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE);
863 mRNAMap["USING_NOISE"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_NOISE);
864 mRNAMap["USING_OBSTACLE"] = getBooleanString(fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
865 mRNAMap["USING_GUIDING"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_GUIDE);
866 mRNAMap["USING_INVEL"] = getBooleanString(fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
867 mRNAMap["USING_OUTFLOW"] = getBooleanString(fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
868 mRNAMap["USING_LOG_DISSOLVE"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_DISSOLVE_LOG);
869 mRNAMap["USING_DISSOLVE"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_DISSOLVE);
870 mRNAMap["DOMAIN_CLOSED"] = getBooleanString(borderCollisions.compare("") == 0);
871 mRNAMap["CACHE_RESUMABLE"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_RESUMABLE_CACHE);
872 mRNAMap["USING_ADAPTIVETIME"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_ADAPTIVE_TIME);
873 mRNAMap["USING_SPEEDVECTORS"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS);
874 mRNAMap["USING_FRACTIONS"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_FRACTIONS);
875 mRNAMap["DELETE_IN_OBSTACLE"] = getBooleanString(fds->flags & FLUID_DOMAIN_DELETE_IN_OBSTACLE);
876 mRNAMap["USING_DIFFUSION"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_DIFFUSION);
877 mRNAMap["USING_MESH"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_MESH);
878 mRNAMap["USING_IMPROVED_MESH"] = getBooleanString(fds->mesh_generator ==
880 mRNAMap["USING_SNDPARTS"] = getBooleanString(fds->particle_type & particleTypes);
881 mRNAMap["SNDPARTICLE_BOUNDARY_DELETE"] = getBooleanString(fds->sndparticle_boundary ==
883 mRNAMap["SNDPARTICLE_BOUNDARY_PUSHOUT"] = getBooleanString(fds->sndparticle_boundary ==
885
886 mRNAMap["SOLVER_DIM"] = to_string(fds->solver_res);
887 mRNAMap["BOUND_CONDITIONS"] = borderCollisions;
888 mRNAMap["BOUNDARY_WIDTH"] = to_string(fds->boundary_width);
889 mRNAMap["RES"] = to_string(mMaxRes);
890 mRNAMap["RESX"] = to_string(mResX);
891 mRNAMap["RESY"] = (is2D) ? to_string(mResZ) : to_string(mResY);
892 mRNAMap["RESZ"] = (is2D) ? to_string(1) : to_string(mResZ);
893 mRNAMap["TIME_SCALE"] = to_string(fds->time_scale);
894 mRNAMap["FRAME_LENGTH"] = to_string(fds->frame_length);
895 mRNAMap["CFL"] = to_string(fds->cfl_condition);
896 mRNAMap["DT"] = to_string(fds->dt);
897 mRNAMap["TIMESTEPS_MIN"] = to_string(fds->timesteps_minimum);
898 mRNAMap["TIMESTEPS_MAX"] = to_string(fds->timesteps_maximum);
899 mRNAMap["TIME_TOTAL"] = to_string(fds->time_total);
900 mRNAMap["TIME_PER_FRAME"] = to_string(fds->time_per_frame);
901 mRNAMap["VORTICITY"] = to_string(fds->vorticity);
902 mRNAMap["FLAME_VORTICITY"] = to_string(fds->flame_vorticity);
903 mRNAMap["NOISE_SCALE"] = to_string(fds->noise_scale);
904 mRNAMap["MESH_SCALE"] = to_string(fds->mesh_scale);
905 mRNAMap["PARTICLE_SCALE"] = to_string(fds->particle_scale);
906 mRNAMap["NOISE_RESX"] = to_string(mResXNoise);
907 mRNAMap["NOISE_RESY"] = (is2D) ? to_string(mResZNoise) : to_string(mResYNoise);
908 mRNAMap["NOISE_RESZ"] = (is2D) ? to_string(1) : to_string(mResZNoise);
909 mRNAMap["MESH_RESX"] = to_string(mResXMesh);
910 mRNAMap["MESH_RESY"] = (is2D) ? to_string(mResZMesh) : to_string(mResYMesh);
911 mRNAMap["MESH_RESZ"] = (is2D) ? to_string(1) : to_string(mResZMesh);
912 mRNAMap["PARTICLE_RESX"] = to_string(mResXParticle);
913 mRNAMap["PARTICLE_RESY"] = (is2D) ? to_string(mResZParticle) : to_string(mResYParticle);
914 mRNAMap["PARTICLE_RESZ"] = (is2D) ? to_string(1) : to_string(mResZParticle);
915 mRNAMap["GUIDING_RESX"] = to_string(mResGuiding[0]);
916 mRNAMap["GUIDING_RESY"] = (is2D) ? to_string(mResGuiding[2]) : to_string(mResGuiding[1]);
917 mRNAMap["GUIDING_RESZ"] = (is2D) ? to_string(1) : to_string(mResGuiding[2]);
918 mRNAMap["MIN_RESX"] = to_string(fds->res_min[0]);
919 mRNAMap["MIN_RESY"] = to_string(fds->res_min[1]);
920 mRNAMap["MIN_RESZ"] = to_string(fds->res_min[2]);
921 mRNAMap["BASE_RESX"] = to_string(fds->base_res[0]);
922 mRNAMap["BASE_RESY"] = to_string(fds->base_res[1]);
923 mRNAMap["BASE_RESZ"] = to_string(fds->base_res[2]);
924 mRNAMap["WLT_STR"] = to_string(fds->noise_strength);
925 mRNAMap["NOISE_POSSCALE"] = to_string(fds->noise_pos_scale);
926 mRNAMap["NOISE_TIMEANIM"] = to_string(fds->noise_time_anim);
927 mRNAMap["COLOR_R"] = to_string(fds->active_color[0]);
928 mRNAMap["COLOR_G"] = to_string(fds->active_color[1]);
929 mRNAMap["COLOR_B"] = to_string(fds->active_color[2]);
930 mRNAMap["BUOYANCY_ALPHA"] = to_string(fds->alpha);
931 mRNAMap["BUOYANCY_BETA"] = to_string(fds->beta);
932 mRNAMap["DISSOLVE_SPEED"] = to_string(fds->diss_speed);
933 mRNAMap["BURNING_RATE"] = to_string(fds->burning_rate);
934 mRNAMap["FLAME_SMOKE"] = to_string(fds->flame_smoke);
935 mRNAMap["IGNITION_TEMP"] = to_string(fds->flame_ignition);
936 mRNAMap["MAX_TEMP"] = to_string(fds->flame_max_temp);
937 mRNAMap["FLAME_SMOKE_COLOR_X"] = to_string(fds->flame_smoke_color[0]);
938 mRNAMap["FLAME_SMOKE_COLOR_Y"] = to_string(fds->flame_smoke_color[1]);
939 mRNAMap["FLAME_SMOKE_COLOR_Z"] = to_string(fds->flame_smoke_color[2]);
940 mRNAMap["CURRENT_FRAME"] = to_string(int(fmd->time));
941 mRNAMap["START_FRAME"] = to_string(fds->cache_frame_start);
942 mRNAMap["END_FRAME"] = to_string(fds->cache_frame_end);
943 mRNAMap["CACHE_DATA_FORMAT"] = getCacheFileEnding(fds->cache_data_format);
944 mRNAMap["CACHE_MESH_FORMAT"] = getCacheFileEnding(fds->cache_mesh_format);
945 mRNAMap["CACHE_NOISE_FORMAT"] = getCacheFileEnding(fds->cache_noise_format);
946 mRNAMap["CACHE_PARTICLE_FORMAT"] = getCacheFileEnding(fds->cache_particle_format);
947 mRNAMap["USING_APIC"] = getBooleanString(fds->simulation_method == FLUID_DOMAIN_METHOD_APIC);
948 mRNAMap["FLIP_RATIO"] = to_string(fds->flip_ratio);
949 mRNAMap["PARTICLE_RANDOMNESS"] = to_string(fds->particle_randomness);
950 mRNAMap["PARTICLE_NUMBER"] = to_string(fds->particle_number);
951 mRNAMap["PARTICLE_MINIMUM"] = to_string(fds->particle_minimum);
952 mRNAMap["PARTICLE_MAXIMUM"] = to_string(fds->particle_maximum);
953 mRNAMap["PARTICLE_RADIUS"] = to_string(fds->particle_radius);
954 mRNAMap["FRACTIONS_THRESHOLD"] = to_string(fds->fractions_threshold);
955 mRNAMap["FRACTIONS_DISTANCE"] = to_string(fds->fractions_distance);
956 mRNAMap["MESH_CONCAVE_UPPER"] = to_string(fds->mesh_concave_upper);
957 mRNAMap["MESH_CONCAVE_LOWER"] = to_string(fds->mesh_concave_lower);
958 mRNAMap["MESH_PARTICLE_RADIUS"] = to_string(fds->mesh_particle_radius);
959 mRNAMap["MESH_SMOOTHEN_POS"] = to_string(fds->mesh_smoothen_pos);
960 mRNAMap["MESH_SMOOTHEN_NEG"] = to_string(fds->mesh_smoothen_neg);
961 mRNAMap["PARTICLE_BAND_WIDTH"] = to_string(fds->particle_band_width);
962 mRNAMap["SNDPARTICLE_TAU_MIN_WC"] = to_string(fds->sndparticle_tau_min_wc);
963 mRNAMap["SNDPARTICLE_TAU_MAX_WC"] = to_string(fds->sndparticle_tau_max_wc);
964 mRNAMap["SNDPARTICLE_TAU_MIN_TA"] = to_string(fds->sndparticle_tau_min_ta);
965 mRNAMap["SNDPARTICLE_TAU_MAX_TA"] = to_string(fds->sndparticle_tau_max_ta);
966 mRNAMap["SNDPARTICLE_TAU_MIN_K"] = to_string(fds->sndparticle_tau_min_k);
967 mRNAMap["SNDPARTICLE_TAU_MAX_K"] = to_string(fds->sndparticle_tau_max_k);
968 mRNAMap["SNDPARTICLE_K_WC"] = to_string(fds->sndparticle_k_wc);
969 mRNAMap["SNDPARTICLE_K_TA"] = to_string(fds->sndparticle_k_ta);
970 mRNAMap["SNDPARTICLE_K_B"] = to_string(fds->sndparticle_k_b);
971 mRNAMap["SNDPARTICLE_K_D"] = to_string(fds->sndparticle_k_d);
972 mRNAMap["SNDPARTICLE_L_MIN"] = to_string(fds->sndparticle_l_min);
973 mRNAMap["SNDPARTICLE_L_MAX"] = to_string(fds->sndparticle_l_max);
974 mRNAMap["SNDPARTICLE_POTENTIAL_RADIUS"] = to_string(fds->sndparticle_potential_radius);
975 mRNAMap["SNDPARTICLE_UPDATE_RADIUS"] = to_string(fds->sndparticle_update_radius);
976 mRNAMap["LIQUID_SURFACE_TENSION"] = to_string(fds->surface_tension);
977 mRNAMap["FLUID_VISCOSITY"] = to_string(viscosity);
978 mRNAMap["FLUID_DOMAIN_SIZE"] = to_string(domainSize);
979 mRNAMap["FLUID_DOMAIN_SIZE_X"] = to_string(fds->global_size[0]);
980 mRNAMap["FLUID_DOMAIN_SIZE_Y"] = to_string(fds->global_size[1]);
981 mRNAMap["FLUID_DOMAIN_SIZE_Z"] = to_string(fds->global_size[2]);
982 mRNAMap["SNDPARTICLE_TYPES"] = particleTypesStr;
983 mRNAMap["GUIDING_ALPHA"] = to_string(fds->guide_alpha);
984 mRNAMap["GUIDING_BETA"] = to_string(fds->guide_beta);
985 mRNAMap["GUIDING_FACTOR"] = to_string(fds->guide_vel_factor);
986 mRNAMap["GRAVITY_X"] = to_string(fds->gravity_final[0]);
987 mRNAMap["GRAVITY_Y"] = to_string(fds->gravity_final[1]);
988 mRNAMap["GRAVITY_Z"] = to_string(fds->gravity_final[2]);
989 mRNAMap["CACHE_DIR"] = cacheDirectory;
990 mRNAMap["COMPRESSION_OPENVDB"] = vdbCompressionMethod;
991 mRNAMap["PRECISION_OPENVDB"] = vdbPrecisionHalf;
992 mRNAMap["CLIP_OPENVDB"] = to_string(fds->clipping);
993 mRNAMap["PP_PARTICLE_MAXIMUM"] = to_string(fds->sys_particle_maximum);
994 mRNAMap["USING_VISCOSITY"] = getBooleanString(fds->flags & FLUID_DOMAIN_USE_VISCOSITY);
995 mRNAMap["VISCOSITY_VALUE"] = to_string(fds->viscosity_value);
996
997 /* Fluid object names. */
998 mRNAMap["NAME_FLAGS"] = FLUID_NAME_FLAGS;
999 mRNAMap["NAME_VELOCITY"] = FLUID_NAME_VELOCITY;
1000 mRNAMap["NAME_VELOCITYTMP"] = FLUID_NAME_VELOCITYTMP;
1001 mRNAMap["NAME_VELOCITY_X"] = FLUID_NAME_VELOCITYX;
1002 mRNAMap["NAME_VELOCITY_Y"] = FLUID_NAME_VELOCITYY;
1003 mRNAMap["NAME_VELOCITY_Z"] = FLUID_NAME_VELOCITYZ;
1004 mRNAMap["NAME_PRESSURE"] = FLUID_NAME_PRESSURE;
1005 mRNAMap["NAME_PHIOBS"] = FLUID_NAME_PHIOBS;
1006 mRNAMap["NAME_PHISIN"] = FLUID_NAME_PHISIN;
1007 mRNAMap["NAME_PHIIN"] = FLUID_NAME_PHIIN;
1008 mRNAMap["NAME_PHIOUT"] = FLUID_NAME_PHIOUT;
1009 mRNAMap["NAME_FORCES"] = FLUID_NAME_FORCES;
1010 mRNAMap["NAME_FORCES_X"] = FLUID_NAME_FORCE_X;
1011 mRNAMap["NAME_FORCES_Y"] = FLUID_NAME_FORCE_Y;
1012 mRNAMap["NAME_FORCES_Z"] = FLUID_NAME_FORCE_Z;
1013 mRNAMap["NAME_NUMOBS"] = FLUID_NAME_NUMOBS;
1014 mRNAMap["NAME_PHIOBSSIN"] = FLUID_NAME_PHIOBSSIN;
1015 mRNAMap["NAME_PHIOBSIN"] = FLUID_NAME_PHIOBSIN;
1016 mRNAMap["NAME_OBVEL"] = FLUID_NAME_OBVEL;
1017 mRNAMap["NAME_OBVELC"] = FLUID_NAME_OBVELC;
1018 mRNAMap["NAME_OBVEL_X"] = FLUID_NAME_OBVEL_X;
1019 mRNAMap["NAME_OBVEL_Y"] = FLUID_NAME_OBVEL_Y;
1020 mRNAMap["NAME_OBVEL_Z"] = FLUID_NAME_OBVEL_Z;
1021 mRNAMap["NAME_FRACTIONS"] = FLUID_NAME_FRACTIONS;
1022 mRNAMap["NAME_INVELC"] = FLUID_NAME_INVELC;
1023 mRNAMap["NAME_INVEL_X"] = FLUID_NAME_INVEL_X;
1024 mRNAMap["NAME_INVEL_Y"] = FLUID_NAME_INVEL_Y;
1025 mRNAMap["NAME_INVEL_Z"] = FLUID_NAME_INVEL_Z;
1026 mRNAMap["NAME_PHIOUTSIN"] = FLUID_NAME_PHIOUTSIN;
1027 mRNAMap["NAME_PHIOUTIN"] = FLUID_NAME_PHIOUTIN;
1028
1029 /* Smoke object names. */
1030 mRNAMap["NAME_SHADOW"] = FLUID_NAME_SHADOW;
1031 mRNAMap["NAME_EMISSION"] = FLUID_NAME_EMISSION;
1032 mRNAMap["NAME_EMISSIONIN"] = FLUID_NAME_EMISSIONIN;
1033 mRNAMap["NAME_DENSITY"] = FLUID_NAME_DENSITY;
1034 mRNAMap["NAME_DENSITYIN"] = FLUID_NAME_DENSITYIN;
1035 mRNAMap["NAME_HEAT"] = FLUID_NAME_HEAT;
1036 mRNAMap["NAME_HEATIN"] = FLUID_NAME_HEATIN;
1037 mRNAMap["NAME_TEMPERATURE"] = FLUID_NAME_TEMPERATURE;
1038 mRNAMap["NAME_TEMPERATUREIN"] = FLUID_NAME_TEMPERATUREIN;
1039 mRNAMap["NAME_COLORR"] = FLUID_NAME_COLORR;
1040 mRNAMap["NAME_COLORG"] = FLUID_NAME_COLORG;
1041 mRNAMap["NAME_COLORB"] = FLUID_NAME_COLORB;
1042 mRNAMap["NAME_COLORRIN"] = FLUID_NAME_COLORRIN;
1043 mRNAMap["NAME_COLORGIN"] = FLUID_NAME_COLORGIN;
1044 mRNAMap["NAME_COLORBIN"] = FLUID_NAME_COLORBIN;
1045 mRNAMap["NAME_FLAME"] = FLUID_NAME_FLAME;
1046 mRNAMap["NAME_FUEL"] = FLUID_NAME_FUEL;
1047 mRNAMap["NAME_REACT"] = FLUID_NAME_REACT;
1048 mRNAMap["NAME_FUELIN"] = FLUID_NAME_FUELIN;
1049 mRNAMap["NAME_REACTIN"] = FLUID_NAME_REACTIN;
1050
1051 /* Liquid object names. */
1052 mRNAMap["NAME_PHIPARTS"] = FLUID_NAME_PHIPARTS;
1053 mRNAMap["NAME_PHI"] = FLUID_NAME_PHI;
1054 mRNAMap["NAME_PHITMP"] = FLUID_NAME_PHITMP;
1055 mRNAMap["NAME_VELOLD"] = FLUID_NAME_VELOCITYOLD;
1056 mRNAMap["NAME_VELPARTS"] = FLUID_NAME_VELOCITYPARTS;
1057 mRNAMap["NAME_MAPWEIGHTS"] = FLUID_NAME_MAPWEIGHTS;
1058 mRNAMap["NAME_PP"] = FLUID_NAME_PP;
1059 mRNAMap["NAME_PVEL"] = FLUID_NAME_PVEL;
1060 mRNAMap["NAME_PARTS"] = FLUID_NAME_PARTS;
1061 mRNAMap["NAME_PARTSVELOCITY"] = FLUID_NAME_PARTSVELOCITY;
1062 mRNAMap["NAME_PINDEX"] = FLUID_NAME_PINDEX;
1063 mRNAMap["NAME_GPI"] = FLUID_NAME_GPI;
1064 mRNAMap["NAME_CURVATURE"] = FLUID_NAME_CURVATURE;
1065
1066 /* Noise object names. */
1067 mRNAMap["NAME_VELOCITY_NOISE"] = FLUID_NAME_VELOCITY_NOISE;
1068 mRNAMap["NAME_DENSITY_NOISE"] = FLUID_NAME_DENSITY_NOISE;
1069 mRNAMap["NAME_PHIIN_NOISE"] = FLUID_NAME_PHIIN_NOISE;
1070 mRNAMap["NAME_PHIOUT_NOISE"] = FLUID_NAME_PHIOUT_NOISE;
1071 mRNAMap["NAME_PHIOBS_NOISE"] = FLUID_NAME_PHIOBS_NOISE;
1072 mRNAMap["NAME_FLAGS_NOISE"] = FLUID_NAME_FLAGS_NOISE;
1073 mRNAMap["NAME_TMPIN_NOISE"] = FLUID_NAME_TMPIN_NOISE;
1074 mRNAMap["NAME_EMISSIONIN_NOISE"] = FLUID_NAME_EMISSIONIN_NOISE;
1075 mRNAMap["NAME_ENERGY"] = FLUID_NAME_ENERGY;
1076 mRNAMap["NAME_TMPFLAGS"] = FLUID_NAME_TMPFLAGS;
1077 mRNAMap["NAME_TEXTURE_U"] = FLUID_NAME_TEXTURE_U;
1078 mRNAMap["NAME_TEXTURE_V"] = FLUID_NAME_TEXTURE_V;
1079 mRNAMap["NAME_TEXTURE_W"] = FLUID_NAME_TEXTURE_W;
1080 mRNAMap["NAME_TEXTURE_U2"] = FLUID_NAME_TEXTURE_U2;
1081 mRNAMap["NAME_TEXTURE_V2"] = FLUID_NAME_TEXTURE_V2;
1082 mRNAMap["NAME_TEXTURE_W2"] = FLUID_NAME_TEXTURE_W2;
1083 mRNAMap["NAME_UV0"] = FLUID_NAME_UV0;
1084 mRNAMap["NAME_UV1"] = FLUID_NAME_UV1;
1085 mRNAMap["NAME_COLORR_NOISE"] = FLUID_NAME_COLORR_NOISE;
1086 mRNAMap["NAME_COLORG_NOISE"] = FLUID_NAME_COLORG_NOISE;
1087 mRNAMap["NAME_COLORB_NOISE"] = FLUID_NAME_COLORB_NOISE;
1088 mRNAMap["NAME_FLAME_NOISE"] = FLUID_NAME_FLAME_NOISE;
1089 mRNAMap["NAME_FUEL_NOISE"] = FLUID_NAME_FUEL_NOISE;
1090 mRNAMap["NAME_REACT_NOISE"] = FLUID_NAME_REACT_NOISE;
1091
1092 /* Mesh object names. */
1093 mRNAMap["NAME_PHIPARTS_MESH"] = FLUID_NAME_PHIPARTS_MESH;
1094 mRNAMap["NAME_PHI_MESH"] = FLUID_NAME_PHI_MESH;
1095 mRNAMap["NAME_PP_MESH"] = FLUID_NAME_PP_MESH;
1096 mRNAMap["NAME_FLAGS_MESH"] = FLUID_NAME_FLAGS_MESH;
1097 mRNAMap["NAME_LMESH"] = FLUID_NAME_LMESH;
1098 mRNAMap["NAME_VELOCITYVEC_MESH"] = FLUID_NAME_VELOCITYVEC_MESH;
1099 mRNAMap["NAME_VELOCITY_MESH"] = FLUID_NAME_VELOCITY_MESH;
1100 mRNAMap["NAME_PINDEX_MESH"] = FLUID_NAME_PINDEX_MESH;
1101 mRNAMap["NAME_GPI_MESH"] = FLUID_NAME_GPI_MESH;
1102
1103 /* Particles object names. */
1104 mRNAMap["NAME_PP_PARTICLES"] = FLUID_NAME_PP_PARTICLES;
1105 mRNAMap["NAME_PVEL_PARTICLES"] = FLUID_NAME_PVEL_PARTICLES;
1106 mRNAMap["NAME_PFORCE_PARTICLES"] = FLUID_NAME_PFORCE_PARTICLES;
1107 mRNAMap["NAME_PLIFE_PARTICLES"] = FLUID_NAME_PLIFE_PARTICLES;
1108 mRNAMap["NAME_PARTS_PARTICLES"] = FLUID_NAME_PARTS_PARTICLES;
1109 mRNAMap["NAME_PARTSVEL_PARTICLES"] = FLUID_NAME_PARTSVEL_PARTICLES;
1110 mRNAMap["NAME_PARTSFORCE_PARTICLES"] = FLUID_NAME_PARTSFORCE_PARTICLES;
1111 mRNAMap["NAME_PARTSLIFE_PARTICLES"] = FLUID_NAME_PARTSLIFE_PARTICLES;
1112 mRNAMap["NAME_VELOCITY_PARTICLES"] = FLUID_NAME_VELOCITY_PARTICLES;
1113 mRNAMap["NAME_FLAGS_PARTICLES"] = FLUID_NAME_FLAGS_PARTICLES;
1114 mRNAMap["NAME_PHI_PARTICLES"] = FLUID_NAME_PHI_PARTICLES;
1115 mRNAMap["NAME_PHIOBS_PARTICLES"] = FLUID_NAME_PHIOBS_PARTICLES;
1116 mRNAMap["NAME_PHIOUT_PARTICLES"] = FLUID_NAME_PHIOUT_PARTICLES;
1117 mRNAMap["NAME_NORMAL_PARTICLES"] = FLUID_NAME_NORMAL_PARTICLES;
1118 mRNAMap["NAME_NEIGHBORRATIO_PARTICLES"] = FLUID_NAME_NEIGHBORRATIO_PARTICLES;
1119 mRNAMap["NAME_TRAPPEDAIR_PARTICLES"] = FLUID_NAME_TRAPPEDAIR_PARTICLES;
1120 mRNAMap["NAME_WAVECREST_PARTICLES"] = FLUID_NAME_WAVECREST_PARTICLES;
1121 mRNAMap["NAME_KINETICENERGY_PARTICLES"] = FLUID_NAME_KINETICENERGY_PARTICLES;
1122
1123 /* Guiding object names. */
1124 mRNAMap["NAME_VELT"] = FLUID_NAME_VELT;
1125 mRNAMap["NAME_WEIGHTGUIDE"] = FLUID_NAME_WEIGHTGUIDE;
1126 mRNAMap["NAME_NUMGUIDES"] = FLUID_NAME_NUMGUIDES;
1127 mRNAMap["NAME_PHIGUIDEIN"] = FLUID_NAME_PHIGUIDEIN;
1128 mRNAMap["NAME_GUIDEVELC"] = FLUID_NAME_GUIDEVELC;
1129 mRNAMap["NAME_GUIDEVEL_X"] = FLUID_NAME_GUIDEVEL_X;
1130 mRNAMap["NAME_GUIDEVEL_Y"] = FLUID_NAME_GUIDEVEL_Y;
1131 mRNAMap["NAME_GUIDEVEL_Z"] = FLUID_NAME_GUIDEVEL_Z;
1132 mRNAMap["NAME_VELOCITY_GUIDE"] = FLUID_NAME_VELOCITY_GUIDE;
1133
1134 /* Cache file names. */
1135 mRNAMap["NAME_CONFIG"] = FLUID_NAME_CONFIG;
1136 mRNAMap["NAME_DATA"] = FLUID_NAME_DATA;
1137 mRNAMap["NAME_NOISE"] = FLUID_NAME_NOISE;
1138 mRNAMap["NAME_MESH"] = FLUID_NAME_MESH;
1139 mRNAMap["NAME_PARTICLES"] = FLUID_NAME_PARTICLES;
1140 mRNAMap["NAME_GUIDING"] = FLUID_NAME_GUIDING;
1141}
1142
1143string MANTA::getRealValue(const string &varName)
1144{
1145 unordered_map<string, string>::iterator it;
1146 it = mRNAMap.find(varName);
1147
1148 if (it == mRNAMap.end()) {
1149 cerr << "Fluid Error -- variable " << varName << " not found in RNA map" << endl;
1150 return "";
1151 }
1152
1153 return it->second;
1154}
1155
1156string MANTA::parseLine(const string &line)
1157{
1158 if (line.size() == 0) {
1159 return "";
1160 }
1161 string res;
1162 int currPos = 0, start_del = 0, end_del = -1;
1163 bool readingVar = false;
1164 const char delimiter = '$';
1165 while (currPos < line.size()) {
1166 if (line[currPos] == delimiter && !readingVar) {
1167 readingVar = true;
1168 start_del = currPos + 1;
1169 res += line.substr(end_del + 1, currPos - end_del - 1);
1170 }
1171 else if (line[currPos] == delimiter && readingVar) {
1172 readingVar = false;
1173 end_del = currPos;
1174 res += getRealValue(line.substr(start_del, currPos - start_del));
1175 }
1176 currPos++;
1177 }
1178 res += line.substr(end_del + 1, line.size() - end_del);
1179 return res;
1180}
1181
1182string MANTA::parseScript(const string &setup_string, FluidModifierData *fmd)
1183{
1184 if (MANTA::with_debug) {
1185 cout << "MANTA::parseScript()" << endl;
1186 }
1187
1188 istringstream f(setup_string);
1189 ostringstream res;
1190 string line;
1191
1192 /* Update RNA map if modifier data is handed over. */
1193 if (fmd) {
1194 initializeRNAMap(fmd);
1195 }
1196 while (getline(f, line)) {
1197 res << parseLine(line) << "\n";
1198 }
1199 return res.str();
1200}
1201
1203static string escapePath(string const &s)
1204{
1205 string result;
1206 for (char c : s) {
1207 if (c == '\\') {
1208 result += "\\\\";
1209 }
1210 else if (c == '\'') {
1211 result += "\\\'";
1212 }
1213 else {
1214 result += c;
1215 }
1216 }
1217 return result;
1218}
1219
1221{
1222 if (with_debug) {
1223 cout << "MANTA::writeConfiguration()" << endl;
1224 }
1225
1226 FluidDomainSettings *fds = fmd->domain;
1227
1228 string directory = getDirectory(fmd, FLUID_DOMAIN_DIR_CONFIG);
1229 string format = FLUID_DOMAIN_EXTENSION_UNI;
1230 string file = getFile(fmd, FLUID_DOMAIN_DIR_CONFIG, FLUID_NAME_CONFIG, format, framenr);
1231
1232 /* Create 'config' subdir if it does not exist already. */
1233 BLI_dir_create_recursive(directory.c_str());
1234
1235 /* Open new file with some compression. */
1236 gzFile gzf = (gzFile)BLI_gzopen(file.c_str(), "wb1");
1237 if (!gzf) {
1238 cerr << "Fluid Error -- Cannot open file " << file << endl;
1239 return false;
1240 }
1241
1242 gzwrite(gzf, &fds->active_fields, sizeof(int));
1243 gzwrite(gzf, &fds->res, 3 * sizeof(int));
1244 gzwrite(gzf, &fds->dx, sizeof(float));
1245 gzwrite(gzf, &fds->dt, sizeof(float));
1246 gzwrite(gzf, &fds->p0, 3 * sizeof(float));
1247 gzwrite(gzf, &fds->p1, 3 * sizeof(float));
1248 gzwrite(gzf, &fds->dp0, 3 * sizeof(float));
1249 gzwrite(gzf, &fds->shift, 3 * sizeof(int));
1250 gzwrite(gzf, &fds->obj_shift_f, 3 * sizeof(float));
1251 gzwrite(gzf, &fds->obmat, 16 * sizeof(float));
1252 gzwrite(gzf, &fds->base_res, 3 * sizeof(int));
1253 gzwrite(gzf, &fds->res_min, 3 * sizeof(int));
1254 gzwrite(gzf, &fds->res_max, 3 * sizeof(int));
1255 gzwrite(gzf, &fds->active_color, 3 * sizeof(float));
1256 gzwrite(gzf, &fds->time_total, sizeof(int));
1257 gzwrite(gzf, &FLUID_CACHE_VERSION, 4 * sizeof(char));
1258
1259 return (gzclose(gzf) == Z_OK);
1260}
1261
1263{
1264 if (with_debug) {
1265 cout << "MANTA::writeData()" << endl;
1266 }
1267
1268 ostringstream ss;
1269 vector<string> pythonCommands;
1270 FluidDomainSettings *fds = fmd->domain;
1271
1272 string directory = getDirectory(fmd, FLUID_DOMAIN_DIR_DATA);
1273 string volume_format = getCacheFileEnding(fds->cache_data_format);
1274 string resumable_cache = !(fds->flags & FLUID_DOMAIN_USE_RESUMABLE_CACHE) ? "False" : "True";
1275
1276 if (mUsingSmoke) {
1277 ss.str("");
1278 ss << "smoke_save_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1279 << ", '" << volume_format << "', " << resumable_cache << ")";
1280 pythonCommands.push_back(ss.str());
1281 }
1282 if (mUsingLiquid) {
1283 ss.str("");
1284 ss << "liquid_save_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1285 << ", '" << volume_format << "', " << resumable_cache << ")";
1286 pythonCommands.push_back(ss.str());
1287 }
1288 return runPythonString(pythonCommands);
1289}
1290
1292{
1293 if (with_debug) {
1294 cout << "MANTA::writeNoise()" << endl;
1295 }
1296
1297 ostringstream ss;
1298 vector<string> pythonCommands;
1299 FluidDomainSettings *fds = fmd->domain;
1300
1301 string directory = getDirectory(fmd, FLUID_DOMAIN_DIR_NOISE);
1302 string volume_format = getCacheFileEnding(fds->cache_data_format);
1303 string resumable_cache = !(fds->flags & FLUID_DOMAIN_USE_RESUMABLE_CACHE) ? "False" : "True";
1304
1305 if (mUsingSmoke && mUsingNoise) {
1306 ss.str("");
1307 ss << "smoke_save_noise_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1308 << ", '" << volume_format << "', " << resumable_cache << ")";
1309 pythonCommands.push_back(ss.str());
1310 }
1311 return runPythonString(pythonCommands);
1312}
1313
1315{
1316 if (with_debug) {
1317 cout << "MANTA::readConfiguration()" << endl;
1318 }
1319
1320 FluidDomainSettings *fds = fmd->domain;
1321 float dummy;
1322
1323 string directory = getDirectory(fmd, FLUID_DOMAIN_DIR_CONFIG);
1324 string format = FLUID_DOMAIN_EXTENSION_UNI;
1325 string file = getFile(fmd, FLUID_DOMAIN_DIR_CONFIG, FLUID_NAME_CONFIG, format, framenr);
1326
1327 if (!hasConfig(fmd, framenr)) {
1328 return false;
1329 }
1330
1331 gzFile gzf = (gzFile)BLI_gzopen(file.c_str(), "rb"); /* Do some compression. */
1332 if (!gzf) {
1333 cerr << "Fluid Error -- Cannot open file " << file << endl;
1334 return false;
1335 }
1336
1337 gzread(gzf, &fds->active_fields, sizeof(int));
1338 gzread(gzf, &fds->res, 3 * sizeof(int));
1339 gzread(gzf, &fds->dx, sizeof(float));
1340 gzread(gzf, &dummy, sizeof(float)); /* dt not needed right now. */
1341 gzread(gzf, &fds->p0, 3 * sizeof(float));
1342 gzread(gzf, &fds->p1, 3 * sizeof(float));
1343 gzread(gzf, &fds->dp0, 3 * sizeof(float));
1344 gzread(gzf, &fds->shift, 3 * sizeof(int));
1345 gzread(gzf, &fds->obj_shift_f, 3 * sizeof(float));
1346 gzread(gzf, &fds->obmat, 16 * sizeof(float));
1347 gzread(gzf, &fds->base_res, 3 * sizeof(int));
1348 gzread(gzf, &fds->res_min, 3 * sizeof(int));
1349 gzread(gzf, &fds->res_max, 3 * sizeof(int));
1350 gzread(gzf, &fds->active_color, 3 * sizeof(float));
1351 gzread(gzf, &fds->time_total, sizeof(int));
1352 gzread(gzf, &fds->cache_id, 4 * sizeof(char)); /* Older caches might have no id. */
1353
1354 fds->total_cells = fds->res[0] * fds->res[1] * fds->res[2];
1355
1356 return (gzclose(gzf) == Z_OK);
1357}
1358
1359bool MANTA::readData(FluidModifierData *fmd, int framenr, bool resumable)
1360{
1361 if (with_debug) {
1362 cout << "MANTA::readData()" << endl;
1363 }
1364
1365 if (!mUsingSmoke && !mUsingLiquid) {
1366 return false;
1367 }
1368
1369 ostringstream ss;
1370 vector<string> pythonCommands;
1371 FluidDomainSettings *fds = fmd->domain;
1372 bool result = true;
1373
1374 string directory = getDirectory(fmd, FLUID_DOMAIN_DIR_DATA);
1375 string volume_format = getCacheFileEnding(fds->cache_data_format);
1376 string resumable_cache = (!resumable) ? "False" : "True";
1377
1378 /* Sanity check: Are cache files present? */
1379 if (!hasData(fmd, framenr)) {
1380 return false;
1381 }
1382
1383 if (mUsingSmoke) {
1384 ss.str("");
1385 ss << "smoke_load_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1386 << ", '" << volume_format << "', " << resumable_cache << ")";
1387 pythonCommands.push_back(ss.str());
1388 result &= runPythonString(pythonCommands);
1389 return (mSmokeFromFile = result);
1390 }
1391 if (mUsingLiquid) {
1392 ss.str("");
1393 ss << "liquid_load_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1394 << ", '" << volume_format << "', " << resumable_cache << ")";
1395 pythonCommands.push_back(ss.str());
1396 result &= runPythonString(pythonCommands);
1397 return (mFlipFromFile = result);
1398 }
1399 return result;
1400}
1401
1402bool MANTA::readNoise(FluidModifierData *fmd, int framenr, bool resumable)
1403{
1404 if (with_debug) {
1405 cout << "MANTA::readNoise()" << endl;
1406 }
1407
1408 if (!mUsingSmoke || !mUsingNoise) {
1409 return false;
1410 }
1411
1412 ostringstream ss;
1413 vector<string> pythonCommands;
1414 FluidDomainSettings *fds = fmd->domain;
1415
1416 string directory = getDirectory(fmd, FLUID_DOMAIN_DIR_NOISE);
1417 string resumable_cache = (!resumable) ? "False" : "True";
1418
1419 /* Support older caches which had more granular file format control. */
1420 char format = (!strcmp(fds->cache_id, FLUID_CACHE_VERSION)) ? fds->cache_data_format :
1421 fds->cache_noise_format;
1422 string volume_format = getCacheFileEnding(format);
1423
1424 /* Sanity check: Are cache files present? */
1425 if (!hasNoise(fmd, framenr)) {
1426 return false;
1427 }
1428
1429 ss.str("");
1430 ss << "smoke_load_noise_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1431 << ", '" << volume_format << "', " << resumable_cache << ")";
1432 pythonCommands.push_back(ss.str());
1433
1434 return (mNoiseFromFile = runPythonString(pythonCommands));
1435}
1436
1437bool MANTA::readMesh(FluidModifierData *fmd, int framenr)
1438{
1439 if (with_debug) {
1440 cout << "MANTA::readMesh()" << endl;
1441 }
1442
1443 /* Clear mesh data from a previously loaded frame when the requested cache cannot be loaded. */
1444 const auto clear_mesh = [this]() {
1445 if (mMeshNodes) {
1446 mMeshNodes->clear();
1447 }
1448 if (mMeshTriangles) {
1449 mMeshTriangles->clear();
1450 }
1451 if (mMeshVelocities) {
1452 mMeshVelocities->clear();
1453 }
1454 mMeshFromFile = false;
1455 };
1456
1457 if (!mUsingLiquid || !mUsingMesh) {
1458 return false;
1459 }
1460
1461 ostringstream ss;
1462 vector<string> pythonCommands;
1463 FluidDomainSettings *fds = fmd->domain;
1464
1465 string directory = getDirectory(fmd, FLUID_DOMAIN_DIR_MESH);
1466 string mesh_format = getCacheFileEnding(fds->cache_mesh_format);
1467 string volume_format = getCacheFileEnding(fds->cache_data_format);
1468
1469 /* Sanity check: Are cache files present? */
1470 if (!hasMesh(fmd, framenr)) {
1471 clear_mesh();
1472 return false;
1473 }
1474
1475 ss.str("");
1476 ss << "liquid_load_mesh_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1477 << ", '" << mesh_format << "')";
1478 pythonCommands.push_back(ss.str());
1479
1480 if (mUsingMVel) {
1481 ss.str("");
1482 ss << "liquid_load_meshvel_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1483 << ", '" << volume_format << "')";
1484 pythonCommands.push_back(ss.str());
1485 }
1486
1487 mMeshFromFile = runPythonString(pythonCommands);
1488 if (!mMeshFromFile) {
1489 clear_mesh();
1490 }
1491 return mMeshFromFile;
1492}
1493
1494bool MANTA::readParticles(FluidModifierData *fmd, int framenr, bool resumable)
1495{
1496 if (with_debug) {
1497 cout << "MANTA::readParticles()" << endl;
1498 }
1499
1500 if (!mUsingLiquid) {
1501 return false;
1502 }
1503 if (!mUsingDrops && !mUsingBubbles && !mUsingFloats && !mUsingTracers) {
1504 return false;
1505 }
1506
1507 ostringstream ss;
1508 vector<string> pythonCommands;
1509 FluidDomainSettings *fds = fmd->domain;
1510
1511 string directory = getDirectory(fmd, FLUID_DOMAIN_DIR_PARTICLES);
1512 string resumable_cache = (!resumable) ? "False" : "True";
1513
1514 /* Support older caches which had more granular file format control. */
1515 char format = (!strcmp(fds->cache_id, FLUID_CACHE_VERSION)) ? fds->cache_data_format :
1517 string volume_format = getCacheFileEnding(format);
1518
1519 /* Sanity check: Are cache files present? */
1520 if (!hasParticles(fmd, framenr)) {
1521 return false;
1522 }
1523
1524 ss.str("");
1525 ss << "liquid_load_particles_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1526 << ", '" << volume_format << "', " << resumable_cache << ")";
1527 pythonCommands.push_back(ss.str());
1528
1529 return (mParticlesFromFile = runPythonString(pythonCommands));
1530}
1531
1532bool MANTA::readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
1533{
1534 if (with_debug) {
1535 cout << "MANTA::readGuiding()" << endl;
1536 }
1537
1538 if (!mUsingGuiding) {
1539 return false;
1540 }
1541 if (!fmd) {
1542 return false;
1543 }
1544
1545 ostringstream ss;
1546 vector<string> pythonCommands;
1547 FluidDomainSettings *fds = fmd->domain;
1548
1549 string directory = (sourceDomain) ? getDirectory(fmd, FLUID_DOMAIN_DIR_DATA) :
1550 getDirectory(fmd, FLUID_DOMAIN_DIR_GUIDE);
1551 string volume_format = getCacheFileEnding(fds->cache_data_format);
1552
1553 /* Sanity check: Are cache files present? */
1554 if (!hasGuiding(fmd, framenr, sourceDomain)) {
1555 return false;
1556 }
1557
1558 if (sourceDomain) {
1559 ss.str("");
1560 ss << "fluid_load_vel_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1561 << ", '" << volume_format << "')";
1562 }
1563 else {
1564 ss.str("");
1565 ss << "fluid_load_guiding_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
1566 << ", '" << volume_format << "')";
1567 }
1568 pythonCommands.push_back(ss.str());
1569
1570 return runPythonString(pythonCommands);
1571}
1572
1573bool MANTA::bakeData(FluidModifierData *fmd, int framenr)
1574{
1575 if (with_debug) {
1576 cout << "MANTA::bakeData()" << endl;
1577 }
1578
1579 ostringstream ss;
1580 vector<string> pythonCommands;
1581 FluidDomainSettings *fds = fmd->domain;
1582
1583 char cacheDirData[FILE_MAX], cacheDirGuiding[FILE_MAX];
1584 cacheDirData[0] = '\0';
1585 cacheDirGuiding[0] = '\0';
1586
1587 string volume_format = getCacheFileEnding(fds->cache_data_format);
1588
1589 BLI_path_join(cacheDirData, sizeof(cacheDirData), fds->cache_directory, FLUID_DOMAIN_DIR_DATA);
1591 cacheDirGuiding, sizeof(cacheDirGuiding), fds->cache_directory, FLUID_DOMAIN_DIR_GUIDE);
1592 BLI_path_make_safe(cacheDirData);
1593 BLI_path_make_safe(cacheDirGuiding);
1594
1595 ss.str("");
1596 ss << "bake_fluid_data_" << mCurrentID << "('" << escapePath(cacheDirData) << "', " << framenr
1597 << ", '" << volume_format << "')";
1598 pythonCommands.push_back(ss.str());
1599
1600 return runPythonString(pythonCommands);
1601}
1602
1604{
1605 if (with_debug) {
1606 cout << "MANTA::bakeNoise()" << endl;
1607 }
1608
1609 ostringstream ss;
1610 vector<string> pythonCommands;
1611 FluidDomainSettings *fds = fmd->domain;
1612
1613 char cacheDirNoise[FILE_MAX];
1614 cacheDirNoise[0] = '\0';
1615
1616 string volume_format = getCacheFileEnding(fds->cache_data_format);
1617
1619 cacheDirNoise, sizeof(cacheDirNoise), fds->cache_directory, FLUID_DOMAIN_DIR_NOISE);
1620 BLI_path_make_safe(cacheDirNoise);
1621
1622 ss.str("");
1623 ss << "bake_noise_" << mCurrentID << "('" << escapePath(cacheDirNoise) << "', " << framenr
1624 << ", '" << volume_format << "')";
1625 pythonCommands.push_back(ss.str());
1626
1627 return runPythonString(pythonCommands);
1628}
1629
1630bool MANTA::bakeMesh(FluidModifierData *fmd, int framenr)
1631{
1632 if (with_debug) {
1633 cout << "MANTA::bakeMesh()" << endl;
1634 }
1635
1636 ostringstream ss;
1637 vector<string> pythonCommands;
1638 FluidDomainSettings *fds = fmd->domain;
1639
1640 char cacheDirMesh[FILE_MAX];
1641 cacheDirMesh[0] = '\0';
1642
1643 string volume_format = getCacheFileEnding(fds->cache_data_format);
1644 string mesh_format = getCacheFileEnding(fds->cache_mesh_format);
1645
1646 BLI_path_join(cacheDirMesh, sizeof(cacheDirMesh), fds->cache_directory, FLUID_DOMAIN_DIR_MESH);
1647 BLI_path_make_safe(cacheDirMesh);
1648
1649 ss.str("");
1650 ss << "bake_mesh_" << mCurrentID << "('" << escapePath(cacheDirMesh) << "', " << framenr << ", '"
1651 << volume_format << "', '" << mesh_format << "')";
1652 pythonCommands.push_back(ss.str());
1653
1654 return runPythonString(pythonCommands);
1655}
1656
1658{
1659 if (with_debug) {
1660 cout << "MANTA::bakeParticles()" << endl;
1661 }
1662
1663 ostringstream ss;
1664 vector<string> pythonCommands;
1665 FluidDomainSettings *fds = fmd->domain;
1666
1667 char cacheDirParticles[FILE_MAX];
1668 cacheDirParticles[0] = '\0';
1669
1670 string volume_format = getCacheFileEnding(fds->cache_data_format);
1671 string resumable_cache = !(fds->flags & FLUID_DOMAIN_USE_RESUMABLE_CACHE) ? "False" : "True";
1672
1673 BLI_path_join(cacheDirParticles,
1674 sizeof(cacheDirParticles),
1675 fds->cache_directory,
1677 BLI_path_make_safe(cacheDirParticles);
1678
1679 ss.str("");
1680 ss << "bake_particles_" << mCurrentID << "('" << escapePath(cacheDirParticles) << "', "
1681 << framenr << ", '" << volume_format << "', " << resumable_cache << ")";
1682 pythonCommands.push_back(ss.str());
1683
1684 return runPythonString(pythonCommands);
1685}
1686
1688{
1689 if (with_debug) {
1690 cout << "MANTA::bakeGuiding()" << endl;
1691 }
1692
1693 ostringstream ss;
1694 vector<string> pythonCommands;
1695 FluidDomainSettings *fds = fmd->domain;
1696
1697 char cacheDirGuiding[FILE_MAX];
1698 cacheDirGuiding[0] = '\0';
1699
1700 string volume_format = getCacheFileEnding(fds->cache_data_format);
1701 string resumable_cache = !(fds->flags & FLUID_DOMAIN_USE_RESUMABLE_CACHE) ? "False" : "True";
1702
1704 cacheDirGuiding, sizeof(cacheDirGuiding), fds->cache_directory, FLUID_DOMAIN_DIR_GUIDE);
1705 BLI_path_make_safe(cacheDirGuiding);
1706
1707 ss.str("");
1708 ss << "bake_guiding_" << mCurrentID << "('" << escapePath(cacheDirGuiding) << "', " << framenr
1709 << ", '" << volume_format << "', " << resumable_cache << ")";
1710 pythonCommands.push_back(ss.str());
1711
1712 return runPythonString(pythonCommands);
1713}
1714
1716{
1717 string tmpString, finalString;
1718 vector<string> pythonCommands;
1719
1720 tmpString += fluid_variables;
1721 if (mUsingSmoke) {
1722 tmpString += smoke_variables;
1723 }
1724 if (mUsingLiquid) {
1725 tmpString += liquid_variables;
1726 }
1727 if (mUsingGuiding) {
1728 tmpString += fluid_variables_guiding;
1729 }
1730 if (mUsingNoise) {
1731 tmpString += fluid_variables_noise;
1732 tmpString += smoke_variables_noise;
1733 tmpString += smoke_wavelet_noise;
1734 }
1735 if (mUsingDrops || mUsingBubbles || mUsingFloats || mUsingTracers) {
1736 tmpString += fluid_variables_particles;
1737 tmpString += liquid_variables_particles;
1738 }
1739 if (mUsingMesh) {
1740 tmpString += fluid_variables_mesh;
1741 }
1742
1743 finalString = parseScript(tmpString, fmd);
1744 pythonCommands.push_back(finalString);
1745
1746 return runPythonString(pythonCommands);
1747}
1748
1750{
1751 if (with_debug) {
1752 cout << "MANTA::exportSmokeScript()" << endl;
1753 }
1754
1755 char cacheDir[FILE_MAX] = "\0";
1756 char cacheDirScript[FILE_MAX] = "\0";
1757
1758 FluidDomainSettings *fds = fmd->domain;
1759
1760 BLI_path_join(cacheDir, sizeof(cacheDir), fds->cache_directory, FLUID_DOMAIN_DIR_SCRIPT);
1761 BLI_path_make_safe(cacheDir);
1762 /* Create 'script' subdir if it does not exist already */
1763 BLI_dir_create_recursive(cacheDir);
1764 BLI_path_join(cacheDirScript, sizeof(cacheDirScript), cacheDir, FLUID_DOMAIN_SMOKE_SCRIPT);
1765 BLI_path_make_safe(cacheDir);
1766
1767 bool noise = fds->flags & FLUID_DOMAIN_USE_NOISE;
1768 bool heat = fds->active_fields & FLUID_DOMAIN_ACTIVE_HEAT;
1769 bool colors = fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS;
1770 bool fire = fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE;
1771 bool obstacle = fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE;
1772 bool guiding = fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE;
1773 bool invel = fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL;
1774 bool outflow = fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW;
1775
1776 string manta_script;
1777
1778 /* Libraries. */
1779 manta_script += header_libraries + manta_import;
1780
1781 /* Variables. */
1782 manta_script += header_variables + fluid_variables + smoke_variables;
1783 if (noise) {
1785 }
1786 if (guiding) {
1787 manta_script += fluid_variables_guiding;
1788 }
1789
1790 /* Solvers. */
1791 manta_script += header_solvers + fluid_solver;
1792 if (noise) {
1793 manta_script += fluid_solver_noise;
1794 }
1795 if (guiding) {
1796 manta_script += fluid_solver_guiding;
1797 }
1798
1799 /* Grids. */
1800 manta_script += header_grids + fluid_alloc + smoke_alloc;
1801 if (noise) {
1802 manta_script += smoke_alloc_noise;
1803 if (colors) {
1804 manta_script += smoke_alloc_colors_noise;
1805 }
1806 if (fire) {
1807 manta_script += smoke_alloc_fire_noise;
1808 }
1809 }
1810 if (heat) {
1811 manta_script += smoke_alloc_heat;
1812 }
1813 if (colors) {
1814 manta_script += smoke_alloc_colors;
1815 }
1816 if (fire) {
1817 manta_script += smoke_alloc_fire;
1818 }
1819 if (guiding) {
1820 manta_script += fluid_alloc_guiding;
1821 }
1822 if (obstacle) {
1823 manta_script += fluid_alloc_obstacle;
1824 }
1825 if (invel) {
1826 manta_script += fluid_alloc_invel;
1827 }
1828 if (outflow) {
1829 manta_script += fluid_alloc_outflow;
1830 }
1831
1832 /* Noise field. */
1833 if (noise) {
1834 manta_script += smoke_wavelet_noise;
1835 }
1836
1837 /* Time. */
1838 manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
1839
1840 /* Import. */
1841 manta_script += header_import + fluid_file_import + fluid_cache_helper + smoke_load_data;
1842 if (noise) {
1843 manta_script += smoke_load_noise;
1844 }
1845 if (guiding) {
1846 manta_script += fluid_load_guiding;
1847 }
1848
1849 /* Pre/Post Steps. */
1850 manta_script += header_prepost + fluid_pre_step + fluid_post_step;
1851
1852 /* Steps. */
1853 manta_script += header_steps + smoke_adaptive_step + smoke_step;
1854 if (noise) {
1855 manta_script += smoke_step_noise;
1856 }
1857
1858 /* Main. */
1859 manta_script += header_main + smoke_standalone + fluid_standalone;
1860
1861 /* Fill in missing variables in script. */
1862 string final_script = MANTA::parseScript(manta_script, fmd);
1863
1864 /* Write script. */
1865 ofstream myfile;
1866 myfile.open(cacheDirScript);
1867 myfile << final_script;
1868 myfile.close();
1869 if (!myfile) {
1870 cerr << "Fluid Error -- Could not export standalone Mantaflow smoke domain script";
1871 return false;
1872 }
1873 return true;
1874}
1875
1877{
1878 if (with_debug) {
1879 cout << "MANTA::exportLiquidScript()" << endl;
1880 }
1881
1882 char cacheDir[FILE_MAX] = "\0";
1883 char cacheDirScript[FILE_MAX] = "\0";
1884
1885 FluidDomainSettings *fds = fmd->domain;
1886
1887 BLI_path_join(cacheDir, sizeof(cacheDir), fds->cache_directory, FLUID_DOMAIN_DIR_SCRIPT);
1888 BLI_path_make_safe(cacheDir);
1889 /* Create 'script' subdir if it does not exist already */
1890 BLI_dir_create_recursive(cacheDir);
1891 BLI_path_join(cacheDirScript, sizeof(cacheDirScript), cacheDir, FLUID_DOMAIN_LIQUID_SCRIPT);
1892 BLI_path_make_safe(cacheDirScript);
1893
1894 bool mesh = fds->flags & FLUID_DOMAIN_USE_MESH;
1895 bool drops = fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY;
1896 bool bubble = fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE;
1897 bool floater = fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM;
1898 bool tracer = fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER;
1899 bool obstacle = fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE;
1900 bool fractions = fds->flags & FLUID_DOMAIN_USE_FRACTIONS;
1901 bool guiding = fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE;
1902 bool invel = fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL;
1903 bool outflow = fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW;
1904 bool viscosity = fds->flags & FLUID_DOMAIN_USE_VISCOSITY;
1905
1906 string manta_script;
1907
1908 /* Libraries. */
1909 manta_script += header_libraries + manta_import;
1910
1911 /* Variables. */
1912 manta_script += header_variables + fluid_variables + liquid_variables;
1913 if (mesh) {
1914 manta_script += fluid_variables_mesh;
1915 }
1916 if (drops || bubble || floater || tracer) {
1918 }
1919 if (guiding) {
1920 manta_script += fluid_variables_guiding;
1921 }
1922 if (viscosity) {
1923 manta_script += fluid_variables_viscosity;
1924 }
1925
1926 /* Solvers. */
1927 manta_script += header_solvers + fluid_solver;
1928 if (mesh) {
1929 manta_script += fluid_solver_mesh;
1930 }
1931 if (drops || bubble || floater || tracer) {
1932 manta_script += fluid_solver_particles;
1933 }
1934 if (guiding) {
1935 manta_script += fluid_solver_guiding;
1936 }
1937 if (viscosity) {
1938 manta_script += fluid_solver_viscosity;
1939 }
1940
1941 /* Grids. */
1942 manta_script += header_grids + fluid_alloc + liquid_alloc;
1943 if (mesh) {
1944 manta_script += liquid_alloc_mesh;
1945 }
1946 if (drops || bubble || floater || tracer) {
1947 manta_script += liquid_alloc_particles;
1948 }
1949 if (guiding) {
1950 manta_script += fluid_alloc_guiding;
1951 }
1952 if (obstacle) {
1953 manta_script += fluid_alloc_obstacle;
1954 }
1955 if (fractions) {
1956 manta_script += fluid_alloc_fractions;
1957 }
1958 if (invel) {
1959 manta_script += fluid_alloc_invel;
1960 }
1961 if (outflow) {
1962 manta_script += fluid_alloc_outflow;
1963 }
1964 if (viscosity) {
1965 manta_script += liquid_alloc_viscosity;
1966 }
1967
1968 /* Domain init. */
1969 manta_script += header_gridinit + liquid_init_phi;
1970
1971 /* Time. */
1972 manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
1973
1974 /* Import. */
1975 manta_script += header_import + fluid_file_import + fluid_cache_helper + liquid_load_data;
1976 if (mesh) {
1977 manta_script += liquid_load_mesh;
1978 }
1979 if (drops || bubble || floater || tracer) {
1980 manta_script += liquid_load_particles;
1981 }
1982 if (guiding) {
1983 manta_script += fluid_load_guiding;
1984 }
1985
1986 /* Pre/Post Steps. */
1987 manta_script += header_prepost + fluid_pre_step + fluid_post_step;
1988
1989 /* Steps. */
1990 manta_script += header_steps + liquid_adaptive_step + liquid_step;
1991 if (mesh) {
1992 manta_script += liquid_step_mesh;
1993 }
1994 if (drops || bubble || floater || tracer) {
1995 manta_script += liquid_step_particles;
1996 }
1997
1998 /* Main. */
1999 manta_script += header_main + liquid_standalone + fluid_standalone;
2000
2001 /* Fill in missing variables in script. */
2002 string final_script = MANTA::parseScript(manta_script, fmd);
2003
2004 /* Write script. */
2005 ofstream myfile;
2006 myfile.open(cacheDirScript);
2007 myfile << final_script;
2008 myfile.close();
2009 if (!myfile) {
2010 cerr << "Fluid Error -- Could not export standalone Mantaflow liquid domain script";
2011 return false;
2012 }
2013 return true;
2014}
2015
2016/* Call Mantaflow Python functions through this function. Use isAttribute for object attributes,
2017 * e.g. s.cfl (here 's' is varname, 'cfl' functionName, and isAttribute true) or
2018 * grid.getDataPointer (here 's' is varname, 'getDataPointer' functionName, and isAttribute
2019 * false)
2020 *
2021 * Important! Return value: New reference or nullptr
2022 * Caller of this function needs to handle reference count of returned object. */
2023static PyObject *callPythonFunction(string varName, string functionName, bool isAttribute = false)
2024{
2025 if ((varName == "") || (functionName == "")) {
2026 if (MANTA::with_debug) {
2027 cout << "Fluid: Missing Python variable name and/or function name -- name is: " << varName
2028 << ", function name is: " << functionName << endl;
2029 }
2030 return nullptr;
2031 }
2032
2033 PyGILState_STATE gilstate = PyGILState_Ensure();
2034 PyObject *var = nullptr, *func = nullptr, *returnedValue = nullptr;
2035
2036 /* Be sure to initialize Python before using it. */
2037 Py_Initialize();
2038
2039 /* Get pyobject that holds result value. */
2040 if (!manta_main_module) {
2041 PyGILState_Release(gilstate);
2042 return nullptr;
2043 }
2044
2045 /* Ensure that requested variable is present in module - avoid attribute errors later on. */
2046 if (!PyObject_HasAttrString(manta_main_module, varName.c_str())) {
2047 PyGILState_Release(gilstate);
2048 return nullptr;
2049 }
2050
2051 var = PyObject_GetAttrString(manta_main_module, varName.c_str());
2052 if (!var) {
2053 PyErr_Clear();
2054 PyGILState_Release(gilstate);
2055 return nullptr;
2056 }
2057
2058 func = PyObject_GetAttrString(var, functionName.c_str());
2059
2060 Py_DECREF(var);
2061 if (!func) {
2062 PyErr_Clear();
2063 PyGILState_Release(gilstate);
2064 return nullptr;
2065 }
2066
2067 if (!isAttribute) {
2068 returnedValue = PyObject_CallObject(func, nullptr);
2069 if (returnedValue == nullptr) {
2070 /* Print any unexpected errors, also clear them. */
2071 PyErr_Print();
2072 }
2073 Py_DECREF(func);
2074 }
2075
2076 PyGILState_Release(gilstate);
2077 return (!isAttribute) ? returnedValue : func;
2078}
2079
2080/* Argument of this function may be a nullptr.
2081 * If it's not function will handle the reference count decrement of that argument. */
2082static void *pyObjectToPointer(PyObject *inputObject)
2083{
2084 if (!inputObject) {
2085 return nullptr;
2086 }
2087
2088 PyGILState_STATE gilstate = PyGILState_Ensure();
2089
2090 PyObject *encoded = PyUnicode_AsUTF8String(inputObject);
2091 char *result = PyBytes_AsString(encoded);
2092
2093 Py_DECREF(inputObject);
2094
2095 string str(result);
2096 istringstream in(str);
2097 void *dataPointer = nullptr;
2098 in >> dataPointer;
2099
2100 Py_DECREF(encoded);
2101
2102 PyGILState_Release(gilstate);
2103 return dataPointer;
2104}
2105
2106/* Argument of this function may be a nullptr.
2107 * If it's not function will handle the reference count decrement of that argument. */
2108static double pyObjectToDouble(PyObject *inputObject)
2109{
2110 if (!inputObject) {
2111 return 0.0;
2112 }
2113
2114 PyGILState_STATE gilstate = PyGILState_Ensure();
2115
2116 /* Cannot use PyFloat_AsDouble() since its error check crashes.
2117 * Likely because of typedef 'Real' for 'float' types in Mantaflow. */
2118 double result = PyFloat_AS_DOUBLE(inputObject);
2119 Py_DECREF(inputObject);
2120
2121 PyGILState_Release(gilstate);
2122 return result;
2123}
2124
2125/* Argument of this function may be a nullptr.
2126 * If it's not function will handle the reference count decrement of that argument. */
2127static long pyObjectToLong(PyObject *inputObject)
2128{
2129 if (!inputObject) {
2130 return 0;
2131 }
2132
2133 PyGILState_STATE gilstate = PyGILState_Ensure();
2134
2135 long result = PyLong_AsLong(inputObject);
2136 Py_DECREF(inputObject);
2137
2138 PyGILState_Release(gilstate);
2139 return result;
2140}
2141
2142template<class T> static T *getPointer(string pyObjectName, string pyFunctionName)
2143{
2144 return static_cast<T *>(pyObjectToPointer(callPythonFunction(pyObjectName, pyFunctionName)));
2145}
2146
2148{
2149 if (with_debug) {
2150 cout << "MANTA::getFrame()" << endl;
2151 }
2152
2153 string func = "frame";
2154 string id = to_string(mCurrentID);
2155 string solver = "s" + id;
2156
2157 return pyObjectToLong(callPythonFunction(solver, func, true));
2158}
2159
2161{
2162 if (with_debug) {
2163 cout << "MANTA::getTimestep()" << endl;
2164 }
2165
2166 string func = "timestep";
2167 string id = to_string(mCurrentID);
2168 string solver = "s" + id;
2169
2170 return (float)pyObjectToDouble(callPythonFunction(solver, func, true));
2171}
2172
2174{
2175 FluidDomainSettings *fds = fmd->domain;
2176 return ((fds->res_max[0] - fds->res_min[0]) != mResX ||
2177 (fds->res_max[1] - fds->res_min[1]) != mResY ||
2178 (fds->res_max[2] - fds->res_min[2]) != mResZ);
2179}
2180
2182{
2183 if (with_debug) {
2184 cout << "MANTA::adaptTimestep()" << endl;
2185 }
2186
2187 vector<string> pythonCommands;
2188 ostringstream ss;
2189
2190 ss << "fluid_adapt_time_step_" << mCurrentID << "()";
2191 pythonCommands.push_back(ss.str());
2192
2193 runPythonString(pythonCommands);
2194}
2195
2197{
2198 if (with_debug) {
2199 cout << "MANTA::updatePointers()" << endl;
2200 }
2201
2202 FluidDomainSettings *fds = fmd->domain;
2203
2204 bool liquid = !flush && (fds->type == FLUID_DOMAIN_TYPE_LIQUID);
2205 bool smoke = !flush && (fds->type == FLUID_DOMAIN_TYPE_GAS);
2206 bool noise = !flush && smoke && fds->flags & FLUID_DOMAIN_USE_NOISE;
2207 bool heat = !flush && smoke && fds->active_fields & FLUID_DOMAIN_ACTIVE_HEAT;
2208 bool colors = !flush && smoke && fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS;
2209 bool fire = !flush && smoke && fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE;
2210 bool obstacle = !flush && fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE;
2211 bool guiding = !flush && fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE;
2212 bool invel = !flush && fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL;
2213 bool outflow = !flush && fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW;
2214 bool drops = !flush && liquid && fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY;
2215 bool bubble = !flush && liquid && fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE;
2216 bool floater = !flush && liquid && fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM;
2217 bool tracer = !flush && liquid && fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER;
2218 bool parts = !flush && liquid && (drops | bubble | floater | tracer);
2219 bool mesh = !flush && liquid && fds->flags & FLUID_DOMAIN_USE_MESH;
2220 bool meshvel = !flush && liquid && mesh && fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS;
2221
2222 string func = "getDataPointer";
2223 string funcNodes = "getNodesDataPointer";
2224 string funcTris = "getTrisDataPointer";
2225
2226 string id = to_string(mCurrentID);
2227 string s_ext = "_s" + id;
2228 string pp_ext = "_pp" + id;
2229 string snd_ext = "_sp" + id;
2230 string sm_ext = "_sm" + id;
2231 string mesh_ext = "_mesh" + id;
2232 string sn_ext = "_sn" + id;
2233
2234 mFlags = (smoke || liquid) ? getPointer<int>("flags" + s_ext, func) : nullptr;
2235 mPhiIn = (smoke || liquid) ? getPointer<float>("phiIn" + s_ext, func) : nullptr;
2236 mPhiStaticIn = (smoke || liquid) ? getPointer<float>("phiSIn" + s_ext, func) : nullptr;
2237 mVelocityX = (smoke || liquid) ? getPointer<float>("x_vel" + s_ext, func) : nullptr;
2238 mVelocityY = (smoke || liquid) ? getPointer<float>("y_vel" + s_ext, func) : nullptr;
2239 mVelocityZ = (smoke || liquid) ? getPointer<float>("z_vel" + s_ext, func) : nullptr;
2240 mForceX = (smoke || liquid) ? getPointer<float>("x_force" + s_ext, func) : nullptr;
2241 mForceY = (smoke || liquid) ? getPointer<float>("y_force" + s_ext, func) : nullptr;
2242 mForceZ = (smoke || liquid) ? getPointer<float>("z_force" + s_ext, func) : nullptr;
2243 mPressure = (smoke || liquid) ? getPointer<float>("pressure" + s_ext, func) : nullptr;
2244
2245 /* Outflow. */
2246 mPhiOutIn = (outflow) ? getPointer<float>("phiOutIn" + s_ext, func) : nullptr;
2247 mPhiOutStaticIn = (outflow) ? getPointer<float>("phiOutSIn" + s_ext, func) : nullptr;
2248
2249 /* Obstacles. */
2250 mPhiObsIn = (obstacle) ? getPointer<float>("phiObsIn" + s_ext, func) : nullptr;
2251 mPhiObsStaticIn = (obstacle) ? getPointer<float>("phiObsSIn" + s_ext, func) : nullptr;
2252 mObVelocityX = (obstacle) ? getPointer<float>("x_obvel" + s_ext, func) : nullptr;
2253 mObVelocityY = (obstacle) ? getPointer<float>("y_obvel" + s_ext, func) : nullptr;
2254 mObVelocityZ = (obstacle) ? getPointer<float>("z_obvel" + s_ext, func) : nullptr;
2255 mNumObstacle = (obstacle) ? getPointer<float>("numObs" + s_ext, func) : nullptr;
2256
2257 /* Guiding. */
2258 mPhiGuideIn = (guiding) ? getPointer<float>("phiGuideIn" + s_ext, func) : nullptr;
2259 mGuideVelocityX = (guiding) ? getPointer<float>("x_guidevel" + s_ext, func) : nullptr;
2260 mGuideVelocityY = (guiding) ? getPointer<float>("y_guidevel" + s_ext, func) : nullptr;
2261 mGuideVelocityZ = (guiding) ? getPointer<float>("z_guidevel" + s_ext, func) : nullptr;
2262 mNumGuide = (guiding) ? getPointer<float>("numGuides" + s_ext, func) : nullptr;
2263
2264 /* Initial velocities. */
2265 mInVelocityX = (invel) ? getPointer<float>("x_invel" + s_ext, func) : nullptr;
2266 mInVelocityY = (invel) ? getPointer<float>("y_invel" + s_ext, func) : nullptr;
2267 mInVelocityZ = (invel) ? getPointer<float>("z_invel" + s_ext, func) : nullptr;
2268
2269 /* Smoke. */
2270 mDensity = (smoke) ? getPointer<float>("density" + s_ext, func) : nullptr;
2271 mDensityIn = (smoke) ? getPointer<float>("densityIn" + s_ext, func) : nullptr;
2272 mShadow = (smoke) ? getPointer<float>("shadow" + s_ext, func) : nullptr;
2273 mEmissionIn = (smoke) ? getPointer<float>("emissionIn" + s_ext, func) : nullptr;
2274
2275 /* Heat. */
2276 mHeat = (heat) ? getPointer<float>("heat" + s_ext, func) : nullptr;
2277 mHeatIn = (heat) ? getPointer<float>("heatIn" + s_ext, func) : nullptr;
2278
2279 /* Fire. */
2280 mFlame = (fire) ? getPointer<float>("flame" + s_ext, func) : nullptr;
2281 mFuel = (fire) ? getPointer<float>("fuel" + s_ext, func) : nullptr;
2282 mReact = (fire) ? getPointer<float>("react" + s_ext, func) : nullptr;
2283 mFuelIn = (fire) ? getPointer<float>("fuelIn" + s_ext, func) : nullptr;
2284 mReactIn = (fire) ? getPointer<float>("reactIn" + s_ext, func) : nullptr;
2285
2286 /* Colors. */
2287 mColorR = (colors) ? getPointer<float>("color_r" + s_ext, func) : nullptr;
2288 mColorG = (colors) ? getPointer<float>("color_g" + s_ext, func) : nullptr;
2289 mColorB = (colors) ? getPointer<float>("color_b" + s_ext, func) : nullptr;
2290 mColorRIn = (colors) ? getPointer<float>("color_r_in" + s_ext, func) : nullptr;
2291 mColorGIn = (colors) ? getPointer<float>("color_g_in" + s_ext, func) : nullptr;
2292 mColorBIn = (colors) ? getPointer<float>("color_b_in" + s_ext, func) : nullptr;
2293
2294 /* Noise. */
2295 mDensityHigh = (noise) ? getPointer<float>("density" + sn_ext, func) : nullptr;
2296 mTextureU = (noise) ? getPointer<float>("texture_u" + s_ext, func) : nullptr;
2297 mTextureV = (noise) ? getPointer<float>("texture_v" + s_ext, func) : nullptr;
2298 mTextureW = (noise) ? getPointer<float>("texture_w" + s_ext, func) : nullptr;
2299 mTextureU2 = (noise) ? getPointer<float>("texture_u2" + s_ext, func) : nullptr;
2300 mTextureV2 = (noise) ? getPointer<float>("texture_v2" + s_ext, func) : nullptr;
2301 mTextureW2 = (noise) ? getPointer<float>("texture_w2" + s_ext, func) : nullptr;
2302
2303 /* Fire with noise. */
2304 mFlameHigh = (noise && fire) ? getPointer<float>("flame" + sn_ext, func) : nullptr;
2305 mFuelHigh = (noise && fire) ? getPointer<float>("fuel" + sn_ext, func) : nullptr;
2306 mReactHigh = (noise && fire) ? getPointer<float>("react" + sn_ext, func) : nullptr;
2307
2308 /* Colors with noise. */
2309 mColorRHigh = (noise && colors) ? getPointer<float>("color_r" + sn_ext, func) : nullptr;
2310 mColorGHigh = (noise && colors) ? getPointer<float>("color_g" + sn_ext, func) : nullptr;
2311 mColorBHigh = (noise && colors) ? getPointer<float>("color_b" + sn_ext, func) : nullptr;
2312
2313 /* Liquid. */
2314 mPhi = (liquid) ? getPointer<float>("phi" + s_ext, func) : nullptr;
2315 mFlipParticleData = (liquid) ? getPointer<vector<pData>>("pp" + s_ext, func) : nullptr;
2316 mFlipParticleVelocity = (liquid) ? getPointer<vector<pVel>>("pVel" + pp_ext, func) : nullptr;
2317
2318 /* Mesh. */
2319 mMeshNodes = (mesh) ? getPointer<vector<Node>>("mesh" + sm_ext, funcNodes) : nullptr;
2320 mMeshTriangles = (mesh) ? getPointer<vector<Triangle>>("mesh" + sm_ext, funcTris) : nullptr;
2321
2322 /* Mesh velocities. */
2323 mMeshVelocities = (meshvel) ? getPointer<vector<pVel>>("mVel" + mesh_ext, func) : nullptr;
2324
2325 /* Secondary particles. */
2326 mParticleData = (parts) ? getPointer<vector<pData>>("ppSnd" + snd_ext, func) : nullptr;
2327 mParticleVelocity = (parts) ? getPointer<vector<pVel>>("pVelSnd" + pp_ext, func) : nullptr;
2328 mParticleLife = (parts) ? getPointer<vector<float>>("pLifeSnd" + pp_ext, func) : nullptr;
2329
2330 mFlipFromFile = false;
2331 mMeshFromFile = false;
2332 mParticlesFromFile = false;
2333 mSmokeFromFile = false;
2334 mNoiseFromFile = false;
2335}
2336
2338{
2339 string extension = FLUID_DOMAIN_EXTENSION_UNI;
2340 return BLI_exists(
2341 getFile(fmd, FLUID_DOMAIN_DIR_CONFIG, FLUID_NAME_CONFIG, extension, framenr).c_str());
2342}
2343
2344bool MANTA::hasData(FluidModifierData *fmd, int framenr)
2345{
2346 string extension = getCacheFileEnding(fmd->domain->cache_data_format);
2347 bool exists = BLI_exists(
2348 getFile(fmd, FLUID_DOMAIN_DIR_DATA, FLUID_NAME_DATA, extension, framenr).c_str());
2349
2350 /* Check single file naming. */
2351 if (!exists) {
2352 string filename = (mUsingSmoke) ? FLUID_NAME_DENSITY : FLUID_NAME_PP;
2353 exists = BLI_exists(getFile(fmd, FLUID_DOMAIN_DIR_DATA, filename, extension, framenr).c_str());
2354 }
2355 if (with_debug) {
2356 cout << "Fluid: Has Data: " << exists << endl;
2357 }
2358
2359 return exists;
2360}
2361
2362bool MANTA::hasNoise(FluidModifierData *fmd, int framenr)
2363{
2364 string extension = getCacheFileEnding(fmd->domain->cache_data_format);
2365 bool exists = BLI_exists(
2366 getFile(fmd, FLUID_DOMAIN_DIR_NOISE, FLUID_NAME_NOISE, extension, framenr).c_str());
2367
2368 /* Check single file naming. */
2369 if (!exists) {
2370 extension = getCacheFileEnding(fmd->domain->cache_data_format);
2371 exists = BLI_exists(
2372 getFile(fmd, FLUID_DOMAIN_DIR_NOISE, FLUID_NAME_DENSITY_NOISE, extension, framenr)
2373 .c_str());
2374 }
2375 /* Check single file naming with deprecated extension. */
2376 if (!exists) {
2377 extension = getCacheFileEnding(fmd->domain->cache_noise_format);
2378 exists = BLI_exists(
2379 getFile(fmd, FLUID_DOMAIN_DIR_NOISE, FLUID_NAME_DENSITY_NOISE, extension, framenr)
2380 .c_str());
2381 }
2382 if (with_debug) {
2383 cout << "Fluid: Has Noise: " << exists << endl;
2384 }
2385
2386 return exists;
2387}
2388
2389bool MANTA::hasMesh(FluidModifierData *fmd, int framenr)
2390{
2391 string extension = getCacheFileEnding(fmd->domain->cache_mesh_format);
2392 bool exists = BLI_exists(
2393 getFile(fmd, FLUID_DOMAIN_DIR_MESH, FLUID_NAME_MESH, extension, framenr).c_str());
2394
2395 /* Check old file naming. */
2396 if (!exists) {
2397 exists = BLI_exists(
2398 getFile(fmd, FLUID_DOMAIN_DIR_MESH, FLUID_NAME_LMESH, extension, framenr).c_str());
2399 }
2400 if (with_debug) {
2401 cout << "Fluid: Has Mesh: " << exists << endl;
2402 }
2403
2404 return exists;
2405}
2406
2408{
2409 string extension = getCacheFileEnding(fmd->domain->cache_data_format);
2410 bool exists = BLI_exists(
2411 getFile(fmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_NAME_PARTICLES, extension, framenr).c_str());
2412
2413 /* Check single file naming. */
2414 if (!exists) {
2415 extension = getCacheFileEnding(fmd->domain->cache_data_format);
2416 exists = BLI_exists(
2417 getFile(fmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_NAME_PP_PARTICLES, extension, framenr)
2418 .c_str());
2419 }
2420 /* Check single file naming with deprecated extension. */
2421 if (!exists) {
2423 exists = BLI_exists(
2424 getFile(fmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_NAME_PP_PARTICLES, extension, framenr)
2425 .c_str());
2426 }
2427 if (with_debug) {
2428 cout << "Fluid: Has Particles: " << exists << endl;
2429 }
2430
2431 return exists;
2432}
2433
2434bool MANTA::hasGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
2435{
2436 string subdirectory = (sourceDomain) ? FLUID_DOMAIN_DIR_DATA : FLUID_DOMAIN_DIR_GUIDE;
2437 string filename = (sourceDomain) ? FLUID_NAME_DATA : FLUID_NAME_GUIDING;
2438 string extension = getCacheFileEnding(fmd->domain->cache_data_format);
2439 bool exists = BLI_exists(getFile(fmd, subdirectory, filename, extension, framenr).c_str());
2440
2441 /* Check old file naming. */
2442 if (!exists) {
2443 filename = (sourceDomain) ? FLUID_NAME_VEL : FLUID_NAME_GUIDEVEL;
2444 exists = BLI_exists(getFile(fmd, subdirectory, filename, extension, framenr).c_str());
2445 }
2446
2447 if (with_debug) {
2448 cout << "Fluid: Has Guiding: " << exists << endl;
2449 }
2450
2451 return exists;
2452}
2453
2454string MANTA::getDirectory(FluidModifierData *fmd, string subdirectory)
2455{
2456 char directory[FILE_MAX];
2457 BLI_path_join(directory, sizeof(directory), fmd->domain->cache_directory, subdirectory.c_str());
2458 BLI_path_make_safe(directory);
2459 return directory;
2460}
2461
2462string MANTA::getFile(
2463 FluidModifierData *fmd, string subdirectory, string fname, string extension, int framenr)
2464{
2465 char targetFile[FILE_MAX];
2466 string path = getDirectory(fmd, subdirectory);
2467 string filename = fname + "_####" + extension;
2468 BLI_path_join(targetFile, sizeof(targetFile), path.c_str(), filename.c_str());
2469 BLI_path_frame(targetFile, sizeof(targetFile), framenr, 0);
2470 return targetFile;
2471}
2472
2473} // namespace blender
File and directory operations.
#define FILE_MAX
#define BLI_path_join(...)
#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_NAME_NOISE
#define FLUID_DOMAIN_DIR_DATA
#define FLUID_NAME_PHIPARTS_MESH
#define FLUID_NAME_DATA
#define FLUID_DOMAIN_DIR_PARTICLES
#define FLUID_NAME_PP
#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_VEL
#define FLUID_NAME_PP_PARTICLES
#define FLUID_NAME_KINETICENERGY_PARTICLES
#define FLUID_NAME_FORCE_Y
#define FLUID_NAME_PINDEX
#define FLUID_NAME_PVEL
#define FLUID_NAME_FUELIN
#define FLUID_NAME_PARTICLES
#define FLUID_DOMAIN_EXTENSION_BINOBJ
#define FLUID_NAME_FORCE_Z
#define FLUID_NAME_UV0
#define FLUID_DOMAIN_SMOKE_SCRIPT
#define FLUID_NAME_HEAT
#define FLUID_NAME_GUIDEVEL_Z
#define FLUID_NAME_PVEL_PARTICLES
#define FLUID_NAME_LMESH
#define FLUID_NAME_GUIDEVEL_X
#define FLUID_NAME_TEXTURE_U
#define FLUID_DOMAIN_DIR_MESH
#define FLUID_DOMAIN_DIR_GUIDE
#define FLUID_NAME_PHIIN
#define FLUID_DOMAIN_DIR_SCRIPT
#define FLUID_NAME_PARTSVEL_PARTICLES
#define FLUID_NAME_TMPIN_NOISE
#define FLUID_NAME_PHI
#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
#define FLUID_NAME_VELOCITYZ
#define FLUID_NAME_GUIDEVELC
#define FLUID_NAME_VELOCITYTMP
#define FLUID_NAME_VELOCITYY
#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_NAME_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
#define FLUID_NAME_TEXTURE_U2
#define FLUID_NAME_PHIOUT
#define FLUID_NAME_TEXTURE_V2
#define FLUID_NAME_EMISSIONIN_NOISE
#define FLUID_NAME_GUIDEVEL_Y
#define FLUID_NAME_TEXTURE_W2
#define FLUID_NAME_FUEL
#define FLUID_NAME_DENSITY_NOISE
#define FLUID_NAME_VELT
#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
#define FLUID_NAME_OBVELC
#define FLUID_NAME_COLORGIN
#define FLUID_NAME_VELOCITY
#define FLUID_NAME_PHIOBSIN
#define FLUID_NAME_PHI_PARTICLES
#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_REACT
#define FLUID_NAME_VELOCITY_GUIDE
#define FLUID_DOMAIN_EXTENSION_UNI
#define FLUID_NAME_TEMPERATUREIN
#define FLUID_NAME_INVEL_X
#define FLUID_NAME_GPI
#define FLUID_NAME_FLAME
#define FLUID_NAME_FLAGS
#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_OBVEL
#define FLUID_NAME_HEATIN
#define FLUID_NAME_UV1
#define FLUID_NAME_FLAGS_PARTICLES
#define FLUID_NAME_TEMPERATURE
#define FLUID_NAME_PHI_MESH
#define FLUID_NAME_FRACTIONS
#define FLUID_NAME_REACT_NOISE
#define FLUID_NAME_TEXTURE_V
#define FLUID_NAME_PARTS
#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
#define UNUSED_VARS(...)
#define BLI_assert(a)
#define str(s)
const std::string fluid_with_outflow
const std::string fluid_variables_noise
const std::string fluid_with_fractions
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 manta_import
const std::string manta_debuglevel
const std::string fluid_with_sndparts
const std::string fluid_variables
const std::string fluid_solver_noise
const std::string fluid_variables_viscosity
const std::string fluid_time_stepping
const std::string fluid_solver
const std::string fluid_solver_guiding
const std::string fluid_variables_guiding
const std::string fluid_variables_mesh
const std::string fluid_with_obstacle
#define pow
const std::string liquid_alloc_viscosity
const std::string liquid_variables
const std::string liquid_variables_particles
const std::string liquid_alloc_particles
const std::string liquid_alloc
const std::string liquid_alloc_curvature
const std::string liquid_alloc_mesh
const std::string liquid_init_phi
#define T
std::string filename(const std::string_view &str, size_t pos)
const char * to_string(ShaderStage stage)
Definition mtl_shader.mm:52
BLI_NOINLINE void fill(T *__restrict data, const T &value, const IndexMask &mask)
BMesh Iterators.
static T * getPointer(string pyObjectName, string pyFunctionName)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ VDB_PRECISION_HALF_FLOAT
@ VDB_PRECISION_MINI_FLOAT
@ VDB_PRECISION_FULL_FLOAT
static PyObject * manta_main_module
static PyObject * manta_python_main_module_ensure()
static string getBooleanString(int value)
@ FLUID_DOMAIN_BORDER_BACK
@ FLUID_DOMAIN_BORDER_LEFT
@ FLUID_DOMAIN_BORDER_TOP
@ FLUID_DOMAIN_BORDER_RIGHT
@ FLUID_DOMAIN_BORDER_FRONT
@ FLUID_DOMAIN_BORDER_BOTTOM
@ VDB_COMPRESSION_BLOSC
bool BLI_path_make_safe(char *path) ATTR_NONNULL(1)
bool BLI_dir_create_recursive(const char *dirname) ATTR_NONNULL()
Definition fileops_c.cc:416
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
@ FLUID_DOMAIN_MESH_IMPROVED
bool BLI_path_frame(char *path, size_t path_maxncpy, int frame, int digits) ATTR_NONNULL(1)
static void manta_python_main_module_clear()
static void manta_python_main_module_backup(PyObject **r_main_mod)
@ FLUID_DOMAIN_USE_ADAPTIVE_TIME
@ FLUID_DOMAIN_USE_DISSOLVE_LOG
@ FLUID_DOMAIN_USE_DISSOLVE
@ FLUID_DOMAIN_USE_DIFFUSION
@ FLUID_DOMAIN_DELETE_IN_OBSTACLE
@ FLUID_DOMAIN_USE_RESUMABLE_CACHE
@ FLUID_DOMAIN_USE_GUIDE
@ FLUID_DOMAIN_USE_FRACTIONS
@ FLUID_DOMAIN_USE_VISCOSITY
@ FLUID_DOMAIN_USE_SPEED_VECTORS
@ FLUID_DOMAIN_USE_NOISE
@ FLUID_DOMAIN_USE_MESH
@ FLUID_DOMAIN_ACTIVE_OUTFLOW
@ FLUID_DOMAIN_ACTIVE_COLORS
@ FLUID_DOMAIN_ACTIVE_FIRE
@ FLUID_DOMAIN_ACTIVE_HEAT
@ FLUID_DOMAIN_ACTIVE_INVEL
@ FLUID_DOMAIN_ACTIVE_GUIDE
@ FLUID_DOMAIN_ACTIVE_OBSTACLE
static string getCacheFileEnding(char cache_format)
static PyObject * callPythonFunction(string varName, string functionName, bool isAttribute=false)
@ SNDPARTICLE_BOUNDARY_PUSHOUT
@ SNDPARTICLE_BOUNDARY_DELETE
@ FLUID_DOMAIN_FILE_RAW
@ FLUID_DOMAIN_FILE_OBJECT
@ FLUID_DOMAIN_FILE_OPENVDB
@ FLUID_DOMAIN_FILE_BIN_OBJECT
@ FLUID_DOMAIN_FILE_UNI
static string escapePath(string const &s)
static double pyObjectToDouble(PyObject *inputObject)
static PyObject * manta_python_main_module_create(const char *filename)
static void manta_python_main_module_restore(PyObject *main_mod)
void * BLI_gzopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static void * pyObjectToPointer(PyObject *inputObject)
static void manta_python_main_module_activate(PyObject *mod_main)
static long pyObjectToLong(PyObject *inputObject)
@ FLUID_DOMAIN_METHOD_APIC
@ FLUID_DOMAIN_TYPE_LIQUID
@ FLUID_DOMAIN_TYPE_GAS
@ FLUID_DOMAIN_PARTICLE_TRACER
@ FLUID_DOMAIN_PARTICLE_FOAM
@ FLUID_DOMAIN_PARTICLE_SPRAY
@ FLUID_DOMAIN_PARTICLE_BUBBLE
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_with_colors
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_alloc_colors_noise
const std::string smoke_init_colors_noise
const std::string smoke_init_colors
const std::string smoke_wavelet_noise
const std::string smoke_alloc_fire
const std::string smoke_alloc
eFluidDomain_FileFormat cache_noise_format
eFluidDomain_FileFormat cache_mesh_format
eFluidDomain_BorderFlags border_collisions
eFluidDomain_OpenVDBCompression openvdb_compression
eFluidDomain_SimMethod simulation_method
eFluidDomain_OpenVDBDepth openvdb_data_depth
eFluidDomain_FileFormat cache_data_format
eFluidDomain_FileFormat cache_particle_format
eFluidDomain_ParticleTypes particle_type
eFluidDomain_ActiveFields active_fields
eFluidDomain_SndParticleBoundary sndparticle_boundary
eFluidDomain_MeshGenerator mesh_generator
struct FluidDomainSettings * domain
bool exportLiquidScript(struct FluidModifierData *fmd)
bool initColors(struct FluidModifierData *fmd=nullptr)
bool initCurvature(FluidModifierData *fmd=nullptr)
bool hasGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
bool initLiquidMesh(FluidModifierData *fmd=nullptr)
bool hasConfig(FluidModifierData *fmd, int framenr)
bool initInVelocity(FluidModifierData *fmd=nullptr)
bool initFireHigh(struct FluidModifierData *fmd=nullptr)
bool initHeat(struct FluidModifierData *fmd=nullptr)
bool initLiquidSndParts(FluidModifierData *fmd=nullptr)
bool initFire(struct FluidModifierData *fmd=nullptr)
bool readMesh(FluidModifierData *fmd, int framenr)
bool initLiquidViscosity(FluidModifierData *fmd=nullptr)
bool initSndParts(FluidModifierData *fmd=nullptr)
bool bakeGuiding(FluidModifierData *fmd, int framenr)
bool exportSmokeScript(struct FluidModifierData *fmd)
bool readParticles(FluidModifierData *fmd, int framenr, bool resumable)
bool hasParticles(FluidModifierData *fmd, int framenr)
bool bakeNoise(FluidModifierData *fmd, int framenr)
bool writeConfiguration(FluidModifierData *fmd, int framenr)
bool readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
bool bakeParticles(FluidModifierData *fmd, int framenr)
bool readData(FluidModifierData *fmd, int framenr, bool resumable)
static int with_debug
Definition MANTA_main.h:407
bool initGuiding(FluidModifierData *fmd=nullptr)
MANTA(int *res, struct FluidModifierData *fmd)
bool initLiquid(FluidModifierData *fmd=nullptr)
bool bakeData(FluidModifierData *fmd, int framenr)
bool needsRealloc(FluidModifierData *fmd)
bool readNoise(FluidModifierData *fmd, int framenr, bool resumable)
bool bakeMesh(FluidModifierData *fmd, int framenr)
static atomic< int > solverID
Definition MANTA_main.h:406
bool initFractions(FluidModifierData *fmd=nullptr)
bool initObstacle(FluidModifierData *fmd=nullptr)
bool hasData(FluidModifierData *fmd, int framenr)
bool writeNoise(FluidModifierData *fmd, int framenr)
bool hasNoise(FluidModifierData *fmd, int framenr)
bool updateVariables(FluidModifierData *fmd)
virtual ~MANTA()
bool readConfiguration(FluidModifierData *fmd, int framenr)
bool hasMesh(FluidModifierData *fmd, int framenr)
bool initColorsHigh(struct FluidModifierData *fmd=nullptr)
void updatePointers(FluidModifierData *fmd, bool flush=false)
bool writeData(FluidModifierData *fmd, int framenr)
bool initOutflow(FluidModifierData *fmd=nullptr)