FLUENT 6 - Scheme file to auto load data files and run journal file (useful in creating animation frames)

DIt is desired to create a transient animation sequence from a set of data files.

A journal file of the sequence of steps to create a single animation frame can be combined with a scheme command to open the series of data files and generate individual frames.



A scheme command was written to take series of data files: (ex: test-0000.dat.gz, test-0001.dat.gz, etc.)
and a journal file for creating a frame in the animation (ex: create_frame.jou).

Scheme command is
(auto-animate "test-" 0 last "create_frame.jou")

where last is the integer of the last data file (ex: if last data file is test-0234.dat.gz, then last = 234)

File is stored in scheme file "auto-animate.scm"

==================================================

Instructions for scheme command "auto-animate"
Author: William Wangard, Ph.D.
Date: April 30, 2003

===================================================

This scheme commmand automates the process for creating images for an animation, or any other repetitive process involving sets of data files.

Consider a set of data files from a transient simulation

square-0001.dat.gz
square-0002.dat.gz
square-0003.dat.gz
...
square-0098.dat.gz
square-0099.dat.gz
square-0100.dat.gz

Suppose that you want to make a movie of contours of some scalar in the domain from each data file and make a movie.

INSTRUCTIONS
============
0. Make sure all of your data files are zipped (having the .gz extension)

1. Next, you create a journal file of the steps needed to create
a single frame in the movie.

... Start recording a JOURNAL file

File->Write->Start Journal...
Give a name like "square_contours.jou"


... record steps to create image on screen ...

Display->Contours->...
...
Turn OFF Auto scaling on your contour plots.
Manually pick the range!
You want the colorbar to have the same range for the entire movie.


... record steps to save a hardcopy of the display ...

Tif files are generally the best to use.
Use color! 640x480 is generally good enough.
You MUST save the name of the image using something
like square_contours-%t.tif.
The %t adds the "time step" to file name. So you will
have square_contours-0001.tif,
square_contours-0002.tif, etc.

... stop recording

File->Write->Stop Journal


2. Edit the journal file.

Remove the last command of the journal file (the one
where it recorded the fact that you stopped recording).
This is because when you re-run the journal file, you will get
an error if this line is encountered.


3. Load the auto-animate command. To do this, place the scheme
in your working directory and type the following in the Fluent
GUI (You MUST include the parentheses!) :

(load "auto-animate.scm")


4. Now, assuming your journal file is named square_contours.jou,
enter the following command at the GUI (including the parentheses):

(auto-animate "square-" 1 100 "square_contours.jou")

This command will sequentially load square-0001.dat.gz
through square-0100.dat.gz and for each of these, run the
journal file "square_contours.jou")

At the end of the process you will have a set of files in
your working directory:
square_contours-0001.tif ... square_contours-0100.tif with
which you can make your movie.


See SOLUTION 738 for how to create an AVI from series of tifs.

==================================================================

========================
SCHEME FILE FOLLOWS
========================
;; auto-animate.scm

;; Scheme file to auto run journal file on sequence of compressed
;; data files.
;;
;; Author: William Wangard, Ph.D.
;;
;; Fluent, Inc.
;; Copyright 2003, All rights reserved.
;;
;; Function to pad a string with zeros to pad-length
(define (pad-zeros name pad-length)
(if (< (string-length name) pad-length)
(begin (pad-zeros (string-append "0" name) pad-length)) name
)
)

;;
;; Function to read (last-first) data files named
;;
;; base000first.dat.gz
;; base000......dat.ga
;; base0000last.dat.gz
;;
;; where first last are integers, base is a string and journal-file-name
;; is a journal file to create an image for animation from the data file
;;
(define (auto-animate base first last journal-file-name)
(if (<= first last)
(begin

; Create index (string) padded with zeros
(define padded-index (pad-zeros (number->string first) 4))

; Create data file string name
(define name (string-append (string-append (string-append base) padded-index) ".dat.gz"))

; Read data file
(read-data name)

; Read animation journal file
(ti-read-journal journal-file-name)

; Recursively call function...
(auto-animate base (+ first 1) last journal-file-name)
)
(begin
(display "Auto-animate is done.")
)
)
)





Show Form
Comments
 
Thanks that solved the problem.
Ali, Tue Aug 28, 2012