Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
src/Integration.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 #include "Integration.h"
00005 
00006 Integration::Integration
00007                 (
00008                     const IntegrationType _integrationType,
00009                     const ngl::Real _timestep
00010                 )
00011 {
00012     m_integrationType = _integrationType;
00013     m_timestep = _timestep;
00014 }
00015 
00016 void Integration::integrateNext(Particle &io_currentParticle)
00017 {
00018     //calls user-chosen integrator
00019     switch (m_integrationType)
00020     {
00021         case SEMI_IMPLICIT_EULER: { evaluateSemiImplicitEuler(io_currentParticle); break; }
00022         case LEAPFROG: { evaluateLeapfrog(io_currentParticle); break; }
00023 
00024         default : break;
00025     }
00026 }
00027 
00028 void Integration::evaluateSemiImplicitEuler(Particle &io_currentParticle)
00029 {
00030     //semi implicit euler from http://en.wikipedia.org/wiki/Semi-implicit_Euler
00031     io_currentParticle.updateVelocity(io_currentParticle.getVelocity() + (io_currentParticle.getAcceleration() * m_timestep));
00032 
00033     io_currentParticle.updatePosition(io_currentParticle.getPosition() + (io_currentParticle.getVelocity() * m_timestep));
00034 }
00035 
00036 void Integration::evaluateLeapfrog(Particle &io_currentParticle)
00037 {
00038     //modified leapfrog from http://en.wikipedia.org/wiki/Leapfrog_integration
00039     io_currentParticle.updateVelocity(io_currentParticle.getVelocity() + (((io_currentParticle.getLastAcceleration() + io_currentParticle.getAcceleration()) / 2.0) * m_timestep));
00040 
00041     io_currentParticle.updatePosition(io_currentParticle.getPosition() + (io_currentParticle.getVelocity() * m_timestep) + ((io_currentParticle.getLastAcceleration() / 2.0) * m_timestep * m_timestep));
00042 }
00043 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator