9 #include "DataStructures/DataBox/PrefixHelpers.hpp"
11 #include "DataStructures/DataBox/Tag.hpp"
13 #include "DataStructures/VariablesTag.hpp"
14 #include "NumericalAlgorithms/DiscontinuousGalerkin/Protocols.hpp"
18 #include "Utilities/ProtocolHelpers.hpp"
22 namespace NumericalFluxes {
58 template <
typename System>
61 using char_speeds_tag =
typename System::char_speeds_tag;
62 using variables_tag =
typename System::variables_tag;
75 using variables_tags =
typename System::variables_tag::tags_list;
77 using package_field_tags =
78 tmpl::append<db::wrap_tags_in<::Tags::NormalDotFlux, variables_tags>,
80 tmpl::list<LargestIngoingSpeed, LargestOutgoingSpeed>>;
81 using package_extra_tags = tmpl::list<>;
84 tmpl::append<db::wrap_tags_in<::Tags::NormalDotFlux, variables_tags>,
89 template <
typename VariablesTagList,
typename NormalDotFluxTagList>
90 struct package_data_helper;
92 template <
typename... VariablesTags,
typename... NormalDotFluxTags>
93 struct package_data_helper<tmpl::list<VariablesTags...>,
94 tmpl::list<NormalDotFluxTags...>> {
97 typename NormalDotFluxTags::type*>... packaged_n_dot_f,
101 packaged_largest_outgoing_speed,
102 const typename NormalDotFluxTags::type&... n_dot_f_to_package,
103 const typename VariablesTags::type&... u_to_package,
104 const typename char_speeds_tag::type& characteristic_speeds) noexcept {
106 expand_pack((*packaged_n_dot_f = n_dot_f_to_package)...);
108 *packaged_largest_ingoing_speed = make_with_value<Scalar<DataVector>>(
109 characteristic_speeds[0],
111 *packaged_largest_outgoing_speed = make_with_value<Scalar<DataVector>>(
112 characteristic_speeds[0],
121 for (
size_t s = 0; s < characteristic_speeds[0].size(); ++s) {
122 get(*packaged_largest_ingoing_speed)[s] = (*std::min_element(
123 characteristic_speeds.begin(), characteristic_speeds.end(),
127 get(*packaged_largest_outgoing_speed)[s] = (*std::max_element(
128 characteristic_speeds.begin(), characteristic_speeds.end(),
136 template <
typename NormalDotNumericalFluxTagList,
typename VariablesTagList,
137 typename NormalDotFluxTagList>
138 struct call_operator_helper;
139 template <
typename... NormalDotNumericalFluxTags,
typename... VariablesTags,
140 typename... NormalDotFluxTags>
141 struct call_operator_helper<tmpl::list<NormalDotNumericalFluxTags...>,
142 tmpl::list<VariablesTags...>,
143 tmpl::list<NormalDotFluxTags...>> {
144 static void function(
146 typename NormalDotNumericalFluxTags::type*>... n_dot_numerical_f,
147 const typename NormalDotFluxTags::type&... n_dot_f_interior,
148 const typename VariablesTags::type&... u_interior,
150 const typename LargestOutgoingSpeed::type&
151 largest_outgoing_speed_interior,
152 const typename NormalDotFluxTags::type&... minus_n_dot_f_exterior,
153 const typename VariablesTags::type&... u_exterior,
155 const typename LargestIngoingSpeed::type&
156 minus_largest_outgoing_speed_exterior,
157 const typename LargestOutgoingSpeed::type&
158 minus_largest_ingoing_speed_exterior) noexcept {
159 const auto number_of_grid_points =
160 get(largest_ingoing_speed_interior).size();
163 for (
size_t s = 0; s < largest_ingoing_speed.begin()->
size(); ++s) {
164 get(largest_ingoing_speed)[s] =
165 std::min({
get(largest_ingoing_speed_interior)[s],
166 -
get(minus_largest_ingoing_speed_exterior)[s], 0.0});
167 get(largest_outgoing_speed)[s] =
168 std::max({
get(largest_outgoing_speed_interior)[s],
169 -
get(minus_largest_outgoing_speed_exterior)[s], 0.0});
172 min(
get(largest_outgoing_speed) -
get(largest_ingoing_speed)) > 0.0,
173 "Max, min speeds are the same:\n"
174 " largest_outgoing_speed = "
175 <<
get(largest_outgoing_speed)
177 " largest_ingoing_speed = "
178 <<
get(largest_ingoing_speed));
180 1.0 / (
get(largest_outgoing_speed) -
get(largest_ingoing_speed));
181 const auto assemble_numerical_flux =
183 &largest_ingoing_speed, &largest_outgoing_speed,
184 &one_over_sp_minus_sm
185 ](
const auto n_dot_num_f,
const auto& n_dot_f_in,
const auto& u_in,
186 const auto& minus_n_dot_f_ex,
const auto& u_ex) noexcept {
187 for (
size_t i = 0; i < n_dot_num_f->size(); ++i) {
189 one_over_sp_minus_sm *
190 (
get(largest_outgoing_speed) * n_dot_f_in[i] +
191 get(largest_ingoing_speed) * minus_n_dot_f_ex[i] -
192 get(largest_outgoing_speed) *
get(largest_ingoing_speed) *
193 (u_in[i] - u_ex[i]));
197 expand_pack(assemble_numerical_flux(n_dot_numerical_f, n_dot_f_interior,
198 u_interior, minus_n_dot_f_exterior,
204 using options = tmpl::list<>;
205 static constexpr
Options::String help = {
"Computes the HLL numerical flux."};
208 void pup(PUP::er& ) noexcept {}
210 template <
class... Args>
211 void package_data(
const Args&... args)
const noexcept {
212 package_data_helper<variables_tags,
214 variables_tags>>::function(args...);
217 template <
class... Args>
218 void operator()(
const Args&... args)
const noexcept {
219 call_operator_helper<
223 variables_tags>>::function(args...);