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

proc tgrid_write_input {} {
    global file_name tgrid_output_path icem_fluent
    global icem_powermesh s2u_path confname
    global file_name

    set outfile tgrid
    set dim2d 0

    set domain [domain_select $file_name(domains_dir) "Select unstructured surface domain." unstruct 0]

    if {$domain == {}} {
	errormsg "No domain selected"
	return
    }
    
    get_boco_topo
    set params {}
    lappend params {dim2d -opt {{3D 0} {2D 1}} \
            -title "Grid Dimension"}
    lappend params {bocofile -type path -title "Boco file"}
    lappend params {outfile -type path -title "Output file"}

    if {![dialog .tgrid "TGrid" \
	    "Please edit the following TGrid options." $params]} return

    # strip extension in case user specified it
    if {[file extension $outfile] == ".msh"} {
	set outfile [file rootname $outfile]
    }

    if {[file exists $outfile.msh] && \
        [query_question .query "Overwrite $outfile.msh?"] != "*okay*"} return



    set command "\"$tgrid_output_path\" -dom \"$domain\""
    if $dim2d {set command "$command -dim2d"}
    if {[file exists $bocofile]} {set command "$command -b \"$bocofile\""}
    set command "$command -tgrid \"$outfile\" "
    
    runcom $command ""
    cmd_rm domain_list
}


