Skip to content

Commit

Permalink
save and load user_data for p4est
Browse files Browse the repository at this point in the history
this fixes restating when using AMR
  • Loading branch information
benegee committed Apr 23, 2024
1 parent dd05156 commit e918b20
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/auxiliary/p4est.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,29 @@ end
# Save `p4est` data to file
# 2D
function save_p4est!(file, p4est::PointerOrWrapper{p4est_t})
# Don't save user data of the quads
p4est_save(file, p4est, false)
# Also save user data to be able to reload it for restarts
p4est_save(file, p4est, true)
end

# 3D
function save_p4est!(file, p8est::PointerOrWrapper{p8est_t})
# Don't save user data of the quads
p8est_save(file, p8est, false)
# Also save user data to be able to reload it for restarts
p8est_save(file, p8est, true)
end

# Load `p4est` from file
# 2D
function load_p4est(file, ::Val{2})
conn_vec = Vector{Ptr{p4est_connectivity_t}}(undef, 1)
comm = P4est.uses_mpi() ? mpi_comm() : C_NULL # Use Trixi.jl's MPI communicator if p4est supports MPI
p4est_load_ext(file, comm, 0, 0, 1, 0, C_NULL, pointer(conn_vec))
p4est_load_ext(file, comm, 2 * sizeof(Int), 1, 1, 0, C_NULL, pointer(conn_vec))
end

# 3D
function load_p4est(file, ::Val{3})
conn_vec = Vector{Ptr{p8est_connectivity_t}}(undef, 1)
comm = P4est.uses_mpi() ? mpi_comm() : C_NULL # Use Trixi.jl's MPI communicator if p4est supports MPI
p8est_load_ext(file, comm, 0, 0, 1, 0, C_NULL, pointer(conn_vec))
p8est_load_ext(file, comm, 2 * sizeof(Int), 1, 1, 0, C_NULL, pointer(conn_vec))
end

# Read `p4est` connectivity from Abaqus mesh file (.inp)
Expand Down

0 comments on commit e918b20

Please sign in to comment.