[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46913] branches/smoke2: - Delete one of many "bak" files

Daniel Genrich daniel.genrich at gmx.net
Wed May 23 01:06:57 CEST 2012


Revision: 46913
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46913
Author:   genscher
Date:     2012-05-22 23:06:57 +0000 (Tue, 22 May 2012)
Log Message:
-----------
- Delete one of many "bak" files
- Commit wip code, to help with merging changes from trunk

Modified Paths:
--------------
    branches/smoke2/intern/smoke/CMakeLists.txt
    branches/smoke2/intern/smoke/intern/FLUID_3D.cpp
    branches/smoke2/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
    branches/smoke2/source/blender/blenkernel/intern/smoke.c

Removed Paths:
-------------
    branches/smoke2/intern/smoke/intern/FLUID_3D.cpp.bak

Modified: branches/smoke2/intern/smoke/CMakeLists.txt
===================================================================
--- branches/smoke2/intern/smoke/CMakeLists.txt	2012-05-22 23:04:18 UTC (rev 46912)
+++ branches/smoke2/intern/smoke/CMakeLists.txt	2012-05-22 23:06:57 UTC (rev 46913)
@@ -25,8 +25,7 @@
 
 set(INC
 	intern
-	../memutil
-	../../extern/bullet2/src
+	../../extern/Eigen3
 )
 
 set(INC_SYS

Modified: branches/smoke2/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- branches/smoke2/intern/smoke/intern/FLUID_3D.cpp	2012-05-22 23:04:18 UTC (rev 46912)
+++ branches/smoke2/intern/smoke/intern/FLUID_3D.cpp	2012-05-22 23:06:57 UTC (rev 46913)
@@ -36,10 +36,18 @@
 
 #include "float.h"
 
+#include <iostream>
+#include <Eigen/Dense>
+#include <Eigen/Sparse>
+
+
 #if PARALLEL==1
 #include <omp.h>
 #endif // PARALLEL 
 
+using namespace std;
+using namespace Eigen;
+
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
@@ -789,6 +797,7 @@
 	}
 
 }
+
 //////////////////////////////////////////////////////////////////////
 // add forces to velocity field
 //////////////////////////////////////////////////////////////////////
@@ -804,6 +813,9 @@
 		_zVelocityTemp[i] = _zVelocity[i] + _dt * _zForce[i];
 	}
 }
+
+#define INDEX(indexX, indexY, indexZ) ((indexZ) * _xRes * _yRes + (indexY) * _xRes + (indexX))
+
 //////////////////////////////////////////////////////////////////////
 // project into divergence free field
 //////////////////////////////////////////////////////////////////////
@@ -811,7 +823,29 @@
 {
 	int x, y, z;
 	size_t index;
+#if 0
+	VectorXf b(_totalCells);
+	VectorXf p(_totalCells);
+	SparseMatrix<float,RowMajor> A(_totalCells, _totalCells);
+	// DG TODO: A.reserve(VectorXi::Constant(_totalCells, 7));
 
+	ArrayXd gridToIndex(_totalCells);
+
+	ArrayXd A0(_totalCells);
+	ArrayXd Ai(_totalCells);
+	ArrayXd Aj(_totalCells);
+	ArrayXd Ak(_totalCells);
+
+	b.setZero(_totalCells);
+	p.setZero(_totalCells);
+
+	unsigned int linearIndex = 0;
+	for (x = 0; x < _xRes; x++)
+	for (y = 0; y < _yRes; y++)
+	for (z = 0; z < _zRes; z++)
+		if (!_obstacles[INDEX(x,y,z)])
+			gridToIndex(INDEX(x,y,z)) = linearIndex++;
+#endif
 	// float *_pressure = new float[_totalCells];
 	float *_divergence   = new float[_totalCells];
 
@@ -873,7 +907,62 @@
 				// Pressure is zero anyway since now a local array is used
 				_pressure[index] = 0.0f;
 			}
+#if 0
+	float scale = 1.0; // DG TODO: make this global and incooperate this into other functions
 
