Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include "DataStructures/Variables.hpp"
7 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/ConservativeFromPrimitive.hpp"
8 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Fluxes.hpp"
9 : #include "Utilities/Gsl.hpp"
10 :
11 : namespace grmhd::ValenciaDivClean {
12 : namespace detail {
13 : template <typename FluxTags, typename BoundaryVarsType, typename... ReturnTags,
14 : typename... ConservativeTags, typename... ArgumentTags,
15 : typename... FluxArgumentTags>
16 : void compute_fluxes_from_primitives_impl(
17 : const gsl::not_null<Variables<FluxTags>*> flux_vars,
18 : const BoundaryVarsType& boundary_vars, tmpl::list<ReturnTags...> /*meta*/,
19 : tmpl::list<ConservativeTags...> /*meta*/,
20 : tmpl::list<ArgumentTags...> /*meta*/,
21 : tmpl::list<FluxArgumentTags...> /*meta*/) {
22 : Variables<typename tmpl::list<ConservativeTags...>> conserved_vars{
23 : flux_vars->number_of_grid_points()};
24 : grmhd::ValenciaDivClean::ConservativeFromPrimitive::apply(
25 : make_not_null(&get<ConservativeTags>(conserved_vars))...,
26 : get<ArgumentTags>(boundary_vars)...);
27 : grmhd::ValenciaDivClean::ComputeFluxes::apply(
28 : make_not_null(&get<ReturnTags>(*flux_vars))...,
29 : get<ConservativeTags>(conserved_vars)...,
30 : get<FluxArgumentTags>(boundary_vars)...);
31 : }
32 : } // namespace detail
33 :
34 : /*!
35 : * \brief Helper function that computes fluxes from a given set of primitive
36 : * variables. Primarily used for filling neighbor data when flux information is
37 : * needed for boundaries.
38 : *
39 : * \warning This computes the conservative variables internally. If you also
40 : * need those, you shouldn't call this function.
41 : */
42 : template <typename FluxTags, typename BoundaryVarsType>
43 1 : void compute_fluxes_from_primitives(
44 : const gsl::not_null<Variables<FluxTags>*> flux_vars,
45 : const BoundaryVarsType& boundary_vars) {
46 : using ConservativeTags =
47 : typename grmhd::ValenciaDivClean::ConservativeFromPrimitive::return_tags;
48 : using FluxArgumentTags =
49 : typename grmhd::ValenciaDivClean::ComputeFluxes::argument_tags;
50 : using flux_arg_tags = tmpl::back<tmpl::split_at<
51 : FluxArgumentTags, tmpl::next<tmpl::index_of<
52 : FluxArgumentTags, tmpl::back<ConservativeTags>>>>>;
53 : detail::compute_fluxes_from_primitives_impl(
54 : flux_vars, boundary_vars,
55 : typename grmhd::ValenciaDivClean::ComputeFluxes::return_tags{},
56 : ConservativeTags{},
57 : typename grmhd::ValenciaDivClean::ConservativeFromPrimitive::
58 : argument_tags{},
59 : flux_arg_tags{});
60 : }
61 : } // namespace grmhd::ValenciaDivClean
|