implementations.datatype_classes.cupy_mesh module¶
- class CuPyMultiComponentMesh(init, *args, **kwargs)[source]¶
Bases:
cupy_mesh
Generic mesh with multiple components.
To make a specific multi-component mesh, derive from this class and list the components as strings in the class attribute
components
. An example:``` class imex_cupy_mesh(CuPyMultiComponentMesh):
components = [‘impl’, ‘expl’]
Instantiating such a mesh will expand the mesh along an added first dimension for each component and allow access to the components with
.
. Continuing the above example:` init = ((100,), None, numpy.dtype('d')) f = imex_cupy_mesh(init) f.shape # (2, 100) f.expl.shape # (100,) `
Note that the components are not attributes of the mesh:
"expl" in dir(f)
will return False! Rather, the components are handled in__getattr__
. This function is called if an attribute is not found and returns a view on to the component if appropriate. Importantly, this means that you cannot name a component like something that is already an attribute ofcupy_mesh
orcupy.ndarray
because this will not result in calls to__getattr__
.- There are a couple more things to keep in mind:
Because a
CuPyMultiComponentMesh
is just acupy.ndarray
with one more dimension, all components must have the same shape.You can use the entire
CuPyMultiComponentMesh
like acupy.ndarray
in operations that accept arrays, but make sure that you really want to apply the same operation on all components if you do.If you omit the assignment operator
[:]
during assignment, you will not change the mesh at all. Omitting this leads to all kinds of trouble throughout the code. But here you really cannot get away without.
- components = []¶
- class comp2_cupy_mesh(init, *args, **kwargs)[source]¶
Bases:
CuPyMultiComponentMesh
- components = ['comp1', 'comp2']¶
- class cupy_mesh(init, val=0.0, offset=0, buffer=None, strides=None, order=None)[source]¶
Bases:
ndarray
CuPy-based datatype for serial or parallel meshes.
- bcast(root=None, comm=None)[source]¶
Routine for broadcasting values
- Parameters:
root (int) – process with value to broadcast
comm – communicator
- Returns:
broadcasted values
- property comm¶
Getter for the communicator
- class imex_cupy_mesh(init, *args, **kwargs)[source]¶
Bases:
CuPyMultiComponentMesh
- components = ['impl', 'expl']¶