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

property
dim
¶ Problem dimension, or number of spatial dimensions.

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

property
dimensions
¶ Spatial dimensions of the computational domain.

property
distributor
¶ The Distributor used for domain decomposition.

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

property
extent
¶ Physical extent of the domain in m.

property
interior
¶ The interior SubDomain of the Grid.

property
origin
¶ Physical coordinates of the domain origin.

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

property
shape
¶ Shape of the physical domain.

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

property
spacing
¶ Spacing between grid points in m.

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

property
spacing_symbols
¶ Symbols representing the grid spacing in each SpaceDimension

property
stepping_dim
¶ Stepping dimension associated with this Grid.

property
subdomains
¶ The SubDomains defined in this Grid.

property
time_dim
¶ Time dimension associated with this Grid.

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