slimgroup / JUDI.jl

Julia Devito inversion.
https://slimgroup.github.io/JUDI.jl
MIT License
96 stars 30 forks source link

All examples fail to run the function `setup_3D_grid` #83

Closed kerim371 closed 2 years ago

kerim371 commented 2 years ago

Hi,

When I try to run any example that uses setup_3D_grid I get error. For example if I run modeling_basic_3D.jl:

# Set up 3D receiver geometry by defining one receiver vector in each x and y direction
nxrec = 120
nyrec = 100
xrec = range(50f0, stop=1150f0, length=nxrec)
yrec = range(100f0, stop=900f0, length=nyrec)
zrec = 50f0

# Construct 3D grid from basis vectors
(xrec, yrec, zrec) = setup_3D_grid(xrec, yrec, zrec)

and the error:

ERROR: LoadError: BoundsError: attempt to access 1-element Vector{Float32} at index [2]
Stacktrace:
 [1] getindex
   @ ./array.jl:805 [inlined]
 [2] setup_3D_grid(xrec::Vector{Vector{Float32}}, yrec::Vector{Vector{Float32}}, zrec::Vector{Float32})
   @ JUDI ~/.julia/packages/JUDI/fPPVi/src/TimeModeling/Utils/auxiliaryFunctions.jl:448
 [3] setup_3D_grid(xrec::StepRangeLen{Float32, Float64, Float64}, yrec::StepRangeLen{Float32, Float64, Float64}, zrec::Float32)
   @ JUDI ~/.julia/packages/JUDI/fPPVi/src/TimeModeling/Utils/auxiliaryFunctions.jl:487
 [4] top-level scope
   @ ~/Documents/mytest.jl:43
in expression starting at ~/Documents/mytest.jl:43

I think that something is wrong with the overloaded function setup_3D_grid.

It is possible to pass the rec positions if they were are arrays:

xrec = Array{Float32, 1}(range(50f0, stop=1150f0, length=nxrec))
yrec = Array{Float32, 1}(range(100f0, stop=900f0, length=nyrec))
zrec = 50f0

(xrec, yrec, zrec) = setup_3D_grid(xrec, yrec, zrec)

This way it works

JUDI version: 2.6.1

mloubout commented 2 years ago

Thanks for pointing out will look into it

mloubout commented 2 years ago

Hope all running smoothly for you now with the fix.