I make a script to extract Mx from the result file of the recorder but it is inefficient!,
#get the moment around the z-axis from file " PierElement-Lf_$idaSa-E$earthquake.out" put them into PierElement-LMZ_$idaSa-E$earthquake.out"
set start [open PierElement-Lf_$idaSa-E$earthquake.out r]
set ctr 0;
foreach line [split [read -nonewline $start] \n] {
set ctr [expr $ctr+1];
set lineSize($ctr) [llength $line];
set lineData($ctr) $line;
set lineNumber $ctr;
}
#-------------------------------------------------------------------
for {set i 1} {$i <= $lineNumber } {incr i 1} {
for {set j 1} {$j <= $lineSize($i)} {incr j 1} {
# puts "lineSize($i) $lineSize($i)"
set matrixa($i,$j) [lindex $lineData($i) [expr $j-1]]
# puts "data($i,$j) $matrixa($i,$j)"
}
}
#---------------------------------------------------------------------
set MZ [open "PierElement-LMZ_$idaSa-E$earthquake.out" a]
for {set i 1} {$i <= $lineNumber } {incr i 1} {
puts -nonewline $MZ "$matrixa($i,1) "
for {set j 2} {$j <=[expr ($lineSize($i)-1)/12+1]} {incr j 1} {
puts -nonewline $MZ "$matrixa($i,[expr 12*($j-2)+7]) "
}
puts -nonewline $MZ "\n"
}
close $MZ
altough the result is right, but the efficience is so low, it needs 40 minutes to extract all the forces (69element, 12forces =689column)(time =4000*0.01=40sec)!
do you have any idea to solve this problem!
I make a Script to extract Mx from the result file?!
Moderators: silvia, selimgunay, Moderators
-
- Posts: 7
- Joined: Wed Mar 28, 2007 9:03 am
- Location: BEIJING UNIVERSITY OF CIVIL ENGINEERING AND ARCHITECTURE
you should do it all within one loop.
tcl is not very efficient in reading data files because it does not do the scanf, it uploads the entire file.
you might want to try it in matlab, instead.
tcl is not very efficient in reading data files because it does not do the scanf, it uploads the entire file.
you might want to try it in matlab, instead.
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
All of the following suggestions are straight from the tcler's wiki which I've found very useful when writing any useful tcl code.
wiki.tcl.tk/348
-Increasing the channel buffer size using fconfigure helps for large files or tell read exactly the size to read
set size [file size "myFile"]
....[read $myFileID $size]
-Put all that stuff in a procedure. Inline Tcl code doesn't get all the optimizations that a procedure can get
Also, all the optimizations would be useless if you are reading files from a network drive. File reading and writing is way faster if these giant files are on your local machine.
wiki.tcl.tk/348
-Increasing the channel buffer size using fconfigure helps for large files or tell read exactly the size to read
set size [file size "myFile"]
....[read $myFileID $size]
-Put all that stuff in a procedure. Inline Tcl code doesn't get all the optimizations that a procedure can get
Also, all the optimizations would be useless if you are reading files from a network drive. File reading and writing is way faster if these giant files are on your local machine.