RES: [Paraview] using kw(vtktemp??) in scripts
Renato N. Elias
rnelias at nacad.ufrj.br
Wed Mar 14 18:26:14 EST 2007
Hy Marcio,
In my case, Im only trying to load several Ensight files (one for each
parallel process), append everything and save them in some VTK format. After
struggling with the PV script language I finally got something working (but
I gave up to append the parallel datasets
). The final script (only opening
and saving the transient data) is listed below. I must mention that although
working fine this script is tooooooooooooo slow.
At the end of this mail Im listing what I was trying to do (load the files,
append, clean and save in vtks format)
#---------------------------------------------------------------------------
---------------------------------------
# IT WORKS ;o)
# This PV trace script loads several transient dataset written in Ensight's
# format and save then in Kitware's format
#
set kw(vtkTemp2) [$Application GetMainWindow]
set kw(vtkTemp82) [$kw(vtkTemp2) GetMainView]
#
# GLOBAL SETTINGS
#
# InputPath: Path pointing to where the Ensight casefiles are placed
# InputFile: Standard name used to build the casefile names
# NumberOfTimeSteps: Number of transient datasets
# NumberOfProcesses: Number of MPI processes ("pieces of model")
#
set InputPath "C:/fef07/planar-lock-exchange/Gr=1.5E6/run_8.15/"
set InputFile "planar-lock-exchange_8_0"
set OutputFile "PVFiles"
set NumberOfTimeSteps 84
set NumberOfProcesses 8
#
# Loading Ensight files
#
for {set i 0} {$i < $NumberOfProcesses } {incr i} {
# Building the input filename
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
# PV stuffs to read an Ensight's file
set mytmp [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $mytmp $tmp
$kw(vtkTemp2) FinalizeRead $mytmp $tmp
set kw(vtkTemp1223) [$mytmp GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$mytmp GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
$kw(vtkTemp555) SetPlayMode 0
$mytmp AcceptCallback
# Building the output filename and directory
set OutputPath $InputPath
append OutputPath "proc"
append OutputPath $i
append OutputPath "/"
#
# Saving transient data
#
$kw(vtkTemp2) ShowAnimationPanes
for {set j 1} {$j < $NumberOfTimeSteps} {incr j} {
set prefix ""
if {$j < 100} { append prefix "0" }
if {$j < 10 } { append prefix "0" }
append prefix $j
set FileName $OutputFile
append FileName $prefix
append FileName ".vtm"
set FullPath $OutputPath
append FullPath $FileName
$kw(vtkTemp2) WriteVTKFile $FullPath 0
$kw(vtkTemp555) SetCurrentTimeWithTrace $j
}
$mytmp DeleteCallback
$kw(vtkTemp2) SetCurrentPVSourceCallback {}
}
#---------------------------------------------------------------------------
---------------------------------------
The next script lists what I was trying to do (including my doubt). Note
that I had to unroll the file loading loop in order to have something
working.
#
# It work, but it should also work without the need of unrolling the
commented loop
#
set kw(vtkTemp2) [$Application GetMainWindow]
set kw(vtkTemp82) [$kw(vtkTemp2) GetMainView]
#
# GLOBAL SETTINGS
#
set InputPath "C:/fef07/planar-lock-exchange/Gr=1.5E6/run_8.15/"
set InputFile "planar-lock-exchange_8_0"
set OutputFile "PVFiles"
set NumberOfTimeSteps 83
set NumberOfProcesses 8
#
# Loading Ensight files
#
#for {set i 0} {$i < $NumberOfProcesses } {incr i} {
# set tmp $InputPath
# append tmp $InputFile
# append tmp $i
# append tmp ".case"
# set mytmp [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
# $kw(vtkTemp2) ReadFileInformation $mytmp $tmp
# $kw(vtkTemp2) FinalizeRead $mytmp $tmp
# set kw(vtkTemp1223) [$mytmp GetPVWidget {Filename}]
# $kw(vtkTemp1223) SetValue $tmp
# set kw(vtkTemp1214) [$mytmp GetPVWidget {PointArrays}]
# $kw(vtkTemp1214) SetArrayStatus {pressure} 1
# $kw(vtkTemp1214) SetArrayStatus {velocity} 1
# $kw(vtkTemp1214) SetArrayStatus {scalar} 1
# $kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
# set kw(vtkTemp1305) [$kw(vtkTemp2) GetAnimationManager]
# set kw(vtkTemp801) [$kw(vtkTemp1305) GetAnimationScene]
# $kw(vtkTemp801) SetPlayMode 0
# $mytmp AcceptCallback
#}
#
# ENSIGHT'S CASEFILE 1
#
set i 0
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
set CASEFILE1 [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $CASEFILE1 $tmp
$kw(vtkTemp2) FinalizeRead $CASEFILE1 $tmp
set kw(vtkTemp1223) [$CASEFILE1 GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$CASEFILE1 GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
#set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
#set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
#$kw(vtkTemp555) SetPlayMode 0
$CASEFILE1 AcceptCallback
#
# ENSIGHT'S CASEFILE 2
#
set i 1
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
set CASEFILE2 [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $CASEFILE2 $tmp
$kw(vtkTemp2) FinalizeRead $CASEFILE2 $tmp
set kw(vtkTemp1223) [$CASEFILE2 GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$CASEFILE2 GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
#set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
#set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
#$kw(vtkTemp555) SetPlayMode 0
$CASEFILE2 AcceptCallback
#
# ENSIGHT'S CASEFILE 3
#
set i 2
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
set CASEFILE3 [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $CASEFILE3 $tmp
$kw(vtkTemp2) FinalizeRead $CASEFILE3 $tmp
set kw(vtkTemp1223) [$CASEFILE3 GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$CASEFILE3 GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
#set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
#set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
#$kw(vtkTemp555) SetPlayMode 0
$CASEFILE3 AcceptCallback
#
# ENSIGHT'S CASEFILE 4
#
set i 3
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
set CASEFILE4 [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $CASEFILE4 $tmp
$kw(vtkTemp2) FinalizeRead $CASEFILE4 $tmp
set kw(vtkTemp1223) [$CASEFILE4 GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$CASEFILE4 GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
#set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
#set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
#$kw(vtkTemp555) SetPlayMode 0
$CASEFILE4 AcceptCallback
#
# ENSIGHT'S CASEFILE 5
#
set i 4
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
set CASEFILE5 [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $CASEFILE5 $tmp
$kw(vtkTemp2) FinalizeRead $CASEFILE5 $tmp
set kw(vtkTemp1223) [$CASEFILE5 GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$CASEFILE5 GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
#set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
#set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
#$kw(vtkTemp555) SetPlayMode 0
$CASEFILE5 AcceptCallback
#
# ENSIGHT'S CASEFILE 6
#
set i 5
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
set CASEFILE6 [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $CASEFILE6 $tmp
$kw(vtkTemp2) FinalizeRead $CASEFILE6 $tmp
set kw(vtkTemp1223) [$CASEFILE6 GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$CASEFILE6 GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
#set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
#set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
#$kw(vtkTemp555) SetPlayMode 0
$CASEFILE6 AcceptCallback
#
# ENSIGHT'S CASEFILE 7
#
set i 6
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
set CASEFILE7 [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $CASEFILE7 $tmp
$kw(vtkTemp2) FinalizeRead $CASEFILE7 $tmp
set kw(vtkTemp1223) [$CASEFILE7 GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$CASEFILE7 GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
#set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
#set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
#$kw(vtkTemp555) SetPlayMode 0
$CASEFILE7 AcceptCallback
#
# ENSIGHT'S CASEFILE 8
#
set i 7
set tmp $InputPath
append tmp $InputFile
append tmp $i
append tmp ".case"
set CASEFILE8 [$kw(vtkTemp2) InitializeReadCustom "ensight" $tmp]
$kw(vtkTemp2) ReadFileInformation $CASEFILE8 $tmp
$kw(vtkTemp2) FinalizeRead $CASEFILE8 $tmp
set kw(vtkTemp1223) [$CASEFILE8 GetPVWidget {Filename}]
$kw(vtkTemp1223) SetValue $tmp
set kw(vtkTemp1214) [$CASEFILE8 GetPVWidget {PointArrays}]
$kw(vtkTemp1214) SetArrayStatus {pressure} 1
$kw(vtkTemp1214) SetArrayStatus {velocity} 1
$kw(vtkTemp1214) SetArrayStatus {scalar} 1
$kw(vtkTemp2) SetCenterOfRotation 1.740475 0.000000 1.000000
set kw(vtkTemp858) [$kw(vtkTemp2) GetAnimationManager]
set kw(vtkTemp555) [$kw(vtkTemp858) GetAnimationScene]
$kw(vtkTemp555) SetPlayMode 0
$CASEFILE8 AcceptCallback
#
# Appending Datasets
#
set kw(vtkTemp1068) [$kw(vtkTemp2) CreatePVSource Append]
$CASEFILE1 SetVisibility 0
$CASEFILE2 SetVisibility 0
$CASEFILE3 SetVisibility 0
$CASEFILE4 SetVisibility 0
$CASEFILE5 SetVisibility 0
$CASEFILE6 SetVisibility 0
$CASEFILE7 SetVisibility 0
$CASEFILE8 SetVisibility 0
set kw(vtkTemp1078) [$kw(vtkTemp1068) GetPVWidget {inputs}]
$kw(vtkTemp1078) AllOffCallback
$kw(vtkTemp1078) SetSelectState $CASEFILE1 1
$kw(vtkTemp1078) SetSelectState $CASEFILE2 1
$kw(vtkTemp1078) SetSelectState $CASEFILE3 1
$kw(vtkTemp1078) SetSelectState $CASEFILE4 1
$kw(vtkTemp1078) SetSelectState $CASEFILE5 1
$kw(vtkTemp1078) SetSelectState $CASEFILE6 1
$kw(vtkTemp1078) SetSelectState $CASEFILE7 1
$kw(vtkTemp1078) SetSelectState $CASEFILE8 1
$kw(vtkTemp1068) AcceptCallback
set kw(vtkTemp1089) [$kw(vtkTemp2) CreatePVSource CleanUnstructuredGrid]
set kw(vtkTemp1092) [$kw(vtkTemp1089) GetPVWidget {Input}]
$kw(vtkTemp1092) SetCurrentValue $kw(vtkTemp1068)
$kw(vtkTemp1089) AcceptCallback
set OutputPath $InputPath
append OutputPath "ConvertedFiles/"
$kw(vtkTemp2) ShowAnimationPanes
for {set i 1} {$i < 5} {incr i} {
set prefix ""
if {$i < 100} { append prefix "0" }
if {$i < 10 } { append prefix "0" }
append prefix $i
set FileName $OutputFile
append FileName $prefix
append FileName ".pvd"
set FullPath $OutputPath
append FullPath $FileName
$kw(vtkTemp2) WriteVTKFile $FullPath 0
$kw(vtkTemp555) SetCurrentTimeWithTrace $i
}
De: Márcio Ricardo Pivello [mailto:pivello at gmail.com]
Enviada em: Wednesday, March 14, 2007 11:56
Para: Renato N. Elias
Assunto: Re: [Paraview] using kw(vtktemp??) in scripts
Hi, Renato. What exactly do you need? I think last year I had to write a
similar script:
::slice a geometry with 200 cut objects
::for each extract the time evolution of pressure in a probe line
::save each pressure history to a separated file file
If you need something like this tell me and I can send you the scripts.
Cheers
Márcio
On 3/12/07, Renato N. Elias < rnelias at nacad.ufrj.br
<mailto:rnelias at nacad.ufrj.br> > wrote:
Hi folks,
Doesn anyone could tell me how those kw(vtktemp) variables are created in PV
scripts? I'd like to use it to create a script but I have no clue how to do
it. Basically the script must do something like:
- Open some datasets;
- Apply a filter;
- Save the output dataset created by the filter.
I can already open the datasets and save them (including the transient
data), but I don't know how to select and pass them to the filter since I
don't know which kw(vtktemp) I have to refer.
I've been doing like the following pseudo-code
#
# Loading files
#
for {set i 0} {$i < $NumberOfProcesses } {incr i} {
set mytmp <--- point to the file to be read
...
...
}
#
# Applying the filter
#
$kw(vtkTemp1078) SetSelectState $mytmp 1 <--- HERE IS MY PROBLEM SINCE I
CAN ONLY SELECT THE LAST $mytmp
#
# Saving the resulting file
#
for {set i 1} {$i < NumberOfTimeSteps} {incr i} {
$kw(vtkTemp2) WriteVTKFile $FullPath 0
...
...
}
Thanks for any help.
Renato N. Elias
==========================================
PhD student, http://www.nacad.ufrj.br/~rnelias
High Performance Computing Center (NACAD)
Federal University of Rio de Janeiro
Rio de Janeiro, Brazil
_______________________________________________
ParaView mailing list
ParaView at paraview.org
http://www.paraview.org/mailman/listinfo/paraview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/paraview/attachments/20070314/45b7cf4f/attachment.htm
More information about the ParaView
mailing list