LuaJIT FFI to Fortran iso_c_binding example
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.lua 705B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env luajit
  2. local particle = require("particle")
  3. local verlet = require("verlet")
  4. local part = particle(10000)
  5. assert(part.n == 10000)
  6. for i = 0, part.n-1 do
  7. part.pos[i].x = 6*i + 1
  8. part.pos[i].y = 6*i + 2
  9. part.pos[i].z = 6*i + 3
  10. part.vel[i].x = 6*i + 4
  11. part.vel[i].y = 6*i + 5
  12. part.vel[i].z = 6*i + 6
  13. end
  14. local dt = 1
  15. for step = 1, 100 do
  16. verlet.integrate(part, dt)
  17. for i = 0, part.n-1 do
  18. assert(part.pos[i].x == 6*i + 1 + (6*i + 4)*step)
  19. assert(part.pos[i].y == 6*i + 2 + (6*i + 5)*step)
  20. assert(part.pos[i].z == 6*i + 3 + (6*i + 6)*step)
  21. assert(part.vel[i].x == 6*i + 4)
  22. assert(part.vel[i].y == 6*i + 5)
  23. assert(part.vel[i].z == 6*i + 6)
  24. end
  25. end