Skip to content

Commit

Permalink
Add get_sarah_list metafunction to BoundaryCorrections
Browse files Browse the repository at this point in the history
  • Loading branch information
knelli2 authored and shabibti committed Feb 16, 2024
1 parent 0e3f187 commit 7269499
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ void apply_boundary_condition_on_face(
tmpl::list<>>;
using tags_on_interior_face = tmpl::remove_duplicates<tmpl::append<
fluxes_tags, interior_temp_tags, interior_prim_tags,
interior_evolved_vars_tags, bcondition_interior_dt_evolved_vars_tags,
detail::get_sarah_list<BoundaryCorrection>, interior_evolved_vars_tags,
bcondition_interior_dt_evolved_vars_tags,
bcondition_interior_deriv_evolved_vars_tags, inverse_spatial_metric_list,
tmpl::list<detail::OneOverNormalVectorMagnitude,
detail::NormalVector<Dim>>>>;
Expand Down Expand Up @@ -415,6 +416,7 @@ void apply_boundary_condition_on_face(
// boundary condition.
using tags_on_exterior_face = tmpl::remove_duplicates<
tmpl::append<variables_tags, fluxes_tags, correction_temp_tags,
detail::get_sarah_list<BoundaryCorrection>,
correction_prim_tags, inverse_spatial_metric_list,
tmpl::list<detail::OneOverNormalVectorMagnitude,
detail::NormalVector<Dim>,
Expand All @@ -426,6 +428,7 @@ void apply_boundary_condition_on_face(
using mortar_tags_list = tmpl::list<PackageFieldTags...>;
using dg_package_data_projected_tags =
tmpl::append<variables_tags, fluxes_tags, correction_temp_tags,
detail::get_sarah_list<BoundaryCorrection>,
correction_prim_tags>;

Variables<mortar_tags_list> internal_packaged_data{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,18 @@ template <typename BoundaryCondition>
using get_deriv_vars_from_boundary_condition =
typename get_deriv_vars_from_boundary_condition_impl<
BoundaryCondition>::type;

template <typename BoundaryCorrection, typename = std::void_t<>>
struct get_sarah_list_impl {
using type = tmpl::list<>;
};

template <typename BoundaryCorrection>
struct get_sarah_list_impl<
BoundaryCorrection, std::void_t<typename BoundaryCorrection::sarah_list>> {
using type = typename BoundaryCorrection::sarah_list;
};

template <typename BoundaryCorrection>
using get_sarah_list = typename get_sarah_list_impl<BoundaryCorrection>::type;
} // namespace evolution::dg::Actions::detail
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void internal_mortar_data_impl(

using dg_package_data_projected_tags =
tmpl::append<variables_tags, fluxes_tags, temporary_tags_for_face,
detail::get_sarah_list<BoundaryCorrection>,
primitive_tags_for_face>;
using FieldsOnFace = Variables<tmpl::remove_duplicates<tmpl::push_back<
tmpl::append<dg_package_data_projected_tags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "Evolution/DgSubcell/Tags/Mesh.hpp"
#include "Evolution/DgSubcell/Tags/OnSubcellFaces.hpp"
#include "Evolution/DgSubcell/Tags/SubcellOptions.hpp"
#include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.hpp"
#include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivativeHelpers.hpp"
#include "Evolution/DiscontinuousGalerkin/Actions/NormalCovectorAndMagnitude.hpp"
#include "Evolution/DiscontinuousGalerkin/Actions/PackageDataImpl.hpp"
#include "Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/BoundaryCorrection.hpp"
Expand Down Expand Up @@ -260,6 +262,7 @@ struct NeighborPackagedData {
packaged_data.initialize(num_face_pts);
using dg_package_data_projected_tags = tmpl::append<
evolved_vars_tags, fluxes_tags, dg_package_data_temporary_tags,
evolution::dg::Actions::detail::get_sarah_list<DerivedCorrection>,
typename DerivedCorrection::dg_package_data_primitive_tags>;
evolution::dg::Actions::detail::dg_package_data<System>(
make_not_null(&packaged_data),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Evolution/DgSubcell/Tags/Mesh.hpp"
#include "Evolution/DgSubcell/Tags/OnSubcellFaces.hpp"
#include "Evolution/DgSubcell/Tags/SubcellOptions.hpp"
#include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivativeHelpers.hpp"
#include "Evolution/DiscontinuousGalerkin/Actions/NormalCovectorAndMagnitude.hpp"
#include "Evolution/DiscontinuousGalerkin/Actions/PackageDataImpl.hpp"
#include "Evolution/DiscontinuousGalerkin/MortarTags.hpp"
Expand Down Expand Up @@ -275,34 +276,34 @@ struct TimeDerivative {
mesh_velocity_dg.value().get(j), dg_mesh,
face_mesh_extents, i);
}
tmpl::for_each<evolved_vars_tags>([&vars_upper_face,
&vars_lower_face,
&mesh_velocity_on_face](
auto tag_v) {
using tag = tmpl::type_from<decltype(tag_v)>;
using flux_tag =
::Tags::Flux<tag, tmpl::size_t<3>, Frame::Inertial>;
using FluxTensor = typename flux_tag::type;
const auto& var_upper = get<tag>(vars_upper_face);
const auto& var_lower = get<tag>(vars_lower_face);
auto& flux_upper = get<flux_tag>(vars_upper_face);
auto& flux_lower = get<flux_tag>(vars_lower_face);
for (size_t storage_index = 0; storage_index < var_upper.size();
++storage_index) {
const auto tensor_index =
var_upper.get_tensor_index(storage_index);
for (size_t j = 0; j < 3; j++) {
const auto flux_storage_index =
FluxTensor::get_storage_index(prepend(tensor_index, j));
flux_upper[flux_storage_index] -=
mesh_velocity_on_face.value().get(j) *
var_upper[storage_index];
flux_lower[flux_storage_index] -=
mesh_velocity_on_face.value().get(j) *
var_lower[storage_index];
}
}
});
tmpl::for_each<evolved_vars_tags>(
[&vars_upper_face, &vars_lower_face,
&mesh_velocity_on_face](auto tag_v) {
using tag = tmpl::type_from<decltype(tag_v)>;
using flux_tag =
::Tags::Flux<tag, tmpl::size_t<3>, Frame::Inertial>;
using FluxTensor = typename flux_tag::type;
const auto& var_upper = get<tag>(vars_upper_face);
const auto& var_lower = get<tag>(vars_lower_face);
auto& flux_upper = get<flux_tag>(vars_upper_face);
auto& flux_lower = get<flux_tag>(vars_lower_face);
for (size_t storage_index = 0;
storage_index < var_upper.size(); ++storage_index) {
const auto tensor_index =
var_upper.get_tensor_index(storage_index);
for (size_t j = 0; j < 3; j++) {
const auto flux_storage_index =
FluxTensor::get_storage_index(
prepend(tensor_index, j));
flux_upper[flux_storage_index] -=
mesh_velocity_on_face.value().get(j) *
var_upper[storage_index];
flux_lower[flux_storage_index] -=
mesh_velocity_on_face.value().get(j) *
var_lower[storage_index];
}
}
});
}

// Normal vectors in curved spacetime normalized by inverse
Expand Down Expand Up @@ -350,6 +351,8 @@ struct TimeDerivative {
// Compute the packaged data
using dg_package_data_projected_tags = tmpl::append<
evolved_vars_tags, fluxes_tags, dg_package_data_temporary_tags,
evolution::dg::Actions::detail::get_sarah_list<
DerivedCorrection>,
typename DerivedCorrection::dg_package_data_primitive_tags>;
evolution::dg::Actions::detail::dg_package_data<System>(
make_not_null(&upper_packaged_data), *derived_correction,
Expand Down

0 comments on commit 7269499

Please sign in to comment.