idefix-code/idefix

NaN in grid are not captured

Closed this issue · 0 comments

In GitLab by @vdbma on Jan 4, 2023, 10:50

When the grid contains NaN values, these are not captured and the end up producing NaN values in the flow.

A way to reproduce this is by using EVOLVE_VECTOR_POTENTIAL and using a log grid with only one cell, eg

X3-grid  1  0  1  l  6.283185307179586

The curl of the vector potential will produce NaNs in the magnetic field.

The error message we get (because of NaNs in BX*):

...
Main: Creating initial conditions.
Dump: Write file n 0...done in 0.00552546 s.
Vtk: Write file n 0...done in 0.00540364 s.
DataBlock: Nans were found in the current calculation
DataBlock: rank 0 found 20480 Nans in Vc and 41796 Nans in Vs in the current datablock. Details will be in corresponding process log file.
rank 0: Nan found  in variable BX1
      global (i,j,k) = (0, 0, 0)
      global (x,y,z) = (0.0101639, 0.138171, -nan)
rank 0: Nan found  in variable BX2
      global (i,j,k) = (0, 0, 0)
      global (x,y,z) = (0.0101639, 0.138171, -nan)
rank 0: Nan found  in variable BX1
      global (i,j,k) = (1, 0, 0)
      global (x,y,z) = (0.0104971, 0.138171, -nan)
rank 0: Nan found  in variable BX2
      global (i,j,k) = (1, 0, 0)
      global (x,y,z) = (0.0104971, 0.138171, -nan)
rank 0: Nan found  in variable BX1
      global (i,j,k) = (2, 0, 0)
      global (x,y,z) = (0.0108412, 0.138171, -nan)
rank 0: Nan found  in variable BX2
      global (i,j,k) = (2, 0, 0)
      global (x,y,z) = (0.0108412, 0.138171, -nan)
rank 0: Nan found  in variable BX1
      global (i,j,k) = (3, 0, 0)
      global (x,y,z) = (0.0111965, 0.138171, -nan)
rank 0: Nan found  in variable BX2
      global (i,j,k) = (3, 0, 0)
      global (x,y,z) = (0.0111965, 0.138171, -nan)
rank 0: Nan found  in variable BX1
      global (i,j,k) = (4, 0, 0)
      global (x,y,z) = (0.0115636, 0.138171, -nan)
rank 0: Nan found  in variable BX2
      global (i,j,k) = (4, 0, 0)
      global (x,y,z) = (0.0115636, 0.138171, -nan)
... 
*** More Nans have been found in current dataBlock. Only showing the first 10.

------------------------------------------------------------------------------
### FATAL ERROR in function main file /home/vandenma/Documents/idefix/src/main.cpp line 130
Nans were found in your initial conditions.
------------------------------------------------------------------------------
Kokkos::Cuda ERROR: Failed to call Kokkos::Cuda::finalize()

Note that one can see that the coordinates at which there are NaN in BX* have a NaN value for the third dimension.

Suggestion :
This could be checked when the grid is created, producing a clearer error message, rather than waiting for a NaN to appear later.