ComputeNonconservativeBoundaryFluxes.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <tuple>
8 #include <utility>
9 
12 #include "DataStructures/DataVector.hpp"
15 #include "Domain/Tags.hpp"
17 #include "Utilities/Gsl.hpp"
18 #include "Utilities/TMPL.hpp"
20 #include "Utilities/TypeTraits.hpp"
21 
22 namespace dg {
23 namespace Actions {
24 
25 /// \ingroup ActionsGroup
26 /// \ingroup DiscontinuousGalerkinGroup
27 /// \brief Compute \f$\hat{n} \cdot F\f$ on the boundaries for a
28 /// non-conservative system.
29 ///
30 /// Uses:
31 /// - System:
32 /// - `variables_tag`
33 /// - DataBox:
34 /// - `DirectionsTag`,
35 /// - Interface items as required by
36 /// `Metavariables::system::normal_dot_fluxes`
37 ///
38 /// DataBox changes:
39 /// - Adds: nothing
40 /// - Removes: nothing
41 /// - Modifies:
42 /// - `Tags::Interface<
43 /// DirectionsTag, db::add_tag_prefix<Tags::NormalDotFlux, variables_tag>>`
44 template <typename DirectionsTag>
46  private:
47  template <typename Metavariables, typename... NormalDotFluxTags,
48  typename... Args>
49  static void apply_flux(
50  gsl::not_null<Variables<tmpl::list<NormalDotFluxTags...>>*> boundary_flux,
51  const Args&... boundary_variables) noexcept {
52  Metavariables::system::normal_dot_fluxes::apply(
53  make_not_null(&get<NormalDotFluxTags>(*boundary_flux))...,
54  boundary_variables...);
55  }
56 
57  public:
58  template <typename DbTags, typename... InboxTags, typename Metavariables,
59  typename ArrayIndex, typename ActionList,
60  typename ParallelComponent>
61  static std::tuple<db::DataBox<DbTags>&&> apply(
64  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
65  const ParallelComponent* const /*meta*/) noexcept {
66  using system = typename Metavariables::system;
67  using variables_tag = typename system::variables_tag;
68 
69  using interface_normal_dot_fluxes_tag =
70  Tags::Interface<DirectionsTag,
72 
74  tmpl::list<interface_normal_dot_fluxes_tag>,
75  tmpl::push_front<tmpl::transform<typename Metavariables::system::
76  normal_dot_fluxes::argument_tags,
77  tmpl::bind<Tags::Interface,
78  DirectionsTag, tmpl::_1>>,
79  DirectionsTag>>(
81  boundary_fluxes,
82  const db::item_type<DirectionsTag>& internal_directions,
83  const auto&... tensors) noexcept {
84  for (const auto& direction : internal_directions) {
85  // Prepending the type name works around an issue with gcc-6
86  ComputeNonconservativeBoundaryFluxes::apply_flux<Metavariables>(
87  make_not_null(&boundary_fluxes->at(direction)),
88  tensors.at(direction)...);
89  }
90  return boundary_fluxes;
91  },
92  make_not_null(&box));
93 
94  return std::forward_as_tuple(std::move(box));
95  }
96 };
97 } // namespace Actions
98 } // namespace dg
Prefix< DataBox_detail::dispatch_add_tag_prefix_impl< Prefix, Tag, Args... >, Args... > add_tag_prefix
Wrap Tag in Prefix<_, Args...>, also wrapping variables tags if Tag is a Tags::Variables.
Definition: DataBoxTag.hpp:533
Defines class tuples::TaggedTuple.
constexpr auto mutate_apply(F f, const gsl::not_null< DataBox< BoxTags > *> box, Args &&... args) noexcept(DataBox_detail::check_mutate_apply_mutate_tags(BoxTags{}, MutateTags{}) and DataBox_detail::check_mutate_apply_argument_tags(BoxTags{}, ArgumentTags{}) and noexcept(DataBox_detail::mutate_apply(f, box, MutateTags{}, ArgumentTags{}, std::forward< Args >(args)...)))
Apply the function f mutating items MutateTags and taking as additional arguments ArgumentTags and ar...
Definition: DataBox.hpp:1773
Definition: InitializeElement.hpp:63
Define prefixes for DataBox tags.
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Defines class Variables.
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
Defines a list of useful type aliases for tensors.
The Poisson equation formulated as a set of coupled first-order PDEs.
Definition: FirstOrderSystem.hpp:55
Wraps the template metaprogramming library used (brigand)
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
Defines functions and classes from the GSL.
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion, but it may be necessary to perform the conversion explicitly when type deduction is desired.
Definition: Gsl.hpp:863
Defines tags related to domain quantities.
Definition: SolvePoissonProblem.hpp:38
Defines class template ConstGlobalCache.
Defines type traits, some of which are future STL type_traits header.
Tag which is either a SimpleTag for quantities on an interface, base tag to a compute item which acts...
Definition: Tags.hpp:217
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12
Compute on the boundaries for a non-conservative system.
Definition: ComputeNonconservativeBoundaryFluxes.hpp:45