if inloc is e.g. at YLOW, this produces a wrong result.
|
if ((vloc == CELL_XLOW) && (diffloc == CELL_CENTRE)) { |
This is wrong if all locations are at CELL_CENTRE
Due to the code duplication, there are probably more cases where things are wrong.
I would suggest splitting the functions into smaller ones.
See e.g. https://github.com/dschwoerer/BOUT-dev/blob/ef41a53c04f6b349a63ac98038903b34b83a3a16/src/mesh/impls/aiolos/generated_derivs.cxx#L1672
After having determined whether we need staggered derivatives, it is much easier if you only need to consider that single case:
https://github.com/dschwoerer/BOUT-dev/blob/ef41a53c04f6b349a63ac98038903b34b83a3a16/src/mesh/impls/aiolos/generated_derivs.cxx#L1318
Further, I would be in favour of complete removing the StaggerGrids bool - which reduces and simplifies the code, without reducing its functionality. It further simplifies the use of BOUT. As this is a breaking change, we should probably wait till 5.0
if inloc is e.g. at YLOW, this produces a wrong result.
BOUT-dev/src/mesh/index_derivs.cxx
Line 1856 in 40d60c5
This is wrong if all locations are at CELL_CENTRE
BOUT-dev/src/mesh/index_derivs.cxx
Line 2681 in 40d60c5
Due to the code duplication, there are probably more cases where things are wrong.
I would suggest splitting the functions into smaller ones.
See e.g. https://github.com/dschwoerer/BOUT-dev/blob/ef41a53c04f6b349a63ac98038903b34b83a3a16/src/mesh/impls/aiolos/generated_derivs.cxx#L1672
After having determined whether we need staggered derivatives, it is much easier if you only need to consider that single case:
https://github.com/dschwoerer/BOUT-dev/blob/ef41a53c04f6b349a63ac98038903b34b83a3a16/src/mesh/impls/aiolos/generated_derivs.cxx#L1318
Further, I would be in favour of complete removing the StaggerGrids bool - which reduces and simplifies the code, without reducing its functionality. It further simplifies the use of BOUT. As this is a breaking change, we should probably wait till 5.0