AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
506 stars 337 forks source link

Add MultiFab::sum(region) and sum_unique(region) #3871

Closed WeiqunZhang closed 3 months ago

WeiqunZhang commented 3 months ago

Summary

Add two new functions to MultiFab that return the sum of the given region.

Additional background

3869

Checklist

The proposed changes:

asalmgren commented 3 months ago

1) duplicatly is misspelled 2) I'm worried about people assuming this works correctly with periodicity even though the code has a comment that it doesn't account for that

WeiqunZhang commented 3 months ago

Yes, there could be potential confusion even though logically speaking it should not because without being provided the periodicity information amrex cannot know how to handle it. So the caller has to assume periodicity is not part of the consideration. This is a feature request from WarpX, which does not need the periodic boundaries to be handled in this function. I didn't try to add periodicity support because it's actually quite awkward to implement. We would need to memcpy a vector of periodically shifted Boxes to device in order to do all these in one kernel. Maybe we can wait till someone wants the feature.