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

proc cobalt_write_input {} {
    global confname file_name cobalt_output_path icem_powermesh
    global file_name

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

    set outfile $file_name(transfer_dir)/cobalt

    get_boco_topo

    set scale 0
    set x 1.0
    set y 1.0
    set z 1.0
    set offset 0

    if {![dialog .cobalt "Cobalt" \
          "Please edit the following Cobalt options." {
               {bocofile -type path -title "bocofile" \
                        -help "Boundary Conditions File"}
	       {offset -type string -title "Specify Offset for Boundary Patch Numbering"}
               {outfile -type path -title "Output file" -help "Output File"}
	       {scale -opt {{"Yes" 1} {"No" 0}} -title "Scaling"}
               {x -type string -active {$scale} -title "x scaling factor" }
               {y -type string -active {$scale} -title "y scaling factor" }
               {z -type string -active {$scale} -title "z scaling factor" }
	       {formatted -opt {{Formatted 1} {Unformatted 0}} \
                -title "Output type" -help "Output type"}
	       {double -opt {{Single 0} {Double 1}} -title Precision -help "Precision"}
           }]} return
  
    if {![file exists $domain]} {
        errormsg "Domain file $domain doesn't exist"
        return
    }

    set command "\"$cobalt_output_path\" -dom \"$domain\" -b \"$bocofile\" -offset $offset"
    if $formatted   {set command "$command -fmt"}
    if $double {set command "$command -double"}
    if $scale   {set command "$command -scale $x,$y,$z"}
    set command "$command \"$outfile\""

    runxcom ICEM-CFD/Cobalt-Interface $command "" 1 0
}
