fluid-project   xtlang


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

Implementation

(bind-func fluid-project
  (lambda (velocx:double* velocy:double* velocz:double* p:double* div:double* iter N)
    (let ((j 0)
    (k 0)
    (i 0)
    (kk 0)
    (jj 0)
    (ii 0))
    (dotimes (k (- N 2))
      (dotimes (j (- N 2))
  (dotimes (i (- N 2))
    (pset! div (fluid-ix (+ i 1) (+ j 1) (+ k 1) N)
     (* -0.5 (/ (+ (- (pref velocx (fluid-ix (+ i 2) (+ j 1) (+ k 1) N))
          (pref velocx (fluid-ix i (+ j 1) (+ k 1) N)))
             (- (pref velocy (fluid-ix (+ i 1) (+ j 2) (+ k 1) N))
          (pref velocy (fluid-ix (+ i 1) j (+ k 1) N)))
             (- (pref velocz (fluid-ix (+ i 1) (+ j 1) (+ k 2) N))
          (pref velocz (fluid-ix (+ i 1) (+ j 1) k N))))
          (i64tod N))))
    (pset! p (fluid-ix (+ i 1) (+ j 1) (+ k 1) N) 0.0)
    1)))


Back to Index

Similar Entries