Accessing coordinates in python calculator

I’m trying to access the coordinates from a hierarchical box data set (AMReX) to do a computation.

What I really want to do is manipulate the coordinates since we are playing around with adding mesh stretching into our CFD code, but the underlying vtkDataType only uses vtkUniformGrids. Or at least that is what it seems to me. After a bunch of trial and error with Programmable filters, I decided to just compute the stretched coordinates and use the Warp By Vector filter.

With the regular calculator I can access them just fine with the coordsX,Y,Z variables, but when I try to use the python calculator I can’t figure out how to access them at all. There is no inputs[0].Points member, or at least calling it doesn’t do anything, and the fields don’t exist in the PointData. Any advice here? Is this just not exposed via the python interface?


vtkUniformGrids have implicit points. You can either convert to a explicit datatype (using AppendDataset) or expose the points (using Calculator)

Okay thanks. I will test out the first option today. Do you have an example of how I can do this? When I try to use the Append Dataset filter on the AMReX dataset it is grayed out. Also to my question about the Python Calculator I take it there is no way for me to access the points then? Calculator will work okay, but I would prefer the python version of the filter if I can use it.

The data is just not there, so you can’t access it. You could access it with a ProgrammableFilter though.

In the context AMR, converting to UG does not seem to be the right solution though.

I see. So what is Calculator doing? Does it just convert the dataset to vtkPolyData or something and add the fields that way? Yes I tried with a programmable filter first. I have a csv file with all the new coordinate locations so I was trying to read them into the dataset with something like

amr = inputs[0]
outputs = amr
# read csv and name variable table, headers are x, y and z
id = ['x', 'y', 'z']
for i in range(3):
   array = table[id[i]]
   outputs.PointData.append(array, id[i])

But this caused my computer to run out of memory doing the computation. It’s a pretty small dataset and I’ve got 32gb of ram on my laptop so that’s not a good sign.

My original thought was if I can just add the fields for the coordinates to the PointData then I can just use Warp by Vector. I guess that will also convert the data type though. Not really sure of how to get around that.

It is using GetPoint(), which is defined for all types of dataset.

But this caused my computer to run out of memory doing the computation. It’s a pretty small dataset and I’ve got 32gb of ram on my laptop so that’s not a good sign.

Thats definitely unexpected.

I will try a few more things today and post a reproducer script for the memory issue if I can’t figure it out.

If it’s a uniform stretching you could just modify the spacing of each of the underlying vtkImageDatas in the programmable filter.

Andy, I will have to take a closer look at this. I’m new to this Hierarchical block data structure. The stretching is done with a hyperbolic tangent (channel flow in this case). I’m not opposed to just reimplementing the stretching function we used in the code in a paraview filter if that works.