Mercurial > repos > public > sbplib_julia
diff src/Grids/grid.jl @ 1416:031514327289 feature/boundary_conditions
Merge with default
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 22 Aug 2023 22:44:42 +0200 |
parents | 2ad518182b37 |
children | 455e6b4c8b02 |
line wrap: on
line diff
--- a/src/Grids/grid.jl Tue Aug 22 21:53:05 2023 +0200 +++ b/src/Grids/grid.jl Tue Aug 22 22:44:42 2023 +0200 @@ -22,6 +22,8 @@ Base.ndims(::Grid{T,D}) where {T,D} = D Base.eltype(::Type{<:Grid{T}}) where T = T +Base.getindex(g::Grid, I::CartesianIndex) = g[Tuple(I)...] + """ coordinate_size(g) @@ -74,7 +76,7 @@ """ eval_on(g::Grid, f) -Lazy evaluation `f` on the grid. `f` can either be on the form `f(x,y,...)` +Lazy evaluation of `f` on the grid. `f` can either be on the form `f(x,y,...)` with each coordinate as an argument, or on the form `f(x̄)` taking a coordinate vector. @@ -89,5 +91,12 @@ end end +""" + eval_on(g::Grid, f::Number) + +Lazy evaluation of a scalar `f` on the grid. +""" +eval_on(g::Grid, f::Number) = return LazyTensors.LazyConstantArray(f, size(g)) + _ncomponents(::Type{<:Number}) = 1 _ncomponents(T::Type{<:SVector}) = length(T)