JuliaGeometry / JuliaGeometry/RegionTrees.jl

A problem related to split! of cell

Open
#25 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
114
Forks
22
PR merge metrics
No merged PRs in 30d

Description

I tweaked the example as follows:

import StaticArrays: SVector
using RegionTrees

include("adaptive_distance_fields.jl")
using .AdaptivelySampledDistanceFields: ASDF, evaluate

s = x -> sqrt(sum((x - SVector(0, 0)).^2))
eps = 0.1
adf = ASDF(s, SVector(0., 0), SVector(1. + eps, 1 + eps), 1e-4, 1e-4)

and got the following error:

ERROR: LoadError: BoundsError: attempt to access interpolate(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}, BSpline(Linear())) with element type Float64 with indices 1:2×1:2 at index [2.000000000000001, 1.4999999999999973]
Stacktrace:
 [1] throw_boundserror(::Interpolations.BSplineInterpolation{Float64,2,StaticArrays.SArray{Tuple{2,2},Float64,2,4},BSpline{Linear},Tuple{Base.Slice{UnitRange{Int64}},Base.Slice{UnitRange{Int64}}}}, ::Tuple{Float64,Float64}) at ./abstractarray.jl:484
 [2] BSplineInterpolation at /home/h-ishida/documents/Interpolations.jl/src/b-splines/indexing.jl:17 [inlined]
 [3] macro expansion at /home/h-ishida/documents/RegionTrees.jl/examples/adaptive_distance_fields/adaptive_distance_fields.jl:10 [inlined]
 [4] evaluate(::Interpolations.BSplineInterpolation{Float64,2,StaticArrays.SArray{Tuple{2,2},Float64,2,4},BSpline{Linear},Tuple{Base.Slice{UnitRange{Int64}},Base.Slice{UnitRange{Int64}}}}, ::StaticArrays.SArray{Tuple{2},Float64,1,2}) at /home/h-ishida/documents/RegionTrees.jl/examples/adaptive_distance_fields/adaptive_distance_fields.jl:10
 [5] evaluate(::Interpolations.BSplineInterpolation{Float64,2,StaticArrays.SArray{Tuple{2,2},Float64,2,4},BSpline{Linear},Tuple{Base.Slice{UnitRange{Int64}},Base.Slice{UnitRange{Int64}}}}, ::HyperRectangle{2,Float64}, ::StaticArrays.SArray{Tuple{2},Float64,1,2}) at /home/h-ishida/documents/RegionTrees.jl/examples/adaptive_distance_fields/adaptive_distance_fields.jl:30
 [6] evaluate at /home/h-ishida/documents/RegionTrees.jl/examples/adaptive_distance_fields/adaptive_distance_fields.jl:19 [inlined]
 [7] needs_refinement(::Cell{Interpolations.BSplineInterpolation{Float64,2,StaticArrays.SArray{Tuple{2,2},Float64,2,4},BSpline{Linear},Tuple{Base.Slice{UnitRange{Int64}},Base.Slice{UnitRange{Int64}}}},2,Float64,4}, ::getfield(Main, Symbol("##107#108")), ::Float64, ::Float64) at /home/h-ishida/documents/RegionTrees.jl/examples/adaptive_distance_fields/adaptive_distance_fields.jl:45
 [8] adaptivesampling!(::Cell{Interpolations.BSplineInterpolation{Float64,2,StaticArrays.SArray{Tuple{2,2},Float64,2,4},BSpline{Linear},Tuple{Base.Slice{UnitRange{Int64}},Base.Slice{UnitRange{Int64}}}},2,Float64,4}, ::Main.AdaptivelySampledDistanceFields.SignedDistanceRefinery{getfield(Main, Symbol("##107#108"))}) at /home/h-ishida/documents/RegionTrees.jl/examples/adaptive_distance_fields/adaptive_distance_fields.jl:33
 [9] ASDF(::Function, ::StaticArrays.SArray{Tuple{2},Float64,1,2}, ::StaticArrays.SArray{Tuple{2},Float64,1,2}, ::Float64, ::Float64) at /home/h-ishida/documents/RegionTrees.jl/examples/adaptive_distance_fields/adaptive_distance_fields.jl:63
 [10] top-level scope at none:0
 [11] include at ./boot.jl:326 [inlined]
 [12] include_relative(::Module, ::String) at ./loading.jl:1038
 [13] include(::Module, ::String) at ./sysimg.jl:29
 [14] include(::String) at ./client.jl:403
 [15] top-level scope at none:0
in expression starting at /home/h-ishida/documents/RegionTrees.jl/examples/adaptive_distance_fields/test.jl:9

As the error messages show, coords computed here is outside the range of itp (i.e. [1, 2]).

I did farther investigation and found that the cell's origin and boundary was [1.0656250000000003,1.0656250000000003] and [0.034375,0.034375] respectively when the evaluate function causes the error. The value of origin is so strange and seems to incur some problem related to floating points.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/adaptive_distance_fields/adaptive_distance_fields.jl, especially the evaluate function around lines 16–30 and the cell-splitting path reached from needs_refinement. Reproduce the issue using the modified example inputs and inspect the reported cell origin, boundary, and computed coords. Done means the reproduction no longer raises a BoundsError when the cell is split near the boundary.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.