Re: [Paraview] Create filter with jump in fields

2018-02-21 Thread Santiago Serebrinsky
I put together a Programmable Filter. I do not know if this is the most
efficient way to do it, but it works.

programmableFilter1 =
ProgrammableFilter(Input=[plotOverLineBot,plotOverLineTop])
programmableFilter1.Script = """
import vtk.util.numpy_support as ns
import numpy as np

input_bot = self.GetInputDataObject(0, 0);
input_top = self.GetInputDataObject(0, 1);
output = self.GetPolyDataOutput()
#output.ShallowCopy(input_bot)

npts_bot = input_bot.GetNumberOfPoints()
npts_top = input_top.GetNumberOfPoints()
if ( npts_bot == npts_top ) :
print( "Number of points: " + str(npts_bot) )
u_bot = input_bot.GetPointData().GetArray("displacement")
u_top = input_top.GetPointData().GetArray("displacement")
u_bot_np = ns.vtk_to_numpy(u_bot)
u_top_np = ns.vtk_to_numpy(u_top)
u_jump_np = np.subtract(u_top_np, u_bot_np)
u_jump = ns.numpy_to_vtk(u_jump_np)
u_jump.SetName("displacement jump");
output.GetPointData().AddArray(u_jump)
else :
pass
"""

programmableFilter1.RequestInformationScript = ''
programmableFilter1.RequestUpdateExtentScript = ''
programmableFilter1.PythonPath = ''
RenameSource("Programmable Filter - Jumps", programmableFilter1)




On Tue, Feb 20, 2018 at 8:37 PM, Santiago Serebrinsky <
sserebrin...@gmail.com> wrote:

> I have a dataset with discontinuous displacements across a few surfaces
> (so far I am working in 2D, so these would be lines, 1D). It is input as a
> PVDReader (just in case it makes any difference here, which I doubt).
>
> *Is there any way to programmatically create a new Source with the
> displacement jumps along those lines? Note that this new field would
> probably have to be defined on a domain with a lower dimension, see above.*
>
> So far, I created filters PlotOverLine, on lines slightly below and
> slightly above the prescribed line. But I do not know how to subtract the
> two and place them in a single field over the line.
>
> *Mathematical description of an example*:
>
> Discontinuous field: u(x,y)
>
> Domain of discontinuity: x axis, y=0
>
> Value of the field on one side of the domain of discontinuity: u(x+,0)
>
> Value of the field on the other side of the domain of discontinuity:
> u(x-,0)
>
> Jump in the field: d(x) = u(x+,0) - u(x-,0)
>
> The field u is defined on a 2D domain. The field d is defined on a 1D
> domain (x axis).
>
>
>
___
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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview


Re: [Paraview] connecting buttons and python

2018-02-21 Thread Scott Wittenburg
That actually looks ok to me.  Why isn't pvpython happy with it?  What
version of ParaView are you running?  If it's a recent ParaView and the
problem is you can't import wslink, then setting up a virtualenv with the
missing modules (wslink and its dependencies) might be what you need.  See
this blog post for more information on how to use pvpython but also bring
in the modules in your virtualenv:

https://blog.kitware.com/using-pvpython-and-virtualenv/

If the problem is something else, we might need more details.

Hope this helps.

Cheers,
Scott



On Wed, Feb 21, 2018 at 5:44 PM, Sgouros, Thomas 
wrote:

> Thank you that's very helpful. Where will I find how to define the
> protocols on the python side? I've only found a wslink example that looks
> like this:
>
> from wslink import register as exportRPC
> from wslink.websocket import LinkProtocol
>
> class myProtocol(LinkProtocol):
> def __init__(self):
> super(myProtocol, self).__init__()
>
> @exportRPC("myprotocol.testButton")
> def testButton(self, nothing):
> print("*** HELP ")
>
> Pvpython isn't happy with this, but I'm not sure where to look for the
> right way to do it.
>
> Thank you,
>
>  -Tom
>
> On Wed, Feb 21, 2018 at 6:55 PM, Scott Wittenburg <
> scott.wittenb...@kitware.com> wrote:
>
>> Yes that link is old and broken, but if you navigate through the api docs
>> links, that is working.  Here's the direct link to the page you couldn't
>> find though:
>>
>> https://kitware.github.io/paraviewweb/api/IO_WebSocket_ParaV
>> iewWebClient.html
>>
>>
>>
>> On Wed, Feb 21, 2018 at 4:43 PM, Sgouros, Thomas <
>> thomas_sgou...@brown.edu> wrote:
>>
>>> Hello all:
>>>
>>> Got some nice looking buttons and widgets, but I can't seem to find
>>> examples of how to deliver the button press or other widget output to my
>>> pvpython server. I imagine the steps are:
>>>
>>> 1. Create a protocol on the python side. Can I use wslink.register, or
>>> is there paraviewweb functionality I should be using?
>>>
>>> 2. Create a matching protocol on the js side, with
>>> ParaviewWebClient.createClient(), but I'm not seeing how to link the
>>> protocol to a function that can be linked to a button press.
>>>
>>> Also, this page, found via a google search, seems potentially useful,
>>> but gives me a 404.
>>>
>>> https://kitware.github.io/paraviewweb/api/ParaViewWebClient.html
>>>
>>> Many thanks,
>>>
>>>  -Tom
>>>
>>> ___
>>> 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
>>>
>>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> https://public.kitware.com/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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview


