From bfbc091cf1b32c2c41af001e7507b24548edbd3c Mon Sep 17 00:00:00 2001 From: Nathan Musoke Date: Thu, 5 May 2022 14:55:33 -0700 Subject: [PATCH] feat: Allow soliton init on other grid types Soliton initialization is different if the soliton is going to be on an Array or a PencilArray. The latter needs one to transform to global indices. As written, the check was against the type of psi_x's container, rather than psi_x itself. Generalize this. This allows for initialization of any grid type that stores psi_x in a Array or PencilArray. --- examples/init_soliton.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/init_soliton.jl b/examples/init_soliton.jl index 79eeb14..58382ac 100644 --- a/examples/init_soliton.jl +++ b/examples/init_soliton.jl @@ -13,12 +13,12 @@ function add_soliton(grids, psi, mass, position, velocity, phase, t0) alpha = (mass / 3.883)^2 beta = 2.454 - if typeof(grids) <: PencilGrids + if typeof(psi) <: PencilArray ψ_glob = global_view(psi) - elseif typeof(grids) <: Grids + elseif typeof(psi) <: Array ψ_glob = psi else - throw("Unrecognised grids type") + throw("Unrecognised array type") end for I in CartesianIndices(ψ_glob)