fluid-cube-get-row   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/external/fluid2d.xtm

Implementation

;; where type is the ref into cube
;; 5 for density
;; 6 for x velocity
;; 7 for y velcority
(bind-func fluid-cube-get-row 10000
  (let ((_ds:double* (salloc 2000))
  (_xs:double* (salloc 2000))
  (_ys:double* (salloc 2000)))
    (lambda (cube:fluidcube* type:i32 offset:i64)
      (let ((xN (tref cube 0))
      (yN (tref cube 10))
      (ds (tref cube 5))
      (xs (tref cube 6))
      (ys (tref cube 7))
      (s (cond ((= type 5) ds)
         ((= type 6) xs)
         ((= type 7) ys)
         (else (printf "error\n") ds)))
      ;; (dat (cond ((= type 5) _ds)
      ;;         ((= type 6) _xs)
      ;;         ((= type 7) _ys)
      ;;         (else _ds)))
      (dat:double* (halloc xN))
      (i 0))
  ;(printf "type:%d:%p\n" type s)
  (dotimes (i xN)
    (pset! dat i (pref s (+ i offset))))
  ;(if (= type 5) (printf "get: %f\n" type (pref dat 100)))
  dat))))


Back to Index