Re: [Paraview] connecting buttons and python

2018-02-21 Thread Sgouros, Thomas
Thank you that's very helpful. Where will I find how to define the
protocols on the python side? I've only found a wslink example that looks
like this:

from wslink import register as exportRPC
from wslink.websocket import LinkProtocol

class myProtocol(LinkProtocol):
def __init__(self):
super(myProtocol, self).__init__()

@exportRPC("myprotocol.testButton")
def testButton(self, nothing):
print("*** HELP ")

Pvpython isn't happy with this, but I'm not sure where to look for the
right way to do it.

Thank you,

 -Tom

On Wed, Feb 21, 2018 at 6:55 PM, Scott Wittenburg <
scott.wittenb...@kitware.com> wrote:

> Yes that link is old and broken, but if you navigate through the api docs
> links, that is working.  Here's the direct link to the page you couldn't
> find though:
>
> https://kitware.github.io/paraviewweb/api/IO_WebSocket_
> ParaViewWebClient.html
>
>
>
> On Wed, Feb 21, 2018 at 4:43 PM, Sgouros, Thomas  > wrote:
>
>> Hello all:
>>
>> Got some nice looking buttons and widgets, but I can't seem to find
>> examples of how to deliver the button press or other widget output to my
>> pvpython server. I imagine the steps are:
>>
>> 1. Create a protocol on the python side. Can I use wslink.register, or is
>> there paraviewweb functionality I should be using?
>>
>> 2. Create a matching protocol on the js side, with
>> ParaviewWebClient.createClient(), but I'm not seeing how to link the
>> protocol to a function that can be linked to a button press.
>>
>> Also, this page, found via a google search, seems potentially useful, but
>> gives me a 404.
>>
>> https://kitware.github.io/paraviewweb/api/ParaViewWebClient.html
>>
>> Many thanks,
>>
>>  -Tom
>>
>> ___
>> 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
>>
>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> https://public.kitware.com/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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview


[Paraview] connecting buttons and python

2018-02-21 Thread Sgouros, Thomas
Hello all:

Got some nice looking buttons and widgets, but I can't seem to find
examples of how to deliver the button press or other widget output to my
pvpython server. I imagine the steps are:

1. Create a protocol on the python side. Can I use wslink.register, or is
there paraviewweb functionality I should be using?

2. Create a matching protocol on the js side, with
ParaviewWebClient.createClient(), but I'm not seeing how to link the
protocol to a function that can be linked to a button press.

Also, this page, found via a google search, seems potentially useful, but
gives me a 404.

https://kitware.github.io/paraviewweb/api/ParaViewWebClient.html

Many thanks,

 -Tom
___
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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview


Re: [Paraview] How to get filled slices of tubes and disks around streamlines

2018-02-21 Thread Moreland, Kenneth
Thomas,

I think a better approach to what you are doing is to use the Glyph filter on 
your streamlines instead of the Tubes filter. After you create your 
streamlines, perform the following steps.


  1.  With the stream tracer selected in the pipeline browser, add the glyph 
filter (it’s icon looks like a Christmas ornament).
  2.  Turn on the advanced properties in the properties panel.
  3.  In the Glyph Type combo box, select “2D Glyph”.
  4.  Assuming you have the advanced properties on, you should see a second 
Glyph Type combo box appear under the first one. Select “Circle” in this second 
box.
  5.  Click on Filled checkbox.
  6.  Under Active Attributes, make sure the Vectors property is set to the 
vector field you used to create the streamlines.
  7.  Scroll down to where it says Glyph Transform. Set the Rotate property to 
