[Bf-blender-cvs] [03c7acf] soc-2014-fluid: Smoke: Updated mantaflow sources

Roman Pogribnyi noreply at git.blender.org
Mon Apr 13 22:19:34 CEST 2015


Commit: 03c7acf3a0a3fa60fcefb2b41ffc8da21ff6b1e4
Author: Roman Pogribnyi
Date:   Mon Apr 13 22:17:59 2015 +0200
Branches: soc-2014-fluid
https://developer.blender.org/rB03c7acf3a0a3fa60fcefb2b41ffc8da21ff6b1e4

Smoke: Updated mantaflow sources

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

M	intern/smoke/intern/MANTA.cpp
M	release/scripts/addons
M	release/scripts/addons_contrib
M	source/blender/python/manta_pp/CMakeLists.txt
M	source/blender/python/manta_pp/conjugategrad.cpp
M	source/blender/python/manta_pp/conjugategrad.h
M	source/blender/python/manta_pp/fastmarch.cpp
M	source/blender/python/manta_pp/fileio.cpp
M	source/blender/python/manta_pp/fileio.h
M	source/blender/python/manta_pp/fluidsolver.cpp
M	source/blender/python/manta_pp/fluidsolver.h
M	source/blender/python/manta_pp/fluidsolver.h.reg
M	source/blender/python/manta_pp/fluidsolver.h.reg.cpp
M	source/blender/python/manta_pp/grid.cpp
M	source/blender/python/manta_pp/grid.h
M	source/blender/python/manta_pp/grid.h.reg
M	source/blender/python/manta_pp/grid.h.reg.cpp
M	source/blender/python/manta_pp/hginfo.h
M	source/blender/python/manta_pp/levelset.cpp
M	source/blender/python/manta_pp/mesh.cpp
M	source/blender/python/manta_pp/mesh.h
M	source/blender/python/manta_pp/mesh.h.reg
M	source/blender/python/manta_pp/mesh.h.reg.cpp
M	source/blender/python/manta_pp/particle.cpp
M	source/blender/python/manta_pp/particle.h
M	source/blender/python/manta_pp/plugin/advection.cpp
M	source/blender/python/manta_pp/plugin/extforces.cpp
M	source/blender/python/manta_pp/plugin/flip.cpp
M	source/blender/python/manta_pp/plugin/initplugins.cpp
M	source/blender/python/manta_pp/plugin/pressure.cpp
M	source/blender/python/manta_pp/plugin/vortexplugins.cpp
M	source/blender/python/manta_pp/plugin/waveletturbulence.cpp
M	source/blender/python/manta_pp/plugin/waves.cpp
M	source/blender/python/manta_pp/test.cpp
M	source/blender/python/manta_pp/util/integrator.h
M	source/blender/python/manta_pp/util/interpol.h
M	source/blender/python/manta_pp/util/interpolHigh.h
M	source/blender/python/manta_pp/util/mcubes.h
M	source/blender/python/manta_pp/util/quaternion.h
M	source/blender/python/manta_pp/util/randomstream.h
A	source/blender/python/manta_pp/util/simpleimage.cpp
A	source/blender/python/manta_pp/util/simpleimage.h
M	source/blender/python/manta_pp/util/solvana.h
M	source/blender/python/manta_pp/util/vectorbase.cpp
M	source/blender/python/manta_pp/util/vectorbase.h

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

diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index b95626a..20464d4 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -551,7 +551,7 @@ string Manta_API::getGridPointer(std::string gridName, std::string solverName)
 	if ((gridName == "") && (solverName == "")){
 		return "";
 	}
-	
+	cout << "getting grid pointer " << gridName<< " , " << solverName <<endl;
 	PyGILState_STATE gilstate = PyGILState_Ensure();
 	PyObject *main = PyImport_AddModule("__main__");
 	if (main == NULL){cout << "null" << 1 << endl;return "";}
@@ -601,7 +601,8 @@ void Manta_API::updatePointers(FLUID_3D *fluid, bool updateColor)
 	/*in 2D case, we want to copy in the Z-axis field that is in the middle of X and Y axes */
 	//x + y * max_x + z * max_x*max_y
 //	int position_to_copy_from(0 + (fluid->xRes()/2) * fluid->xRes() + (fluid->zRes()/2) * fluid->xRes()*fluid->yRes());
-//	float *whereToCopy = &fluid->_density[position_to_copy_from]; 
+//	float *whereToCopy = &fluid->_density[position_to_copy_from];
+	cout << 'updating pointers'<<endl;
 	if (fluid->manta_resoution == 2)
 	{
 		float* manta_fluid_density = (float* )pointerFromString(getGridPointer("density", "s")); 
@@ -625,6 +626,7 @@ void Manta_API::updatePointers(FLUID_3D *fluid, bool updateColor)
 			}		
 	}
 	else{
+		cout << '3D'<<endl;
 		fluid->_density = (float* )pointerFromString(getGridPointer("density", "s"));	
 		fluid->_manta_flags = (int* )pointerFromString(getGridPointer("flags", "s"));
 	}
diff --git a/release/scripts/addons b/release/scripts/addons
index 3fc5b82..e716a35 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 3fc5b82c6bdba2f9c954fbf497621b9bb794a1bc
+Subproject commit e716a3503d0e4ece893d42e394e684ebce90ea4e
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index cf842d8..d9b4c8f 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit cf842d8bb7b0033ca4fa99f7ebedcbd3810fd274
+Subproject commit d9b4c8f5ddc958a66cd53f630d5569da426efb4f
diff --git a/source/blender/python/manta_pp/CMakeLists.txt b/source/blender/python/manta_pp/CMakeLists.txt
index 73027c8a..b91314c 100644
--- a/source/blender/python/manta_pp/CMakeLists.txt
+++ b/source/blender/python/manta_pp/CMakeLists.txt
@@ -130,6 +130,8 @@ ${CMAKE_CURRENT_SOURCE_DIR}/util/interpolHigh.h
 ${CMAKE_CURRENT_SOURCE_DIR}/util/mcubes.h
 ${CMAKE_CURRENT_SOURCE_DIR}/util/randomstream.h
 ${CMAKE_CURRENT_SOURCE_DIR}/util/solvana.h
+${CMAKE_CURRENT_SOURCE_DIR}/util/simpleimage.cpp
+${CMAKE_CURRENT_SOURCE_DIR}/util/simpleimage.h
 )
 list(REMOVE_DUPLICATES "SRC")
 list_assert_duplicates("${SRC}")
diff --git a/source/blender/python/manta_pp/conjugategrad.cpp b/source/blender/python/manta_pp/conjugategrad.cpp
index 95caa18..03b101f 100644
--- a/source/blender/python/manta_pp/conjugategrad.cpp
+++ b/source/blender/python/manta_pp/conjugategrad.cpp
@@ -255,8 +255,8 @@ bool GridCg<APPLYMAT>::iterate() {
 	else
 		mTmp.copyFrom( mResidual );
 		
-	// compute norm of the residual?
-	if(this->mUseResNorm) { 
+	// use the l2 norm of the residual for convergence check? (usually max norm is recommended instead)
+	if(this->mUseL2Norm) { 
 		mResNorm = GridSumSqr(mResidual).sum; 
 	} else {
 		mResNorm = mResidual.getMaxAbsValue();        
diff --git a/source/blender/python/manta_pp/conjugategrad.h b/source/blender/python/manta_pp/conjugategrad.h
index ccf5983..18d65ee 100644
--- a/source/blender/python/manta_pp/conjugategrad.h
+++ b/source/blender/python/manta_pp/conjugategrad.h
@@ -29,6 +29,7 @@
 #include "grid.h"
 #include "kernel.h"
 
+
 namespace Manta { 
 
 static const bool CG_DEBUG = false;
@@ -38,7 +39,7 @@ class GridCgInterface {
 	public:
 		enum PreconditionType { PC_None=0, PC_ICP, PC_mICP };
 		
-		GridCgInterface() : mUseResNorm(true) {};
+		GridCgInterface() : mUseL2Norm(true) {};
 		virtual ~GridCgInterface() {};
 
 		// solving functions
@@ -55,12 +56,12 @@ class GridCgInterface {
 		virtual void setAccuracy(Real set) = 0;
 		virtual Real getAccuracy() const = 0;
 
-		void setUseResNorm(bool set) { mUseResNorm = set; }
+		void setUseL2Norm(bool set) { mUseL2Norm = set; }
 
 	protected:
 
-		// use norm of residual, or max value for threshold?
-		bool mUseResNorm; 
+		// use l2 norm of residualfor threshold? (otherwise uses max norm)
+		bool mUseL2Norm; 
 };
 
 
@@ -122,10 +123,13 @@ class GridCg : public GridCgInterface {
 
 
  struct ApplyMatrix : public KernelBase { ApplyMatrix(FlagGrid& flags, Grid<Real>& dst, Grid<Real>& src, Grid<Real>& A0, Grid<Real>& Ai, Grid<Real>& Aj, Grid<Real>& Ak) :  KernelBase(&flags,0) ,flags(flags),dst(dst),src(src),A0(A0),Ai(Ai),Aj(Aj),Ak(Ak)   { run(); }  inline void op(int idx, FlagGrid& flags, Grid<Real>& dst, Grid<Real>& src, Grid<Real>& A0, Grid<Real>& Ai, Grid<Real>& Aj, Grid<Real>& Ak )  {
+	if (flags[idx] & FlagGrid::TypeZeroPressure) { 
+		dst[idx]=0.; return; 
+	} 
 	if (!flags.isFluid(idx)) {
-		dst[idx] = src[idx];
-		return;
+		dst[idx] = src[idx]; return;
 	}    
+
 	dst[idx] =  src[idx] * A0[idx]
 				+ src[idx-X] * Ai[idx-X]
 				+ src[idx+X] * Ai[idx]
@@ -142,10 +146,14 @@ class GridCg : public GridCgInterface {
  struct ApplyMatrix2D : public KernelBase { ApplyMatrix2D(FlagGrid& flags, Grid<Real>& dst, Grid<Real>& src, Grid<Real>& A0, Grid<Real>& Ai, Grid<Real>& Aj, Grid<Real>& Ak) :  KernelBase(&flags,0) ,flags(flags),dst(dst),src(src),A0(A0),Ai(Ai),Aj(Aj),Ak(Ak)   { run(); }  inline void op(int idx, FlagGrid& flags, Grid<Real>& dst, Grid<Real>& src, Grid<Real>& A0, Grid<Real>& Ai, Grid<Real>& Aj, Grid<Real>& Ak )  {
 	unusedParameter(Ak); // only there for parameter compatibility with ApplyMatrix
 	
+	if (flags[idx] & FlagGrid::TypeZeroPressure) { 
+		dst[idx]=0.; return; 
+	}
+
 	if (!flags.isFluid(idx)) {
-		dst[idx] = src[idx];
-		return;
+		dst[idx] = src[idx]; return;
 	}    
+
 	dst[idx] =  src[idx] * A0[idx]
 				+ src[idx-X] * Ai[idx-X]
 				+ src[idx+X] * Ai[idx]
@@ -155,22 +163,36 @@ class GridCg : public GridCgInterface {
 
 //! Kernel: Construct the matrix for the poisson equation
 
- struct MakeLaplaceMatrix : public KernelBase { MakeLaplaceMatrix(FlagGrid& flags, Grid<Real>& A0, Grid<Real>& Ai, Grid<Real>& Aj, Grid<Real>& Ak) :  KernelBase(&flags,1) ,flags(flags),A0(A0),Ai(Ai),Aj(Aj),Ak(Ak)   { run(); }  inline void op(int i, int j, int k, FlagGrid& flags, Grid<Real>& A0, Grid<Real>& Ai, Grid<Real>& Aj, Grid<Real>& Ak )  {
+ struct MakeLaplaceMatrix : public KernelBase { MakeLaplaceMatrix(FlagGrid& flags, Grid<Real>& A0, Grid<Real>& Ai, Grid<Real>& Aj, Grid<Real>& Ak, MACGrid* fractions = 0) :  KernelBase(&flags,1) ,flags(flags),A0(A0),Ai(Ai),Aj(Aj),Ak(Ak),fractions(fractions)   { run(); }  inline void op(int i, int j, int k, FlagGrid& flags, Grid<Real>& A0, Grid<Real>& Ai, Grid<Real>& Aj, Grid<Real>& Ak, MACGrid* fractions = 0 )  {
 	if (!flags.isFluid(i,j,k))
 		return;
 	
-	// center
-	if (!flags.isObstacle(i-1,j,k)) A0(i,j,k) += 1.;
-	if (!flags.isObstacle(i+1,j,k)) A0(i,j,k) += 1.;
-	if (!flags.isObstacle(i,j-1,k)) A0(i,j,k) += 1.;
-	if (!flags.isObstacle(i,j+1,k)) A0(i,j,k) += 1.;
-	if (flags.is3D() && !flags.isObstacle(i,j,k-1)) A0(i,j,k) += 1.;
-	if (flags.is3D() && !flags.isObstacle(i,j,k+1)) A0(i,j,k) += 1.;
-	
-	if (flags.isFluid(i+1,j,k)) Ai(i,j,k) = -1.;
-	if (flags.isFluid(i,j+1,k)) Aj(i,j,k) = -1.;
-	if (flags.is3D() && flags.isFluid(i,j,k+1)) Ak(i,j,k) = -1.;    
-}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline Grid<Real>& getArg1() { return A0; } typedef Grid<Real> type1;inline Grid<Real>& getArg2() { return Ai; } typedef Grid<Real> type2;inline Grid<Real>& getArg3() { return Aj; } typedef Grid<Real> type3;inline Grid<Real>& getArg4() { return Ak; } typedef Grid<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< _max [...]
+	if(fractions) {
+		A0(i,j,k) += fractions->get(i,j,k).x;
+		A0(i,j,k) += fractions->get(i+1,j,k).x;
+		A0(i,j,k) += fractions->get(i,j,k).y;
+		A0(i,j,k) += fractions->get(i,j+1,k).y;
+		if (flags.is3D()) A0(i,j,k) += fractions->get(i,j,k).z;
+		if (flags.is3D()) A0(i,j,k) += fractions->get(i,j,k+1).z;
+
+		Ai(i,j,k) = -fractions->get(i+1,j,k).x;
+		Aj(i,j,k) = -fractions->get(i,j+1,k).y;
+		if (flags.is3D()) Ak(i,j,k) = -fractions->get(i,j,k+1).z;
+	}else{
+		// center
+		if (!flags.isObstacle(i-1,j,k)) A0(i,j,k) += 1.;
+		if (!flags.isObstacle(i+1,j,k)) A0(i,j,k) += 1.;
+		if (!flags.isObstacle(i,j-1,k)) A0(i,j,k) += 1.;
+		if (!flags.isObstacle(i,j+1,k)) A0(i,j,k) += 1.;
+		if (flags.is3D() && !flags.isObstacle(i,j,k-1)) A0(i,j,k) += 1.;
+		if (flags.is3D() && !flags.isObstacle(i,j,k+1)) A0(i,j,k) += 1.;
+		
+		if (flags.isFluid(i+1,j,k)) Ai(i,j,k) = -1.;
+		if (flags.isFluid(i,j+1,k)) Aj(i,j,k) = -1.;
+		if (flags.is3D() && flags.isFluid(i,j,k+1)) Ak(i,j,k) = -1.;
+	}
+
+}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline Grid<Real>& getArg1() { return A0; } typedef Grid<Real> type1;inline Grid<Real>& getArg2() { return Ai; } typedef Grid<Real> type2;inline Grid<Real>& getArg3() { return Aj; } typedef Grid<Real> type3;inline Grid<Real>& getArg4() { return Ak; } typedef Grid<Real> type4;inline MACGrid* getArg5() { return fractions; } typedef MACGrid type5; void run() {  const int _maxX = maxX; const int _maxY = maxY; for (int k= [...]
 
 
 
@@ -179,3 +201,4 @@ class GridCg : public GridCgInterface {
 
 #endif 
 
+
diff --git a/source/blender/python/manta_pp/fastmarch.cpp b/source/blender/python/manta_pp/fastmarch.cpp
index 66612ed..e66bbe7 100644
--- a/source/blender/python/manta_pp/fastmarch.cpp
+++ b/source/blender/python/manta_pp/fastmarch.cpp
@@ -170,6 +170,7 @@ void FastMarch<COMP,TDIR>::addToList(const Vec3i& p, const Vec3i& src) {
 	// update field
 	mFmFlags[id

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list