SubDomain
SubDomain(*args, **kwargs)Base class to define Grid subdomains.
To create a new SubDomain, all one needs to do is overriding :meth:define. This method takes as input a set of Dimensions and produce a mapper
``M : Dimensions -> {d, ('left', N), ('middle', N, M), ('right', N)}``
so that:
* If ``M(d) = d``, then the SubDomain spans the entire Dimension ``d``.
* If ``M(d) = ('left', N)``, then the SubDomain spans a contiguous
region of ``N`` points starting at ``d``'s left extreme.
* ``M(d) = ('right', N)`` is analogous to the case above.
* If ``M(d) = ('middle', N, M)``, then the SubDomain spans a contiguous
region of ``d_size - (N + M)`` points starting at ``N`` and finishing
at ``d_sizeM - M``.
Attributes
| Name | Type | Description |
|---|---|---|
| separated | bool, default=False | Set to True to require a stencil-safe gap between opposite left/right regions, as in SubDimension, allowing concurrent scheduling when safe. By default, touching or overlapping regions are allowed. Applies to SubDimensions generated from tuple definitions; explicit Dimensions returned by :meth:define retain their own settings. |
Examples
An “Inner” SubDomain, which spans the entire domain except for an exterior boundary region of thickness=3, can be implemented as follows
>>> from devito import SubDomain
>>> class Inner(SubDomain):
... name = 'inner'
... def define(self, dimensions):
... return {d: ('middle', 3, 3) for d in dimensions}Like before, but now spanning the entire y Dimension of a three-dimensional grid
>>> class InnerY(SubDomain):
... name = 'inner_y'
... def define(self, dimensions):
... x, y, z = dimensions
... return {x: ('middle', 3, 3), y: y, z: ('middle', 3, 3)}To declare that opposite boundary regions leave a stencil-safe gap, set separated = True on the SubDomain subclass:
>>> class LeftBoundary(SubDomain):
... name = 'left_boundary'
... separated = True
... def define(self, dimensions):
... x, y = dimensions
... return {x: ('left', 3), y: y}See Also
Domain : An example of preset SubDomain. Interior : An example of preset Subdomain.
Notes
SubDomains are the only way to harness the benefits of domain decomposition, especially when defining BCs.
Methods
| Name | Description |
|---|---|
| define | Parametrically describe the SubDomain w.r.t. a generic Grid. |
define
define(dimensions)Parametrically describe the SubDomain w.r.t. a generic Grid.
Notes
This method should be overridden by each SubDomain subclass. For more information, refer to SubDomain.__doc__.