CS838_28_Sep_2011

001frameendtime time layoutwriteoutputframe

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: frame_time; // Frame (snapshot) interval void SIMULATION_LAYOUT<T>::Clear_Values_Of_Kinematic_Particles(ARRAY<TV>& array) const T CFL_number; // CFL number (not to exceed 1) { // Only the first particle is constrained SEGMENTED_CURVE<TV>* wire_curve; array(1)=TV(); FREE_PARTICLES<TV>* wire_particles; } SIMULATION_LAYOUT(const STREAM_TYPE stream_type_input); void Initialize(); void Add_Elastic_Forces(const ARRAY_VIEW<TV>& X,ARRAY<TV>& force); void Add_Damping_Forces(const ARRAY_VIEW<TV>& X,const ARRAY_VIEW<TV>& V, ARRAY<TV>& force); void Add_External_Forces(ARRAY<TV>& force); T Maximum_Dt(); void Write_Output(const int frame); void Set_Kinematic_Positions(const T time,ARRAY_VIEW<TV>& X); void Set_Kinematic_Velocities(const T time,ARRAY_VIEW<TV>& V); void Clear_Values_Of_Kinematic_Particles(ARRAY<TV>& array); }; } CS838 Advanced Modeling and Simulation namespace PhysBAM{ template<class T> class SIMULATION_LAYOUT { public: typedef VECTOR<T,3> TV; const STREAM_TYPE stream_type; const int n; const T youngs_modulus,damping_coefficient const T wire_mass,wire_restlength; ARRAY<T> mass,restlength; // // // // Number of particles in wire mesh Elasticity and damping coefficients Mass and length for entire wire Mass (per each particle), restlength (per each spring) GEOMETRY_PARTICLES<TV> particles; DEFORMABLE_GEOMETRY_COLLECTION<TV> collection; const int number_of_frames; const T frame_time; const T CFL_number; // Total number of frames // Frame (snapshot) interval // CFL number (not to exceed 1) SEGMENTED_CURVE<TV>* wire_curve; FREE_PARTICLES<TV>* wire_particles; SIMULATION_LAYOUT(const STREAM_TYPE stream_type_input); void Initialize(); void Add_Elastic_Forces(const ARRAY_VIEW<TV>& X,ARRAY<TV>& force); void Add_Damping_Forces(const ARRAY_VIEW<TV>& X,const ARRAY_VIEW<TV>& V, ARRAY<TV>& force); void Add_External_Forces(ARRAY<TV>& force); T Maximum_Dt(); void Write_Output(const int frame); void Set_Kinematic_Positions(const T time,ARRAY_VIEW<TV>& X); void Set_Kinematic_Velocities(const T time,ARRAY_VIEW<TV>& V); void Clear_Values_Of_Kinematic_Particles(ARRAY<TV>& array); }; } CS838 Advanced Modeling and Simulation Implementation of time integration methods • Improvement : Factor out a “Layout” class • • main.cpp now only calls the LAYOUT class main.cpp retains the time integration algorithm (for now) CS838 Advanced Modeling and Simulation #include "SIMULATION_LAYOUT.h" using namespace PhysBAM; int main(int argc,char* argv) { typedef float T;typedef float RW;typedef VECTOR<T,3> TV; RW rw=RW();STREAM_TYPE stream_type(rw); LOG::Initialize_Logging(); SIMULATION_LAYOUT<T> layout(stream_type); layout.Initialize();layout.Write_Output(0); T dt_max=layout.Maximum_Dt(),dt,time=0.; for(int frame=1;frame<=layout.number_of_frames;frame++){ T frame_end_time=la...
View Full Document

Ask a homework question - tutors are online