[Paraview] injecting objects from python
David E DeMarle
dave.demarle at kitware.com
Tue Jun 19 07:56:14 EDT 2012
On Tue, Jun 19, 2012 at 7:24 AM, Gertjan van Zwieten
<gertjanvanzwieten at gmail.com> wrote:
> Hi Hal, thanks for your quick reply and the example code. That's very
> helpful. I do have these remaining questions that perhaps you could help me
> with:
>
> In your experience, is a programmable source a suitable place to call a
> potentially long running finite element code?
ParaView is single threaded so the GUI will be non-responsive while
the simulation runs unless you get very creative.
> Is it possible to update the data structure while it is already being
> displayed, that is, before the script finishes?
There is no support in ParaView for this. The primary reasons being
its single threaded nature and pull pipeline architecture. It can and
has been done before (with open source all things are possible given
time) but it took significant effort and was never done robustly
enough to make it into the official code repository. Search the
mailing list for livedata and coprocessing for discussions on this
topic.
> And is it possible to have a programmable source output multiple data sets
> if necessary?
Hal is right, the right thing to do is produce vtkMultiblockData.
>
> Thanks again!
> Gertjan
>
You should also investigate ParaView's coprocessing library as an option.
http://paraview.org/Wiki/CoProcessing
>
> On Tue, Jun 19, 2012 at 12:44 PM, Hal Canary <hal at cs.unc.edu> wrote:
>>
>> On 06/19/2012 06:10 AM, Gertjan van Zwieten wrote:
>>>
>>> [...]
>>>
>>> So my question is simply if it is possible to inject objects from python
>>> into an already running or separately spawned paraview instance? If so,
>>> any pointers in that direction (an example script?) would of course be
>>> enormously helpful.
>>
>>
>> I use a programmable source. Here's a macro to create an image:
>>
>> #####################
>> script="""
>> image = self.GetImageDataOutput()
>> image.SetSpacing(0.01,0.01,0.01)
>> image.SetOrigin(0,0,0)
>> image.SetDimensions(101,101,101)
>> array = numpy.zeros((101,101,101,), dtype=numpy.float32)
>> space = numpy.linspace(0,1,101)
>> for i,x in enumerate(space):
>> for j,y in enumerate(space):
>> for k,z in enumerate(space):
>> array[i,j,k] = (math.sin(4*x)
>> + math.sin(4*y) + math.sin(4*z))
>> image.GetPointData().AddArray(
>> paraview.vtk.dataset_adapter.numpyTovtkDataArray(
>> array.reshape(101*101*101), name="myarray"))
>> """
>> script_request_information = """
>> from paraview import util
>> util.SetOutputWholeExtent(self, [0, 100, 0, 100, 0, 100])
>> """
>> ps = ProgrammableSource(
>> guiName="My Source",
>> Script=script,
>> ScriptRequestInformation=script_request_information,
>> OutputDataSetType='vtkImageData' )
>> Show(ps)
>> ###################################
>> _______________________________________________
>> 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 ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.paraview.org/mailman/listinfo/paraview
>
>
>
> _______________________________________________
> 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 ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
More information about the ParaView
mailing list