Skip to content

Commit 95f4335

Browse files
committed
bugfix for add_sphere!, more tests
1 parent 48b6791 commit 95f4335

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Setup_geometry.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,15 @@ function add_sphere!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
420420
# Set phase number & thermal structure in the full domain
421421
ind = findall(((X .- cen[1]).^2 + (Y .- cen[2]).^2 + (Z .- cen[3]).^2).^0.5 .< radius)
422422

423+
ind_flat = flatten_index_dimensions(Phase, ind)
424+
423425
# Compute thermal structure accordingly. See routines below for different options
424426
if T != nothing
425-
Temp[ind] = compute_thermal_structure(Temp[ind], X[ind], Y[ind], Z[ind], Phase[ind], T)
427+
Temp[ind_flat] = compute_thermal_structure(Temp[ind_flat], X[ind], Y[ind], Z[ind], Phase[ind_flat], T)
426428
end
427429

428430
# Set the phase. Different routines are available for that - see below.
429-
Phase[ind] = compute_phase(Phase[ind], Temp[ind], X[ind], Y[ind], Z[ind], phase)
431+
Phase[ind_flat] = compute_phase(Phase[ind_flat], Temp[ind_flat], X[ind], Y[ind], Z[ind], phase)
430432

431433
return nothing
432434
end

test/test_Chmy.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,9 @@ grid = UniformGrid(arch;
6868
Temp2D_C = Field(backend, grid, Center())
6969
Phases2D_C = Field(backend, grid, Center(), Int32)
7070

71+
# check
7172
add_box!(Phases2D_C,Temp2D_C,grid, xlim=(0,1.0), zlim=(-2,0), phase=ConstantPhase(2))
73+
@test extrema(Phases2D_C) == (0,2)
74+
75+
add_sphere!(Phases2D_C,Temp2D_C,grid, cen=(0,0,-1), radius=2.5, phase=ConstantPhase(3), T=ConstantTemp(800))
76+
@test extrema(Phases2D_C) == (0,3)

0 commit comments

Comments
 (0)