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 <
[email protected]> 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

Reply via email to