boutproject / BOUT-dev

BOUT++: Plasma fluid finite-difference simulation code in curvilinear coordinate systems
http://boutproject.github.io/
GNU Lesser General Public License v3.0
179 stars 93 forks source link

PETSc XZHermiteSpline #2917

Open ZedThree opened 1 month ago

ZedThree commented 1 month ago

Continues #2858 pulling out a separate class for PetscXZHermiteSpline that was started in #2651

This does have a working implementation, but I've tried to switch it the existing PetscMatrix wrapper, and unfortunately I've gone wrong somewhere -- probably at the boundaries.

Double unfortunately, I really don't have much time to spend digging into this. @dschwoerer Maybe you want to take a look?

ZedThree commented 1 month ago

Ok, I have managed to convert this to use the PetscMatrix interface. I need to spend a lot of time faffing about with GlobalIndexer and realised the source of my pain: it can only convert indices that are both local to and owned by the current process. For the interpolation here, we want to deal with indices that are on other processes. And because PetscMatrix wants to convert local indices to global ones, we need to first convert the global index of the (x, z) offsets into local ones, and then convert those to global indices.

So I've implemented a new GlobalIndexer subclass that will probably only work for very simple parallel decompositions, but can convert e.g. negative local indices into global ones. That gets an index converter that is actually pretty straightforward and can be used with PetscMatrix, which then allows a pretty clean implementation in our new interpolation!

github-actions[bot] commented 1 month ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 1 month ago

clang-tidy review says "All clean, LGTM! :+1:"