Commit: d77b67826547a4fedfb517601df110dde568229d
Author: Sebastián Barschkis
Date:   Wed Dec 16 00:15:49 2015 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rBd77b67826547a4fedfb517601df110dde568229d

buoyancy improvements

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

M       intern/smoke/intern/FLUID_3D.cpp
M       intern/smoke/intern/scenarios/smoke.h
M       source/blender/blenkernel/intern/smoke.c
M       source/blender/python/manta_pp/plugin/extforces.cpp

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

diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index 113c89f..b86d6fc 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -757,6 +757,8 @@ FLUID_3D::~FLUID_3D()
 //////////////////////////////////////////////////////////////////////
 void FLUID_3D::step(float dt, float gravity[3])
 {
+       clock_t start = clock();
+
        // Blender computes heat buoyancy, not yet impl. in Manta
        //manta_write_effectors(this);
        Manta_API::updatePointers(this);
@@ -767,16 +769,22 @@ void FLUID_3D::step(float dt, float gravity[3])
        PyGILState_Release(gilstate);
        Manta_API::updatePointers(this);
 
+#if 0
        for (int i = 0; i < _totalCells; i++)
        {
                _xForce[i] = _yForce[i] = _zForce[i] = 0.0f;
        }
-
+#endif
+       clock_t end = clock();
+       float seconds = (float)(end - start) / CLOCKS_PER_SEC;
+       printf("TIME FOR STEP: %f \n", seconds);
 }
 
 void FLUID_3D::processBurn(float *fuel, float *smoke, float *react, float 
*heat,
                                                   float *r, float *g, float 
*b, int total_cells, float dt)
 {
+       clock_t start = clock();
+
        // Need to make sure that color grids are initialized as they are 
needed in processBurn
        initColors(0.0f, 0.0f, 0.0f);
 
@@ -785,15 +793,25 @@ void FLUID_3D::processBurn(float *fuel, float *smoke, 
float *react, float *heat,
        PyRun_SimpleString(py_string_0.c_str());
        PyGILState_Release(gilstate);
        Manta_API::updatePointers(this);
+       
+       clock_t end = clock();
+       float seconds = (float)(end - start) / CLOCKS_PER_SEC;
+       printf("TIME FOR PROCESS_BURN: %f \n", seconds);
 }
 
 void FLUID_3D::updateFlame(float *react, float *flame, int total_cells)
 {
+       clock_t start = clock();
+
        PyGILState_STATE gilstate = PyGILState_Ensure();
        std::string py_string_0 = string("update_flame()");
        PyRun_SimpleString(py_string_0.c_str());
        PyGILState_Release(gilstate);
        Manta_API::updatePointers(this);
+       
+       clock_t end = clock();
+       float seconds = (float)(end - start) / CLOCKS_PER_SEC;
+       printf("TIME FOR UPDATE_FLAME: %f \n", seconds);
 }
 
 #endif /*WITH_MANTA*/
diff --git a/intern/smoke/intern/scenarios/smoke.h 
b/intern/smoke/intern/scenarios/smoke.h
index 59836d9..272412f 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -178,16 +178,6 @@ def step_low():\n\
   if solver_dim == 2:\n\
     density.add(inflow_grid)\n\
   \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\
-    addBuoyancy2(flags=flags, grid=density, vel=vel, gravity=gravity, 
coefficient=(-0.001))\n\
-    addBuoyancy2(flags=flags, grid=heat_low, vel=vel, gravity=gravity, 
coefficient=$BETA$*(-10))\n\
-  else:\n\
-    print ('Adding buoyancy')\n\
-    gravity=vec3(0,0,-0.01 * $ALPHA$) if solver_dim==3 else vec3(0,-0.01* 
$ALPHA$,0)\n\
-    addBuoyancy(density=density, vel=vel, gravity=gravity, flags=flags)\n\
-  \n\
   if manta_using_colors:\n\
     print ('Advecting colors')\n\
     advectSemiLagrange(flags=flags, vel=vel, grid=color_r_low, 
order=$ADVECT_ORDER$)\n\
@@ -208,6 +198,16 @@ def step_low():\n\
   print ('Walls')\n\
   setWallBcs(flags=flags, vel=vel)\n\
   \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\
+    addBuoyancy2(flags=flags, grid=density, vel=vel, gravity=gravity, 
coefficient=$ALPHA$)\n\
+    addBuoyancy2(flags=flags, grid=heat_low, vel=vel, gravity=gravity, 
coefficient=$BETA$*10)\n\
+  else:\n\
+    print ('Adding buoyancy')\n\
+    gravity=vec3(0,0,-0.01 * $ALPHA$) if solver_dim==3 else vec3(0,-0.01* 
$ALPHA$,0)\n\
+    addBuoyancy(density=density, vel=vel, gravity=gravity, flags=flags)\n\
+  \n\
   print('Vorticity')\n\
   if $VORTICITY$ > 0.01:\n\
     vorticityConfinement( vel=vel, flags=flags, strength=$VORTICITY$ )\n\
diff --git a/source/blender/blenkernel/intern/smoke.c 
b/source/blender/blenkernel/intern/smoke.c
index 51945a5..b2d9d9f 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -555,7 +555,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
                        smd->domain->alpha = -0.001;
                        smd->domain->beta = 0.1;
                        smd->domain->time_scale = 1.0;
-                       smd->domain->vorticity = 0.01;
+                       smd->domain->vorticity = 0.2;
                        smd->domain->border_collisions = SM_BORDER_OPEN; // 
open domain
                        smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG;
                        smd->domain->highres_sampling = SM_HRES_FULLSAMPLE;
diff --git a/source/blender/python/manta_pp/plugin/extforces.cpp 
b/source/blender/python/manta_pp/plugin/extforces.cpp
index 2acff64..58456b7 100644
--- a/source/blender/python/manta_pp/plugin/extforces.cpp
+++ b/source/blender/python/manta_pp/plugin/extforces.cpp
@@ -86,9 +86,9 @@ void addBuoyancy(FlagGrid& flags, Grid<Real>& density, 
MACGrid& vel, Vec3 gravit
 //! add Buoyancy force based on coeffiecient
  struct KnAddBuoyancy2 : public KernelBase { KnAddBuoyancy2(FlagGrid& flags, 
Grid<Real>& grid, MACGrid& vel, Vec3 strength, Real coefficient) :  
KernelBase(&flags,1) 
,flags(flags),grid(grid),vel(vel),strength(strength),coefficient(coefficient)   
{ run(); }  inline void op(int i, int j, int k, FlagGrid& flags, Grid<Real>& 
grid, MACGrid& vel, Vec3 strength, Real coefficient )  {
        if (!flags.isFluid(i,j,k)) return;
-       vel(i,j,k).x += (strength.x) * coefficient * grid(i,j,k);
-       vel(i,j,k).y += (strength.y) * coefficient * grid(i,j,k);
-       vel(i,j,k).z += (strength.z) * coefficient * grid(i,j,k);
+       vel(i,j,k).x -= (strength.x) * coefficient * grid(i,j,k);
+       vel(i,j,k).y -= (strength.y) * coefficient * grid(i,j,k);
+       vel(i,j,k).z -= (strength.z) * coefficient * grid(i,j,k);
 }   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline 
Grid<Real>& getArg1() { return grid; } typedef Grid<Real> type1;inline MACGrid& 
getArg2() { return vel; } typedef MACGrid type2;inline Vec3& getArg3() { return 
strength; } typedef Vec3 type3;inline Real& getArg4() { return coefficient; } 
typedef Real type4; void run() {  const int _maxX = maxX; const int _maxY = 
maxY; for (int k=minZ; k< maxZ; k++) for (int j=1; j< _maxY; j++) for (int i=1; 
i< _maxX; i++) op(i [...]
 
 //! add Buoyancy force based on coeffiecient

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

Reply via email to