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

Output the mpi rank to element_variables (SaveSolutionCallback) for visualization with trixi2vtk #2132

Merged
merged 10 commits into from
Nov 18, 2024
12 changes: 12 additions & 0 deletions src/solvers/dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/solvers/dgsem_tree/dg_parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
@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,
Expand Down
Loading