GiD - The personal pre and post processor

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

This functions are based on the implementation of a problemtype for the Frame3DD solver, but can be useful to anyone.


Basic and advanced tcl commands for writing the input file - example

  • How to write a string.

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

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])"


  • Nodes in the mesh

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.


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"


  • Elements assigned to the condition that assigns a material
set condition_name "frameData"
set condition_formats [list {"%1d" "element" "id"} {"%13.5e" "property" "Ax"} {"%13.5e" "property" "Asy"} ... {"%13.5e" "material" "Density"}]
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


  • Contraints

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

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


  • Basic data

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

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"


  • Single load case

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"

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


  • Several load cases

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.

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:

    %
    % Coordinates
    %
    global coordinates
    coordinates = [
      0.00 , 0.00;
      0.50 , 0.00;
      2.50 , 1.00  ];
        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 "\] ; "



  • No labels