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

proc crunch_write_input {} {
    global confname file_name crunch_output_path icem_powermesh
    global file_name

    get_boco_topo

    set outfile $file_name(transfer_dir)/crunch_cfd.precrunch
    if {[info exists file_name(domain)] && [file isfile $file_name(domain)]} {
        set domainfile $file_name(domain)
    } else {
        set domainfile $file_name(domains_dir)/hex.uns
    }
    set mvgrd 0
    if {![dialog .crunch "CRUNCH CFD" \
	    "Please edit the following CRUNCH CFD options." {

        {domainfile -type path -title "Domain file" -help "Domain file"}
        {bocofile -type path -title "Boundary condition file" \
		-help "Boundary condition file"}
        {outfile -type path -title "Output file" -help "Output file"}
        {mvgrd -opt {{Yes 1} {No 0}} -title "Is this a moving grid?"}
    }]} return
	
    if {![file exists $domainfile]} {
        errormsg "Domain file doesn't exist!"
        return
    }
    if {![file exists $bocofile]} {
        errormsg "Boco file doesn't exist!"
        return
    } else {
        set send_boco 1
    }
 
    set command   "\"$crunch_output_path\" -d \"$domainfile\" -o \"$outfile\""
    if $send_boco {set command "$command -b \"$bocofile\""}
    if $mvgrd     {set command "$command -mvgrd"}

    runcom $command ""
}
#
# For documentation on this format, see the file lib/iceman/solver_table.tcl

#set solver_boco_info(crunch) {
#    { MVGRD {Moving Grid} subface {flag 2} {
#        { {Tagging name}                {flag 1}  string "*famname*" }
#        { {X-directed velocity}         {value 2} float  0.0 }
#        { {Y-directed velocity}         {value 3} float  0.0 }
#        { {Z-directed velocity}         {value 4} float  0.0 }
#    } }
#    
#    { USER {User-set source} {subface domain} {flag 2} {
#        { {Tagging name}                {flag 1}  string "*famname*" }
#    } }
#}











