
# ICEM CFD solver interface routine for the manager.
#
# Copyright (c) 1993-1995 ICEM Systems.

proc fastu_write_input {} {
    global file_name fastu_output_path
    global file_name
    
    if ![ic_uns_is_loaded] {
      mess "Please load the mesh file before calling the translator.\n"
      return 1
    }
    set domain $file_name(domain)
# set domain [domain_select $file_name(domains_dir) "Select an unstructured domain." unstruct 0]
    if {$domain == {}} return
    
    set types [ic_uns_list_types]
    if {([lsearch -regexp $types  TETRA_4] < 0) && \
        ([lsearch -regexp $types  TRI_3] < 0)} {
	mess "Fastu interface supports only TRI and TETRA meshes.\n" red
        return 1
    }

    set outfile "$file_name(transfer_dir)/fastu"
    set stuff {{"Unformatted output" "Formatted output" "" "" "Binary output"}
	       {"Triangles only" "Tetras and triangles" "" ""}}
   
    if {![dialog .fastu "Fastu" \
	  "Please edit the following fastu options. \
If you request a binary file, the suffix .bin \
will be added to the output file, for an unformatted file the suffix .dat \
will be used, and .fmt is used for a formatted file." {
               {form -opt {{Formatted 0} {Unformatted 1} {Binary 2}} \
		   -title "Output type" -help "Output type"}
	       {trionly -opt {{"Triangles only" 1} {"Tetras and triangles" 0}} \
		   -title "Element types" -help "Types of elements to use"}
	       {outfile -type path -title "Output file" -help "Output file"}
	   }]} return
    
    case $form in {
	1 {
	    # set outfile $outfile.dat
	    set options "-u"
	}
	0 {
	    # set outfile $outfile.fmt
	    set options ""
	}
	2 {
	    # set outfile $outfile.bin
	    set options "-bin"
	}
    }
    if {!$trionly} {set options "$options -tetra"}
    
    set command "\"$fastu_output_path\" $options \"$domain\" \"$outfile\""
    
    runcom $command ""
}
