[Bf-blender-cvs] [1f314b9ea5c] fluid-mantaflow: adapted spiral velocity getter from mantaflow
Sebastián Barschkis
noreply at git.blender.org
Fri Aug 4 23:08:48 CEST 2017
Commit: 1f314b9ea5cade30a8be22bcab3aca71d2bab836
Author: Sebastián Barschkis
Date: Tue Aug 1 20:16:57 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB1f314b9ea5cade30a8be22bcab3aca71d2bab836
adapted spiral velocity getter from mantaflow
now possible to get 3D instead of just 2D target vel grid (useful for tornado effect)
===================================================================
M intern/mantaflow/intern/manta_pp/tbb/plugin/fluidguiding.cpp
M intern/mantaflow/intern/manta_pp/tbb/registration.cpp
===================================================================
diff --git a/intern/mantaflow/intern/manta_pp/tbb/plugin/fluidguiding.cpp b/intern/mantaflow/intern/manta_pp/tbb/plugin/fluidguiding.cpp
index 810cc823dee..a3e56bdf5cf 100644
--- a/intern/mantaflow/intern/manta_pp/tbb/plugin/fluidguiding.cpp
+++ b/intern/mantaflow/intern/manta_pp/tbb/plugin/fluidguiding.cpp
@@ -180,26 +180,29 @@ Real getEpsDual(const Real eps_abs, const Real eps_rel, MACGrid &y) {
return eps_dual;
}
-//! Create a spiral velocity field in 2D as a test scene
-void getSpiralVelocity2D(const FlagGrid &flags, MACGrid &vel, Real strength = 1.0) {
- int nx = flags.getSizeX(), ny = flags.getSizeY();
+//! Create a spiral velocity field in 2D as a test scene (optionally in 3D)
+void getSpiralVelocity(const FlagGrid &flags, MACGrid &vel, Real strength = 1.0, bool with3D=false) {
+ int nx = flags.getSizeX(), ny = flags.getSizeY(), nz = 1;
+ if (with3D) nz = flags.getSizeZ();
Real midX = 0.5*(Real)(nx - 1);
Real midY = 0.5*(Real)(ny - 1);
- int k = 0;
+ Real midZ = 0.5*(Real)(nz - 1);
for (int i = 0; i < nx; i++) {
for (int j = 0; j < ny; j++) {
- int idx = flags.index(i, j, k);
- Real diffX = midX - i;
- Real diffY = midY - j;
- Real hypotenuse = sqrt(diffX*diffX + diffY*diffY);
- if (hypotenuse > 0) {
- vel[idx].x = diffY / hypotenuse;
- vel[idx].y = -diffX / hypotenuse;
+ for (int k = 0; k < nz; k++) {
+ int idx = flags.index(i, j, k);
+ Real diffX = midX - i;
+ Real diffY = midY - j;
+ Real hypotenuse = sqrt(diffX*diffX + diffY*diffY);
+ if (hypotenuse > 0) {
+ vel[idx].x = diffY / hypotenuse;
+ vel[idx].y = -diffX / hypotenuse;
+ }
}
}
}
vel.multConst(strength);
-} static PyObject* _W_0 (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, "getSpiralVelocity2D" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; const FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); MACGrid& vel = *_args.getPtr<MACGrid >("vel",1,&_lock); Real strength = _args.getOpt<Real >("strength",2 [...]
+} static PyObject* _W_0 (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, "getSpiralVelocity" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; const FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); MACGrid& vel = *_args.getPtr<MACGrid >("vel",1,&_lock); Real strength = _args.getOpt<Real >("strength",2,1 [...]
//! Set the guiding weight W as a gradient in the y-direction
void setGradientYWeight(Grid<Real> &W, const int minY, const int maxY, const Real valAtMin, const Real valAtMax) {
diff --git a/intern/mantaflow/intern/manta_pp/tbb/registration.cpp b/intern/mantaflow/intern/manta_pp/tbb/registration.cpp
index b2f83c2ddc4..05946925eb7 100644
--- a/intern/mantaflow/intern/manta_pp/tbb/registration.cpp
+++ b/intern/mantaflow/intern/manta_pp/tbb/registration.cpp
@@ -73,7 +73,7 @@ extern "C" {
extern void PbRegister_sampleSndParts() ;
extern void PbRegister_processBurn() ;
extern void PbRegister_updateFlame() ;
- extern void PbRegister_getSpiralVelocity2D() ;
+ extern void PbRegister_getSpiralVelocity() ;
extern void PbRegister_setGradientYWeight() ;
extern void PbRegister_PD_fluid_guiding() ;
extern void PbRegister_KEpsilonComputeProduction() ;
@@ -230,7 +230,7 @@ namespace Pb {
PbRegister_sampleSndParts() ;
PbRegister_processBurn() ;
PbRegister_updateFlame() ;
- PbRegister_getSpiralVelocity2D() ;
+ PbRegister_getSpiralVelocity() ;
PbRegister_setGradientYWeight() ;
PbRegister_PD_fluid_guiding() ;
PbRegister_KEpsilonComputeProduction() ;
More information about the Bf-blender-cvs
mailing list