Elbeem / Fluidsim update:

a) Enable the possibility to remove the "air bubble" around submerged collision object. This feature is enabled as standard for new files. The code was found in elbeem by nudelZ, coded and provided by Nils Thürey (thanks!)
b) Old baked files gets deleted if a new bake gets started (were overwritten before and resulted in weird old bake + new bake mixture) (idea by nudelZ)
This commit is contained in:
Daniel Genrich 2011-06-12 23:51:30 +00:00
parent f96769ef0a
commit 5745f99dee
10 changed files with 94 additions and 11 deletions

@ -77,6 +77,10 @@ typedef struct elbeemSimulationSettings {
/* boundary types and settings for domain walls */ /* boundary types and settings for domain walls */
short domainobsType; short domainobsType;
float domainobsPartslip; float domainobsPartslip;
/* what surfaces to generate */
int mFsSurfGenSetting;
/* generate speed vectors for vertices (e.g. for image based motion blur)*/ /* generate speed vectors for vertices (e.g. for image based motion blur)*/
short generateVertexVectors; short generateVertexVectors;
/* strength of surface smoothing */ /* strength of surface smoothing */
@ -108,10 +112,12 @@ typedef struct elbeemSimulationSettings {
#define OB_FLUIDSIM_PARTICLE 64 #define OB_FLUIDSIM_PARTICLE 64
#define OB_FLUIDSIM_CONTROL 128 #define OB_FLUIDSIM_CONTROL 128
// defines for elbeemMesh->obstacleType below // defines for elbeemMesh->obstacleType below (low bits) high bits (>=64) are reserved for mFsSurfGenSetting flags which are defined in solver_class.h
#define FLUIDSIM_OBSTACLE_NOSLIP 1 #define FLUIDSIM_OBSTACLE_NOSLIP 1
#define FLUIDSIM_OBSTACLE_PARTSLIP 2 #define FLUIDSIM_OBSTACLE_PARTSLIP 2
#define FLUIDSIM_OBSTACLE_FREESLIP 3 #define FLUIDSIM_OBSTACLE_FREESLIP 3
#define FLUIDSIM_FSSG_NOOBS 64
#define OB_VOLUMEINIT_VOLUME 1 #define OB_VOLUMEINIT_VOLUME 1
#define OB_VOLUMEINIT_SHELL 2 #define OB_VOLUMEINIT_SHELL 2

@ -181,6 +181,9 @@ int SimulationObject::initializeLbmSimulation(ntlRenderGlobals *glob)
mpLbm->setGenerateParticles(mpElbeemSettings->generateParticles); mpLbm->setGenerateParticles(mpElbeemSettings->generateParticles);
// set initial particles // set initial particles
mpParts->setNumInitialParticles(mpElbeemSettings->numTracerParticles); mpParts->setNumInitialParticles(mpElbeemSettings->numTracerParticles);
// surface generation flag
mpLbm->setSurfGenSettings(mpElbeemSettings->mFsSurfGenSetting);
string dinitType = string("no"); string dinitType = string("no");
if (mpElbeemSettings->domainobsType==FLUIDSIM_OBSTACLE_PARTSLIP) dinitType = string("part"); if (mpElbeemSettings->domainobsType==FLUIDSIM_OBSTACLE_PARTSLIP) dinitType = string("part");

@ -308,6 +308,9 @@ class LbmFsgrSolver :
//! for raytracing, preprocess //! for raytracing, preprocess
void prepareVisualization( void ); void prepareVisualization( void );
/* surface generation settings */
virtual void setSurfGenSettings(short value);
protected: protected:
//! internal quick print function (for debugging) //! internal quick print function (for debugging)

@ -538,6 +538,15 @@ void LbmFsgrSolver::parseAttrList()
} }
/******************************************************************************
* (part of enabling chapter 6 of "Free Surface Flows with Moving and Deforming Objects for LBM")
*****************************************************************************/
void LbmFsgrSolver::setSurfGenSettings(short value)
{
mFsSurfGenSetting = value;
}
/****************************************************************************** /******************************************************************************
* Initialize omegas and forces on all levels (for init/timestep change) * Initialize omegas and forces on all levels (for init/timestep change)
*****************************************************************************/ *****************************************************************************/

