Fluent Scheme 中 Custom Field Function 相关操作

在 Fluent 中,Custom Field Function(CFF) 对于后处理得到想要间接结果是一个非常有用的工具。Fluent Scheme 中提供了一些 procedure 进行操作。


(1)  定义一个 CFF --- custom-field-function/define


下面定义的是一个求到点 (x,y,z) 距离的一个 CFF,定义起来是蛮繁琐的。


;;
(define (hy-cff-distance-define cffname x y z)
  (if (string? cffname)
    (set! cffname (string->symbol cffname))
    #f
  )
  (define opsym-x "-")
  (define fsym-x 'field--)
  (if (< x 0)
    (begin
      (set! opsym-x "+")
      (set! fsym-x 'field-+)
       (set! x (- x))
    )
    #f
  )
  (define opsym-y "-")
  (define fsym-y 'field--)
  (if (< y 0)
    (begin
      (set! opsym-y "+")
      (set! fsym-y 'field-+)
       (set! y (- y))
    )
    #f
  )
  (define opsym-z "-")
  (define fsym-z 'field--)
  (if (< z 0)
    (begin
      (set! opsym-z "+")
      (set! fsym-z 'field-+)
       (set! z (- z))
    )
    #f
  )
  (custom-field-function/define
    (list
     (list
      (list 'name cffname)
      (list 'display (format #f "sqrt ((x ~a ~a) ^ 2 + (y ~a ~a) ^ 2) + (z ~a ~a) ^ 2)" opsym-x x opsym-y y opsym-z z))
      (list 'syntax-tree
        (list
          "sqrt"
          (list "+"
            (list "+"
              (list "**" (list opsym-x "x-coordinate" x) 2)
              (list "**" (list opsym-y "y-coordinate" y) 2)
            )
            (list "**" (list opsym-z "z-coordinate" z) 2)
          )
        )
      )
      (list 'code
        (list 'field-sqrt
          (list 'field-+
            (list 'field-+
              (list 'field-** (list fsym-x (list 'field-load "x-coordinate") x) 2)
              (list 'field-** (list fsym-y (list 'field-load "y-coordinate") y) 2)
            )
            (list 'field-** (list fsym-z (list 'field-load "z-coordinate") z) 2)
          )
        )
      )
     )
    )
  )
)



(2) 删除 CFF


(define (hy-cff-delete cffname)
  (cx-delete-cf cffname)
)



(3) 其他就是 load/save 之类的功能


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值