Skip to content

Commit

Permalink
Output the mpi rank to element_variables (SaveSolutionCallback) for v…
Browse files Browse the repository at this point in the history
…isualization 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 <[email protected]>

* Use the right array data structure for the mpi rank

* Update src/solvers/dgsem_tree/dg_parallel.jl

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>

---------

Co-authored-by: Hendrik Ranocha <[email protected]>
Co-authored-by: Joshua Lampert <[email protected]>
Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
  • Loading branch information
4 people authored Nov 18, 2024
1 parent 9c2f326 commit db83c71
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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
10 changes: 10 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,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,
Expand Down

0 comments on commit db83c71

Please sign in to comment.