From db83c715b54dfdeef15cad5f5e826596eb5a3b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Mon, 18 Nov 2024 21:01:02 +0100 Subject: [PATCH] Output the mpi rank to element_variables (SaveSolutionCallback) for visualization with trixi2vtk (#2132) * Output the mpi rank to element_variables for visualization * Added comments * Added functionality for all parallel mesh types * Update src/solvers/dg.jl Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> * Use the right array data structure for the mpi rank * Update src/solvers/dgsem_tree/dg_parallel.jl Co-authored-by: Michael Schlottke-Lakemper --------- Co-authored-by: Hendrik Ranocha Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> Co-authored-by: Michael Schlottke-Lakemper --- src/solvers/dg.jl | 12 ++++++++++++ src/solvers/dgsem_tree/dg_parallel.jl | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/solvers/dg.jl b/src/solvers/dg.jl index 0e4d667fbc2..a0fb0d95079 100644 --- a/src/solvers/dg.jl +++ b/src/solvers/dg.jl @@ -12,6 +12,17 @@ function get_element_variables!(element_variables, u, mesh, equations, nothing end +# Function to define "element variables" for the SaveSolutionCallback. It does +# nothing by default, but can be specialized for certain mesh types. For instance, +# parallel meshes output the mpi rank as an "element variable". +function get_element_variables!(element_variables, mesh, dg, cache) + nothing +end + +# Function to define "element variables" for the SaveSolutionCallback. It does +# nothing by default, but can be specialized for certain volume integral types. +# For instance, shock capturing volume integrals output the blending factor +# as an "element variable". function get_node_variables!(node_variables, mesh, equations, volume_integral::AbstractVolumeIntegral, dg, cache) nothing @@ -427,6 +438,7 @@ Base.summary(io::IO, dg::DG) = print(io, "DG(" * summary(dg.basis) * ")") function get_element_variables!(element_variables, u, mesh, equations, dg::DG, cache) get_element_variables!(element_variables, u, mesh, equations, dg.volume_integral, dg, cache) + get_element_variables!(element_variables, mesh, dg, cache) end function get_node_variables!(node_variables, mesh, equations, dg::DG, cache) diff --git a/src/solvers/dgsem_tree/dg_parallel.jl b/src/solvers/dgsem_tree/dg_parallel.jl index c614fe0d0e6..3b33c9c33a5 100644 --- a/src/solvers/dgsem_tree/dg_parallel.jl +++ b/src/solvers/dgsem_tree/dg_parallel.jl @@ -5,6 +5,16 @@ @muladd begin #! format: noindent +# Function to output the mpi rank for visualization +function get_element_variables!(element_variables, + mesh::Union{ParallelTreeMesh, ParallelP4estMesh, + ParallelT8codeMesh}, + dg, cache) + element_variables[:mpi_rank] = ones(real(dg), nelements(mesh, dg, cache)) * + mpi_rank() + return nothing +end + # Initialize MPI data structures. This works for both the # `TreeMesh` and the `P4estMesh` and is dimension-agnostic. function init_mpi_data_structures(mpi_neighbor_interfaces, mpi_neighbor_mortars, n_dims,