BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

NaulinSolver initial derivatives have wrong boundary conditions

Open johnomotani opened this issue 6 years ago • 2 comments

In the NaulinSolver, before starting the iteration loop, we take derivatives of the initial guess https://github.com/boutproject/BOUT-dev/blob/450f4d1b1148b4f94af8dcba4253361714022b3e/src/invert/laplace/impls/naulin/naulin_laplace.cxx#L197-L199 When using the INVERT_SET options, the x-boundary guard cells of x0, are set to the desired value for the boundary condition, not the value that the guard cells would have after the boundary condition is applied. Especially in the case of Neumann boundary conditions, this can be a large difference. x in L.197-99 is copied from x0 so the derivative next to the boundaries will be wrong when INVERT_SET is used. The final solution, if the iteration converges, should be OK, because inside the loop x gets boundary conditions correctly applied by delp2solver, and the x-guard cells are only changed (by copy_x_boundaries) after the derivatives are taken.

The solution to this is, when INVERT_SET is used, apply the boundary condition to x after copying from x0 and before taking derivatives. Need to write a special method for doing this, since the standard boundary conditions don't allow setting to values from a Field3D. It should be enough to handle Dirichlet and Neumann cases though, so isn't a huge amount of work.

Spotted by Fabio Riva.

johnomotani avatar Jan 23 '19 14:01 johnomotani

Is this still an issue?

ZedThree avatar Mar 20 '20 14:03 ZedThree

Yes, I think it's still an issue.

johnomotani avatar Mar 20 '20 14:03 johnomotani