

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

proc fidap_write_input {} {
    global confname file_name fidap_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 outputfile $file_name(transfer_dir)/fidap
    set toler 0.0
    set unsh_sf 0
    set edg_thin 0
    set fam_group 1

    if {![dialog .fidap "Fidap" \
	  "Please edit the following fidap options.  This program creates \
a Fidap version 7.0 neutral file." {
	       {outputfile -type path -title "Set prefix of output file(s)"}
	       {bocofile -type path -title "Boundary condition file" }
               {fdread -opt {{Yes 1} {No 0}} -title "Create FDREAD file"
		   -help "Create FDREAD file"}
               {fam_group -opt {{Yes 1} {No 0}} \
                   -title "Create groups according to mesher families" \
		   -active {!$unsh_sf}}
	       {unsh_sf -opt {{Yes 1} {No 0}} \
		   -title "Add groups for untagged boundaries (3D)" \
		   -active {!$fam_group} -help "Create groups with external subfaces"}
	       {edg_thin -opt {{Yes 1} {No 0}} \
		   -title "Thin edges overwrite non-thin edges" \
		   -help "Set precedence at nodes on edge intersections"}
	       {toler -type string -title "Zero tolerance" \
                      -help "Each coordinates smaller than the given value is set to zero."}
	   }]} 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 "\"$fidap_output_path\" -dom \"$domain\" \
		-b \"$bocofile\" -o \"$outputfile\" -tol $toler"
    if {$fdread} {set command "$command -fdread"}
    if {$fam_group} {set command "$command -fam"}
    if {$unsh_sf && !$fam_group} {set command "$command -unsh_sf"}
    if {$edg_thin} {set command "$command -edg_thin"}
    
    runxcom ICEM-CFD/FIDAP-Interface $command "" 1 0
}
