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



proc  abaqus_get_families {} {
    global  famboco_data
    set ret ""
    foreach f [array names  famboco_data] {
        lappend ret "$f $f"
    }
    return $ret
}
proc abaqus_write_input {} {
    global confname abaqus_output_path place
    global file_name

	if [info exists file_name(domains_dir)] {
		set domdir $file_name(domains_dir)
	} else {
		set domdir $place/domains
	}

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

    set pname [file rootname [file rootname [file tail $file_name(settings)]]]
	if {$pname==""} {set pname abaqus}
    
    set outfile $pname.inp
#    set bocofile $file_name(family_boco)
    set parfile $file_name(solver_params)
    
	set ignore_node 0
	set ignore_bar 0
	set ignore_shell 0
	set mesh_dump 0
	set internal 0

    	get_boco_topo

    	if {![dialog .abaqus "abaqus" \
		"Please edit the following abaqus v6.2 options." {
			{bocofile -type path -title "bocofile" \
				-help "Boundary Conditions File"}
			{outfile -type path -title "Output file" 
				-help "Output File"}
			{parfile -type path -title "Par file" 
				-help "Solver Parameter File"}
			{mesh_dump -opt {{"yes" 1} {"no" 0}}
			-title "Write all elements"}
			{ignore_node -opt {{"yes" 1} {"no" 0}}
			-title "Ignore NODE elements"}
			{ignore_bar -opt {{"yes" 1} {"no" 0}}
			-title "Ignore BAR elements"}
			{ignore_shell -opt {{"yes" 1} {"no" 0}} 
		        -title "Ignore SHELL elements"}
			{internal -opt {{"yes" 1} {"no" 0}}
			-title "Use internal element numbering"}
		}
	]} return
  
    if {![file exists $domain]} {
        errormsg "Domain file $domain doesn't exist"
        return
    }

    	if {![file exists $bocofile]} {
        	errormsg "Bound. Cond. file $bocofile doesn't exist"
        	return
    	}

    if {![file exists $parfile]} {
        errormsg "File $parfile doesn't exist"
		errormsg "Please open ABAQUS params menu, set solver parameters"
		errormsg "and Press <Accept> button to create abaqus.par file."
        return
    }
	
    	set command "\"$abaqus_output_path\" -dom \"$domain\" -b \"$bocofile\" -par \"$parfile\""
    	if $ignore_node {set command "$command -ignore_node"}
    	if $ignore_bar {set command "$command -ignore_bar"}
    	if $ignore_shell {set command "$command -ignore_shell"}
    	if $mesh_dump {set command "$command -mesh_dump"}
        if $internal {set command "$command -internal"}
	set command "$command \"$outfile\""

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

