Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Level Info TreeMesh without AMR #2104

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 42 additions & 17 deletions src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi)
mpi_println(" #elements: " *
@sprintf("% 14d", nelementsglobal(mesh, solver, cache)))

# Level information (only show for AMR)
print_amr_information(integrator.opts.callback, mesh, solver, cache)
# Level information (only for AMR or non-uniform `TreeMesh`es)
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
print_level_information(integrator.opts.callback, mesh, solver, cache)
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
mpi_println()

# Open file for appending and store time step and time information
Expand Down Expand Up @@ -489,21 +489,7 @@ function (analysis_callback::AnalysisCallback)(io, du, u, u_ode, t, semi)
return nothing
end

# Print level information only if AMR is enabled
function print_amr_information(callbacks, mesh, solver, cache)

# Return early if there is nothing to print
uses_amr(callbacks) || return nothing

# Get global minimum and maximum level from the AMRController
min_level = max_level = 0
for cb in callbacks.discrete_callbacks
if cb.affect! isa AMRCallback
min_level = cb.affect!.controller.base_level
max_level = cb.affect!.controller.max_level
end
end

function print_level_information(mesh, solver, cache, min_level, max_level)
# Get local element count per level
elements_per_level = get_elements_per_level(min_level, max_level, mesh, solver,
cache)
Expand All @@ -522,6 +508,45 @@ function print_amr_information(callbacks, mesh, solver, cache)
return nothing
end

function print_level_information(callbacks, mesh::TreeMesh, solver, cache)
if uses_amr(callbacks)
# Get global minimum and maximum level from the AMRController
min_level = max_level = 0
for cb in callbacks.discrete_callbacks
if cb.affect! isa AMRCallback
min_level = cb.affect!.controller.base_level
max_level = cb.affect!.controller.max_level
end
end
print_level_information(mesh, solver, cache, min_level, max_level)
# Special check for `TreeMesh`es without AMR.
# These meshes may still be non-uniform due to `refinement_patches`, see
# `refine_box!`, `coarsen_box`, and `refine_sphere!`.
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
elseif minimum_level(mesh.tree) != maximum_level(mesh.tree)
min_level = minimum_level(mesh.tree)
max_level = maximum_level(mesh.tree)
print_level_information(mesh, solver, cache, min_level, max_level)
else # Uniform mesh
return nothing
end
end

function print_level_information(callbacks, mesh, solver, cache)
if uses_amr(callbacks)
# Get global minimum and maximum level from the AMRController
min_level = max_level = 0
for cb in callbacks.discrete_callbacks
if cb.affect! isa AMRCallback
min_level = cb.affect!.controller.base_level
max_level = cb.affect!.controller.max_level
end
end
print_level_information(mesh, solver, cache, min_level, max_level)
else # Uniform mesh
return nothing
end
end

function get_elements_per_level(min_level, max_level, mesh::P4estMesh, solver, cache)
elements_per_level = zeros(P4EST_MAXLEVEL + 1)

Expand Down
Loading