Skip to content

Commit

Permalink
Modify neighboringnodes for AbstractMesh
Browse files Browse the repository at this point in the history
  • Loading branch information
KeitaNakamura committed Aug 5, 2024
1 parent 769bc01 commit 2755c8c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/Interpolations/mpvalue.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
abstract type Interpolation end
abstract type Kernel <: Interpolation end

#=
Expand All @@ -17,6 +18,8 @@ function create_property(::Type{T}, it::Interpolation, mesh::CartesianMesh{dim};
error("wrong differentiation type, choose `nothing`, `gradient` and `hessian`")
end

NeighboringNodesType(::Interpolation, ::CartesianMesh{dim}) where {dim} = CartesianIndices{dim, NTuple{dim, UnitRange{Int}}}

"""
MPValue(Vec{dim}, interpolation)
MPValue(Vec{dim, T}, interpolation)
Expand Down Expand Up @@ -73,10 +76,14 @@ end

@inline neighboringnodes(mp::MPValue) = getfield(mp, :indices)[]
@inline function neighboringnodes(mp::MPValue, grid::Grid)
neighboringnodes(mp, get_mesh(grid))
end
@inline function neighboringnodes(mp::MPValue, mesh::CartesianMesh)
inds = neighboringnodes(mp)
@boundscheck checkbounds(grid, inds)
@boundscheck checkbounds(mesh, inds)
inds
end
# SpGrid always use CartesianMesh
@inline function neighboringnodes(mp::MPValue, grid::SpGrid)
inds = neighboringnodes(mp)
spinds = get_spinds(grid)
Expand Down
2 changes: 0 additions & 2 deletions src/Tesserae.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export
closevtm,
closepvd

abstract type Interpolation end

include("utils.jl")
include("mesh.jl")
include("blockspace.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/grid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spacing_inv(grid::Grid) = spacing_inv(get_mesh(grid))
# SpGrid #
##########

const SpGrid{N, T, NT <: NamedTuple{<: Any, <: Tuple{AbstractMesh, SpArray, Vararg{SpArray}}}, I} = StructArray{T, N, NT, I}
const SpGrid{N, T, NT <: NamedTuple{<: Any, <: Tuple{CartesianMesh, SpArray, Vararg{SpArray}}}, I} = StructArray{T, N, NT, I}

function check_gridproperty(::Type{GridProp}, ::Type{Vec{dim, T}}) where {GridProp, dim, T}
V = fieldtype(GridProp, 1)
Expand Down
2 changes: 0 additions & 2 deletions src/mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ CartesianIndices((1:5,))
end
@inline EmptyCartesianIndices(::Val{dim}) where {dim} = CartesianIndices(nfill(1:0, Val(dim)))

NeighboringNodesType(::Interpolation, ::CartesianMesh{dim}) where {dim} = CartesianIndices{dim, NTuple{dim, UnitRange{Int}}}

"""
whichcell(x::Vec, mesh::CartesianMesh)
Expand Down

0 comments on commit 2755c8c

Please sign in to comment.