[Bf-blender-cvs] [bf64cd1] soc-2014-fluid: Forces passed to Mantaflow correctly, vortex working

Roman Pogribnyi noreply at git.blender.org
Mon Mar 9 23:09:48 CET 2015


Commit: bf64cd1fd81f4021b8db476edbad4a7e45ae41ea
Author: Roman Pogribnyi
Date:   Thu Mar 5 00:19:24 2015 +0100
Branches: soc-2014-fluid
https://developer.blender.org/rBbf64cd1fd81f4021b8db476edbad4a7e45ae41ea

Forces passed to Mantaflow correctly, vortex working

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

M	intern/smoke/intern/FLUID_3D.cpp
M	intern/smoke/intern/scenarios/smoke.h
M	intern/smoke/intern/smoke_API.cpp
M	source/blender/blenkernel/intern/smoke.c

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

diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index 8bc9077..ef5cac9 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -704,11 +704,11 @@ void FLUID_3D::initBlenderRNA(float *alpha, float *beta, float *dt_factor, float
 void FLUID_3D::step(float dt, float gravity[3])
 {
 		// BLender computes heat buoyancy, not yet impl. in Manta
+	manta_write_effectors(this);
 	Manta_API::updatePointers(this,using_colors);
 //	diffuseHeat();
 
 	int sim_frame = 1;
-	manta_write_effectors(this);
 	PyGILState_STATE gilstate = PyGILState_Ensure();
 	std::string frame_str = static_cast<ostringstream*>( &(ostringstream() << sim_frame) )->str();
 	std::string py_string_0 = string("sim_step_low(").append(frame_str);
diff --git a/intern/smoke/intern/scenarios/smoke.h b/intern/smoke/intern/scenarios/smoke.h
index d931114..91eb27a 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -180,6 +180,7 @@ const string smoke_step_low = "def sim_step_low(t, standalone = False):\n\
     vorticityConfinement( vel=vel, flags=flags, strength=$VORTICITY$ ) \n\
   print ('forcefield')\n\
   addForceField(flags=flags, vel=vel,force=forces)\n\
+  forces.clear()\n\
   \n\
   print ('pressure')\n\
   solvePressure(flags=flags, vel=vel, pressure=pressure, openBound=boundConditions)\n\
diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp
index 81e2d9d..3a61b39 100644
--- a/intern/smoke/intern/smoke_API.cpp
+++ b/intern/smoke/intern/smoke_API.cpp
@@ -36,7 +36,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include "MANTA.h"
-
+#include "../../../source/blender/python/manta_pp/util/vectorbase.h"
 #include "../extern/smoke_API.h"  /* to ensure valid prototypes */
 
 extern "C" int *smoke_get_manta_flags(struct FLUID_3D *fluid){
@@ -534,25 +534,26 @@ extern "C" void manta_write_effectors(struct FLUID_3D *fluid)
 	float *force_z = smoke_get_force_z(fluid);
 //	export_force_fields(size_x, size_y, size_z, force_x, force_y, force_z);
 	/*accumulate all force fields in one grid*/	
-	Vec3 * accumulated_force = NULL;
+	Manta::Vec3 * accumulated_force = NULL;
+	long index(0);
 	if (fluid->manta_resoution == 3){
-		accumulated_force = (Vec3*)malloc(size_x * size_y * size_z * sizeof(Vec3));
-		long index(0);
-		for (int x(0); x < size_x; x++){
-			for (int y(0); y < size_y; y++){
-				for (int z(0); z < size_z; z++){
-					index = x + y * size_x + z * size_x * size_y;
-					accumulated_force[index] = Vec3(force_x[x], force_y[y], force_z[z]);
+		accumulated_force = (Manta::Vec3*)calloc(size_x * size_y * size_z , sizeof(Manta::Vec3));
+			for (int z(0); z < size_z; z++){
+				for (int y(0); y < size_y; y++){
+					for (int x(0); x < size_x; x++){
+					index = smoke_get_index(x, size_x, y, size_y, z);
+					accumulated_force[index] = Manta::Vec3(force_x[index], force_y[index], force_z[index]);
 				}	
 			}		
 		}
 	}
 	else if (fluid->manta_resoution == 2){
-		accumulated_force = (Vec3*)malloc(size_x * size_z * sizeof(Vec3));
+		accumulated_force = (Manta::Vec3*)malloc(size_x * size_z * sizeof(Manta::Vec3));
 		int step(0);
 		for (int x(0); x < size_x; x++){
 				for (int z(0); z < size_z; z++){
-					accumulated_force[x + z * size_x] = Vec3(force_x[x], force_z[z], 0.0);
+					index = smoke_get_index(x, size_x, size_y/2, size_y, z);
+					accumulated_force[x + z * size_x] = Manta::Vec3(force_x[index], force_z[index], 0.0);
 				}	
 		}
 	}
@@ -560,6 +561,8 @@ extern "C" void manta_write_effectors(struct FLUID_3D *fluid)
 		cout << "ERROR: Manta solver resoltion is neither 2 nor 3; Cannot write forces"<<endl;
 		return;
 	}
+	
+	
 	bool is2D = (fluid->manta_resoution == 2);
 	Manta_API::addGrid(accumulated_force, "forces", "Vec3", size_x, size_y, size_z, is2D);
 }
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index d47851a..0884ca2 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -2452,11 +2452,8 @@ static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds,
 					float mag;
 					float voxelCenter[3] = {0, 0, 0}, vel[3] = {0, 0, 0}, retvel[3] = {0, 0, 0};
 					unsigned int index = smoke_get_index(x, sds->res[0], y, sds->res[1], z);
-
-#ifndef WITH_MANTA
 					if (((fuel ? MAX2(density[index], fuel[index]) : density[index]) < FLT_EPSILON) || obstacle[index])
 						continue;
-#endif
 					vel[0] = velocity_x[index];
 					vel[1] = velocity_y[index];
 					vel[2] = velocity_z[index];




More information about the Bf-blender-cvs mailing list