{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS838_28_Sep_2011 - Implementation of time integration...

Info icon This 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!!
Image of page 1

Info icon This 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!!
Image of page 2
CS838 Advanced Modeling and Simulation Implementation of time integration methods Issues with flat code organization (i.e. everything in main.cpp) Difficult to read (even more so, when we start increasing the complexity) Algorithms and scene setup are not separated WARNING: SOURCE CODE AHEAD!!
Image of page 3

Info icon This 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);
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;
Image of page 5

Info icon This 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 ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern