(in-package :clf)

(defun make-output-filename (grid)
  "Return a filename to print field to according to format
`*output-filename-format*'"
  (format nil *output-filename-format* (iteration grid)))

(defun make-nodes-filename (grid)
  (format nil *nodes-filename-format* (iteration grid)))

(defun export-grid (grid &key print-out-border)
  (let ((filename (make-output-filename grid)))
    (format t "Export grid into file ~s... " filename)
    (send-output-to-file filename (print-grid grid :print-out-border print-out-border))
    (format t "OK~%")))

;;(defun export-nodes (grid)
;;  (let ((filename (make-nodes-filename grid)))
;;    (format t "Export nodes into file ~s... " filename)
;;    (send-output-to-file filename (print-nodes grid))
;;    (format t "OK~%")))
;;
;;(defun export-grid&nodes (grid)
;;  (export-grid grid :print-out-border t)
;;  (export-nodes grid))

(defun gridbg (text grid)
  (when *debug-grids-in-make-step*
    (format t "ttt ~a: ~%" text)
    (print-grid grid :print-out-border nil)
    (format t "----~%~%")))