Skip to content

Commit

Permalink
Merge pull request #4739 from nilsdeppe/send_cell_centered_fluxes
Browse files Browse the repository at this point in the history
Send cell centered fluxes
  • Loading branch information
nilsdeppe committed Feb 27, 2023
2 parents 57e51ad + df8904e commit cdd15ca
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/Evolution/DgSubcell/PrepareNeighborData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <utility>

#include "DataStructures/DataBox/DataBox.hpp"
#include "DataStructures/DataBox/PrefixHelpers.hpp"
#include "DataStructures/DataBox/Prefixes.hpp"
#include "DataStructures/DataVector.hpp"
#include "DataStructures/Index.hpp"
#include "Domain/Structure/Direction.hpp"
Expand Down Expand Up @@ -53,8 +55,12 @@ namespace evolution::dg::subcell {
* elide any slicing or projection cost in that direction.
*/
template <typename Metavariables, typename DbTagsList, size_t Dim>
auto prepare_neighbor_data(const gsl::not_null<Mesh<Dim>*> ghost_data_mesh,
const gsl::not_null<db::DataBox<DbTagsList>*> box)
auto prepare_neighbor_data(
const gsl::not_null<Mesh<Dim>*> ghost_data_mesh,
const gsl::not_null<db::DataBox<DbTagsList>*> box,
[[maybe_unused]] const Variables<db::wrap_tags_in<
::Tags::Flux, typename Metavariables::system::flux_variables,
tmpl::size_t<Dim>, Frame::Inertial>>& volume_fluxes)
-> DirectionMap<Metavariables::volume_dim, DataVector> {
const Mesh<Dim>& dg_mesh = db::get<::domain::Tags::Mesh<Dim>>(*box);
const Mesh<Dim>& subcell_mesh =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ namespace evolution::dg::subcell {
// We use a forward declaration instead of including a header file to avoid
// coupling to the DG-subcell libraries for executables that don't use subcell.
template <typename Metavariables, typename DbTagsList, size_t Dim>
auto prepare_neighbor_data(gsl::not_null<Mesh<Dim>*> ghost_data_mesh,
gsl::not_null<db::DataBox<DbTagsList>*> box)
auto prepare_neighbor_data(
gsl::not_null<Mesh<Dim>*> ghost_data_mesh,
gsl::not_null<db::DataBox<DbTagsList>*> box,
[[maybe_unused]] const Variables<db::wrap_tags_in<
::Tags::Flux, typename Metavariables::system::flux_variables,
tmpl::size_t<Dim>, Frame::Inertial>>& volume_fluxes)
-> DirectionMap<Metavariables::volume_dim, DataVector>;
template <typename DbTagsList>
int get_tci_decision(const db::DataBox<DbTagsList>& box);
Expand Down Expand Up @@ -353,7 +357,10 @@ struct ComputeTimeDerivative {
typename Metavariables>
static void send_data_for_fluxes(
gsl::not_null<Parallel::GlobalCache<Metavariables>*> cache,
gsl::not_null<db::DataBox<DbTagsList>*> box);
gsl::not_null<db::DataBox<DbTagsList>*> box,
[[maybe_unused]] const Variables<db::wrap_tags_in<
::Tags::Flux, typename EvolutionSystem::flux_variables,
tmpl::size_t<Dim>, Frame::Inertial>>& volume_fluxes);
};

template <size_t Dim, typename EvolutionSystem, typename DgStepChoosers,
Expand Down Expand Up @@ -606,7 +613,7 @@ ComputeTimeDerivative<Dim, EvolutionSystem, DgStepChoosers, LocalTimeStepping>::
}

send_data_for_fluxes<ParallelComponent>(make_not_null(&cache),
make_not_null(&box));
make_not_null(&box), volume_fluxes);
return {Parallel::AlgorithmExecution::Continue, std::nullopt};
}

Expand All @@ -618,7 +625,10 @@ void ComputeTimeDerivative<Dim, EvolutionSystem, DgStepChoosers,
LocalTimeStepping>::
send_data_for_fluxes(
const gsl::not_null<Parallel::GlobalCache<Metavariables>*> cache,
const gsl::not_null<db::DataBox<DbTagsList>*> box) {
const gsl::not_null<db::DataBox<DbTagsList>*> box,
[[maybe_unused]] const Variables<db::wrap_tags_in<
::Tags::Flux, typename EvolutionSystem::flux_variables,
tmpl::size_t<Dim>, Frame::Inertial>>& volume_fluxes) {
auto& receiver_proxy =
Parallel::get_parallel_component<ParallelComponent>(*cache);
const auto& element = db::get<domain::Tags::Element<Dim>>(*box);
Expand All @@ -637,7 +647,7 @@ void ComputeTimeDerivative<Dim, EvolutionSystem, DgStepChoosers,
if constexpr (using_subcell_v<Metavariables>) {
all_neighbor_data_for_reconstruction =
evolution::dg::subcell::prepare_neighbor_data<Metavariables>(
make_not_null(&ghost_data_mesh), box);
make_not_null(&ghost_data_mesh), box, volume_fluxes);
tci_decision = evolution::dg::subcell::get_tci_decision(*box);
}

Expand Down
9 changes: 8 additions & 1 deletion tests/Unit/Evolution/DgSubcell/Test_PrepareNeighborData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct Metavariables {

struct system {
using variables_tag = ::Tags::Variables<tmpl::list<Var1>>;
using flux_variables = tmpl::list<Var1>;
};

struct SubcellOptions {
Expand Down Expand Up @@ -149,6 +150,12 @@ void test(const bool all_neighbors_are_doing_dg) {

Variables<tmpl::list<Var1>> vars{dg_mesh.number_of_grid_points(), 0.0};
get(get<Var1>(vars)) = get<0>(logical_coordinates(dg_mesh));
using flux_tag = ::Tags::Flux<Var1, tmpl::size_t<Dim>, Frame::Inertial>;
Variables<tmpl::list<flux_tag>> volume_fluxes{dg_mesh.number_of_grid_points(),
0.0};
for (size_t i = 0; i < Dim; ++i) {
get<flux_tag>(volume_fluxes).get(i) = logical_coordinates(dg_mesh).get(i);
}

const size_t ghost_zone_size = 2;
auto box = db::create<tmpl::list<GhostZoneSize, domain::Tags::Mesh<Dim>,
Expand All @@ -162,7 +169,7 @@ void test(const bool all_neighbors_are_doing_dg) {
Mesh<Dim> ghost_data_mesh{};
const auto data_for_neighbors =
evolution::dg::subcell::prepare_neighbor_data<Metavariables<Dim>>(
make_not_null(&ghost_data_mesh), make_not_null(&box));
make_not_null(&ghost_data_mesh), make_not_null(&box), volume_fluxes);

CHECK(ghost_data_mesh ==
(all_neighbors_are_doing_dg ? dg_mesh : subcell_mesh));
Expand Down

0 comments on commit cdd15ca

Please sign in to comment.