Skip to content

Commit

Permalink
Merge pull request #130 from ChevronETC/buffer_support
Browse files Browse the repository at this point in the history
buffer object support and tests
  • Loading branch information
deckerla authored Jun 11, 2022
2 parents feed8b3 + 3727cf6 commit de36f7e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Devito.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,17 @@ function SubDomain(name::String, instructions...)
return SubDomain{N}(subdom(name,instructions))
end

struct Buffer
o::PyObject
end

"""
Buffer(value::Int)
Construct a devito buffer. This may be used as a save= keyword argument in the construction of TimeFunctions.
"""
Buffer(value::Int) = Buffer(pycall(devito.Buffer, PyObject, value))
PyCall.PyObject(x::Buffer) = x.o

"""
nsimplify(expr::PyObject; constants=(), tolerance=none, full=false, rational=none, rational_conversion="base10")
Expand Down Expand Up @@ -1938,6 +1949,6 @@ Base.isequal(x::Union{SubDomain, DiscreteFunction, Constant, AbstractDimension,

Base.hash(x::Union{SubDomain, DiscreteFunction, Constant, AbstractDimension, Operator, Grid, Eq, Injection}) = hash(PyObject(x))

export Constant, DiscreteFunction, Grid, Function, SparseFunction, SparseTimeFunction, SubDomain, TimeFunction, apply, backward, ccode, configuration, configuration!, coordinates, coordinates_data, data, data_allocated, data_with_halo, data_with_inhalo, dimension, dimensions, dx, dy, dz, evaluate, extent, forward, grid, halo, inject, interpolate, localindices, localindices_with_halo, localindices_with_inhalo, localsize, name, nsimplify, origin, size_with_halo, simplify, solve, spacing, spacing_map, step, subdomains, subs, thickness, value, value!
export Buffer, Constant, DiscreteFunction, Grid, Function, SparseFunction, SparseTimeFunction, SubDomain, TimeFunction, apply, backward, ccode, configuration, configuration!, coordinates, coordinates_data, data, data_allocated, data_with_halo, data_with_inhalo, dimension, dimensions, dx, dy, dz, evaluate, extent, forward, grid, halo, inject, interpolate, localindices, localindices_with_halo, localindices_with_inhalo, localsize, name, nsimplify, origin, size_with_halo, simplify, solve, spacing, spacing_map, step, subdomains, subs, thickness, value, value!

end
9 changes: 9 additions & 0 deletions test/serialtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1026,3 +1026,12 @@ end
@test data_with_inhalo(sf) ones(Float32, npoint)
@test data_with_inhalo(stf) ones(Float32, npoint, nt)
end

@testset "Buffer construction and use, buffer size = $value" for value in (1,2,4)
b = Buffer(value)
@test typeof(b) == Buffer
shp = (5,6)
grd = Grid(shape=shp)
u = TimeFunction(name="u", grid=grd, save=b)
@test size(u) == (shp...,value)
end

0 comments on commit de36f7e

Please sign in to comment.