Commit: 519a9e04a46c2c08290dcd2cc1407ecfaca5d30b
Author: Sebastián Barschkis
Date:   Fri Sep 22 14:37:39 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB519a9e04a46c2c08290dcd2cc1407ecfaca5d30b

general cleanup

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

M       intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
M       intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
M       intern/mantaflow/intern/manta_pp/omp/registration.cpp
M       intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
M       intern/mantaflow/intern/manta_pp/tbb/plugin/flip.cpp
M       intern/mantaflow/intern/manta_pp/tbb/registration.cpp
M       intern/mantaflow/intern/strings/liquid_script.h
M       source/blender/blenkernel/intern/smoke.c

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

diff --git a/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp 
b/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
index b2e6c62a111..02e5f3a0904 100644
--- a/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
@@ -92,61 +92,67 @@ void addGridToPartsVec3( Grid<Vec3>& source , 
BasicParticleSystem& parts , Parti
        knAddFromGrid<Vec3>(parts, source, target);
 } static PyObject* _W_1 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) 
{ try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = 
_args.obtainParent(); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); 
pbPreparePlugin(parent, "addGridToPartsVec3" , !noTiming ); PyObject *_retval = 
0; { ArgLocker _lock; Grid<Vec3>& source = *_args.getPtr<Grid<Vec3> 
>("source",0,&_lock); BasicParticleSystem& parts = 
*_args.getPtr<BasicParticleSystem >("parts",1,&_lock); ParticleDataImpl<Vec3 
[...]
        
-//! add Forces between fl/fl and fl/em cells (interpolate cell centered forces 
to MAC grid)
- struct KnAddForceField : public KernelBase { KnAddForceField(FlagGrid& flags, 
MACGrid& vel, Grid<Vec3>& force) :  KernelBase(&flags,1) 
,flags(flags),vel(vel),force(force)   { runMessage(); run(); }  inline void 
op(int i, int j, int k, FlagGrid& flags, MACGrid& vel, Grid<Vec3>& force )  {
+//! add constant force between fl/fl and fl/em cells
+ struct KnApplyForceField : public KernelBase { KnApplyForceField(FlagGrid& 
flags, MACGrid& vel, Grid<Vec3>& force, Grid<Real>* include, bool additive, 
bool isMAC) :  KernelBase(&flags,1) 
,flags(flags),vel(vel),force(force),include(include),additive(additive),isMAC(isMAC)
   { runMessage(); run(); }  inline void op(int i, int j, int k, FlagGrid& 
flags, MACGrid& vel, Grid<Vec3>& force, Grid<Real>* include, bool additive, 
bool isMAC )  {
        bool curFluid = flags.isFluid(i,j,k);
        bool curEmpty = flags.isEmpty(i,j,k);
        if (!curFluid && !curEmpty) return;
+       if (include && ((*include)(i,j,k) > 0.)) return;
+       
+       Real forceX = (isMAC) ? force(i,j,k).x : 0.5*(force(i-1,j,k).x + 
force(i,j,k).x);
+       Real forceY = (isMAC) ? force(i,j,k).y : 0.5*(force(i,j-1,k).y + 
force(i,j,k).y);
+       Real forceZ = (isMAC) ? force(i,j,k).z : 0.5*(force(i,j,k-1).z + 
force(i,j,k).z);
        
        if (flags.isFluid(i-1,j,k) || (curFluid && flags.isEmpty(i-1,j,k))) 
-               vel(i,j,k).x += 0.5*(force(i-1,j,k).x + force(i,j,k).x);
+               vel(i,j,k).x = (additive) ? vel(i,j,k).x+forceX : forceX;
        if (flags.isFluid(i,j-1,k) || (curFluid && flags.isEmpty(i,j-1,k))) 
-               vel(i,j,k).y += 0.5*(force(i,j-1,k).y + force(i,j,k).y);
+               vel(i,j,k).y = (additive) ? vel(i,j,k).y+forceY : forceY;
        if (vel.is3D() && (flags.isFluid(i,j,k-1) || (curFluid && 
flags.isEmpty(i,j,k-1))))
-               vel(i,j,k).z += 0.5*(force(i,j,k-1).z + force(i,j,k).z);
-}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline 
MACGrid& getArg1() { return vel; } typedef MACGrid type1;inline Grid<Vec3>& 
getArg2() { return force; } typedef Grid<Vec3> type2; void runMessage() { 
debMsg("Executing kernel KnAddForceField ", 3); debMsg("Kernel range" <<  " x 
"<<  maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 4); }; 
void run() {  const int _maxX = maxX; const int _maxY = maxY; if (maxZ > 1) { 
+               vel(i,j,k).z = (additive) ? vel(i,j,k).z+forceZ : forceZ;
+}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline 
MACGrid& getArg1() { return vel; } typedef MACGrid type1;inline Grid<Vec3>& 
getArg2() { return force; } typedef Grid<Vec3> type2;inline Grid<Real>* 
getArg3() { return include; } typedef Grid<Real> type3;inline bool& getArg4() { 
return additive; } typedef bool type4;inline bool& getArg5() { return isMAC; } 
typedef bool type5; void runMessage() { debMsg("Executing kernel 
KnApplyForceField ", 3); debMsg("Kernel r [...]
 #pragma omp parallel 
  {  
 #pragma omp for  
-  for (int k=minZ; k < maxZ; k++) for (int j=1; j < _maxY; j++) for (int i=1; 
i < _maxX; i++) op(i,j,k,flags,vel,force);  } } else { const int k=0; 
+  for (int k=minZ; k < maxZ; k++) for (int j=1; j < _maxY; j++) for (int i=1; 
i < _maxX; i++) op(i,j,k,flags,vel,force,include,additive,isMAC);  } } else { 
const int k=0; 
 #pragma omp parallel 
  {  
 #pragma omp for  
-  for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) 
op(i,j,k,flags,vel,force);  } }  } FlagGrid& flags; MACGrid& vel; Grid<Vec3>& 
force;   };
+  for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) 
op(i,j,k,flags,vel,force,include,additive,isMAC);  } }  } FlagGrid& flags; 
MACGrid& vel; Grid<Vec3>& force; Grid<Real>* include; bool additive; bool 
isMAC;   };
 #line 66 "plugin/extforces.cpp"
 
 
 
 //! add constant force between fl/fl and fl/em cells
