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

proc ls_dyna3d_write_input {} {
    global confname place ls_dyna3d_output_path icem_powermesh
    global file_name

    get_boco_topo
	
    set domain [domain_select $place/domains "Select an unstructured domain." unstruct 0]
    if {$domain == {}} return

    set pname [file rootname [file rootname [file tail $file_name(settings)]]]
	if {$pname==""} {set pname lsdyna}
    
    set outfile $pname.k
#    set bocofile $file_name(family_boco)
    set paramfile $file_name(solver_params)
    
    set ignore_node 0
    set ignore_bar 0
    set ignore_shell 0

    if {![dialog .ls_dyna3d "ls_dyna3d" \
		"Please edit the following ls_dyna3d v960 options." {
			{bocofile -type path -title "bocofile" \
				-help "Boundary Conditions File"}
			{outfile -type path -title "Output file" 
				-help "Output File"}
			{paramfile -type path -title "params file" 
				-help "Solver Parameters File"}
			{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"}
		}]} return
  
    if {![file exists $bocofile]} {
        errormsg "Bound. Cond. file $bocofile doesn't exist"
        return
    }

    if {![file exists $paramfile]} {
	    errormsg "Parameter file $paramfile doesn't exist"
	    return
    }
 
    set command "\"$ls_dyna3d_output_path\" -dom \"$domain\" -b \"$bocofile\" -par \"$paramfile\" -thickness 0"
    if $ignore_node   {set command "$command -ignore_node"}
    if $ignore_bar   {set command "$command -ignore_bar"}
    if $ignore_shell {set command "$command -ignore_shell"}
    set command "$command \"$outfile\""


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

proc lsdyna_set_beam_section_formulation {node node_name var val} {
	array set choices { "Hughes-Liu" 1 "Belytschko-Schwer resultant" 2 \
						"Truss" 3 "Belytschko-Schwer full C/S" 4 \
						"Belytschko-Schwer tubular" 5 "Discrete" 6 \
						"2D plane strain shell" 7 "2D axisymmetric shell" 8 \
						"Springs & Dampers" 10 "Seatbelt" 11 }  
#puts "lsdyna_set_beam_section_formulation $node $node_name $var $val"
	array set src [ic_param_get_values $node]
#puts "src: [array get src]"
	set formul 1
	if [info exists choices($val)] {
	set formul $choices($val)
	}
	if {$formul>10} {
		set formul 1
	}
	array set tgt [ic_param_get_values $node:sec_beam]
#puts "tgt: [array get tgt]"
	set tgt(formul) $src(formul)
	ic_param_set_values $node:sec_beam [array get tgt]
}
