Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
|
handles integration to find next position and velocity of particles More...
#include <Integration.h>
Public Member Functions | |
Integration (const IntegrationType _integrationType, const ngl::Real _timestep) | |
ctor | |
void | integrateNext (Particle &io_currentParticle) |
integrate next velocity and position of a particle | |
IntegrationType | getIntegrationType () const |
get the integration method | |
void | setIntegrationType (const IntegrationType _v) |
sets the integration method | |
void | setIntegrationType (const int _v) |
set the integration method of the simulation | |
ngl::Real | getTimestep () const |
get the timestep of the simulation | |
void | setTimestep (const ngl::Real _v) |
set the timestep of the simulation | |
Private Member Functions | |
void | evaluateSemiImplicitEuler (Particle &io_currentParticle) |
integrate a particle using semi implicit euler | |
void | evaluateLeapfrog (Particle &io_currentParticle) |
integrate a particle using leapfrog | |
Private Attributes | |
IntegrationType | m_integrationType |
integration method | |
ngl::Real | m_timestep |
timestep of simulation |
handles integration to find next position and velocity of particles
Definition at line 23 of file Integration.h.
Integration::Integration | ( | const IntegrationType | _integrationType, |
const ngl::Real | _timestep | ||
) |
ctor
[in] | _integrationType | the integration method |
[in] | _timestep | the timestep of the simulation |
Definition at line 7 of file Integration.cpp.
{ m_integrationType = _integrationType; m_timestep = _timestep; }
void Integration::evaluateLeapfrog | ( | Particle & | io_currentParticle | ) | [private] |
integrate a particle using leapfrog
[in,out] | io_currentParticle | the particle that is being affected |
Definition at line 36 of file Integration.cpp.
References Particle::getAcceleration(), Particle::getLastAcceleration(), Particle::getPosition(), Particle::getVelocity(), m_timestep, Particle::updatePosition(), and Particle::updateVelocity().
{ //modified leapfrog from http://en.wikipedia.org/wiki/Leapfrog_integration io_currentParticle.updateVelocity(io_currentParticle.getVelocity() + (((io_currentParticle.getLastAcceleration() + io_currentParticle.getAcceleration()) / 2.0) * m_timestep)); io_currentParticle.updatePosition(io_currentParticle.getPosition() + (io_currentParticle.getVelocity() * m_timestep) + ((io_currentParticle.getLastAcceleration() / 2.0) * m_timestep * m_timestep)); }
void Integration::evaluateSemiImplicitEuler | ( | Particle & | io_currentParticle | ) | [private] |
integrate a particle using semi implicit euler
[in,out] | io_currentParticle | the particle that is being affected |
Definition at line 28 of file Integration.cpp.
References Particle::getAcceleration(), Particle::getPosition(), Particle::getVelocity(), m_timestep, Particle::updatePosition(), and Particle::updateVelocity().
{ //semi implicit euler from http://en.wikipedia.org/wiki/Semi-implicit_Euler io_currentParticle.updateVelocity(io_currentParticle.getVelocity() + (io_currentParticle.getAcceleration() * m_timestep)); io_currentParticle.updatePosition(io_currentParticle.getPosition() + (io_currentParticle.getVelocity() * m_timestep)); }
IntegrationType Integration::getIntegrationType | ( | ) | const [inline] |
get the integration method
Definition at line 40 of file Integration.h.
References m_integrationType.
{ return m_integrationType; }
ngl::Real Integration::getTimestep | ( | ) | const [inline] |
get the timestep of the simulation
Definition at line 51 of file Integration.h.
References m_timestep.
{ return m_timestep; }
void Integration::integrateNext | ( | Particle & | io_currentParticle | ) |
integrate next velocity and position of a particle
[in,out] | io_currentParticle | the particle that is being affected |
Definition at line 16 of file Integration.cpp.
References evaluateLeapfrog(), evaluateSemiImplicitEuler(), LEAPFROG, m_integrationType, and SEMI_IMPLICIT_EULER.
{ //calls user-chosen integrator switch (m_integrationType) { case SEMI_IMPLICIT_EULER: { evaluateSemiImplicitEuler(io_currentParticle); break; } case LEAPFROG: { evaluateLeapfrog(io_currentParticle); break; } default : break; } }
void Integration::setIntegrationType | ( | const int | _v | ) | [inline] |
set the integration method of the simulation
[in] | _v | new integration method |
Definition at line 48 of file Integration.h.
References m_integrationType.
{ m_integrationType = (IntegrationType)_v; }
void Integration::setIntegrationType | ( | const IntegrationType | _v | ) | [inline] |
sets the integration method
[in] | _v | the new integration method |
Definition at line 44 of file Integration.h.
References m_integrationType.
{ m_integrationType = _v; }
void Integration::setTimestep | ( | const ngl::Real | _v | ) | [inline] |
set the timestep of the simulation
[in] | _v | new timestep |
Definition at line 55 of file Integration.h.
References m_timestep.
{ m_timestep = _v; }
integration method
Definition at line 60 of file Integration.h.
ngl::Real Integration::m_timestep [private] |
timestep of simulation
Definition at line 63 of file Integration.h.