[Bf-committers] Fluidsim issues solved!

Austin Benesh bfdeveloper at gmail.com
Fri Mar 3 07:11:36 CET 2006


After much arduous debugging, I have solved the issues with <vector> in 
the fluidsimulator. Overall, it should be much more stable now. Here is 
the patch (it is also on the patch tracker). Please tell me if it 
works/doesn't (it should) and if you get a different output than that of 
before. Patch this file to ("blender/intern/elbeem/intern/solver_main.diff")
-------------- next part --------------
Index: solver_main.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/elbeem/intern/solver_main.cpp,v
retrieving revision 1.6
diff -u -i -r1.6 solver_main.cpp
--- solver_main.cpp	27 Feb 2006 11:45:41 -0000	1.6
+++ solver_main.cpp	3 Mar 2006 06:00:27 -0000
@@ -2493,8 +2493,10 @@
 		if((RFLAG(workLev,i,j,k, workSet)&(CFInter|CFNoDelete)) == (CFInter|CFNoDelete)) {
 			// remove entry
 			if(debugFlagreinit) errMsg("EMPT REMOVED!!!", PRINT_IJK<<" mss"<<QCELL(workLev, i,j,k, workSet, dMass) <<" rho"<< QCELL(workLev, i,j,k, workSet, 0) ); // DEBUG SYMM
-			iter = mListEmpty.erase(iter); 
-			iter--; // and continue with next...
+		
+		/* std::copy used instead of vector::erase(iter) because it does 
+		   not throw exceptions due to NULL pointer; see vector::erase() for more details */	
+			std::copy(iter + 1, mListEmpty.end(), iter);
 
 			// treat as "new inter"
 			addToNewInterList(i,j,k);
@@ -2541,7 +2543,7 @@
 
 	
 	// precompute weights to get rid of order dependancies
-	vector<lbmFloatSet> vWeights;
+	vector<lbmFloatSet> vWeights(1);
 	vWeights.reserve( mListFull.size() + mListEmpty.size() );
 	int weightIndex = 0;
   int nbCount = 0;
@@ -2570,6 +2572,7 @@
     	vWeights[weightIndex].numNbs = 0.0;
 		}
 		weightIndex++;
+		vWeights.resize( weightIndex + 1 );
 	}
   for( vector<LbmPoint>::iterator iter=mListEmpty.begin();
        iter != mListEmpty.end(); iter++ ) {
@@ -2594,6 +2597,7 @@
     	vWeights[weightIndex].numNbs = 0.0;
 		}
 		weightIndex++;
+		vWeights.resize( weightIndex + 1 );
 	} 
 	weightIndex = 0;
 	
@@ -2642,6 +2646,7 @@
 			//errMsg(" FULL PROBLEM ", PRINT_IJK<<" "<<this->mFixMass);
 		}
 		weightIndex++;
+		vWeights.resize( weightIndex + 1 );
 
     // already done? RFLAG(workLev,i,j,k, workSet) = CFFluid;
     QCELL(workLev,i,j,k, workSet, dMass) = myrho; // should be rho... but unused?
@@ -2695,6 +2700,7 @@
 			//errMsg(" EMPT PROBLEM ", PRINT_IJK<<" "<<this->mFixMass);
 		}
 		weightIndex++;
+		vWeights.resize( weightIndex + 1 );
 		
 		// finally... make it empty 
     // already done? RFLAG(workLev,i,j,k, workSet) = CFEmpty;


More information about the Bf-committers mailing list