Skip to content

Commit 27b9c5e

Browse files
committed
iMultiFab Python Extensions
1 parent df024a9 commit 27b9c5e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/amrex/extensions/MultiFab.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def mf_to_numpy(self, copy=False, order="F"):
4545

4646
mf = self
4747
if copy:
48-
mf = amr.MultiFab(
48+
mf_type = type(self) # MultiFab or iMultiFab
49+
mf = mf_type(
4950
self.box_array(),
5051
self.dm(),
5152
self.n_comp,
@@ -156,7 +157,8 @@ def copy_multifab(amr, self):
156157
amrex.MultiFab
157158
A copy of this MultiFab.
158159
"""
159-
mf = amr.MultiFab(
160+
mf_type = type(self) # MultiFab or iMultiFab
161+
mf = mf_type(
160162
self.box_array(),
161163
self.dm(),
162164
self.n_comp,
@@ -657,3 +659,17 @@ def register_MultiFab_extension(amr):
657659
amr.MultiFab.shape_with_ghosts = property(shape_with_ghosts)
658660
amr.MultiFab.__getitem__ = __getitem__
659661
amr.MultiFab.__setitem__ = __setitem__
662+
663+
# iMultiFab
664+
amr.iMultiFab.to_numpy = mf_to_numpy
665+
amr.iMultiFab.to_cupy = mf_to_cupy
666+
amr.iMultiFab.to_xp = mf_to_xp
667+
668+
amr.iMultiFab.copy = lambda self: copy_multifab(amr, self)
669+
amr.iMultiFab.copy.__doc__ = copy_multifab.__doc__
670+
671+
amr.iMultiFab.imesh = imesh
672+
amr.iMultiFab.shape = property(shape)
673+
amr.iMultiFab.shape_with_ghosts = property(shape_with_ghosts)
674+
amr.iMultiFab.__getitem__ = __getitem__
675+
amr.iMultiFab.__setitem__ = __setitem__

0 commit comments

Comments
 (0)