3

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 for the question, 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.


Notes:

  1. So far I am working in 2D (domain where the discontinuity is defined is 1D). I mean to get also discontinuities in fields on 3D domains (domain where the discontinuity is defined is 2D).
  2. As a simple example (see below) I take for Domain of discontinuity: x axis, y=0. I actually mean to have an arbitrary line (in 2D) or plane (in 3D).
  3. I would provide an extra reward if the Domain of discontinuity is an arbitrary curve (in 2D) or surface (in 3D).

Mathematical description:

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).

3 Answers3

1

Ressample with dataset should do the trick as far as I understand.

  • First generate a line using the line source
  • open your 2D dataset containing the discontinuous U field.
  • Use ressample with dataset on your dataset and use the line source as source input
  • You now have a line which contains the field defined on your datasets

If you need to do some computation on it, you can then use a calculator or a programmable filter.

Mathieu Westphal
  • 2,544
  • 1
  • 19
  • 33
  • This does not provide the intended result. I want to get the difference d(x) = u(x+,0) - u(x-,0). This only gives at some points u(x+,0), and at some others u(x-,0). I would find it surprising if this filter did what I need... how will it know if I wanted instead the average (u(x+,0)+u(x-,0))/2, e.g. This filter seems to me useful for continuous fields, where d(x)=0 (and nobody would be interested in getting that!). Besides, I did not find how to tell the filter how many data points I want along the line. So far, it uses only 7 points (too sparse). – sancho.s ReinstateMonicaCellio Feb 02 '18 at 18:53
  • do you have a way to test if a point is on the discontinuity ? The number of point is controlled by the resolution parameter. – Mathieu Westphal Feb 02 '18 at 18:56
  • I do not know what you mean by testing that. I know exactly which is the discontinuity line, and that is confirmed by using the WarpByVector filter, which produces openings, e.g. I do not see any Resolution parameter. – sancho.s ReinstateMonicaCellio Feb 02 '18 at 19:02
  • in this case you have no choice but to use a full programmable filter. Please take a look here : https://www.paraview.org/Wiki/Python_Programmable_Filter and use the paraview mailing list in case of problems. – Mathieu Westphal Feb 05 '18 at 10:42
  • If you could provide more specific details, with perhaps some code (of course, not necessarily code in its final form) useful for this case, that would be great. In particular, the way I started to deal with this is by two separate PlotOverLine sources, and I had no success in combining them in a Programmable Filter as a subtraction. – sancho.s ReinstateMonicaCellio Feb 20 '18 at 22:19
  • Quite hard to produce. I would suggest you to give it a go and then try to paraview mailing list for help. – Mathieu Westphal Mar 14 '18 at 02:34
1

If I understood correctly, you want to plot discontinuity in u(x,y) a 2D surface as a line and associate as a field the jump in u() with d(x) = u(x+,0) - u(x-,0)

Theorically speaking, it should be possible to use a Programmable Filter or develop a ParaView Filter which could take advantage of your filter PlotOverLine and use the lines slightly above and below as its first parameters and use the output line as last parameter (or create it as output).

The different parameters are exposed in the PF script in the array inputs. The question of the order of the parameters can be addressed with a special field 'LineType' for example indicating which is above and which is below.

This way, maybe you could explicitly compute the fields u(x+,0) and u(x-,0) and then the jump field d(x) to finally associate it to the output line.

I'm well aware this is more a suggestion about how it could be done than a real answer but I wanted to share ideas.

  • Thanks Guillaume. These ideas are generally in line with my expectations. If you could provide a more detailed workflow, with more explicit references to Paraview features, this could work well. – sancho.s ReinstateMonicaCellio Feb 15 '18 at 09:31
0

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)