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

Print global number of cells and dofs #1865

Merged
merged 25 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
954a502
switch to global count of cells
benegee Mar 7, 2024
ed6d5a9
introduce ndofsglobal for generic types as fallback
benegee Mar 7, 2024
0fd2376
switch to ndofsglobal for console output
benegee Mar 7, 2024
51127eb
add ncellsglobal
benegee Mar 7, 2024
eef69b9
Merge branch 'main' into bg/print-global-number-of-cells-dofs
benegee Mar 7, 2024
2efdfd8
Update src/semidiscretization/semidiscretization.jl
benegee Mar 8, 2024
b883b3a
remove docstring
benegee Mar 8, 2024
6a48c77
ndofsglobal in analysis callback
benegee Mar 8, 2024
d82aff5
remove unnecessary fallback
benegee Mar 26, 2024
a158728
Merge branch 'main' into bg/print-global-number-of-cells-dofs
benegee Mar 26, 2024
6c4d1d1
Merge branch 'main' into bg/print-global-number-of-cells-dofs
benegee May 29, 2024
b8dbb4a
Update src/semidiscretization/semidiscretization.jl
benegee May 29, 2024
0ad58de
Merge branch 'bg/print-global-number-of-cells-dofs' of github.com:tri…
benegee May 29, 2024
0d6c935
Update src/semidiscretization/semidiscretization_coupled.jl
benegee May 29, 2024
60ed55f
missing calls to *global functions
benegee May 29, 2024
e0df3b4
sum up and print global element count per level
benegee May 29, 2024
5c9e8a3
Merge branch 'bg/print-global-number-of-cells-dofs' of github.com:tri…
benegee May 29, 2024
a773257
formatter
benegee May 29, 2024
e217ab3
simplify
benegee May 29, 2024
97c1c2d
revert change in relative runtime
benegee May 29, 2024
9301e65
add nelementsglobal in analogy to ndofsglobal
benegee May 29, 2024
9282cb6
fix signature
benegee May 29, 2024
710c9c3
add mesh parameter to nelementsglobal
benegee May 29, 2024
db3bf43
:/
benegee May 29, 2024
bded959
Update src/callbacks_step/analysis.jl
benegee May 31, 2024
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
2 changes: 1 addition & 1 deletion src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi)
mpi_println(" " * " " *
" " *
" PID: " * @sprintf("%10.8e s", performance_index))
mpi_println(" #DOFs per field:" * @sprintf("% 14d", ndofs(semi)) *
mpi_println(" #DOFs per field:" * @sprintf("% 14d", ndofsglobal(semi)) *
benegee marked this conversation as resolved.
Show resolved Hide resolved
" " *
" alloc'd memory: " * @sprintf("%14.3f MiB", memory_use))
mpi_println(" #elements: " *
Expand Down
3 changes: 2 additions & 1 deletion src/meshes/p4est_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ end
end
# returns Int32 by default which causes a weird method error when creating the cache
@inline ncells(mesh::P4estMesh) = Int(mesh.p4est.local_num_quadrants[])
@inline ncellsglobal(mesh::P4estMesh) = Int(mesh.p4est.global_num_quadrants[])

function Base.show(io::IO, mesh::P4estMesh)
print(io, "P4estMesh{", ndims(mesh), ", ", real(mesh), "}")
Expand All @@ -105,7 +106,7 @@ function Base.show(io::IO, ::MIME"text/plain", mesh::P4estMesh)
else
setup = [
"#trees" => ntrees(mesh),
benegee marked this conversation as resolved.
Show resolved Hide resolved
"current #cells" => ncells(mesh),
"current #cells" => ncellsglobal(mesh),
"polydeg" => length(mesh.nodes) - 1,
]
summary_box(io,
Expand Down
3 changes: 2 additions & 1 deletion src/meshes/t8code_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const ParallelT8codeMesh{NDIMS} = T8codeMesh{NDIMS, <:Real, <:True}

@inline ntrees(mesh::T8codeMesh) = size(mesh.tree_node_coordinates)[end]
@inline ncells(mesh::T8codeMesh) = Int(t8_forest_get_local_num_elements(mesh.forest))
@inline ncellsglobal(mesh::T8codeMesh) = Int(t8_forest_get_global_num_elements(mesh.forest))

function Base.show(io::IO, mesh::T8codeMesh)
print(io, "T8codeMesh{", ndims(mesh), ", ", real(mesh), "}")
Expand All @@ -91,7 +92,7 @@ function Base.show(io::IO, ::MIME"text/plain", mesh::T8codeMesh)
else
setup = [
"#trees" => ntrees(mesh),
benegee marked this conversation as resolved.
Show resolved Hide resolved
"current #cells" => ncells(mesh),
"current #cells" => ncellsglobal(mesh),
"polydeg" => length(mesh.nodes) - 1,
]
summary_box(io,
Expand Down
17 changes: 17 additions & 0 deletions src/semidiscretization/semidiscretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ Return the number of degrees of freedom associated with each scalar variable.
ndofs(mesh, solver, cache)
end

"""
ndofsglobal(semi::AbstractSemidiscretization)

Return the global number of degrees of freedom associated with each scalar variable.
benegee marked this conversation as resolved.
Show resolved Hide resolved
This is the same as [`ndofs`](@ref) for simulations running in serial or
parallelized via threads. It will in general be different for simulations
running in parallel with MPI.
"""
@inline function ndofsglobal(semi::AbstractSemidiscretization)
mesh, _, solver, cache = mesh_equations_solver_cache(semi)
ndofsglobal(mesh, solver, cache)
end

@inline function ndofsglobal(mesh, solver, cache)
ndofs(mesh, solver, cache)
end
sloede marked this conversation as resolved.
Show resolved Hide resolved

"""
integrate_via_indices(func, u_ode, semi::AbstractSemidiscretization, args...; normalize=true)

Expand Down
6 changes: 5 additions & 1 deletion src/semidiscretization/semidiscretization_coupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Base.show(io::IO, ::MIME"text/plain", semi::SemidiscretizationCoupled)
semi.semis[i].source_terms)
summary_line(increment_indent(io), "solver", solver |> typeof |> nameof)
end
summary_line(io, "total #DOFs per field", ndofs(semi))
summary_line(io, "total #DOFs per field", ndofsglobal(semi))
summary_footer(io)
end
end
Expand Down Expand Up @@ -123,6 +123,10 @@ end
sum(ndofs, semi.semis)
end

@inline function ndofsglobal(semi::SemidiscretizationCoupled)
sum(ndofsglobal, semi.semis)
end
Comment on lines +134 to +136
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@inline function ndofsglobal(semi::SemidiscretizationCoupled)
sum(ndofsglobal, semi.semis)
end
"""
ndofsglobal(semi::SemidiscretizationCoupled)
Return the global number of degrees of freedom associated with each scalar variable across all MPI ranks, and summed up over all coupled systems.
This is the same as [`ndofs`](@ref) for simulations running in serial or
parallelized via threads. It will in general be different for simulations
running in parallel with MPI.
"""
@inline function ndofsglobal(semi::SemidiscretizationCoupled)
sum(ndofsglobal, semi.semis)
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually argue that this docstring doesn't really help in practice since it's the same as the one for the AbstractSemidiscretization - and SemidiscretizationCoupled <: AbstractSemidiscretization. But I don't have a strong opinion on this. Shall we keep it, @sloede?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it explicitly mentions that it is the number of DOFs over all coupled systems. I don't have a strong opinion either, so I'll leave it up to @benegee to decide 🙂


function compute_coefficients(t, semi::SemidiscretizationCoupled)
@unpack u_indices = semi

Expand Down
2 changes: 1 addition & 1 deletion src/semidiscretization/semidiscretization_hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ function Base.show(io::IO, ::MIME"text/plain", semi::SemidiscretizationHyperboli

summary_line(io, "source terms", semi.source_terms)
summary_line(io, "solver", semi.solver |> typeof |> nameof)
summary_line(io, "total #DOFs per field", ndofs(semi))
summary_line(io, "total #DOFs per field", ndofsglobal(semi))
benegee marked this conversation as resolved.
Show resolved Hide resolved
summary_footer(io)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function Base.show(io::IO, ::MIME"text/plain",
summary_line(io, "source terms", semi.source_terms)
summary_line(io, "solver", semi.solver |> typeof |> nameof)
summary_line(io, "parabolic solver", semi.solver_parabolic |> typeof |> nameof)
summary_line(io, "total #DOFs per field", ndofs(semi))
summary_line(io, "total #DOFs per field", ndofsglobal(semi))
summary_footer(io)
end
end
Expand Down
Loading