The scripts below show examples of procedures defining a Tdyn Tcl extension. In order to execute these procedures, they have to be saved to a file and the file has to be inserted in theTcl extension entry in the Data > Problem Data | OTHER page.
proc TdynTcl_AssembleFluidSpecies { ispecies } {
# Reading Tdyn internal time
set t [TdynTcl_Time]
# Writing a message in Tdyn info window
TdynTcl_Message "Executing TdynTcl_AssembleFluidSpecies $ispecies: time $t" notice
}
proc TdynTcl_AssembleFluidPressure { } {
# Reading the number of total nodes
set nnode [TdynTcl_NNode 0]
# Imposing boundary conditions
for { set i 1 } { $i <= $nnode } { incr i } {
# Check if the node is in the fluid domain
if { [TdynTcl_IsFluid $i] } {
# Read y coordinate of the node i
set y [TdynTcl_Coord $i 2]
# Fix degree of freedom i to y^2+1
TdynTcl_FixSystemRow $i [expr pow($y,2)+1]
}
}
}
proc TdynTcl_FinishStep { } {
# Open file "C:/Temp/writing_in_this_file" ...
cd {C:/Temp}
set fileid [open writing_in_this_file w+]
# ... and writes some info for a list of nodes
set nodelist [list 1 2 3 4 5]
puts $fileid "Velocity info for time $t"
foreach inode $nodelist {
puts $fileid "Velocity of node $inode: \
[TdynTcl_VecVal vx $inode] \
[TdynTcl_VecVal vy $inode] \
[TdynTcl_VecVal vz $inode]"
}
# Finally close the file
close $fileid
}