[prev in list] [next in list] [prev in thread] [next in thread] 

List:       paraview
Subject:    Re: [Paraview] Calling the calculator filter repeatedly inside a
From:       pat marion <pat.marion () kitware ! com>
Date:       2010-11-28 22:56:48
Message-ID: AANLkTin+CV1qUXr2MhZVa+SzH1sJ41MECM4YaUnetASC () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


You can run it in a loop, but I'm not sure it will accomplish what you are
trying to do. Your code says:

    CalculatorX.Function = 'Result+p'

But the input to the calculator filter only has the "p" array.  It's the
output of the calculator that has the "Result" array.  So you can call the
calculator filter a second time, but the input still won't have any "Result"
array.  You could apply a 2nd Calculator filter that operates on the output
of the first calculator filter.  You would apply a 2nd calculator filter by
calling Calculator() again.  You could use your for loop to apply a new
calculator filter each time.  But it's important that you understand
paraview's pipeline model, filters do not operate on their data in place.

Pat

On Sun, Nov 28, 2010 at 4:51 PM, George <george.gerber@gmail.com> wrote:

>  Hi  Pat,
>
> Thank you for the advice.
> Is it therefore not possible to run the calculator filter inside a for
> loop? Or do I need to create an intermediate array (say ResultTemp) by deep
> copying the original Result array?
>
> Thank you,
> George
>
>
> On 2010/11/28 10:09 PM, pat marion wrote:
>
> Hi George,
>
> To execute a filter from python you can call UpdatePipeline().  This is
> just like clicking the Apply button.  So for your code it would be
> CalculatorX.UpdatePipeline().  But your loop isn't going to do what you
> want.  Filters operate on their input data and output new data, they do not
> modify their input data in place.  If you call the calculator filter 10
> times, it's going to produce the same output each time unless its input has
> changed.
>
> Pat
>
> On Sun, Nov 28, 2010 at 2:33 PM, George <george.gerber@gmail.com> wrote:
>
>> Hi paraviewers,
>>
>> I am trying to write a python script where I call the Calculator filter
>> repeatedly inside a for-loop.
>> However, I am not quite sure how to write this for paraview. At the moment
>> my code looks like this:
>> ~~~~~~~~~~~~
>> try: paraview.simple
>> except: from paraview.simple import *
>> paraview.simple._DisableFirstRenderCameraReset()
>>
>> # Data Processing
>> Coarse = OpenFOAMReader( FileName='C:\\Users\\Public\\Mesh.OpenFOAM' )
>> Coarse.CellArrays = ['U', 'U_0', 'p']
>> Coarse.MeshRegions = ['internalMesh']
>> SetActiveSource(Coarse)
>> CalculatorX = Calculator()
>> CalculatorX.AttributeMode = 'point_data'
>> CalculatorX.Function = 'p'
>> CalculatorX.ResultArrayName = 'Result'
>>
>> # A hypothetical for-loop where I repeatedly add the array 'p' to the
>> array 'Result'
>> for i in range(10):
>>    CalculatorX.Function = 'Result+p'    #( Result = Result + p)
>> ~~~~~~~~~~~~
>> The above script will not work in paraview as is.
>> Can anyone tell me the proper way of writing this in Python?
>>
>> Thank you very much,
>> George
>> _______________________________________________
>> 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
>>
>
>
>

[Attachment #5 (text/html)]

You can run it in a loop, but I&#39;m not sure it will accomplish what you are trying \
to do. Your code says:<br><br>    CalculatorX.Function = \
&#39;Result+p&#39;<br><br>But the input to the calculator filter only has the \
&quot;p&quot; array.  It&#39;s the output of the calculator that has the \
&quot;Result&quot; array.  So you can call the calculator filter a second time, but \
the input still won&#39;t have any &quot;Result&quot; array.  You could apply a 2nd \
Calculator filter that operates on the output of the first calculator filter.  You \
would apply a 2nd calculator filter by calling  Calculator() again.  You could use \
your for loop to apply a new calculator filter each time.  But it&#39;s important \
that you understand paraview&#39;s pipeline model, filters do not operate on their \
data in place.<br> <br>Pat<br><br><div class="gmail_quote">On Sun, Nov 28, 2010 at \
4:51 PM, George <span dir="ltr">&lt;<a \
href="mailto:george.gerber@gmail.com">george.gerber@gmail.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; \
border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



  

<div bgcolor="#ffffff" text="#000000">
Hi  Pat,<br>
<br>
Thank you for the advice.<br>
Is it therefore not possible to run the calculator filter inside a for
loop? Or do I need to create an intermediate array (say ResultTemp) by
deep copying the original Result array?<br>
<br>
Thank you,<br><font color="#888888">
George</font><div><div></div><div class="h5"><br>
<br>
On 2010/11/28 10:09 PM, pat marion wrote:
<blockquote type="cite">Hi George,<br>
  <br>
To execute a filter from python you can call UpdatePipeline().  This is
just like clicking the Apply button.  So for your code it would be
CalculatorX.UpdatePipeline().  But your loop isn&#39;t going to do what you
want.  Filters operate on their input data and output new data, they do
not modify their input data in place.  If you call the calculator
filter 10 times, it&#39;s going to produce the same output each time unless
its input has changed.<br>
  <br>
Pat<br>
  <br>
  <div class="gmail_quote">On Sun, Nov 28, 2010 at 2:33 PM, George <span \
dir="ltr">&lt;<a href="mailto:george.gerber@gmail.com" \
target="_blank">george.gerber@gmail.com</a>&gt;</span> wrote:<br>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi paraviewers,<br>
    <br>
I am trying to write a python script where I call the Calculator filter
repeatedly inside a for-loop.<br>
However, I am not quite sure how to write this for paraview. At the
moment my code looks like this:<br>
~~~~~~~~~~~~<br>
try: paraview.simple<br>
except: from paraview.simple import *<br>
paraview.simple._DisableFirstRenderCameraReset()<br>
    <br>
# Data Processing<br>
Coarse = OpenFOAMReader( FileName=&#39;C:\\Users\\Public\\Mesh.OpenFOAM&#39; )<br>
Coarse.CellArrays = [&#39;U&#39;, &#39;U_0&#39;, &#39;p&#39;]<br>
Coarse.MeshRegions = [&#39;internalMesh&#39;]<br>
SetActiveSource(Coarse)<br>
CalculatorX = Calculator()<br>
CalculatorX.AttributeMode = &#39;point_data&#39;<br>
CalculatorX.Function = &#39;p&#39;<br>
CalculatorX.ResultArrayName = &#39;Result&#39;<br>
    <br>
# A hypothetical for-loop where I repeatedly add the array &#39;p&#39; to the
array &#39;Result&#39;<br>
for i in range(10):<br>
   CalculatorX.Function = &#39;Result+p&#39;    #( Result = Result + p)<br>
~~~~~~~~~~~~<br>
The above script will not work in paraview as is.<br>
Can anyone tell me the proper way of writing this in Python?<br>
    <br>
Thank you very much,<br>
George<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
    <br>
Visit other Kitware open-source projects at <a \
href="http://www.kitware.com/opensource/opensource.html" \
target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>  <br>
Please keep messages on-topic and check the ParaView Wiki at: <a \
href="http://paraview.org/Wiki/ParaView" \
target="_blank">http://paraview.org/Wiki/ParaView</a><br>  <br>
Follow this link to subscribe/unsubscribe:<br>
    <a href="http://www.paraview.org/mailman/listinfo/paraview" \
target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>  \
</blockquote>  </div>
  <br>
</blockquote>
<br>
</div></div></div>

</blockquote></div><br>



_______________________________________________
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic