Assigning coordinates from variable

Hi,
I have a fairly simple question I believe, but after almost an hour of googling and searching I could not find a reasonable answer. I have a structured grid output from a model, whose coordinates are simply a range of values from 0 to the number of grid points. I also have variables that correspond to the location of these gridpoints in meters. I would like to use the data axes grid to display the values of meters instead of the index of the grid point. I looked into transforming this, but I couldn’t get it to where I would like and it would be much simpler to just assign a variable to be the coordinate. Furthermore, I have a stretched vertical grid, so a simple transformation will not display the vertical extent of the data correctly. I’m sure there is a very simple method to go about this, but transforming, nor warping by vector, nor using custom data axes bounds worked for what I’m trying to accomplish.

1 Like

The Calculator filter has an option named Coordinate Results. If you turn that on, the results of the calculator are set to the point coordinates instead of a field. Does that do what you want?

image

Hi Kenneth, yes that’s exactly what I wanted! However, since I have a structured grid, I had to use the clean to grid filter like suggested in this ticket (https://discourse.paraview.org/t/coordinate-transformation-problem/193/2). Is this still the best way to handle this?

tl;dr: I recommend using the Transform filter with the default properties rather than Clean to Grid. It is more efficient.

You will need to be more specific by what you mean by a “structured” grid. ParaView/VTK has at least 3 flavors of grids with regular topology:

  • An axis-aligned grid with uniform spacing between grid points (ParaView/VTK calls this an “image”, even if it’s 3D)
  • An axis-aligned grid with variable spacing between grid points (ParaView/VTK calls this a “rectilinear grid”)
  • A curvilinear grid of points where the points are placed at arbitrary locations (ParaView/VTK calls this a “structured grid”)

When you said you had a “structured grid”, I assumed you meant the last one, but I think you meant the first one. With a curvilinear grid, you can assign coordinates to points directly, which is what you want to do. You cannot do that with uniform or rectilinear grids. You might argue that calling curvilinear grids simply “structured” is bad because it leads to confusion, and I would agree. But the name was picked around 30 years ago, so what are you gonna do?

The most efficient thing to do is to convert your grid to the curvilinear (structured) grid. It retains the structured topology but allows you to assign new points. The easiest way to do this conversion is to run the Transform filter. The Transform filter will convert a uniform grid to a curvilinear grid so that the points can be moved around. The default properties of Transform are the identity, so the points won’t actually move. But the conversion happens anyway.

Clean to Grid works fine too, but it converts your data to a completely unstructured grid. This means that each cell in your grid now has to be explicitly represented by a set of 8 corner vertices. It will look the same, but it is a less efficient representation in ParaView.

Ah yes, my apologies on the naming convention, I did indeed mean the first one, an image. That is helpful knowing that the transform filter will convert the points to the grid and then using the calculator I can assign it coordinate vector I want.

Thanks for your very helpful and thorough replies, answered exactly what I was looking for!