CS838_28_Sep_2011 - Implementation of time integration...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CS838 Advanced Modeling and Simulation Implementation of time integration methods Restructuring of sample code using driver & layout Separates scene layout from simulation algorithms Compartmentalized, reusable operations Switching between integration methods is more straightforward Initially demonstrated on our Forward Euler example WARNING: SOURCE CODE AHEAD!!
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS838 Advanced Modeling and Simulation Implementation of time integration methods Restructuring of sample code using driver & layout Separates scene layout from simulation algorithms Compartmentalized, reusable operations Switching between integration methods is more straightforward Initially demonstrated on our Forward Euler example WARNING: SOURCE CODE AHEAD!!
Background image of page 2
CS838 Advanced Modeling and Simulation Implementation of time integration methods Issues with Fat code organization (i.e. everything in main.cpp) Dif±cult to read (even more so, when we start increasing the complexity) Algorithms and scene setup are not separated WARNING: SOURCE CODE AHEAD!!
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
#include <PhysBAM_Tools/Log/LOG.h> #include <PhysBAM_Tools/Parsing/STRING_UTILITIES.h> #include <PhysBAM_Tools/Read_Write/Utilities/FILE_UTILITIES.h> #include <PhysBAM_Geometry/Geometry_Particles/GEOMETRY_PARTICLES.h> #include <PhysBAM_Geometry/Geometry_Particles/REGISTER_GEOMETRY_READ_WRITE.h> #include <PhysBAM_Geometry/Solids_Geometry/DEFORMABLE_GEOMETRY_COLLECTION.h> #include <PhysBAM_Geometry/Topology_Based_Geometry/SEGMENTED_CURVE.h> #include <PhysBAM_Geometry/Topology_Based_Geometry/FREE_PARTICLES.h> using namespace PhysBAM; int main(int argc,char* argv[]) { typedef float T; typedef float RW; RW rw=RW();STREAM_TYPE stream_type(rw); typedef VECTOR<T,3> TV; LOG::Initialize_Logging(); Initialize_Geometry_Particle();Initialize_Read_Write_Structures(); const int n=11; // Number of particles in wire mesh const int number_of_frames=100; // Total number of frames const T frame_time=.05; // Frame (snapshot) interval const T youngs_modulus=10.; // Elasticity and damping coefficients const T damping_coefficient=10.; const T wire_mass=1.; // Mass and length for entire wire const T wire_length=1.; const T mass=wire_mass/(T)n; // Mass (per each particle) const T restlength=wire_length/(T)(n-1); // Restlength (per each spring) GEOMETRY_PARTICLES<TV> particles;particles.Store_Velocity(); SEGMENTED_CURVE<TV>& wire_curve=*SEGMENTED_CURVE<TV>::Create(particles); wire_curve.mesh.Initialize_Straight_Mesh(n);particles.array_collection->Add_Elements(n); for(int p=1;p<=n;p++) particles.X(p)=TV(0,(T)(1-p)/(T)(n-1),.5); FREE_PARTICLES<TV>& wire_particles=*FREE_PARTICLES<TV>::Create(particles); for(int p=1;p<=n;p++) wire_particles.nodes.Append(p); DEFORMABLE_GEOMETRY_COLLECTION<TV> collection(particles); collection.Add_Structure(&wire_curve);collection.Add_Structure(&wire_particles);
Background image of page 4
DEFORMABLE_GEOMETRY_COLLECTION<TV> collection(particles); collection.Add_Structure(&wire_curve);collection.Add_Structure(&wire_particles); ARRAY<TV> force(n),dX(n),dV(n); T dt_damping=mass*restlength/damping_coefficient; T dt_elastic=damping_coefficient*restlength/youngs_modulus; T CFL_number=0.5;
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

{[ snackBarMessage ]}

Page1 / 62

CS838_28_Sep_2011 - Implementation of time integration...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online