How to load initial conditions from an external dataset (CSV) into IdefixArray on GPU? #351
-
|
Hello, I am currently working on implementing a Parker wind setup in Idefix and I would like to initialize the flow variables using an external dataset (a CSV file containing dimensionless profiles of radius r, velocity v(r), and density ρ(r)). My goal is to read this dataset in setup.cpp and use it to set the initial conditions by copying the values into IdefixArray so that they are accessible inside the GPU parallel_for loops. However, when I attempted to pass the host vectors (read from the CSV using std::vector) directly into the device kernel, the compilation failed with errors such as “identifier X is undefined in device code” and warnings like “address of a host variable cannot be directly taken in a device function”. I understand that host variables cannot be accessed directly on the device, but I am not sure what is the proper way in Idefix/Kokkos to transfer external data into IdefixArray or another device-resident container. Additionally, when I tried different approaches to make the arrays visible to the GPU, the simulation sometimes compiled but crashed at runtime with a segmentation fault (core dumped) when calling UserdefBoundary or during initialization. My question is: what is the recommended workflow in Idefix for reading external data (from CSV on host) and then safely making it available on the GPU, so that I can initialize Vc(RHO,...) and Vc(VX1,...) with my Parker wind profile without encountering these compilation errors or segmentation faults? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
If you want to load a csv file, you can use the "lookuptable" class https://idefix.readthedocs.io/latest/programmingguide.html#lookuptable-class Alternatively, you can initialise the flow in python as in this example: test/IO/pydefix Without showing us your code and the exact error you have, we can't really help. |
Beta Was this translation helpful? Give feedback.
If you want to load a csv file, you can use the "lookuptable" class https://idefix.readthedocs.io/latest/programmingguide.html#lookuptable-class
Initialise a lookup table in Setup::Initflow and then use the lookup table to initialise the Vc(RHO....) variable, as shown in the many examples (note that all the examples provided use a host copy of the DataBlock, you should do the same).
Alternatively, you can initialise the flow in python as in this example: test/IO/pydefix
Without showing us your code and the exact error you have, we can't really help.