[vtkusers] Choosing time for vtkOpenFOAMReader
David E DeMarle
dave.demarle at kitware.com
Wed Nov 9 09:39:25 EST 2016
The problem appears to be that SetUpdateTimeStep helper method on the
vtkAlgorithm was not wrapped in python for some reason so you can't get it
directly from reader (or any other algorithm).
This is the vtk 6.3 python API.
reader.UpdateInformation()
outinfo = reader.GetExecutive().GetOutputInformation(0)
infkey = vtk.vtkStreamingDemandDrivenPipeline.UPDATE_TIME_STEP()
outinfo.Set(infkey, 0.5)
reader.Update().
And no worries about being new to VTK, even for an old timer like me it
took me some head scratching to figure it out.
Yet another reason to try 7.1 if you can. The new API is just:
reader->UpdateTimeStep(0.5)
David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909
On Thu, Nov 3, 2016 at 7:21 AM, Timofey Mukha <timofey.mukha at it.uu.se>
wrote:
> Dear David,
>
> Thank you for the fast reply! I am trying to use your tip, but since I am
> very new to VTK it is not working out well for me.
>
> Could you elaborate a bit, what would "anAlgorithm" be. A child to
> vtkAlgorithm? The thing is none of the objects I create seem to have the
> SetUpdateTimeStep() as a member. Browsing doxygen made me think that it is
> a member of vtkStreamingDemandDrivenPipeline, is that something I should
> have in the script?
>
> Kind regards,
>
> Timofey
>
> On 2016-11-02 18:40, David E DeMarle wrote:
>
> In vtk 6.3 it was:
> anAlgorithm->UpdateInformation();
> anAlgorithm->SetUpdateTimeStep(0.5);
> anAlgorithm->Update();
> Try that.
>
> In vtk 7.1 it is:
> anAlgorithm->UpdateTimeSep(0.5);
> Since Berk cleaned up the parts of the pipeline that caused issues like
> you are seeing.
>
>
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
> On Wed, Nov 2, 2016 at 12:43 PM, Timofey Mukha <timofey.mukha at it.uu.se>
> wrote:
>
>> Hello!
>>
>> I am trying to write a python script for doing some stuff with an
>> OpenFOAM case. Everything works great, except that I can't choose the
>> time-value that I want the reader to get the data for.
>>
>> I have found the SetTimeValue() function which is supposed to do the job
>> I think, but it doesn't -- the first availbale time-value is always used.
>> Here is how I use the reader:
>>
>> reader = vtk.vtkOpenFOAMReader()
>> reader.SetFileName(path)
>> reader.CreateCellToPointOff()
>> reader.DisableAllPointArrays()
>> reader.Update()
>> print(vtk_to_numpy(reader.GetTimeValues())) # Grab the available
>> timesteps
>> reader.SetTimeValue(vtk_to_numpy(reader.GetTimeValues())[-1]) # Try to
>> load the latest time
>> reader.Update()
>>
>> I use the version provided by the Anaconda python disstro, 6.3.0 I
>> believe.
>>
>> Thanks in advance,
>>
>> Timofey
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161109/db002403/attachment.html>
More information about the vtkusers
mailing list