fluid-advect   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/fluid_dynamics.xtm

Implementation

(bind-func fluid-advect
  (lambda (b:i64 d:double* d0:double* velocx:double* velocy:double* velocz:double* dt:double N:i64)
    (let ((n-2 (i64tod (- N 2)))
    (dtx (* dt n-2))
    (dty dtx)
    (dtz dty)
    (kfloat 0.0) (jfloat 0.0) (ifloat 0.0)
    (s0 0.0) (s1 0.0) (t0 0.0) (t1 0.0) (u0 0.0) (u1 0.0)
    (i0 0.0) (i0i:i64 0) (i1 0.0) (i1i:i64 0)
    (j0 0.0) (j0i:i64 0) (j1 0.0) (j1i:i64 0)
    (k 0) (j 0) (i 0)
    (tmp1 0.0) (tmp2 0.0) (tmp3 0.0)
    (x 0.0) (y 0.0) (z 0.0)
    (k0 0.0) (k0i:i64 0) (k1 0.0) (k1i:i64 0)
    (Nfloat (i64tod N)))
      (dotimes (k (- N 2))
  (set! kfloat (+ kfloat 1.0))
  (set! jfloat 0.0)
  (dotimes (j (- N 2))
    (set! jfloat (+ jfloat 1.0))
    (set! ifloat 0.0)
    (dotimes (i (- N 2))
      (set! ifloat (+ ifloat 1.0))
      (set! tmp1 (* dtx (pref velocx (fluid-ix (+ i 1) (+ j 1) (+ k 1) N))))
      (set! tmp2 (* dty (pref velocy (fluid-ix (+ i 1) (+ j 1) (+ k 1) N))))
      (set! tmp3 (* dtz (pref velocz (fluid-ix (+ i 1) (+ j 1) (+ k 1) N))))
      (set! x (- ifloat tmp1))
      (set! y (- jfloat tmp2))
      (set! z (- kfloat tmp3))


Back to Index

Similar Entries