xcompact3d / x3d2

https://xcompact3d.github.io/x3d2
BSD 3-Clause "New" or "Revised" License
3 stars 4 forks source link

Add a vector_calculus class #120

Closed semi-h closed 2 months ago

semi-h commented 2 months ago

This PR moves the vector calculus operations currently implemented inside solver class out to a dedicated new class. This new structure should allow accessing vector calculus operations outside the solver class. Examples include the laplacian operation iterative Poisson solver needs and curl/divergence for postprocessing/monitoring.

semi-h commented 2 months ago

looks good to me, I just think it would be good to properly define what is expected from the input variables in terms of direction and dataloc.

Thanks! Changed the namings from velocity/pressure grid to data_loc based VERT/CELL. Also added a bit more explanation in subroutine headers to explain expected DIRs and data_locs for input and output arrays.

pbartholomew08 commented 2 months ago

Nanoseb: is it worth checking that u is in DIR_X before doing that? or at least add a comment in the header to explain that it is expected semi-h: tds_solve is doing a check based on directions so added a comment in the laplacian subroutine header to explain

I think it might be worth checking the conditions at the start of the curl/div/grad/xxx subroutines. A "invalid field locations passed to curl" will be easier to debug than "invalid fields in tdsops" (which you then need to figure out where it came from). Having the tdsops perform this last level check is good to ensure we catch everything, but a higher-level check might ultimately be beneficial in my opinion.