Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

See how we print the units, we are asking gid for the current active units for the different magnitudes: F for Force, L for Lenght, M for Mass

Code Block
languagetcl
customlib::WriteString "Input Data file for Frame3DD - 3D structural frame analysis ([gid_groups_conds::give_active_unit F],[gid_groups_conds::give_active_unit L],[gid_groups_conds::give_active_unit M])"

...

See how we get the number of nodes of the whole mesh. Also notice the way we are passing the writing format for the coordinates.

Code Block
languagetcl
customlib::WriteString ""
customlib::WriteString "[GiD_Info Mesh NumNodes] # number of nodes"
customlib::WriteString "#.node x y z r"
customlib::WriteString "# [gid_groups_conds::give_active_unit L] [gid_groups_conds::give_active_unit L] [gid_groups_conds::give_active_unit L] [gid_groups_conds::give_active_unit L]"
customlib::WriteString ""
customlib::WriteCoordinates "%5d %14.5e %14.5e %14.5e 0.0\n"

...

This is the way we get the number of nodes assigned to a condition called 'constraints' in the spd.

Code Block
languagetcl
set constraints_list [list "constraints"]
set number_of_constraints [customlib::GetNumberOfNodes $constraints_list]

...

This is the way we access to the data in the tree. Notice that we are building what we call xpath, that is a kind of path in the spd, from the root to the item we want.
Then we get the xml node from the document using selectNodes, and finaly we get the current value with get_domnode_attribute

Code Block
languagetcl
set document [$::gid_groups_conds::doc documentElement] 
 set xpath "/frame3dd_data/container\[@n = 'extraOptions' \]/value\[@n = 'shear_deformation' \]"
 set xml_node [$document selectNodes $xpath]
 set shear_deformation [get_domnode_attribute $xml_node v]
 customlib::WriteString "$shear_deformation # 1=Do, 0=Don't include shear deformation effects"

...

This is the way we get the number of elements assigned to a condition, and then print the element id and the properties assigned to it.
set condition_name "line_Uniform_load"

Code Block
languagetcl
set condition_name "line_Uniform_load"
 set condition_formats [list {"%1d" "element" "id"} {"%13.5e" "property" "Load_x"} {"%13.5e" "property" "Load_y"} {"%13.5e" "property" "Load_z"}]
 set formats [customlib::GetElementsFormats $condition_name $condition_formats]
 set number_of_elements [GiD_WriteCalculationFile elements -count -elemtype Linear $formats]
 customlib::WriteConnectivities $condition_name $formats "" active

...

For the several load case, we will need to iterate over the xml nodes corresponding to the blockdatas that define each load case.
For each load case, we need to print all the loads information, so we need to know if a load has any group assigned.
If so, we'll need to know how many elements are involved, and print them with the properties of the load.

Code Block
languagetcl
set xpath "/frame3dd_data/container\[@n = 'staticCases' \]/blockdata"
 set xml_nodes [$document selectNodes $xpath]
 foreach load_case $xml_nodes {
     set xpath "./condition\[@n = 'uniformLoad' \]/group"
     set groups [$load_case selectNodes $xpath]
     set number_of_elements 0
     set formats_dict [dict create ]
     foreach group $groups {
         set group_name [get_domnode_attribute $group n]
         set Ux_node [$group selectNodes "./value\[@n = 'Ux'\]"]
         set Ux_value [get_domnode_attribute $Ux_node v]
         set Uy_node [$group selectNodes "./value\[@n = 'Uy'\]"]
         set Uy_value [get_domnode_attribute $Uy_node v]
         set Uz_node [$group selectNodes "./value\[@n = 'Uz'\]"]
         set Uz_value [get_domnode_attribute $Uz_node v]
         set format "%5d $Ux_value $Uy_value $Uz_value"
         set formats_dict [dict merge $formats_dict [dict create $group_name $format]]
     }
     set number_of_elements [GiD_WriteCalculationFile elements -count -elemtype Linear $formats_dict]
     if {$number_of_elements > 0} {
     GiD_WriteCalculationFile elements -elemtype Linear $formats_dict
     }
 }

...

  • Write elements:
    Example:

    Code Block
    languagematlab
    %
    % Elements
    %
    global elements
    elements = [
        1,   2,   7 ;
        2,   3,   8 ;
       18,  17,  12 ];


    Code:

    Code Block
    languagetcl
        customlib::WriteString "%"
        customlib::WriteString "% Elements"
        customlib::WriteString "%"
        customlib::WriteString "global elements"
        set elements_t [GiD_Mesh list -element_type Triangle element]
        set elements_q [GiD_Mesh list -element_type Quadrilateral element]
        customlib::WriteString "elements = \["
        for {set i 0} {$i < [llength $elements_t] } {incr i} {
            set element [lindex $elements_t $i]
            lassign [GiD_Mesh get element $element connectivities] c1 c2 c3
            if {$i < [expr [llength $elements_t] -1] } {set end ";"} {set end ""}
            customlib::WriteString "$c1 , $c2 , $c3 $end"
        }
        for {set i 0} {$i < [llength $elements_q] } {incr i} {
            set element [lindex $elements_q $i]
            lassign [GiD_Mesh get element $element connectivities] c1 c2 c3 c4
            if {$i < [expr [llength $elements_q] -1]  } {set end ";"} {set end ""}
            customlib::WriteString "$c1 , $c2 , $c3 , $c4 $end"
        }
        customlib::WriteString "\] ; "

  • Conditions
    Example:

    Code Block
    languagematlab
    %
    % Point loads
    %
    pointload = [
    6, 2, -1.0 ;
    12, 2, -1.0 ;
    18, 2, -1.0 ];


    Code:
    spd

    Code Block
    languagexml
    <condition n="PuntualLoads" pn="Load" ov="point" ovm="node" icon="moad">
        <value n="x-force" pn="Force X" v="0.0" units="N" unit_magnitude="F" />
        <value n="y-force" pn="Force Y" v="0.0" units="N" unit_magnitude="F" />
    </condition>

tcl

Code Block
languagetcl
# Point load
    customlib::WriteString ""
    customlib::WriteString "%"
    customlib::WriteString "% Point loads"
    customlib::WriteString "%"
    customlib::WriteString "pointload = \["
    set displacement_fix_nodes [$root selectNodes "*/condition\[@n='PuntualLoads'\]/group"]
    foreach node $displacement_fix_nodes {
        set group [$node @n]
        set val_x [get_domnode_attribute [$node selectNodes "./value\[@n='x-force'\]"] v]
        set val_y [get_domnode_attribute [$node selectNodes "./value\[@n='y-force'\]"] v]
        set fix_x [expr $val_x == 0.0 ? "false" : "true"]
        set fix_y [expr $val_y == 0.0 ? "false" : "true"]
        set nodes [GiD_EntitiesGroups get $group nodes]
        set num_nodes [objarray length $nodes]

        for {set i 0} {$i < $num_nodes} {incr i} {
            set node_id [objarray get $nodes $i]
            if {$i < [expr $num_nodes -1]  } {set end ";"} {set end ""}
            if {$fix_x eq "true" && $fix_y eq "true"} {set end ";" }
            if {$fix_x eq "true"} { customlib::WriteString "$node_id , 1 , $val_x $end" }
            if {$i < [expr $num_nodes -1]  } {set end ";"} {set end ""}
            if {$fix_y eq "true"} { customlib::WriteString "$node_id , 2 , $val_y $end" }
        }
    }
    customlib::WriteString "\] ; "

...