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