#

# ~cvs/scrib/app_bsm_ford/procedures.tcl

#

# author: jason aftosmis (jason@icemcfd.com)

# date:   april 2002  

#

#

#

proc app_compute_bolt_hole_dia {val} {

    global proc_scrib_data

        

    if [info exists proc_scrib_data(ratio_rings)] {
	set ratio $proc_scrib_data(ratio_rings)
    } else { 
	set ratio 0.6
    }
    if [info exists proc_scrib_data(number_rings)] {
	set Nr $proc_scrib_data(number_rings)
    } else { 
	set Nr 2
    }
    if [info exists proc_scrib_data(mesh_size)] {
	set Msize $proc_scrib_data(mesh_size)
    } else { 
	set Msize 10
    }

     if [info exists proc_scrib_data(Fudge)] {
	set Fudge $proc_scrib_data(Fudge)
	# Note: Fudge does not currently exist in the GUI, but may be added later.
         #           The Fudge factor exists because the equation would otherwise predict the one optimal diameter, but we want a range.
         #           Seting a Fudge factor above 1 allows us to have a range of sizes above optimal.
         #           When time permits, I will make up a way to optimise this so that the optimal size apears in the middle of each range.
    } else { 
	set Fudge 1.25
    }

    set Pi 3.14159265359
    set Ne $val
    set w2w1 [expr 1.0+$ratio*sin(2*$Pi/$Ne)]
    return [expr round($Ne * $Msize * pow(( 1 / $w2w1), $Nr) * $Fudge / $Pi) ]

}

proc app_compute_fillet_length {nodes} {

    global proc_scrib_data

    if [info exists proc_scrib_data(mesh_size)] {
	set Msize $proc_scrib_data(mesh_size)
    } else { 
	set Msize 10
    }

    if [info exists proc_scrib_data(Fudge2)] {
	set Fudge2 $proc_scrib_data(Fudge2)
	# Note: Fudge2 does not currently exist in the GUI, but may be added later.
         #           The Fudge factor exists so I can tweak this setting later.
         #           Seting a Fudge2 factor below 1 means that fillet mesh will be finer than average mesh.
         #           Currently I have it set to 1, which means that the size of elements on the fillet should 
         #           not exceed the overall mesh size setting. 
    } else { 
	set Fudge2 0.75
    }

 
    return [expr round($Msize * ($nodes-1) * $Fudge2) ]
	

}



proc app_bsm_ford_generate_mesh {} {

    #

    # call the export cad function in the scripting library

    #

    stdout "this (scrib_lib_export_cad_bydir) is a trivial call\n"

    stdout "you could call scrib_lib_export_cad_bydir directly!\n"

    scrib_lib_export_cad_bydir

}







