From 1086956cdd328c4be95939b1ca345915391ccfb6 Mon Sep 17 00:00:00 2001 From: Sarah Habib Date: Thu, 11 Jan 2024 13:40:39 -0800 Subject: [PATCH] Pass spatial metric to dg_package_data --- .../Actions/BoundaryConditionsImpl.hpp | 5 +- .../BoundaryCorrections/Hll.cpp | 8 +++ .../BoundaryCorrections/Hll.hpp | 11 ++++ .../Subcell/NeighborPackagedData.hpp | 3 + .../Subcell/TimeDerivative.hpp | 59 ++++++++++--------- 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/src/Evolution/DiscontinuousGalerkin/Actions/BoundaryConditionsImpl.hpp b/src/Evolution/DiscontinuousGalerkin/Actions/BoundaryConditionsImpl.hpp index e13e3f2d1203..922d9ebb90fd 100644 --- a/src/Evolution/DiscontinuousGalerkin/Actions/BoundaryConditionsImpl.hpp +++ b/src/Evolution/DiscontinuousGalerkin/Actions/BoundaryConditionsImpl.hpp @@ -206,7 +206,8 @@ void apply_boundary_condition_on_face( tmpl::list<>>; using tags_on_interior_face = tmpl::remove_duplicates, interior_evolved_vars_tags, + bcondition_interior_dt_evolved_vars_tags, bcondition_interior_deriv_evolved_vars_tags, inverse_spatial_metric_list, tmpl::list>>>; @@ -415,6 +416,7 @@ void apply_boundary_condition_on_face( // boundary condition. using tags_on_exterior_face = tmpl::remove_duplicates< tmpl::append, correction_prim_tags, inverse_spatial_metric_list, tmpl::list, @@ -426,6 +428,7 @@ void apply_boundary_condition_on_face( using mortar_tags_list = tmpl::list; using dg_package_data_projected_tags = tmpl::append, correction_prim_tags>; Variables internal_packaged_data{ diff --git a/src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Hll.cpp b/src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Hll.cpp index 49bd9bebd2b1..9d43482799a0 100644 --- a/src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Hll.cpp +++ b/src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Hll.cpp @@ -41,6 +41,7 @@ double Hll::dg_package_data( const gsl::not_null*> packaged_normal_dot_flux_tilde_b, const gsl::not_null*> packaged_normal_dot_flux_tilde_phi, + const gsl::not_null*> packaged_spatial_metric, const gsl::not_null*> packaged_largest_outgoing_char_speed, const gsl::not_null*> @@ -62,6 +63,9 @@ double Hll::dg_package_data( const Scalar& lapse, const tnsr::I& shift, + const tnsr::ii& spatial_metric, + const tnsr::II& inverse_spatial_metric, + const tnsr::i& normal_covector, const tnsr::I& /*normal_vector*/, const std::optional>& @@ -104,6 +108,8 @@ double Hll::dg_package_data( normal_dot_flux(packaged_normal_dot_flux_tilde_phi, normal_covector, flux_tilde_phi); +// *packaged_spatial_metric = spatial_metric; + using std::max; return max(max(abs(get(*packaged_largest_outgoing_char_speed))), max(abs(get(*packaged_largest_ingoing_char_speed)))); @@ -130,6 +136,7 @@ void Hll::dg_boundary_terms( const tnsr::i& normal_dot_flux_tilde_s_int, const tnsr::I& normal_dot_flux_tilde_b_int, const Scalar& normal_dot_flux_tilde_phi_int, + const tnsr::ii& spatial_metric_int, const Scalar& largest_outgoing_char_speed_int, const Scalar& largest_ingoing_char_speed_int, const Scalar& tilde_d_ext, @@ -144,6 +151,7 @@ void Hll::dg_boundary_terms( const tnsr::i& normal_dot_flux_tilde_s_ext, const tnsr::I& normal_dot_flux_tilde_b_ext, const Scalar& normal_dot_flux_tilde_phi_ext, + const tnsr::ii& spatial_metric_ext, const Scalar& largest_outgoing_char_speed_ext, const Scalar& largest_ingoing_char_speed_ext, const dg::Formulation dg_formulation) { diff --git a/src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Hll.hpp b/src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Hll.hpp index a1b1d42485f3..17345d64a4da 100644 --- a/src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Hll.hpp +++ b/src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Hll.hpp @@ -3,6 +3,7 @@ #pragma once +#include #include #include @@ -122,11 +123,14 @@ class Hll final : public BoundaryCorrection { ::Tags::NormalDotFlux>, ::Tags::NormalDotFlux>, ::Tags::NormalDotFlux, + gr::Tags::SpatialMetric, LargestOutgoingCharSpeed, LargestIngoingCharSpeed>; using dg_package_data_temporary_tags = tmpl::list, gr::Tags::Shift>; using dg_package_data_primitive_tags = tmpl::list<>; using dg_package_data_volume_tags = tmpl::list<>; + using sarah_list = tmpl::list, + gr::Tags::InverseSpatialMetric>; static double dg_package_data( gsl::not_null*> packaged_tilde_d, @@ -143,6 +147,8 @@ class Hll final : public BoundaryCorrection { gsl::not_null*> packaged_normal_dot_flux_tilde_b, gsl::not_null*> packaged_normal_dot_flux_tilde_phi, + gsl::not_null*> + packaged_spatial_metric, gsl::not_null*> packaged_largest_outgoing_char_speed, gsl::not_null*> packaged_largest_ingoing_char_speed, @@ -162,6 +168,9 @@ class Hll final : public BoundaryCorrection { const Scalar& lapse, const tnsr::I& shift, + const tnsr::ii& spatial_metric, + const tnsr::II& inverse_spatial_metric, + const tnsr::i& normal_covector, const tnsr::I& normal_vector, const std::optional>& @@ -191,6 +200,7 @@ class Hll final : public BoundaryCorrection { const tnsr::I& normal_dot_flux_tilde_b_int, const Scalar& normal_dot_flux_tilde_phi_int, + const tnsr::ii& spatial_metric_int, const Scalar& largest_outgoing_char_speed_int, const Scalar& largest_ingoing_char_speed_int, const Scalar& tilde_d_ext, @@ -207,6 +217,7 @@ class Hll final : public BoundaryCorrection { const tnsr::I& normal_dot_flux_tilde_b_ext, const Scalar& normal_dot_flux_tilde_phi_ext, + const tnsr::ii& spatial_metric_ext, const Scalar& largest_outgoing_char_speed_ext, const Scalar& largest_ingoing_char_speed_ext, dg::Formulation dg_formulation); diff --git a/src/Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/NeighborPackagedData.hpp b/src/Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/NeighborPackagedData.hpp index fd00bf165f33..f57e1bbad13e 100644 --- a/src/Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/NeighborPackagedData.hpp +++ b/src/Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/NeighborPackagedData.hpp @@ -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" @@ -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, typename DerivedCorrection::dg_package_data_primitive_tags>; evolution::dg::Actions::detail::dg_package_data( make_not_null(&packaged_data), diff --git a/src/Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/TimeDerivative.hpp b/src/Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/TimeDerivative.hpp index a6c76a80d0c2..fc1bd648ff68 100644 --- a/src/Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/TimeDerivative.hpp +++ b/src/Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/TimeDerivative.hpp @@ -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" @@ -275,34 +276,34 @@ struct TimeDerivative { mesh_velocity_dg.value().get(j), dg_mesh, face_mesh_extents, i); } - tmpl::for_each([&vars_upper_face, - &vars_lower_face, - &mesh_velocity_on_face]( - auto tag_v) { - using tag = tmpl::type_from; - using flux_tag = - ::Tags::Flux, Frame::Inertial>; - using FluxTensor = typename flux_tag::type; - const auto& var_upper = get(vars_upper_face); - const auto& var_lower = get(vars_lower_face); - auto& flux_upper = get(vars_upper_face); - auto& flux_lower = get(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( + [&vars_upper_face, &vars_lower_face, + &mesh_velocity_on_face](auto tag_v) { + using tag = tmpl::type_from; + using flux_tag = + ::Tags::Flux, Frame::Inertial>; + using FluxTensor = typename flux_tag::type; + const auto& var_upper = get(vars_upper_face); + const auto& var_lower = get(vars_lower_face); + auto& flux_upper = get(vars_upper_face); + auto& flux_lower = get(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 @@ -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( make_not_null(&upper_packaged_data), *derived_correction,