Access solution and primitives via python wrapper by pcarruscag · Pull Request #1938 · su2code/SU2
@patelha57 @aa-g @Nicola-Fonzi @bigfooted
I'm proposing this as the way to interact with volume fields via the python wrapper.
We create a matrix view (does not copy data) into the coordinates, solution, primitives, etc. which then allows point-wise or row-wise access to the data (read or write). We can extend it to also expose derivative information.
For example:
coords = driver.Coordinates() print(coords(iPoint, 1)) # read a value coords.Set(iPoint, (x, y, z)) # write a row coords.Set(iPoint, 0, coords.Get(iPoint, 0)) # set a value and different way of reading a value solversIndices = driver.GetSolverIndices() # maps solver names to our solver integers, similar to what we do with markers solution = driver.Solution(solverIndices["C.FLOW"]) # same object type as coords primitiveIndices = driver.GetPrimitiveIndices() # maps primitive names to their indices. temperatureIndex = primitiveIndices["TEMPERATURE"] primitives = driver.Primitives() print(primitives(iPoint, temperatureIndex))