Ejemplo n.º 1
0
	//----------------------------------------------------------------------
    void SPH::updateSPHP()
    {
        sphp.mass = settings->GetSettingAs<float>("Mass");
        sphp.rest_density = settings->GetSettingAs<float>("rho0");
        sphp.rest_distance = settings->GetSettingAs<float>("Rest Distance");
        sphp.smoothing_distance = settings->GetSettingAs<float>("Smoothing Distance");
        sphp.simulation_scale = settings->GetSettingAs<float>("Simulation Scale");
        sphp.boundary_stiffness = settings->GetSettingAs<float>("Boundary Stiffness");
        sphp.boundary_dampening = settings->GetSettingAs<float>("Boundary Dampening");
        sphp.boundary_distance = settings->GetSettingAs<float>("Boundary Distance");
        sphp.K = settings->GetSettingAs<float>("Gas Constant");        
        sphp.viscosity = settings->GetSettingAs<float>("Viscosity");
        sphp.velocity_limit = settings->GetSettingAs<float>("Acceleration Limit");
        sphp.xsph_factor = settings->GetSettingAs<float>("XSPH Factor");
        sphp.gravity = settings->GetSettingAs<float>("Gravity"); // -9.8 m/sec^2
        sphp.friction_coef = settings->GetSettingAs<float>("Friction");
        sphp.restitution_coef = settings->GetSettingAs<float>("Restitution");

        //next 3 not used at the moment
        sphp.shear = settings->GetSettingAs<float>("Shear");
        sphp.attraction = settings->GetSettingAs<float>("Attraction");
        sphp.spring = settings->GetSettingAs<float>("Spring");
        //sphp.surface_threshold;

        //constants
        sphp.EPSILON = settings->GetSettingAs<float>("EPSILON");
        sphp.PI = settings->GetSettingAs<float>("PI");       //delicious
        //Kernel Coefficients
        sphp.wpoly6_coef = settings->GetSettingAs<float>("wpoly6");
        sphp.wpoly6_d_coef = settings->GetSettingAs<float>("wpoly6_d");
        sphp.wpoly6_dd_coef = settings->GetSettingAs<float>("wpoly6_dd"); // laplacian
        sphp.wspiky_coef = settings->GetSettingAs<float>("wspiky");
        sphp.wspiky_d_coef = settings->GetSettingAs<float>("wspiky_d");
        sphp.wspiky_dd_coef = settings->GetSettingAs<float>("wspiky_dd");
        sphp.wvisc_coef = settings->GetSettingAs<float>("wvisc");
        sphp.wvisc_d_coef = settings->GetSettingAs<float>("wvisc_d");
        sphp.wvisc_dd_coef = settings->GetSettingAs<float>("wvisc_dd");
        sphp.wspline_coef  = settings->GetSettingAs<float>("wspline_coef");

        //CL parameters
        sphp.num = settings->GetSettingAs<int>("Number of Particles");
        sphp.nb_vars = settings->GetSettingAs<int>("Number of Variables"); // for combined variables (vars_sorted, etc.)
        sphp.choice = settings->GetSettingAs<int>("Choice"); // which kind of calculation to invoke
        sphp.max_num = settings->GetSettingAs<int>("Maximum Number of Particles");
        sphp.cloud_num = settings->GetSettingAs<int>("Number of Cloud Particles");
        sphp.max_cloud_num = settings->GetSettingAs<int>("Maximum Number of Cloud Particles");

        //update the OpenCL buffer
        std::vector<SPHParams> vparams(0);
        vparams.push_back(sphp);
        cl_sphp.copyToDevice(vparams);

        settings->updated();
    }
Ejemplo n.º 2
0
//----------------------------------------------------------------------
FLOCK::FLOCK(RTPSSettings* set, CL* c):System(set,c)
{
    //seed random
    srand ( time(NULL) );

    std::vector<FLOCKParameters> vparams(0);
    vparams.push_back(flock_params);
    cl_FLOCKParameters= Buffer<FLOCKParameters>(cli, vparams);

    calculate();
    updateParams();

    spacing = settings->GetSettingAs<float>("spacing");
    dout<<"spacing ="<<spacing<<endl;

    //set up the grid
    setupDomain(flock_params.smoothing_distance/flock_params.simulation_scale,flock_params.simulation_scale);

    //set up the timers
    setupTimers();

    //setup the sorted and unsorted arrays
    prepareSorted();

#ifdef CPU
    dout<<"RUNNING ON THE CPU"<<endl;
#endif
#ifdef GPU
    dout<<"RUNNING ON THE GPU"<<endl;

    //should be more cross platform
    string flock_source_dir = settings->GetSettingAs<string>("rtps_path") + "/" + std::string(FLOCK_CL_SOURCE_DIR);

    cli->addIncludeDir(flock_source_dir);

    rules = Rules(flock_source_dir, cli, timers["rules_gpu"]);
    euler_integration = EulerIntegration(flock_source_dir, cli, timers["euler_gpu"]);
#endif
        //renderer->setParticleRadius(spacing);
}
Ejemplo n.º 3
0
    void FLOCK::updateFLOCKP(){
        
        // CL SETTINGS
        flock_params.max_num = settings->GetSettingAs<int>("Maximum Number of Particles");
        flock_params.num = settings->GetSettingAs<int>("Number of Particles");

        // SIMULATION SETTINGS
        flock_params.rest_distance = settings->GetSettingAs<float>("Rest Distance");
        flock_params.smoothing_distance = settings->GetSettingAs<float>("Smoothing Distance");
        flock_params.simulation_scale = settings->GetSettingAs<float>("Simulation Scale");

        // SPACING
        spacing = settings->GetSettingAs<float>("Spacing");

        // BOID SETTINGS
        flock_params.min_dist = 0.5f * flock_params.smoothing_distance * settings->GetSettingAs<float>("Min Separation Distance");
        flock_params.search_radius = 0.8f * flock_params.smoothing_distance * settings->GetSettingAs<float>("Searching Radius");
        flock_params.max_speed = settings->GetSettingAs<float>("Max Speed");
        flock_params.ang_vel = settings->GetSettingAs<float>("Angular Velocity");

        // BOID WEIGHTS
        flock_params.w_sep = settings->GetSettingAs<float>("Separation Weight");
        flock_params.w_align = settings->GetSettingAs<float>("Alignment Weight");
        flock_params.w_coh = settings->GetSettingAs<float>("Cohesion Weight");
        flock_params.w_goal = settings->GetSettingAs<float>("Goal Weight");
        flock_params.w_avoid = settings->GetSettingAs<float>("Avoid Weight");
        flock_params.w_wander = settings->GetSettingAs<float>("Wander Weight");
        flock_params.w_leadfoll = settings->GetSettingAs<float>("LeaderFollowing Weight");
        
        // BOID RULE'S SETTINGS 
        flock_params.slowing_distance= settings->GetSettingAs<float>("Slowing Distance");
        flock_params.leader_index = settings->GetSettingAs<int>("Leader Index");
        
        // update the OpenCL buffer
        std::vector<FLOCKParameters> vparams(0);
        vparams.push_back(flock_params);
        cl_FLOCKParameters.copyToDevice(vparams);

        settings->updated();
    }