Add a gui control for setting omp threads in fluids
authorJens Verwiebe <info@jensverwiebe.de>
Wed, 10 Apr 2013 18:35:18 +0000 (18:35 +0000)
committerJens Verwiebe <info@jensverwiebe.de>
Wed, 10 Apr 2013 18:35:18 +0000 (18:35 +0000)
intern/elbeem/extern/elbeem.h
intern/elbeem/intern/simulation_object.cpp
release/scripts/startup/bl_ui/properties_physics_fluid.py
source/blender/editors/physics/physics_fluid.c
source/blender/makesdna/DNA_object_fluidsim.h
source/blender/makesrna/intern/rna_fluidsim.c
source/blender/modifiers/intern/MOD_fluidsim_util.c

index 6df08ccebd2e44d7435304d3204a96d6161e6fdf..bd50b6f08dcc0251ee9db11e3ecd609619a81d53 100644 (file)
@@ -99,6 +99,8 @@ typedef struct elbeemSimulationSettings {
        elbeemRunSimulationCallback runsimCallback;
        /* pointer passed to runsimCallback for user data storage */
        void* runsimUserData;
+       /* simulation threads used by omp */
+       int threads;
 
 } elbeemSimulationSettings;
 
index 87828b260888a075b2f7ffe0c92b7d649b4db064..79b1a2ce635aa3e16edcea30f998a225c1e6e745 100644 (file)
 #include "particletracer.h"
 #include "elbeem.h"
 
+#if PARALLEL==1
+#include <omp.h>
+#endif
+
 #ifdef _WIN32
 #else
 #include <sys/time.h>
@@ -173,6 +177,7 @@ int SimulationObject::initializeLbmSimulation(ntlRenderGlobals *glob)
                mpLbm->initDomainTrafo( mpElbeemSettings->surfaceTrafo );
                mpLbm->setSmoothing(1.0 * mpElbeemSettings->surfaceSmoothing, 1.0 * mpElbeemSettings->surfaceSmoothing);
                mpLbm->setIsoSubdivs(mpElbeemSettings->surfaceSubdivs);
+               omp_set_num_threads(mpElbeemSettings->threads);
                mpLbm->setSizeX(mpElbeemSettings->resolutionxyz);
                mpLbm->setSizeY(mpElbeemSettings->resolutionxyz);
                mpLbm->setSizeZ(mpElbeemSettings->resolutionxyz);
index b3cd5dc5464196c3b6248392372ca8af6e6cb679..78bb21e76a566fbc78c65fecfabab118c2216cd2 100644 (file)
@@ -67,6 +67,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
             # odd formatting here so translation script can extract string
             layout.operator("fluid.bake", text=iface_("Bake (Req. Memory: %s)") % fluid.memory_estimate,
                             translate=False, icon='MOD_FLUIDSIM')
+            layout.prop(fluid, "threads", text="Simulation Threads")
             split = layout.split()
 
             col = split.column()
index 9197b9e99da62b0eb01bcb7130a346031d5ea779..1de2f14dbc0f0add6c153bdbc2c80c9cbf49792b 100644 (file)
@@ -994,7 +994,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
        /* ******** export domain to elbeem ******** */
        elbeemResetSettings(fsset);
        fsset->version = 1;
-
+       fsset->threads = domainSettings->threads;
        // setup global settings
        copy_v3_v3(fsset->geoStart, domainSettings->bbStart);
        copy_v3_v3(fsset->geoSize, domainSettings->bbSize);
index dc4e4f54fd7fede5b44159f57cab77c7e422aca5..aaebdf579f86f9c3a2cc21bfbf9511984ba12fe5 100644 (file)
@@ -48,6 +48,9 @@ typedef struct FluidVertexVelocity {
        
 typedef struct FluidsimSettings {
        struct FluidsimModifierData *fmd; /* for fast RNA access */
+       /* threadcont the calculation is done with */
+       int threads;
+       int pad1;
        /* domain, fluid or obstacle */
        short type;
        /* display advanced options in fluid sim tab (on=1, off=0)*/
@@ -75,7 +78,7 @@ typedef struct FluidsimSettings {
        int bakeStart, bakeEnd;
        /* offset for baked frames */
        int frameOffset;
-       int pad;
+       int pad2;
        /* g star param (LBM compressibility) */
        float gstar;
        /* activate refinement? */
index 9ff83daa2f828e4a6a5542ca084b535a1536c814..d6ca900397a7cd37c96fd32c2e5bf5be8496e9d6 100644 (file)
@@ -280,6 +280,11 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
 
        /* standard settings */
 
+       prop = RNA_def_property(srna, "threads", PROP_INT, PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "threads");
+       RNA_def_property_range(prop, 1, 32);
+       RNA_def_property_ui_text(prop, "Simulation Threads", "Threads used to calculate the simulation");
+       
        prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "resolutionxyz");
        RNA_def_property_range(prop, 1, 1024);
index b39ddf62c55b9a5f2f63c1423cf10fe590181126..6afe121be904d0cd2bf600d9cd66aad300219f1b 100644 (file)
@@ -75,6 +75,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
                
                fss->fmd = fluidmd;
                fss->type = OB_FLUIDSIM_ENABLE;
+               fss->threads = 4;
                fss->show_advancedoptions = 0;
 
                fss->resolutionxyz = 65;