+	index = _slabSize + _xRes + 1;
+	for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+		for (y = 1; y < _yRes - 1; y++, index += 2)
+			for (x = 1; x < _xRes - 1; x++, index++)
+			{
+				if(!_obstacles[INDEX(x, y, z)])
+				{
+					if(_obstacles[INDEX(x + 1, y, z)]) A0[INDEX(x, y, z)] += scale;
+					if(_obstacles[INDEX(x - 1, y, z)]) A0[INDEX(x, y, z)] += scale;
+					if(_obstacles[INDEX(x, y + 1, z)]) A0[INDEX(x, y, z)] += scale;
+					if(_obstacles[INDEX(x, y - 1, z)]) A0[INDEX(x, y, z)] += scale;
+					if(_obstacles[INDEX(x, y, z + 1)]) A0[INDEX(x, y, z)] += scale;
+					if(_obstacles[INDEX(x, y, z - 1)]) A0[INDEX(x, y, z)] += scale;
+
+					if(_obstacles[INDEX(x + 1, y, z)]) Ai[INDEX(x, y, z)] = -scale;
+					if(_obstacles[INDEX(x, y + 1, z)]) Aj[INDEX(x, y, z)] = -scale;
+					if(_obstacles[INDEX(x, y, z + 1)]) Ak[INDEX(x, y, z)] = -scale;
+				}
+
+			}
+
+	unsigned int valCount = 0;
+	index = _slabSize + _xRes + 1;
+	for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
+		for (y = 1; y < _yRes - 1; y++, index += 2)
+			for (x = 1; x < _xRes - 1; x++, index++)
+		if (!_obstacles[INDEX(x,y,z)])
+		{
+			if(Ai[INDEX(x - 1, y, z)] < 0)
+				A.insert(valCount, gridToIndex(INDEX(x - 1, y, z))) = Ai[INDEX(x - 1, y, z)];
+			if(Aj[INDEX(x, y - 1, z)] < 0)
+				A.insert(valCount, gridToIndex(INDEX(x, y - 1, z))) = Aj[INDEX(x, y - 1, z)];
+			if(Ak[INDEX(x, y, z - 1)] < 0)
+				A.insert(valCount, gridToIndex(INDEX(x, y, z - 1))) = Ak[INDEX(x, y, z - 1)];
+
+				A.insert(valCount, gridToIndex(INDEX(x, y, z))) = A0[INDEX(x, y, z)];
+
+			if(Ai[INDEX(x + 1, y, z)] > 0)
+				A.insert(valCount, gridToIndex(INDEX(x + 1, y, z))) = Ai[INDEX(x + 1, y, z)];
+			if(Aj[INDEX(x, y + 1, z)] > 0)
+				A.insert(valCount, gridToIndex(INDEX(x, y + 1, z))) = Aj[INDEX(x, y + 1, z)];
+			if(Ak[INDEX(x, y, z + 1)] > 0)
+				A.insert(valCount, gridToIndex(INDEX(x, y, z + 1))) = Ak[INDEX(x, y, z + 1)];
+
+				valCount++;
+		}
+
+	for (x = 0; x < _xRes; x++)
+	for (y = 0; y < _yRes; y++)
+	for (z = 0; z < _zRes; z++)
+		if (!_obstacles[INDEX(x,y,z)])
+			b[gridToIndex(INDEX(x, y, z))] = _divergence[INDEX(x,y,z)];
+#endif
 	// copyBorderAll(_pressure, 0, _zRes);
 
 	// solve Poisson equation

