SparseTimeFunction
self, *args, **kwargs) SparseTimeFunction(
Tensor symbol representing a space- and time-varying sparse array in symbolic equations.
Like SparseFunction, SparseTimeFunction carries multi-dimensional data that are not aligned with the computational grid. As such, each data value is associated some coordinates. A SparseTimeFunction provides symbolic interpolation routines to convert between TimeFunctions and sparse data points. These are based upon standard [bi,tri]linear interpolation.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the symbol. | required |
npoint | int | Number of sparse points. | required |
nt | int | Number of timesteps along the time Dimension. | required |
grid | Grid | The computational domain from which the sparse points are sampled. | required |
coordinates | np.ndarray | The coordinates of each sparse point. | required |
space_order | int | Discretisation order for space derivatives. | 0 |
time_order | int | Discretisation order for time derivatives. | 1 |
shape | tuple of ints | Shape of the object. | (nt, npoint) |
dimensions | tuple of Dimension | Dimensions associated with the object. Only necessary if the SparseFunction defines a multi-dimensional tensor. | required |
dtype | data - type | Any object that can be interpreted as a numpy data type. | np.float32 |
initializer | callable or any object exposing the buffer interface | Data initializer. If a callable is provided, data is allocated lazily. | None |
allocator | MemoryAllocator | Controller for memory allocation. To be used, for example, when one wants to take advantage of the memory hierarchy in a NUMA architecture. Refer to default_allocator.__doc__ for more information. |
required |
Examples
Creation
>>> from devito import Grid, SparseTimeFunction
>>> grid = Grid(shape=(4, 4))
>>> sf = SparseTimeFunction(name='sf', grid=grid, npoint=2, nt=3)
>>> sf
sf(time, p_sf)
Inspection
>>> sf.data
0., 0.],
Data([[0., 0.],
[0., 0.]], dtype=float32)
[>>> sf.coordinates
sf_coords(p_sf, d)>>> sf.coordinates_data
0., 0.],
array([[0., 0.]], dtype=float32) [
Symbolic interpolation routines
>>> from devito import TimeFunction
>>> f = TimeFunction(name='f', grid=grid)
>>> exprs0 = sf.interpolate(f)
>>> exprs1 = sf.inject(f, sf)
Notes
The parameters must always be given as keyword arguments, since SymPy uses *args
to (re-)create the Dimension arguments of the symbolic object.
Attributes
Name | Description |
---|---|
forward | Symbol for the time-forward state of the TimeFunction. |
is_SparseTimeFunction | bool(x) -> bool |
Methods
Name | Description |
---|---|
inject | Generate equations injecting an arbitrary expression into a field. |
interpolate | Generate equations interpolating an arbitrary expression into self . |
inject
=None, p_t=None, implicit_dims=None) inject(field, expr, u_t
Generate equations injecting an arbitrary expression into a field.
Parameters
Name | Type | Description | Default |
---|---|---|---|
field | Function | Input field into which the injection is performed. | required |
expr | expr - like | Injected expression. | required |
u_t | expr - like | Time index at which the interpolation is performed. | None |
p_t | expr - like | Time index at which the result of the interpolation is stored. | None |
implicit_dims | Dimension or list of Dimension | An ordered list of Dimensions that do not explicitly appear in the injection expression, but that should be honored when constructing the operator. | None |
interpolate
=None, p_t=None, increment=False, implicit_dims=None) interpolate(expr, u_t
Generate equations interpolating an arbitrary expression into self
.
Parameters
Name | Type | Description | Default |
---|---|---|---|
expr | expr - like | Input expression to interpolate. | required |
u_t | expr - like | Time index at which the interpolation is performed. | None |
p_t | expr - like | Time index at which the result of the interpolation is stored. | None |
increment | If True, generate increments (Inc) rather than assignments (Eq). | False |