Commit: 6ec6e8156393d1bbb1512a6dded7f02763baca0b
Author: Sebastián Barschkis
Date:   Sat Oct 24 13:06:40 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB6ec6e8156393d1bbb1512a6dded7f02763baca0b

fixed issue with bound conditions

===================================================================

M       intern/smoke/intern/FLUID_3D.cpp
M       intern/smoke/intern/MANTA.cpp
M       intern/smoke/intern/MANTA.h
M       intern/smoke/intern/scenarios/smoke.h
M       source/blender/blenkernel/intern/pointcache.c
M       source/blender/python/manta_pp/pwrapper/pymain.cpp

===================================================================

diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index 6b5ca9e..113c89f 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -705,6 +705,9 @@ void FLUID_3D::initFire()
 
 FLUID_3D::~FLUID_3D()
 {
+       cout << "~FLUID_3D" << endl;
+// TODO: Get rid of all the initializations from FLUID_3D Manta constructor
+#if 0
        if (_xVelocity) delete[] _xVelocity;
        if (_yVelocity) delete[] _yVelocity;
        if (_zVelocity) delete[] _zVelocity;
@@ -744,7 +747,8 @@ FLUID_3D::~FLUID_3D()
        if (_color_b) delete[] _color_b;
        if (_color_bOld) delete[] _color_bOld;
        if (_color_bTemp) delete[] _color_bTemp;
-       
+#endif
+
     // printf("deleted fluid\n");
 }
 
diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index 0b47622..0e065cc 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -478,10 +478,11 @@ std::string Manta_API::getRealValue( const std::string& 
varName, SmokeModifierDa
                char parent_dir[1024];
                BLI_split_dir_part(smd->domain->_manta_filepath, parent_dir, 
sizeof(parent_dir));
                ss << parent_dir;
-       } else if (varName == "VORTICITY"){
+       } else if (varName == "VORTICITY") {
                ss << smd->domain->vorticity / 
smd->domain->fluid->_constantScaling;
-       } else if (varName == "BOUNDCONDITIONS"){
-               if(smd->domain->border_collisions == SM_BORDER_OPEN) ss << 
"xXyY";
+       } else if (varName == "BOUNDCONDITIONS") {
+               // OLD SETUP. WHY LIKE THAT??
+               /*if(smd->domain->border_collisions == SM_BORDER_OPEN) ss << 
"xXyY";
                else if (smd->domain->border_collisions == SM_BORDER_VERTICAL) 
ss << "xXyY";
                else if (smd->domain->border_collisions == SM_BORDER_CLOSED) ss 
<< "xXyY";
                
@@ -489,8 +490,19 @@ std::string Manta_API::getRealValue( const std::string& 
varName, SmokeModifierDa
                        if(smd->domain->border_collisions == SM_BORDER_OPEN) ss 
<< "z";
                        else if (smd->domain->border_collisions == 
SM_BORDER_VERTICAL) ss << "z";
                        else if (smd->domain->border_collisions == 
SM_BORDER_CLOSED) ss << "zZ";
+               }*/
+               if(smd->domain->border_collisions == SM_BORDER_OPEN) ss << 
"xXyY";
+               else if (smd->domain->border_collisions == SM_BORDER_VERTICAL) 
ss << "zZ";
+               else if (smd->domain->border_collisions == SM_BORDER_CLOSED) ss 
<< "";
+               
+               if (smd->domain->manta_solver_res == 3) {
+                       if(smd->domain->border_collisions == SM_BORDER_OPEN) ss 
<< "zZ";
+                       else if (smd->domain->border_collisions == 
SM_BORDER_VERTICAL) ss << "";
+                       else if (smd->domain->border_collisions == 
SM_BORDER_CLOSED) ss << "";
                }
        }
+       else if (varName == "DO_OPEN")
+               ss << ((smd->domain->border_collisions == SM_BORDER_CLOSED) ? 
"False" : "True");
        else if (varName == "GRAVITY")
                ss << "vec3(0,0,-0.981)";
        else if (varName == "ABS_FLOW")
diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h
index ab54397..d9c0413 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.h
@@ -75,7 +75,6 @@ public:
        
        unsigned char*  _obstacles; /* only used (useful) for static obstacles 
like domain */
        void step(float dt, float gravity[3]);
-//     void runMantaScript(const string&, vector<string>& args);//defined in 
manta_pp/pwrapper/pymain.cpp
        
        void indent_ss(stringstream& ss, int indent);
        
diff --git a/intern/smoke/intern/scenarios/smoke.h 
b/intern/smoke/intern/scenarios/smoke.h
index 261a07f..59836d9 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -12,6 +12,7 @@ import os, shutil, math, sys\n\
 res = $RES$\n\
 solver_dim = $SOLVER_DIM$\n\
 gs = vec3($RESX$,$RESY$,$RESZ$)\n\
+doOpen = $DO_OPEN$\n\
 boundConditions = '$BOUNDCONDITIONS$'\n\
 if solver_dim == 2:\n\
   gs.z = 1\n\
@@ -180,9 +181,7 @@ def step_low():\n\
   if manta_using_heat:\n\
     print ('Adding heat buoyancy')\n\
     gravity=vec3(0,0,-0.0981) if solver_dim==3 else vec3(0,-0.0981,0)\n\
-    print ('Here 1')\n\
     addBuoyancy2(flags=flags, grid=density, vel=vel, gravity=gravity, 
coefficient=(-0.001))\n\
-    print ('Here 2')\n\
     addBuoyancy2(flags=flags, grid=heat_low, vel=vel, gravity=gravity, 
coefficient=$BETA$*(-10))\n\
   else:\n\
     print ('Adding buoyancy')\n\
@@ -204,7 +203,7 @@ def step_low():\n\
   advectSemiLagrange(flags=flags, vel=vel, grid=density, 
order=$ADVECT_ORDER$)\n\
   \n\
   print('Advecting velocity')\n\
-  advectSemiLagrange(flags=flags, vel=vel, grid=vel, order=$ADVECT_ORDER$)\n\
+  advectSemiLagrange(flags=flags, vel=vel, grid=vel, order=$ADVECT_ORDER$, 
openBounds=doOpen)\n\
   \n\
   print ('Walls')\n\
   setWallBcs(flags=flags, vel=vel)\n\
diff --git a/source/blender/blenkernel/intern/pointcache.c 
b/source/blender/blenkernel/intern/pointcache.c
index f9463ec..9054ecc 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -574,17 +574,6 @@ static void ptcache_smoke_error(void *smoke_v, const char 
*message)
 
 #define SMOKE_CACHE_VERSION "1.04"
 
