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

proc ideas_write_input {} {
    global confname file_name ideas_output_path icem_powermesh
    global file_name

    set domain [domain_select $file_name(domains_dir) "Select an unstructured domain." unstruct 0]
    if {$domain == {}} return
   
    get_boco_topo

    set outfile $file_name(transfer_dir)/ideas
    set beam_elements 0
    set shell_elements 1
    set unit_164 0
    set length 1.0
    set user_color 1

    if {![dialog .ideas "IDEAS" \
          "Please edit the following IDEAS options." {
               {bocofile -type path -title "Boco file" \
                   -help "Boundary condition file"}
	       {shell_elements -opt {{"Yes" 1} {"No" 0}} \
		   -title "Create shell elements"}
	       {beam_elements -opt {{"Yes" 1} {"No" 0}} \
		   -title "Create beam elements"}
	       {unit_164 -opt {{"Yes" 1} {"No" 0}} \
		   -title "Create unit 164"}
	       {length -type string -active {$unit_164} \
		   -title "Length value in unit 164 (Record 2, Field 1)"}
               {user_color -opt {{"User defined" 1} {"Automatic" 0}} \
                   -title "Color id"}
	       {outfile -type path -title "Output file" -help "Output file"}
           }]} return

   
    if {![file exists $domain]} {
        errormsg "Domain file $domain doesn't exist"
        return
    }

    if {![file exists $bocofile]} {
        errormsg "File $bocofile doesn't exist"
        return
    }

#   set command "\"$ideas_output_path\" -dom \"$domain\" -b \"$bocofile\" -config \"$confname\""
    set command "\"$ideas_output_path\" -dom \"$domain\" -b \"$bocofile\""
    if $shell_elements {set command "$command -shell"}
    if $beam_elements {set command "$command -beam"}
    if $unit_164 {set command "$command -u164 -length $length"}
    if $user_color {set command "$command -ucolor"}
    set command "$command \"$outfile\""

    runcom $command ""
}
