CS838_28_Sep_2011

Clearvaluesofkinematicparticlesdx

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ARRAY<TV> force(layout.n),dX(layout.n),dV(layout.n); layout.Add_Elastic_Forces(layout.particles.X,force); layout.Add_Damping_Forces(layout.particles.X,layout.particles.V,force); layout.Add_External_Forces(force); // Apply the Forward Euler method dX=dt*layout.particles.V; // Compute position change for(int p=1;p<=layout.n;p++) dV(p)=(dt/layout.mass(p))*force(p); // Compute velocity change layout.Clear_Values_Of_Kinematic_Particles(dX); layout.Clear_Values_Of_Kinematic_Particles(dV); layout.particles.X+=dX; layout.particles.V+=dV; // Update particle positions and velocities layout.Set_Kinematic_Positions(time+dt,layout.particles.X); layout.Set_Kinematic_Velocities(time+dt,layout.particles.V);} layout.Write_Output(frame);} LOG::Finish_Logging(); } CS838 Advanced Modeling and Simulation [...] int main(int argc,char* argv) { [...] for(int frame=1;frame<=layout.number_of_frames;frame++){ T frame_end_time=layout.frame_time*(T)frame; for(;time<frame_end_time;time+=dt){ dt=std::min(dt_max,(T)1.001*(frame_end_time-time)); layout.Set_Kinematic_Positions(time,layout.particles.X); layout.Set_Kinematic_Velocities(time,layout.particles.V); ARRAY<TV> force(layout.n),dX(layout.n),dV(layout.n); layout.Add_Elastic_Forces(layout.particles.X,force); layout.Add_Damping_Forces(layout.particles.X,layout.particles.V,force); layout.Add_External_Forces(force); // Apply the Forward Euler method dX=dt*layout.particles.V; // Compute position change for(int p=1;p<=layout.n;p++) dV(p)=(dt/layout.mass(p))*force(p); // Compute velocity change layout.Clear_Values_Of_Kinematic_Particles(dX); layout.Clear_Values_Of_Kinematic_Particles(dV); layout.particles.X+=dX; layout.particles.V+=dV; // Update particle positions and velocities layout.Set_Kinematic_Positions(time+dt,layout.particles.X); layout.Set_Kinematic_Velocities(time+dt,layout.particles.V);} layout.Write_Output(frame);} LOG::Finish_Logging(); } CS838 Advanced Modeling and Simulation [...] int main(int argc,char* argv) { [...] for(int frame=1;frame<=layout.number_of_frames;frame++){ T frame_end_time=layout.frame_time*(T)frame; for(;time<frame_end_time;time+=dt){ dt=std::min(dt_max,(T)1.001*(frame_end_time-time)); layout.Set_Kinematic_Positions(time,layout.particles.X); layout.Set_Kinematic_Velocities(time,layout.particles.V); ARRAY<TV> force(layout.n),dX(layout.n),dV(layout.n); layout.Add_Elastic_Forces(layout.particles.X,force); layout.Add_Damping_Forces(layout.particles.X,layout.particles.V,force); layout.Add_External_Forces(force); // Apply the Forward Euler method dX=dt*layout.particles.V; // Compute position change for(int p=1;p<=layout.n;p++) dV(p)=(dt/layout.mass(p))*force(p); // Compute velocity change layout.Clear_Values_Of_Kinematic_Particles(dX); layout.Clear_Values_Of_Kinematic_Particles(dV); layout.particles.X+=dX; layout.particles.V+=dV; // Update particle positions and velocities layout.Set_Kinematic_Positions(time+dt,layout.particles.X); layout.Set_Kinematic_Velocities(t...
View Full Document

Ask a homework question - tutors are online