FirstOrderComputeTags.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
11 #include "Elliptic/Tags.hpp"
13 #include "Utilities/TMPL.hpp"
14 
15 namespace elliptic {
16 namespace Tags {
17 
18 template <size_t Dim, typename System,
19  typename VarsTag = typename System::variables_tag,
20  typename FluxesComputer = typename System::fluxes,
21  typename PrimalVars = typename System::primal_variables,
22  typename AuxiliaryVars = typename System::auxiliary_variables,
23  typename FluxesArgs = typename FluxesComputer::argument_tags>
25 
26 template <size_t Dim, typename System, typename VarsTag,
27  typename FluxesComputer, typename... PrimalVars,
28  typename... AuxiliaryVars, typename... FluxesArgs>
30  Dim, System, VarsTag, FluxesComputer, tmpl::list<PrimalVars...>,
31  tmpl::list<AuxiliaryVars...>, tmpl::list<FluxesArgs...>>
32  : db::add_tag_prefix<::Tags::Flux, VarsTag, tmpl::size_t<Dim>,
33  Frame::Inertial>,
35  private:
37 
38  public:
41  using argument_tags = tmpl::list<VarsTag, fluxes_computer_tag, FluxesArgs...>;
42  using volume_tags = tmpl::list<fluxes_computer_tag>;
43  static constexpr auto function(
44  const db::const_item_type<VarsTag>& vars,
45  const FluxesComputer& fluxes_computer,
46  const db::const_item_type<FluxesArgs>&... fluxes_args) noexcept {
47  auto fluxes = make_with_value<db::item_type<base>>(vars, 0.);
48  // Compute fluxes for primal fields
49  fluxes_computer.apply(
51  &get<::Tags::Flux<PrimalVars, tmpl::size_t<Dim>, Frame::Inertial>>(
52  fluxes))...,
53  fluxes_args..., get<AuxiliaryVars>(vars)...);
54  // Compute fluxes for auxiliary fields
55  fluxes_computer.apply(
56  make_not_null(&get<::Tags::Flux<AuxiliaryVars, tmpl::size_t<Dim>,
57  Frame::Inertial>>(fluxes))...,
58  fluxes_args..., get<PrimalVars>(vars)...);
59  return fluxes;
60  }
61 };
62 
63 template <typename System, typename VarsTag = typename System::variables_tag,
64  typename SourcesComputer = typename System::sources,
65  typename PrimalVars = typename System::primal_variables,
66  typename AuxiliaryVars = typename System::auxiliary_variables,
67  typename SourcesArgs = typename SourcesComputer::argument_tags>
69 
70 template <typename System, typename VarsTag, typename SourcesComputer,
71  typename... PrimalVars, typename... AuxiliaryVars,
72  typename... SourcesArgs>
74  System, VarsTag, SourcesComputer, tmpl::list<PrimalVars...>,
75  tmpl::list<AuxiliaryVars...>, tmpl::list<SourcesArgs...>>
76  : db::add_tag_prefix<::Tags::Source, VarsTag>, db::ComputeTag {
78  using argument_tags = tmpl::list<VarsTag, SourcesArgs...>;
79  static constexpr auto function(
80  const db::const_item_type<VarsTag>& vars,
81  const db::const_item_type<SourcesArgs>&... sources_args) noexcept {
82  auto sources = make_with_value<db::item_type<base>>(vars, 0.);
83  // Compute sources for primal fields
85  make_not_null(&get<::Tags::Source<PrimalVars>>(sources))...,
86  sources_args..., get<PrimalVars>(vars)...);
87  // Compute sources for auxiliary fields. They are just the auxiliary field
88  // values.
89  tmpl::for_each<tmpl::list<AuxiliaryVars...>>(
90  [&sources, &vars ](const auto auxiliary_field_tag_v) noexcept {
91  using auxiliary_field_tag =
92  tmpl::type_from<decltype(auxiliary_field_tag_v)>;
93  get<::Tags::Source<auxiliary_field_tag>>(sources) =
94  get<auxiliary_field_tag>(vars);
95  });
96  return sources;
97  }
98 };
99 
100 } // namespace Tags
101 } // namespace elliptic
Prefix indicating a source term.
Definition: Prefixes.hpp:86
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:616
Definition: Digraph.hpp:11
Definition: InitializeAnalyticSolution.hpp:27
Marks a DataBoxTag as being a compute item that executes a function.
Definition: DataBoxTag.hpp:154
Define prefixes for DataBox tags.
Definition: FirstOrderComputeTags.hpp:68
Definition: FirstOrderComputeTags.hpp:24
Prefix indicating a flux.
Definition: Prefixes.hpp:54
Defines class Variables.
Definition: DataBoxTag.hpp:29
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1623
Wraps the template metaprogramming library used (brigand)
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:879
Holds an object that computes the principal part of the elliptic PDEs.
Definition: Tags.hpp:26
Definition: IndexType.hpp:44
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines make_with_value.