Last active
March 28, 2018 19:28
-
-
Save sebbbi/2371bd0b67056df990f7d34c5505fcb2 to your computer and use it in GitHub Desktop.
BDF2 integrator in HLSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void BFD2(inout ParticleSimulationData Particle, float3 Accel) | |
{ | |
float3 x = Particle.Position; | |
float3 v = Particle.Velocity; | |
float3 x1 = Particle.PositionPrev; | |
float3 v1 = Particle.VelocityPrev; | |
Particle.Position = (4.0/3.0) * x - (1.0/3.0) * x1 + 1.0 * ((8.0/9.0) * v - (2.0/9.0) * v1 + (4.0/9.0) * TimeStep2 * Accel); | |
Particle.PositionPrev = x; | |
} | |
void BDF2VelocityUpdate(inout ParticleSimulationData Particle) | |
{ | |
Particle.Velocity = (3.0/2.0) * Particle.Position - 2.0 * Particle.PositionPrev + 0.5 * Particle.PositionPrev2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment