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

proc vectis_write_input {} {
    global confname file_name vectis_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)/vectis
    set double_precision 0
    set orient 0
    set scale 0
    set x 1.0
    set y 1.0
    set z 1.0

    if {![dialog .vectis "VECTIS" \
          "Please edit the following VECTIS options." {
	       {orient -opt {{"No" 0} {"Yes" 1}}\
                   -title "Automatic alignment of surface normals"}
	       {double_precision -opt {{"Single" 0} {"Double" 1}}\
                   -title "Precision"}
               {scale -opt {{"Yes" 1} {"No" 0}} -title "Scaling"\
                           -help "Scaling of coordinates of geometry file"}
               {x -type string -active {$scale} -title "x scaling factor" \
                           -help "Enter x scaling factor"}
               {y -type string -active {$scale} -title "y scaling factor" \
                           -help "Enter y scaling factor"}
               {z -type string -active {$scale} -title "z scaling factor" \
                           -help "Enter z scaling factor"}

               {bocofile -type path -title "Boco file" \
                   -help "Boundary condition file"}
	       {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 "\"$vectis_output_path\" -dom \"$domain\" -b \"$bocofile\""
    if $double_precision {set command "$command -dp"}
    if $orient {set command "$command -orient"}
    if $scale {set command "$command -scale $x,$y,$z"}
    set command "$command \"$outfile\""

    runcom $command ""
}
