Skip to content

Commit

Permalink
add plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-de-montserrat committed Dec 29, 2023
1 parent 203a961 commit a7c7aa9
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions miniapps/benchmarks/thermal_diffusion/diffusion/diffusion2D_MPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,28 @@ function diffusion_2D(;
center_perturbation = lx/2, -ly/2
elliptical_perturbation!(thermal.T, δT, center_perturbation..., r, xvi)

# # Plot initial T and η profiles
# let
# Yv = [y for x in xvi[1], y in xvi[2]][:]
# fig = Figure(size = (1200, 900))
# ax1 = Axis(fig[1,1], aspect = 2/3, title = "T")
# scatter!(ax1, Array(thermal.T[2:end-1,:][:]), Yv./1e3)
# ylims!(ax1, minimum(xvi[2])./1e3, 0)
# rank = igg.me
# # println("rank $rank => $(extrema(xvi[2])./1e3)")
# save("initial_profile_rank_$(rank).png", fig)
# fig
# end
# global array
nx_v = ((nx + 2) - 2) * igg.dims[1]
ny_v = ((ny + 1) - 2) * igg.dims[2]
T_v = zeros(nx_v, ny_v)
T_nohalo = zeros((nx + 2)-2, (ny + 1)-2)

# Plot initial T and η profiles
let
Yv = [y for x in xvi[1], y in xvi[2]][:]
fig = Figure(size = (1200, 900))
ax1 = Axis(fig[1,1], aspect = 2/3, title = "T")
scatter!(ax1, Array(thermal.T[2:end-1,:][:]), Yv./1e3)
ylims!(ax1, minimum(xvi[2])./1e3, 0)
rank = igg.me
# println("rank $rank => $(extrema(xvi[2])./1e3)")
save("initial_profile_rank_$(rank).png", fig)
fig
end

# Time loop
t = 0.0
it = 0
# nt = Int(ceil(ttot / dt))
while it < 10
heatdiffusion_PT!(
thermal,
Expand All @@ -119,24 +124,20 @@ function diffusion_2D(;
b_width=(4, 4, 1),
)

@views T_nohalo .= Array(thermal.T[2:end-2, 2:end-1]) # Copy data to CPU removing the halo
gather!(T_nohalo, T_v)

if igg.me == 0
fig, = heatmap(T_v)
save("temperature_it_($it).png", fig)
println("\n SAVED TEMPERATURE \n")
end

t += dt
it += 1
end

# Plot initial T and η profiles
let
Yv = [y for x in xvi[1], y in xvi[2]][:]
fig = Figure(size = (1200, 900))
ax1 = Axis(fig[1,1], aspect = 2/3, title = "T")
scatter!(ax1, Array(thermal.T[2:end-1,:][:]), Yv./1e3)
ylims!(ax1, minimum(xvi[2])./1e3, 0)
rank = igg.me
# println("rank $rank => $(extrema(xvi[2])./1e3)")
save("initial_profile_rank_$(rank).png", fig)
fig
end

# return (ni=ni, xci=xci, xvi=xvi, li=li, di=di), thermal
return nothing
end

n = 32
Expand Down

0 comments on commit a7c7aa9

Please sign in to comment.