-static void writeArrToFile(char* name, float* arr, int numElements)
-{      
-       FILE *filePtr;
-       filePtr = fopen(name,"w");
-       int i=0;
-       for (i = 0; i < numElements; i++) {
-               fprintf(filePtr, "%f \n", arr[i]);
-       }
-       fclose(filePtr);
-}
-
 static int  ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
 {      
        SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
@@ -598,9 +587,10 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
        ptcache_file_write(pf, &sds->active_fields, 1, sizeof(int));
        ptcache_file_write(pf, &sds->res, 3, sizeof(int));
        ptcache_file_write(pf, &sds->dx, 1, sizeof(float));
+       
        if (sds->fluid) {
                size_t res = sds->res[0]*sds->res[1]*sds->res[2];
-               float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, 
*manta_inflow, *vx, *vy, *vz, *r, *g, *b;
+               float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, 
*vx, *vy, *vz, *r, *g, *b;
                unsigned char *obstacles;
                unsigned int in_len = sizeof(float)*(unsigned int)res;
                unsigned char *out = (unsigned char 
*)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
@@ -608,29 +598,13 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
                int mode=1;             // light
                if (sds->cache_comp == SM_CACHE_HEAVY) mode=2;  // heavy
 
-               #ifndef WITH_MANTA
-                       smoke_export(sds->fluid, &dt, &dx, &dens, &react, 
&flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
-               #else
-                       smoke_export(sds->fluid, &dt, &dx, &dens, &react, 
&flame, &fuel, &heat, &manta_inflow, &vx, &vy, &vz, &r, &g, &b, &obstacles);
-               #endif
+               smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, 
&fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
 
                ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, 
in_len, out, mode);
-               
-               /*      writeArrToFile("sh.txt", sds->shadow, res);
-               */
                ptcache_file_compressed_write(pf, (unsigned char *)dens, 
in_len, out, mode);
-
-               /*      writeArrToFile("dens.txt", dens, res);
-*/
-               #ifdef WITH_MANTA
-                       ptcache_file_compressed_write(pf, (unsigned char 
*)manta_inflow, in_len, out, mode);
-               #endif
                if (fluid_fields & SM_ACTIVE_HEAT) {
                        ptcache_file_compressed_write(pf, (unsigned char 
*)heat, in_len, out, mode);
-                       
-                       #ifndef WITH_MANTA
-                               ptcache_file_compressed_write(pf, (unsigned 
char *)heatold, in_len, out, mode);
-                       #endif
+                       ptcache_file_compressed_write(pf, (unsigned char 
*)heatold, in_len, out, mode);
                }
                if (fluid_fields & SM_ACTIVE_FIRE) {
                        ptcache_file_compressed_write(pf, (unsigned char 
*)flame, in_len, out, mode);
@@ -643,17 +617,8 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
                        ptcache_file_compressed_write(pf, (unsigned char *)b, 
in_len, out, mode);
                }
                ptcache_file_compressed_write(pf, (unsigned char *)vx, in_len, 
out, mode);
-
-/*                     writeArrToFile("vx.txt", vx, res);
-*/
                ptcache_file_compressed_write(pf, (unsigned char *)vy, in_len, 
out, mode);
-               
-/*                     writeArrToFile("vy.txt", vx, res);
-*/
                ptcache_file_compressed_write(pf, (unsigned char *)vz, in_len, 
out, mode);
-
-/*                     writeArrToFile("vz.txt", vx, res);
-*/             
                ptcache_file_compressed_write(pf, (unsigned char *)obstacles, 
(unsigned int)res, out, mode);
                ptcache_file_write(pf, &dt, 1, sizeof(float));
                ptcache_file_write(pf, &dx, 1, sizeof(float));
@@ -727,7 +692,7 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void 
*smoke_v)
        
        if (sds->fluid) {
                size_t res = sds->res[0]*sds->res[1]*sds->res[2];
-               float dt, dx, *dens, *heat, *heatold, *manta_inflow, *vx, *vy, 
*vz;
+               float dt, dx, *dens, *heat, *heatold, *vx, *vy, *vz;
                unsigned char *obstacles;
                unsigned int out_len = (unsigned int)res * sizeof(float);
                float *tmp_array = MEM_callocN(out_len, "Smoke old cache tmp");
@@ -739,24 +704,16 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void 
*smoke_v)
                sds->active_color[1] = 0.7f;
                sds->active_color[2] = 0.7f;
                
-               #ifndef WITH_MANTA
-                       smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, 
NULL, &heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles);
-               #else
-                       smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, 
NULL, &heat, &manta_inflow, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles);
-               #endif
+               smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, NULL, 
&heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles);
 
                ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, 
out_len);
                ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len);
                ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, 
out_len);
 
-               #ifdef WITH_MANTA
-                       ptcache_file_compressed_read(pf, (unsigned 
char*)manta_inflow, out_len);
-               #endif
-               if (fluid_fields & SM_ACTIVE_HEAT) {
+               if (fluid_fields & SM_ACTIVE_HEAT)
+               {
                        ptcache_file_compressed_read(pf, (unsigned char*)heat, 
out_len);
-                       #ifndef WITH_MANTA
-                               ptcache_file_compressed_read(pf, (unsigned 
char*)heatold, out_len);
-                       #endif
+                       ptcache_file_compressed_read(pf, (unsigned 
char*)heatold, out_len);
                }
                else
                {
@@ -860,29 +817,17 @@ static int ptcache_smoke_read(PTCacheFile *pf, void 
*smoke_v)
        
        if (sds->fluid) {
                size_t res = sds->res[0]*sds->res[1]*sds->res[2];
-               float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, 
*manta_inflow, *vx, *vy, *vz, *r, *g, *b;
+               float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, 
*vx, *vy, *

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to