@ -271,6 +271,9 @@ class LbmSolverInterface
/*! debug object display */ /*! debug object display */
virtual vector<ntlGeometryObject*> getDebugObjects() { vector<ntlGeometryObject*> empty(0); return empty; } virtual vector<ntlGeometryObject*> getDebugObjects() { vector<ntlGeometryObject*> empty(0); return empty; }
/* surface generation settings */
virtual void setSurfGenSettings(short value) = 0;
#if LBM_USE_GUI==1 #if LBM_USE_GUI==1
/*! show simulation info */ /*! show simulation info */
virtual void debugDisplay(int) = 0; virtual void debugDisplay(int) = 0;

@ -257,6 +257,7 @@ class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, bpy.types.Panel):
col.prop(fluid, "slip_type", text="") col.prop(fluid, "slip_type", text="")
if fluid.slip_type == 'PARTIALSLIP': if fluid.slip_type == 'PARTIALSLIP':
col.prop(fluid, "partial_slip_factor", slider=True, text="Amount") col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
col.prop(fluid, "surface_noobs")
col = split.column() col = split.column()
col.label(text="Surface:") col.label(text="Surface:")

@ -56,6 +56,7 @@
#include "DNA_object_fluidsim.h" #include "DNA_object_fluidsim.h"
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "BLI_fileops.h"
#include "BLI_threads.h" #include "BLI_threads.h"
#include "BLI_math.h" #include "BLI_math.h"
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
@ -125,7 +126,7 @@ static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fs
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
copy_v3_v3(gravity, scene->physics_settings.gravity); copy_v3_v3(gravity, scene->physics_settings.gravity);
} else { } else {
copy_v3_v3(gravity, &fss->gravx); copy_v3_v3(gravity, fss->grav);
} }
} }
@ -442,8 +443,8 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
for (fobj=fobjects->first; fobj; fobj=fobj->next) { for (fobj=fobjects->first; fobj; fobj=fobj->next) {
Object *ob = fobj->object; Object *ob = fobj->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
float active= (float)(fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE); float active= (float)(fluidmd->fss->flag && OB_FLUIDSIM_ACTIVE);
float rot_d[3], old_rot[3] = {0.f, 0.f, 0.f}; float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
continue; continue;
@ -809,6 +810,44 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects,
} }
} }
/* copied from rna_fluidsim.c: fluidsim_find_lastframe() */
static void fluidsim_delete_until_lastframe(FluidsimSettings *fss)
{
char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
char targetDirVel[FILE_MAXFILE+FILE_MAXDIR], targetFileVel[FILE_MAXFILE+FILE_MAXDIR];
char previewDir[FILE_MAXFILE+FILE_MAXDIR], previewFile[FILE_MAXFILE+FILE_MAXDIR];
int curFrame = 1, exists = 0;
BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath);
BLI_snprintf(targetDirVel, sizeof(targetDir), "%sfluidsurface_final_####.bvel.gz", fss->surfdataPath);
BLI_snprintf(previewDir, sizeof(targetDir), "%sfluidsurface_preview_####.bobj.gz", fss->surfdataPath);
BLI_path_abs(targetDir, G.main->name);
BLI_path_abs(targetDirVel, G.main->name);
BLI_path_abs(previewDir, G.main->name);
do {
BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
BLI_strncpy(targetFileVel, targetDirVel, sizeof(targetFileVel));
BLI_strncpy(previewFile, previewDir, sizeof(previewFile));
BLI_path_frame(targetFile, curFrame, 0);
BLI_path_frame(targetFileVel, curFrame, 0);
BLI_path_frame(previewFile, curFrame, 0);
curFrame++;
if(exists = BLI_exist(targetFile))
{
BLI_delete(targetFile, 0, 0);
BLI_delete(targetFileVel, 0, 0);
BLI_delete(previewFile, 0, 0);
}
} while(exists);
return;
}
static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
{ {
Scene *scene= CTX_data_scene(C); Scene *scene= CTX_data_scene(C);
@ -878,6 +917,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
// reset last valid frame // reset last valid frame
domainSettings->lastgoodframe = -1; domainSettings->lastgoodframe = -1;
/* delete old baked files */
fluidsim_delete_until_lastframe(domainSettings);
/* rough check of settings... */ /* rough check of settings... */
if(domainSettings->previewresxyz > domainSettings->resolutionxyz) { if(domainSettings->previewresxyz > domainSettings->resolutionxyz) {
@ -1018,6 +1060,13 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
else if (domainSettings->typeFlags&OB_FSBND_PARTSLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP; else if (domainSettings->typeFlags&OB_FSBND_PARTSLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP;
else if (domainSettings->typeFlags&OB_FSBND_FREESLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP; else if (domainSettings->typeFlags&OB_FSBND_FREESLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP;
fsset->domainobsPartslip = domainSettings->partSlipValue; fsset->domainobsPartslip = domainSettings->partSlipValue;
/* use domainobsType also for surface generation flag (bit: >=64) */
if(domainSettings->typeFlags & OB_FSSG_NOOBS)
fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS;
else
fsset->mFsSurfGenSetting = 0; // "normal" mode
fsset->generateVertexVectors = (domainSettings->domainNovecgen==0); fsset->generateVertexVectors = (domainSettings->domainNovecgen==0);
// init blender domain transform matrix // init blender domain transform matrix

@ -69,7 +69,7 @@ typedef struct FluidsimSettings {
short viscosityMode; short viscosityMode;
short viscosityExponent; short viscosityExponent;
/* gravity strength */ /* gravity strength */
float gravx,gravy,gravz; float grav[3];
/* anim start end time (in seconds) */ /* anim start end time (in seconds) */
float animStart, animEnd; float animStart, animEnd;
/* bake start end time (in blender frames) */ /* bake start end time (in blender frames) */
@ -161,6 +161,9 @@ typedef struct FluidsimSettings {
#define OB_FSBND_FREESLIP (1<<(OB_TYPEFLAG_START+4)) #define OB_FSBND_FREESLIP (1<<(OB_TYPEFLAG_START+4))
#define OB_FSINFLOW_LOCALCOORD (1<<(OB_TYPEFLAG_START+5)) #define OB_FSINFLOW_LOCALCOORD (1<<(OB_TYPEFLAG_START+5))
/* surface generation flag (part of enabling chapter 6 of "Free Surface Flows with Moving and Deforming Objects for LBM") */
#define OB_FSSG_NOOBS (1<<(OB_TYPEFLAG_START+6))
// guiDisplayMode particle flags // guiDisplayMode particle flags
#define OB_FSDOM_GEOM 1 #define OB_FSDOM_GEOM 1
#define OB_FSDOM_PREVIEW 2 #define OB_FSDOM_PREVIEW 2

@ -312,7 +312,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
/* advanced settings */ /* advanced settings */
prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
RNA_def_property_float_sdna(prop, NULL, "gravx"); RNA_def_property_float_sdna(prop, NULL, "grav");
RNA_def_property_array(prop, 3); RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, -1000.1, 1000.1); RNA_def_property_range(prop, -1000.1, 1000.1);
RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction"); RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction");
@ -384,6 +384,12 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Generate Speed Vectors", "Generate speed vectors for vector blur"); RNA_def_property_ui_text(prop, "Generate Speed Vectors", "Generate speed vectors for vector blur");
/* no collision object surface */
prop= RNA_def_property(srna, "surface_noobs", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSSG_NOOBS);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Hide fluid surface", "");
/* particles */ /* particles */
prop= RNA_def_property(srna, "tracer_particles", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "tracer_particles", PROP_INT, PROP_NONE);

@ -90,10 +90,10 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
fss->viscosityValue = 1.0; fss->viscosityValue = 1.0;
fss->viscosityExponent = 6; fss->viscosityExponent = 6;
// dg TODO: change this to [] fss->grav[0] = 0.0;
fss->gravx = 0.0; fss->grav[1] = 0.0;
fss->gravy = 0.0; fss->grav[2] = -9.81;
fss->gravz = -9.81;
fss->animStart = 0.0; fss->animStart = 0.0;
fss->animEnd = 4.0; fss->animEnd = 4.0;
fss->gstar = 0.005; // used as normgstar fss->gstar = 0.005; // used as normgstar
@ -111,7 +111,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
// no bounding box needed // no bounding box needed
// todo - reuse default init from elbeem! // todo - reuse default init from elbeem!
fss->typeFlags = OB_FSBND_PARTSLIP; fss->typeFlags = OB_FSBND_PARTSLIP | OB_FSSG_NOOBS;
fss->domainNovecgen = 0; fss->domainNovecgen = 0;
fss->volumeInitType = 1; // volume fss->volumeInitType = 1; // volume
fss->partSlipValue = 0.2; fss->partSlipValue = 0.2;