The grid_dx field is only needed for a subset of grackle operations and it sometimes doesn't make sense for a downstream application to properly set the value (e.g. where cells are not perfect cubes or if the code isn't grid-based).
I also tweaked the documentation to recommend that downstream applications set grackle_field_data.grid_dx to something -1 in cases where it's not applicable (if the value is not initialized at all, the new error check might not work...)
As part of this commit, I actually factored the error-check out into it's own function (as well as another related check) in order to make sure that we apply the same test in both the calculate_cooling_time and solve_chemistry functions.
I placed that function inside of a newly created file called utils.c. I think that could be a good place to place functions that represent duplicated logic present in more than 1 c-routine (e.g. resetting the UVbackground rates, calculating comoving length/density units) and maybe some other basic error checks
The
grid_dx
field is only needed for a subset of grackle operations and it sometimes doesn't make sense for a downstream application to properly set the value (e.g. where cells are not perfect cubes or if the code isn't grid-based).I also tweaked the documentation to recommend that downstream applications set
grackle_field_data.grid_dx
to something-1
in cases where it's not applicable (if the value is not initialized at all, the new error check might not work...)As part of this commit, I actually factored the error-check out into it's own function (as well as another related check) in order to make sure that we apply the same test in both the
calculate_cooling_time
andsolve_chemistry
functions.I placed that function inside of a newly created file called
utils.c
. I think that could be a good place to place functions that represent duplicated logic present in more than 1 c-routine (e.g. resetting the UVbackground rates, calculating comoving length/density units) and maybe some other basic error checks