- struct KnAddForce : public KernelBase { KnAddForce(FlagGrid& flags, MACGrid& 
vel, Vec3 force) :  KernelBase(&flags,1) ,flags(flags),vel(vel),force(force)   
{ runMessage(); run(); }  inline void op(int i, int j, int k, FlagGrid& flags, 
MACGrid& vel, Vec3 force )  {
+ struct KnApplyForce : public KernelBase { KnApplyForce(FlagGrid& flags, 
MACGrid& vel, Vec3 force, Grid<Real>* exclude, bool additive) :  
KernelBase(&flags,1) 
,flags(flags),vel(vel),force(force),exclude(exclude),additive(additive)   { 
runMessage(); run(); }  inline void op(int i, int j, int k, FlagGrid& flags, 
MACGrid& vel, Vec3 force, Grid<Real>* exclude, bool additive )  {
        bool curFluid = flags.isFluid(i,j,k);
        bool curEmpty = flags.isEmpty(i,j,k);
        if (!curFluid && !curEmpty) return;
+       if (exclude && ((*exclude)(i,j,k) < 0.)) return;
        
        if (flags.isFluid(i-1,j,k) || (curFluid && flags.isEmpty(i-1,j,k))) 
-               vel(i,j,k).x += force.x;
+               vel(i,j,k).x = (additive) ? vel(i,j,k).x+force.x : force.x;
        if (flags.isFluid(i,j-1,k) || (curFluid && flags.isEmpty(i,j-1,k))) 
-               vel(i,j,k).y += force.y;
+               vel(i,j,k).y = (additive) ? vel(i,j,k).y+force.y : force.y;
        if (vel.is3D() && (flags.isFluid(i,j,k-1) || (curFluid && 
flags.isEmpty(i,j,k-1))))
-               vel(i,j,k).z += force.z;
-}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline 
MACGrid& getArg1() { return vel; } typedef MACGrid type1;inline Vec3& getArg2() 
{ return force; } typedef Vec3 type2; void runMessage() { debMsg("Executing 
kernel KnAddForce ", 3); debMsg("Kernel range" <<  " x "<<  maxX  << " y "<< 
maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 4); }; void run() {  const int 
_maxX = maxX; const int _maxY = maxY; if (maxZ > 1) { 
+               vel(i,j,k).z = (additive) ? vel(i,j,k).z+force.z : force.z;
+}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline 
MACGrid& getArg1() { return vel; } typedef MACGrid type1;inline Vec3& getArg2() 
{ return force; } typedef Vec3 type2;inline Grid<Real>* getArg3() { return 
exclude; } typedef Grid<Real> type3;inline bool& getArg4() { return additive; } 
typedef bool type4; void runMessage() { debMsg("Executing kernel KnApplyForce 
", 3); debMsg("Kernel range" <<  " x "<<  maxX  << " y "<< maxY  << " z "<< 
minZ<<" - "<< maxZ  << " [...]
 #pragma omp parallel 
  {  
 #pragma omp for  
-  for (int k=minZ; k < maxZ; k++) for (int j=1; j < _maxY; j++) for (int i=1; 
i < _maxX; i++) op(i,j,k,flags,vel,force);  } } else { const int k=0; 
+  for (int k=minZ; k < maxZ; k++) for (int j=1; j < _maxY; j++) for (int i=1; 
i < _maxX; i++) op(i,j,k,flags,vel,force,exclude,additive);  } } else { const 
int k=0; 
 #pragma omp parallel 
  {  
 #pragma omp for  
-  for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) 
op(i,j,k,flags,vel,force);  } }  } FlagGrid& flags; MACGrid& vel; Vec3 force;   
};
-#line 80 "plugin/extforces.cpp"
+  for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) 
op(i,j,k,flags,vel,force,exclude,additive);  } }  } FlagGrid& flags; MACGrid& 
vel; Vec3 force; Grid<Real>* exclude; bool additive;   };
+#line 85 "plugin/extforces.cpp"
 
 
 
 //! add gravity forces to all fluid cells
-void addGravity(FlagGrid& flags, MACGrid& vel, Vec3 gravity) {    
+void addGravity(FlagGrid& flags, MACGrid& vel, Vec3 gravity, Grid<Real>* 
exclude=NULL) {
        Vec3 f = gravity * flags.getParent()->getDt() / flags.getDx();
-       KnAddForce(flags, vel, f);
-} static PyObject* _W_2 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) 
{ try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = 
_args.obtainParent(); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); 
pbPreparePlugin(parent, "addGravity" , !noTiming ); PyObject *_retval = 0; { 
ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); 
MACGrid& vel = *_args.getPtr<MACGrid >("vel",1,&_lock); Vec3 gravity = 
_args.get<Vec3 >("gravity",2,&_lock);   _retval  [...]
+       KnApplyForce(flags, vel, f, exclude, true);
+} static PyObject* _W_2 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) 
{ try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = 
_args.obtainParent(); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); 
pbPreparePlugin(parent, "addGravity" , !noTiming ); PyObject *_retval = 0; { 
ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); 
MACGrid& vel = *_args.getPtr<MACGrid >("vel",1,&_lock); Vec3 gravity = 
_args.get<Vec3 >("gravity",2,&_lock); Grid<Real> [...]

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to