Skip to content

Commit

Permalink
feat: Allow soliton init on other grid types
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
musoke committed May 6, 2022
1 parent 4eab2b4 commit bfbc091
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/init_soliton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bfbc091

Please sign in to comment.