0, 90, 0. (That is, change the middle number from 0 to 90.)
  8.  Click Apply.

You should now see filled circles perpendicular to the streamlines. You might 
need to change the Glyph filter’s Masking mode to either “All Points” or “Every 
Nth Point” to get the samples of circles how you want them.

-Ken

From: ParaView [mailto:paraview-boun...@public.kitware.com] On Behalf Of Thomas 
Oliveira
Sent: Wednesday, February 21, 2018 6:56 AM
To: ParaView 
Subject: [EXTERNAL] [Paraview] How to get filled slices of tubes and disks 
around streamlines

Hi,
I am tracing streamlines using "Stream Tracer with Custom Source" and creating 
tubes along them using "Tubes". Since "Tubes" creates surfaces, if I use 
"Slice" on the tubes I don't get elliptical disks but ellipses.
I would like to:
1) Visualize elliptical disks when using "Slice" on "Tubes".

I would be even better if, instead of getting the elliptical disks, which are 
bounded by the cross section of the tubes, I could get circular disks in the 
same position, i.e., if I could
2) represent circular disks on a plane that crosses the streamlines centred on 
the intersections between the plane and the streamlines

Would you see a way of doing that or getting the same visual result?
Thank you,
Thomas Oliveira
___
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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview


[Paraview] How to get filled slices of tubes and disks around streamlines

2018-02-21 Thread Thomas Oliveira
Hi,

I am tracing streamlines using "Stream Tracer with Custom Source" and
creating tubes along them using "Tubes". Since "Tubes" creates surfaces, if
I use "Slice" on the tubes I don't get elliptical disks but ellipses.

I would like to:
1) Visualize elliptical disks when using "Slice" on "Tubes".

I would be even better if, instead of getting the elliptical disks, which
are bounded by the cross section of the tubes, I could get circular disks
in the same position, i.e., if I could
2) represent circular disks on a plane that crosses the streamlines centred
on the intersections between the plane and the streamlines

Would you see a way of doing that or getting the same visual result?

Thank you,
Thomas Oliveira
___
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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview


Re: [Paraview] New variable to a mesh

2018-02-21 Thread kenichiro yoshimi
Hello Moulshree,

Using the function numpy.random.uniform(), you can define the range of
random numbers by the half-open interval [low, high):

  np_rand = np.random.uniform(0,100,numCells)

The details are as follows.
https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.uniform.html

And of course the conditional statements are available in Programmable
filter's script as is the case in normal python script.

Best

2018-02-21 18:06 GMT+09:00 Moulshree Tripathi :
> Hello
>
> Thank you very much for the response. It worked. Also, is it possible to
> give a range between which we want random numbers and could we use
> conditional statements?
>
> Best Regards
>
> Moulshree Tripathi
>
> On Wed, Feb 21, 2018 at 1:42 AM, kenichiro yoshimi 
> wrote:
>>
>> Hi Moulshree,
>>
>> The Programmable filter's script would be more flexible to add an
>> array rather than doing it in the calculator filter since it allows us
>> to use various NumPy modules.
>>
>> Here is a simple example that generates a random numpy array and adds
>> it to the mesh as a vtk array.
>> 
>> import numpy as np
>>
>> input = self.GetInput()
>> numCells = input.GetNumberOfCells()
>> np_rand = np.random.rand(numCells)
>> output.CellData.append(np_rand, "random")
>> 
>>
>> Some information can be found here:
>> https://www.paraview.org/Wiki/Python_Programmable_Filter
>>
>> Thanks
>>
>> 2018-02-20 17:37 GMT+09:00 Moulshree Tripathi :
>> > Greetings!
>> >
>> > I am new to ParaView and have few queries regarding the assigning of a
>> > new
>> > variable in mesh:
>> >
>> > 1: I am using calculator filter to add a new array. Is it possible to
>> > interpolate the values in this array and also is it possible to generate
>> > random numbers? (say if I want values between 0 to 1 in my array of 2000
>> > cells)
>> >
>> > 2: Is there any other method by which I could assign properties to the
>> > mesh?
>> > (say I want to assign different values to my cell - say hydraulic
>> > conductivities in inhomogeneous porous medium) How can I do this with
>> > calculator filter or with any other tool?
>> >
>> > I am sorry if the questions are naive.
>> > Looking forward to your response.
>> >
>> > Regards
>> >
>> > Moulshree Tripathi
>> >
>> > ___
>> > 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
>> >
>> > Search the list archives at: http://markmail.org/search/?q=ParaView
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > https://public.kitware.com/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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview