Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cstddef> 7 : #include <optional> 8 : 9 : #include "DataStructures/DataBox/DataBox.hpp" 10 : #include "DataStructures/DataVector.hpp" 11 : #include "DataStructures/Tensor/EagerMath/DotProduct.hpp" 12 : #include "DataStructures/Tensor/Tensor.hpp" 13 : #include "DataStructures/Variables.hpp" 14 : #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivativeHelpers.hpp" 15 : #include "Evolution/DiscontinuousGalerkin/Actions/NormalCovectorAndMagnitude.hpp" 16 : #include "Utilities/Gsl.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : 19 : namespace evolution::dg::Actions::detail { 20 : // Helper function to get parameter packs so we can forward `Tensor`s instead 21 : // of `Variables` to the boundary corrections. Returns the maximum absolute 22 : // char speed on the face, which can be used for setting or monitoring the CFL 23 : // without having to compute the speeds for each dimension in the volume. 24 : // Whether using only the face speeds is accurate enough to guarantee 25 : // stability is yet to be determined. However, if the CFL condition is 26 : // violated on the boundaries we are definitely in trouble, so it can at least 27 : // be used as a cheap diagnostic. 28 : template <typename System, typename BoundaryCorrection, 29 : typename... PackagedFieldTags, typename... ProjectedFieldTags, 30 : typename... ProjectedFieldTagsForCorrection, size_t Dim, 31 : typename... VolumeArgs> 32 : double dg_package_data( 33 : const gsl::not_null<Variables<tmpl::list<PackagedFieldTags...>>*> 34 : packaged_data, 35 : const BoundaryCorrection& boundary_correction, 36 : const Variables<tmpl::list<ProjectedFieldTags...>>& projected_fields, 37 : const tnsr::i<DataVector, Dim, Frame::Inertial>& unit_normal_covector, 38 : const std::optional<tnsr::I<DataVector, Dim, Frame::Inertial>>& 39 : mesh_velocity, 40 : tmpl::list<ProjectedFieldTagsForCorrection...> /*meta*/, 41 : const VolumeArgs&... volume_args) { 42 : std::optional<Scalar<DataVector>> normal_dot_mesh_velocity{}; 43 : if (mesh_velocity.has_value()) { 44 : normal_dot_mesh_velocity = 45 : dot_product(*mesh_velocity, unit_normal_covector); 46 : } 47 : 48 : if constexpr (evolution::dg::Actions::detail:: 49 : has_inverse_spatial_metric_tag_v<System>) { 50 : return boundary_correction.dg_package_data( 51 : make_not_null(&get<PackagedFieldTags>(*packaged_data))..., 52 : get<ProjectedFieldTagsForCorrection>(projected_fields)..., 53 : unit_normal_covector, 54 : get<evolution::dg::Actions::detail::NormalVector<Dim>>( 55 : projected_fields), 56 : mesh_velocity, normal_dot_mesh_velocity, volume_args...); 57 : } else { 58 : return boundary_correction.dg_package_data( 59 : make_not_null(&get<PackagedFieldTags>(*packaged_data))..., 60 : get<ProjectedFieldTagsForCorrection>(projected_fields)..., 61 : unit_normal_covector, mesh_velocity, normal_dot_mesh_velocity, 62 : volume_args...); 63 : } 64 : } 65 : 66 : template <typename System, typename BoundaryCorrection, 67 : typename... PackagedFieldTags, typename... ProjectedFieldTags, 68 : typename... ProjectedFieldTagsForCorrection, size_t Dim, 69 : typename... VolumeTags> 70 : double dg_package_data( 71 : const gsl::not_null<Variables<tmpl::list<PackagedFieldTags...>>*> 72 : packaged_data, 73 : const BoundaryCorrection& boundary_correction, 74 : const Variables<tmpl::list<ProjectedFieldTags...>>& projected_fields, 75 : const tnsr::i<DataVector, Dim, Frame::Inertial>& unit_normal_covector, 76 : const std::optional<tnsr::I<DataVector, Dim, Frame::Inertial>>& 77 : mesh_velocity, 78 : const db::Access& box, tmpl::list<VolumeTags...> /*meta*/, 79 : tmpl::list<ProjectedFieldTagsForCorrection...> /*meta*/) { 80 : return dg_package_data<System>( 81 : packaged_data, boundary_correction, projected_fields, 82 : unit_normal_covector, mesh_velocity, 83 : tmpl::list<ProjectedFieldTagsForCorrection...>{}, 84 : db::get<VolumeTags>(box)...); 85 : } 86 : } // namespace evolution::dg::Actions::detail