Deleted: branches/smoke2/intern/smoke/intern/FLUID_3D.cpp.bak
===================================================================
--- branches/smoke2/intern/smoke/intern/FLUID_3D.cpp.bak	2012-05-22 23:04:18 UTC (rev 46912)
+++ branches/smoke2/intern/smoke/intern/FLUID_3D.cpp.bak	2012-05-22 23:06:57 UTC (rev 46913)
@@ -1,1458 +0,0 @@
-/** \file smoke/intern/FLUID_3D.cpp
- *  \ingroup smoke
- */
-//////////////////////////////////////////////////////////////////////
-// This file is part of Wavelet Turbulence.
-//
-// Wavelet Turbulence is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Wavelet Turbulence is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
-//
-// Copyright 2008 Theodore Kim and Nils Thuerey
-//
-// FLUID_3D.cpp: implementation of the FLUID_3D class.
-//
-//////////////////////////////////////////////////////////////////////
-// Heavy parallel optimization done. Many of the old functions now
-// take begin and end parameters and process only specified part of the data.
-// Some functions were divided into multiple ones.
-//		- MiikaH
-//////////////////////////////////////////////////////////////////////
-
-#include "FLUID_3D.h"
-#include "IMAGE.h"
-#include <INTERPOLATE.h>
-#include "SPHERE.h"
-#include <zlib.h>
-
-#include "float.h"
-
-#if PARALLEL==1
-#include <omp.h>
-#endif // PARALLEL 
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-FLUID_3D::FLUID_3D(int *res, float *p0, float dtdef) :
-	_xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
-{
-	// set simulation consts
-	_dt = dtdef;	// just in case. set in step from a RNA factor
-	
-	// start point of array
-	_p0[0] = p0[0];
-	_p0[1] = p0[1];
-	_p0[2] = p0[2];
-
-	_iterations = 100;
-	_tempAmb = 0; 
-	_heatDiffusion = 1e-3;
-	_totalTime = 0.0f;
-	_totalSteps = 0;
-	_res = Vec3Int(_xRes,_yRes,_zRes);
-	_maxRes = MAX3(_xRes, _yRes, _zRes);
-	
-	// initialize wavelet turbulence
-	/*
-	if(amplify)
-		_wTurbulence = new WTURBULENCE(_res[0],_res[1],_res[2], amplify, noisetype);
-	else
-		_wTurbulence = NULL;
-	*/
-	
-	// scale the constants according to the refinement of the grid
-	_dx = 1.0f / (float)_maxRes;
-	_constantScaling = 64.0f / _maxRes;
-	_constantScaling = (_constantScaling < 1.0f) ? 1.0f : _constantScaling;
-	_vorticityEps = 2.0f / _constantScaling; // Just in case set a default value
-
-	// allocate arrays
-	_totalCells   = _xRes * _yRes * _zRes;
-	_slabSize = _xRes * _yRes;
-	_xVelocity    = new float[_totalCells];
-	_yVelocity    = new float[_totalCells];
-	_zVelocity    = new float[_totalCells];
-	_xVelocityOb  = new float[_totalCells];
-	_yVelocityOb  = new float[_totalCells];
-	_zVelocityOb  = new float[_totalCells];
-	_xVelocityOld = new float[_totalCells];
-	_yVelocityOld = new float[_totalCells];
-	_zVelocityOld = new float[_totalCells];
-	_xForce       = new float[_totalCells];
-	_yForce       = new float[_totalCells];
-	_zForce       = new float[_totalCells];
-	_density      = new float[_totalCells];
-	_densityOld   = new float[_totalCells];
-	_heat         = new float[_totalCells];
-	_heatOld      = new float[_totalCells];
-	_obstacles    = new unsigned char[_totalCells]; // set 0 at end of step
-	
-	// For debugging purposes
-	_pressure	  = new float[_totalCells];
-
-	// For threaded version:
-	_xVelocityTemp = new float[_totalCells];
-	_yVelocityTemp = new float[_totalCells];
-	_zVelocityTemp = new float[_totalCells];
-	_densityTemp   = new float[_totalCells];
-	_heatTemp      = new float[_totalCells];
-
-	// DG TODO: check if alloc went fine
-
-	for (int x = 0; x < _totalCells; x++)
-	{
-		_density[x]      = 0.0f;
-		_densityOld[x]   = 0.0f;
-		_heat[x]         = 0.0f;
-		_heatOld[x]      = 0.0f;
-		_xVelocity[x]    = 0.0f;
-		_yVelocity[x]    = 0.0f;
-		_zVelocity[x]    = 0.0f;
-		_xVelocityOb[x]  = 0.0f;
-		_yVelocityOb[x]  = 0.0f;
-		_zVelocityOb[x]  = 0.0f;
-		_xVelocityOld[x] = 0.0f;
-		_yVelocityOld[x] = 0.0f;
-		_zVelocityOld[x] = 0.0f;
-		_xForce[x]       = 0.0f;
-		_yForce[x]       = 0.0f;
-		_zForce[x]       = 0.0f;
-		_obstacles[x]    = false;
-		_pressure[x]	 = 0.0f;
-	}
-
-	// boundary conditions of the fluid domain
-	// set default values -> vertically non-colliding
-	_domainBcFront = true;
-	_domainBcTop = false;
-	_domainBcLeft = true;
-	_domainBcBack = _domainBcFront;
-	_domainBcBottom = _domainBcTop;
-	_domainBcRight	= _domainBcLeft;
-
-	_colloPrev = 1;	// default value
-
-	setBorderObstacles(); // walls
-
-}
-
-void FLUID_3D::setBorderObstacles()
-{
-	
-	// set side obstacles
-	unsigned int index;
-	for (int y = 0; y < _yRes; y++)
-	for (int x = 0; x < _xRes; x++)
-	{
-		// bottom slab
-		index = x + y * _xRes;
-		if(_domainBcBottom==1) _obstacles[index] = 1;
-
-		// top slab
-		index += _totalCells - _slabSize;
-		if(_domainBcTop==1) _obstacles[index] = 1;
-	}
-
-	for (int z = 0; z < _zRes; z++)
-	for (int x = 0; x < _xRes; x++)
-	{
-		// front slab
-		index = x + z * _slabSize;
-		if(_domainBcFront==1) _obstacles[index] = 1;
-
-		// back slab
-		index += _slabSize - _xRes;
-		if(_domainBcBack==1) _obstacles[index] = 1;
-	}
-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list