This script will generate cut sections in CFD++/Tecplot format from a CFD++ solution file.
Techplot cut sections can be visualized in ParaView.
How to use this script:
Save the below script with a name say cfd_cuts and execute it in following way:
./cfd_cuts Min Max Number_of_cuts Axis
For example to make 10 cuts in X direction starting from 1.2 to 3 issue following command:
./cfd_cuts 1.2 3 10 x
#!/usr/bin/tclsh8.4
#User inputs
#Minimum value of axis
set Min [format %0.3f [lindex $argv 0]]
#Maximum value of axis
set Max [format %0.3f [lindex $argv 1]]
#Number of cuts in between Min and max value
set Number [format %0.3f [lindex $argv 2]]
#Axis in which we need these cuts
set Direction [lindex $argv 3]
#Calculating the intervals for cuts
set Interval [expr (($Max-$Min)/($Number))]
#Opening files for writing CFD++ commands for cuts
set fp [open "section_cuts.sh" w]
set fpt [open "section_cuts_tec.sh" w]
#Loops for number of cuts
set j $Min
for {set i 0 } {$i <= $Number} {incr i} {
puts $fp "npfcutpl $Direction= [expr $j] cellsin.bin pltosout.bin mpf $Direction=[expr $j]m"
puts $fpt "mpf3dtecp cut_$Direction=[expr $j]m.mpf3d
cut_$Direction=[expr $j]m_tec"
set j [expr $j+$Interval]
}
#Closing files
close $fp
close $fpt
#Executing cuts commands for generating cuts in CFD++ format
exec /usr/bin/sh section_cuts.sh
puts "\033\[01;32mIf you want to convert CFD++ sections files into Tecplot files press y otherwise press n\n\033\[0m"
set input [gets stdin]
scan $input "%s" answer
if {$answer == "y"} {
#Executing cuts commands for generating cuts in Tecplot format, these files can be visualize in ParaView
exec /usr/bin/sh section_cuts_tec.sh
} elseif {$answer == "n"} {
exit 0
} else {
exit 0
}
#User inputs
#Minimum value of axis
set Min [format %0.3f [lindex $argv 0]]
#Maximum value of axis
set Max [format %0.3f [lindex $argv 1]]
#Number of cuts in between Min and max value
set Number [format %0.3f [lindex $argv 2]]
#Axis in which we need these cuts
set Direction [lindex $argv 3]
#Calculating the intervals for cuts
set Interval [expr (($Max-$Min)/($Number))]
#Opening files for writing CFD++ commands for cuts
set fp [open "section_cuts.sh" w]
set fpt [open "section_cuts_tec.sh" w]
#Loops for number of cuts
set j $Min
for {set i 0 } {$i <= $Number} {incr i} {
puts $fp "npfcutpl $Direction= [expr $j] cellsin.bin pltosout.bin mpf $Direction=[expr $j]m"
puts $fpt "mpf3dtecp cut_$Direction=[expr $j]m.mpf3d
cut_$Direction=[expr $j]m_tec"
set j [expr $j+$Interval]
}
#Closing files
close $fp
close $fpt
#Executing cuts commands for generating cuts in CFD++ format
exec /usr/bin/sh section_cuts.sh
puts "\033\[01;32mIf you want to convert CFD++ sections files into Tecplot files press y otherwise press n\n\033\[0m"
set input [gets stdin]
scan $input "%s" answer
if {$answer == "y"} {
#Executing cuts commands for generating cuts in Tecplot format, these files can be visualize in ParaView
exec /usr/bin/sh section_cuts_tec.sh
} elseif {$answer == "n"} {
exit 0
} else {
exit 0
}
Let me know if you need any explanation.
Any comments are welcome.
This script can be downloaded from here: