# Out of memory error in \`viz\` of 3D \`RectilinearGrid\` from Meshes.jl

**URL:** <https://discourse.julialang.org/t/out-of-memory-error-in-viz-of-3d-rectilineargrid-from-meshes-jl/128643>\
**Category:** Visualization\
**Tags:** hdf5, memory, glmakie, meshes\
**Created:** [May 2, 2025, 9:46pm UTC](https://discourse.julialang.org/t/out-of-memory-error-in-viz-of-3d-rectilineargrid-from-meshes-jl/128643 "2025-05-02T21:46:04Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![raman\_kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raman_kumar/32/26782_2.png) [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Post date:** [May 3, 2025, 11:49am UTC](https://discourse.julialang.org/t/out-of-memory-error-in-viz-of-3d-rectilineargrid-from-meshes-jl/128643/11 "2025-05-03T11:49:07Z")

</div>

This code gives correct scatter plot but i want 3D volume plot. My grid is non-uniform so i have trouble getting volume plot. Please guide me how to get volume plot?

```julia
using HDF5, GLMakie, Colors, LinearAlgebra
GLMakie.activate!(ssao=true)
GLMakie.closeall() # close any open screen

function plothdf(h5file::String)

    h5 = h5open(h5file, "r")
    num_blocks = read(HDF5.attributes(h5), "NumMeshBlocks")
    ρ = read(h5["prim"])[:,:,:,:,1] # shape: (Nx, Ny, Nz, Nvars, Nblocks)
    x_all = read(h5["x1v"]) # shape: (Nx, Nblocks)
    y_all = read(h5["x2v"])
    z_all = read(h5["x3v"])
    close(h5)

    all_xs, all_ys, all_zs, all_density = Float32[], Float32[], Float32[], Float32[]

    for b in 1:num_blocks
        x = x_all[:, b]
        y = y_all[:, b]
        z = z_all[:, b]
        density = ρ[:,:,:,b] # 3D array

        for i in 1:length(x), j in 1:length(y), k in 1:length(z)
            r, θ, ϕ = x[i], y[j], z[k]
            X = r * sin(θ) * cos(ϕ)
            Y = r * sin(θ) * sin(ϕ)
            Z = r * cos(θ)

            push!(all_xs, X)
            push!(all_ys, Y)
            push!(all_zs, Z)
            push!(all_density, density[i, j, k])
        end
    end

    # Normalize density
    norm_density = log10.(abs.(normalize!(all_density)))
    cmap = cgrad(:plasma)
    colors = get.(Ref(cmap), norm_density)
    fig = Figure(size = (1000, 800))
    ssao = Makie.SSAO(radius = 5.0, blur = 3)
    ax = LScene(fig[1, 1], scenekw = (ssao=ssao,))
    ax.scene.ssao.bias[] = 1.95
    plt = scatter!(ax, all_xs, all_ys, all_zs, color = norm_density, markersize = 5)
    Colorbar(fig[1, 2], plt, label = "log₁₀(norm(ρ))")
    display(fig)
end
plothdf("sane00.prim.01800.athdf")

```

---

_[View the full topic](https://discourse.julialang.org/t/out-of-memory-error-in-viz-of-3d-rectilineargrid-from-meshes-jl/128643)._
