Versions Compared

Key

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

...

Code Block
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
     }
 }


Alternatives

In this section, we will write the coordinates, connectivites, and conditions assuming that the input can be different, such as the one in Matfem . In some codes, like matfem, the input file into the solver is not written in a text file, but in a "code like file". The coordinates section in the matfem solver is a matlab array, with a single comma splitting x and y (x, y) and a semicolon spliting a node from another (x1, y1; x2, y2; ...)

  • Write coordinates:

    Code Block
    %
    % Coordinates
    %
    global coordinates
    coordinates = [
      0.00 , 0.00;
      0.50 , 0.00;
      2.50 , 1.00  ];


    Code Block
        customlib::WriteString "%"
        customlib::WriteString "% Coordinates"
        customlib::WriteString "%"
        customlib::WriteString "global coordinates"
        set nodes [GiD_Mesh list node]
        customlib::WriteString "coordinates = \["
        for {set i 0} {$i < [llength $nodes]} {incr i} {
            set node [lindex $nodes $i]
            lassign [GiD_Mesh get node $node coordinates] x y z
            if {$i < [expr [llength $nodes] -1] } {set end ";"} {set end ""}
            customlib::WriteString "$x , $y $end"
    
        }
        customlib::WriteString "\] ; "