Grid¶

class
devito.types.
Grid
(shape, extent=None, origin=None, dimensions=None, time_dimension=None, dtype=<class 'numpy.float32'>, subdomains=None, comm=None)[source]¶ Bases:
devito.types.args.ArgProvider
A cartesian grid that encapsulates a computational domain over which to discretize a Function.
Parameters:  shape (tuple of ints) – Shape of the computational domain in grid points.
 extent (tuple of floats, optional) – Physical extent of the domain in m; defaults to a unit box of extent 1m in all dimensions.
 origin (tuple of floats, optional) – Physical coordinate of the origin of the domain; defaults to 0.0 in all dimensions.
 dimensions (tuple of SpaceDimension, optional) – The dimensions of the computational domain encapsulated by this Grid.
 time_dimension (TimeDimension, optional) – The dimension used to define time in a TimeFunction created from this Grid.
 dtype (datatype, optional) – Any object that can be interpreted as a numpy data type, used as default
data type to be inherited by all Functions created from this Grid.
Defaults to
np.float32
.  subdomains (tuple of SubDomain, optional) – If no subdomains are specified, the Grid only defines the two default
subdomains
interior
anddomain
.  comm (MPI communicator, optional) – The set of processes over which the grid is distributed. Only relevant in case of MPI execution.
Examples
>>> from devito import Grid, Function >>> grid = Grid(shape=(4, 4), extent=(3.0, 3.0)) >>> f = Function(name='f', grid=grid) >>> f.shape (4, 4) >>> f.dimensions (x, y) >>> f.dtype <class 'numpy.float32'>
In a Function, the domain defined by a Grid is often surrounded by a “halo region”, which guarantees the correctness of stencil updates nearby the domain boundary. However, the size of the halo region does not depend on the Grid; for more information, refer to
Function.__doc__
.>>> f.shape_with_halo (6, 6)
Notes
A Grid encapsulates the topology and geometry information of the computational domain that a Function can be discretized on. As such, it defines and provides the physical coordinate information of the logical cartesian grid underlying the discretized Functions. For example, the conventions for defining the coordinate space in 2D are:
x >  origin  oo         DOMAIN  extent[1] y         extent[0]   oo  origin + extent  v

dim
¶ Problem dimension, or number of spatial dimensions.

dimension_map
¶ Map between SpaceDimensions and their global/local size.

dimensions
¶ Spatial dimensions of the computational domain.

distributor
¶ The Distributor used for domain decomposition.

dtype
¶ Data type inherited by all Functions defined on this Grid.

extent
¶ Physical extent of the domain in m.

interior
¶ The interior SubDomain of the Grid.

origin
¶ Physical coordinates of the domain origin.

origin_offset
¶ Offset of the local (perprocess) origin from the domain origin.

shape
¶ Shape of the physical domain.

shape_local
¶ Shape of the local (perprocess) physical domain.

spacing
¶ Spacing between grid points in m.

spacing_map
¶ Map between spacing symbols and their values for each SpaceDimension.

spacing_symbols
¶ Symbols representing the grid spacing in each SpaceDimension

stepping_dim
¶ Stepping dimension associated with this Grid.

subdomains
¶ The SubDomains defined in this Grid.

time_dim
¶ Time dimension associated with this Grid.

volume_cell
¶ Volume of a single cell e.g h_x*h_y*h_z in 3D.