Ejemplo n.º 1
0
Archivo: sim.cpp Proyecto: mtao/MSc
void MACStableFluids::step(Scalar dt)
{
    float t=0;
    int count=0;
    while(t<dt)
    {
        float substep=cfl();

        if(substep<0.000001)
        {
            std::cerr << "SUBSTEP GOING TOO LOW QUITTING\n";
            return;
        }
        if(t+substep > dt)
            substep=dt-t;


        add_force(dt);
        advect(dt);
        diffuse(dt);
        project(dt);
        advect_particles(dt);
        ++count;
        t+=substep;
    }
    time += dt;


}
//The main fluid simulation step
void FluidSim::advance(float dt) {
   float t = 0;
   
   while(t < dt) {
      float substep = cfl();   
      if(t + substep > dt)
         substep = dt - t;
   
      //Passively advect particles
      advect_particles(substep);
     
      //Estimate the liquid signed distance
      compute_phi();

      //Advance the velocity
      advect(substep);
      add_force(substep);

      apply_viscosity(substep);

      apply_projection(substep); 
      
      //Pressure projection only produces valid velocities in faces with non-zero associated face area.
      //Because the advection step may interpolate from these invalid faces, 
      //we must extrapolate velocities from the fluid domain into these zero-area faces.
      extrapolate(u, u_valid);
      extrapolate(v, v_valid);

      //For extrapolated velocities, replace the normal component with
      //that of the object.
      constrain_velocity();
   
      t+=substep;
   }
}
Ejemplo n.º 3
0
//The main fluid simulation step
void FluidSim::advance(float dt) {
   
   //Passively advect particles
   advect_particles(dt);

   //Advance the velocity
   advect(dt);
   add_force(dt);
   project(dt); 
   
   //Pressure projection only produces valid velocities in faces with non-zero associated face area.
   //Because the advection step may interpolate from these invalid faces, 
   //we must extrapolate velocities from the fluid domain into these zero-area faces.
   extrapolate(u, u_weights, valid, old_valid);
   extrapolate(v, v_weights, valid, old_valid);
   
   //For extrapolated velocities, replace the normal component with
   //that of the object.
   constrain_velocity();
   
}
Ejemplo n.º 4
0
//The main fluid simulation step
void FluidSim::advance(float dt) {
   float t = 0;

   while(t < dt) {
      float substep = cfl();   
      if(t + substep > dt)
         substep = dt - t;
      printf("Taking substep of size %f (to %0.3f%% of the frame)\n", substep, 100 * (t+substep)/dt);
      
      printf(" Surface (particle) advection\n");
      advect_particles(substep);

      printf(" Velocity advection\n");
      //Advance the velocity
      advect(substep);
      add_force(substep);
      
      printf(" Solve viscosity");
      apply_viscosity(substep);

      printf(" Pressure projection\n");
      project(substep); 
       
      //Pressure projection only produces valid velocities in faces with non-zero associated face area.
      //Because the advection step may interpolate from these invalid faces, 
      //we must extrapolate velocities from the fluid domain into these invalid faces.
      printf(" Extrapolation\n");
      extrapolate(u, u_valid);
      extrapolate(v, v_valid);
      extrapolate(w, w_valid);
    
      //For extrapolated velocities, replace the normal component with
      //that of the object.
      printf(" Constrain boundary velocities\n");
      constrain_velocity();

      t+=substep;
   }
}