Skip to content

Commit

Permalink
iMultiFab Python Extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Jan 29, 2025
1 parent 71ca219 commit d6cccd0
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/amrex/extensions/MultiFab.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def mf_to_numpy(self, copy=False, order="F"):

mf = self
if copy:
mf = amr.MultiFab(
mf_type = type(self) # MultiFab or iMultiFab
mf = mf_type(
self.box_array(),
self.dm(),
self.n_comp,
Expand Down Expand Up @@ -156,7 +157,8 @@ def copy_multifab(amr, self):
amrex.MultiFab
A copy of this MultiFab.
"""
mf = amr.MultiFab(
mf_type = type(self) # MultiFab or iMultiFab
mf = mf_type(
self.box_array(),
self.dm(),
self.n_comp,
Expand Down Expand Up @@ -657,3 +659,19 @@ def register_MultiFab_extension(amr):
amr.MultiFab.shape_with_ghosts = property(shape_with_ghosts)
amr.MultiFab.__getitem__ = __getitem__
amr.MultiFab.__setitem__ = __setitem__

# iMultiFab
amr.iMultiFab.__iter__ = lambda imfab: amr.MFIter(imfab)

amr.iMultiFab.to_numpy = mf_to_numpy
amr.iMultiFab.to_cupy = mf_to_cupy
amr.iMultiFab.to_xp = mf_to_xp

amr.iMultiFab.copy = lambda self: copy_multifab(amr, self)
amr.iMultiFab.copy.__doc__ = copy_multifab.__doc__

amr.iMultiFab.imesh = imesh
amr.iMultiFab.shape = property(shape)
amr.iMultiFab.shape_with_ghosts = property(shape_with_ghosts)
amr.iMultiFab.__getitem__ = __getitem__
amr.iMultiFab.__setitem__ = __setitem__

0 comments on commit d6cccd0

Please sign in to comment.