Implement mesh_function_correction for getting derivatives of functions that are non-zero at the boundaries
What is happening
Suppose a mesh_function
is significantly non-zero at the border. In that case, taking any derivative will result in spikes at the boundaries (meaning at the last row of points, between gr%np
and towards the inside).
This is due to the fact the derivatives
module sets the value of the function to zero between gr%np
and gr%np_part
. Since then there is a jump, we observe a spike in the result.
How to reproduce it
To reproduce the bug, it is possible to use the input file 35-helmholtz_decom.02-small_box_no_surf_corr.inp
and look at functions after a derivative is taken after a Poisson equation.
Proposed solution
A possible solution is to expand the function in the region between gr%np
and gr%np_part
. This can be done using some polynomial expansion (e.g. Taylor series) or multipolar expansion. Multipolar expansion is implemented in poisson_corrections.F90
, and it is used for the poisson_cg
solver.
The idea is to create a new module, mesh_function_correction
that implements several ways to expand a mesh function in the aforementioned region.