Grid(shape, extent=None, origin=None, dimensions=None, time_dimension=None, dtype=<class 'numpy.float32'>, subdomains=None, comm=None)¶
A cartesian grid that encapsulates a computational domain over which to discretize a Function.
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 (data-type, 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
subdomains (tuple of SubDomain, optional) – If no subdomains are specified, the Grid only defines the two default subdomains
comm (MPI communicator, optional) – The set of processes over which the grid is distributed. Only relevant in case of MPI execution.
>>> 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
>>> f.shape_with_halo (6, 6)
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 | o------------o | | | | | | | | DOMAIN | extent y | | | | | | | | extent | | o------------o | origin + extent | v
Problem dimension, or number of spatial dimensions.
Map between SpaceDimensions and their global/local size.
Spatial dimensions of the computational domain.
The Distributor used for domain decomposition.
Data type inherited by all Functions defined on this Grid.
Physical extent of the domain in m.
The interior SubDomain of the Grid.
dimis a distributed Dimension, False otherwise.
Physical coordinates of the domain origin.
Offset of the local (per-process) origin from the domain origin.
Shape of the physical domain.
Shape of the local (per-process) physical domain.
Spacing between grid points in m.
Map between spacing symbols and their values for each SpaceDimension.
Symbols representing the grid spacing in each SpaceDimension
Stepping dimension associated with this Grid.
The SubDomains defined in this Grid.
Time dimension associated with this Grid.
Volume of a single cell e.g h_x*h_y*h_z in 3D.