pyAMReX
Functions
amrex.Array4 Namespace Reference

Functions

def array4_to_numpy (self, copy=False, order="F")
 
def array4_to_cupy (self, copy=False, order="F")
 
def register_Array4_extension (amr)
 

Detailed Description

This file is part of pyAMReX

Copyright 2023 AMReX community
Authors: Axel Huebl
License: BSD-3-Clause-LBNL

Function Documentation

◆ array4_to_cupy()

def amrex.Array4.array4_to_cupy (   self,
  copy = False,
  order = "F" 
)
Provide a Cupy view into an Array4.

This includes ngrow guard cells of the box.

Note on the order of indices:
By default, this is as in AMReX in Fortran contiguous order, indexing as
x,y,z. This has performance implications for use in external libraries such
as cupy.
The order="C" option will index as z,y,x and perform better with cupy.
https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074

Parameters
----------
self : amrex.Array4_*
    An Array4 class in pyAMReX
copy : bool, optional
    Copy the data if true, otherwise create a view (default).
order : string, optional
    F order (default) or C. C is faster with external libraries.

Returns
-------
cupy.array
    A cupy n-dimensional array.

Raises
------
ImportError
    Raises an exception if cupy is not installed

◆ array4_to_numpy()

def amrex.Array4.array4_to_numpy (   self,
  copy = False,
  order = "F" 
)
Provide a Numpy view into an Array4.

This includes ngrow guard cells of the box.

Note on the order of indices:
By default, this is as in AMReX in Fortran contiguous order, indexing as
x,y,z. This has performance implications for use in external libraries such
as cupy.
The order="C" option will index as z,y,x and perform better with cupy.
https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074

Parameters
----------
self : amrex.Array4_*
    An Array4 class in pyAMReX
copy : bool, optional
    Copy the data if true, otherwise create a view (default).
order : string, optional
    F order (default) or C. C is faster with external libraries.

Returns
-------
np.array
    A numpy n-dimensional array.

◆ register_Array4_extension()

def amrex.Array4.register_Array4_extension (   amr)
Array4 helper methods