Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement multifab wrapper functionality from WarpX (#370)
This adds the code from the WarpX fields.py that allows global indexing of MultiFabs. This is done by adding `__getitem__` and `__setitem__` methods for the MultiFab object. Note that this incorporates the changes from WarpX PR #4370 that had not been merged in. This currently only does the get/set without including the ghost cells. What is needed is a way of specifying inclusion of the ghost cells. Perhaps this? ```py mf = MultiFab() mf[:,5,6] # without ghost cells mf[:,5,6] = 2. # without ghost cells mf.with_ghosts([slice(None),5,6]) # with ghost cells (in the first dimension) mf.with_ghosts([slice(None),5,6], 2.) # with ghost cells ``` Maybe this, using imaginary numbers to refer to ghost cells? ```py mf[-1j,5,6] # the first ghost cell on the lower boundary mf[+1j,5,6] # the first ghost cell on the upper boundary mf[(),5,6] # the full first dimension including ghosts mf[:,5,6] # the first dimension without ghosts ``` I prefer this method. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information