ali-ramadhan / Atmosfoolery.jl

Compressible non-hydrostatic model built on top of Oceananigans.jl so it runs on CPUs and GPUs
MIT License
3 stars 0 forks source link

Do we really need halos of size 2? #77

Open ali-ramadhan opened 3 years ago

ali-ramadhan commented 3 years ago

Overriding Base.getindex(A::OffsetArray{T,N}, I::Vararg{Int,N}) where {T,N} to print a stacktrace if it's in the second halo point,

function Base.getindex(A::OffsetArray{T,N}, I::Vararg{Int,N}) where {T,N}
    any(I .< 0) && display(stacktrace())
    @boundscheck checkbounds(A, I...)
    J = map(parentindex, axes(A), I)
    @inbounds parent(A)[J...]
end

I get three results which makes sense but can we rewrite so that the strain rate tensor doesn't dip into the second halo point?

 getindex(::OffsetArray{Float64,3,Array{Float64,3}}, ::Int64, ::Int64, ::Int64) at REPL[74]:2
 getindex at abstract_field.jl:172 [inlined]
 ℑxᶠᵃᵃ at interpolation_operators.jl:8 [inlined]
 U_over_ρ at compressible_operators.jl:15 [inlined]
 ∂xᶜᵃᵃ at derivative_operators.jl:18 [inlined]
 strain_rate_tensor_ux at compressible_operators.jl:171 [inlined]
 viscous_flux_ux at compressible_operators.jl:182 [inlined]
 δxᶠᵃᵃ at difference_operators.jl:21 [inlined]
 ∂ⱼτ₁ⱼ at compressible_operators.jl:193 [inlined]
 FU at right_hand_sides.jl:8 [inlined]
 getindex(::OffsetArray{Float64,3,Array{Float64,3}}, ::Int64, ::Int64, ::Int64) at REPL[74]:2
 getindex at abstract_field.jl:172 [inlined]
 ℑyᵃᶠᵃ at interpolation_operators.jl:11 [inlined]
 V_over_ρ at compressible_operators.jl:16 [inlined]
 ∂yᵃᶜᵃ at derivative_operators.jl:21 [inlined]
 strain_rate_tensor_vy at compressible_operators.jl:172 [inlined]
 viscous_flux_vy at compressible_operators.jl:183 [inlined]
 δyᵃᶠᵃ at difference_operators.jl:24 [inlined]
 ∂ⱼτ₂ⱼ at compressible_operators.jl:199 [inlined]
 FV at right_hand_sides.jl:13 [inlined]
 getindex(::OffsetArray{Float64,3,Array{Float64,3}}, ::Int64, ::Int64, ::Int64) at REPL[74]:2
 getindex at abstract_field.jl:172 [inlined]
 ℑzᵃᵃᶠ at interpolation_operators.jl:14 [inlined]
 W_over_ρ at compressible_operators.jl:17 [inlined]
 ∂zᵃᵃᶜ at derivative_operators.jl:24 [inlined]
 strain_rate_tensor_wz at compressible_operators.jl:173 [inlined]
 viscous_flux_wz at compressible_operators.jl:184 [inlined]
 δzᵃᵃᶠ at difference_operators.jl:27 [inlined]
 ∂ⱼτ₃ⱼ at compressible_operators.jl:205 [inlined]
 FW at right_hand_sides.jl:17 [inlined]