Sources.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
10 #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
11 #include "Utilities/TMPL.hpp"
12 
13 namespace NewtonianEuler {
14 
15 /*!
16  * \brief Compute the source terms for the NewtonianEuler evolution
17  * using a problem-specific source.
18  *
19  * \details The source term type is fetched from the initial data, so
20  * any `InitialDataType` instance must have a type alias `source_term_type`.
21  * In turn, any source term type used by `ComputeSources` must hold type aliases
22  * `sourced_variables` and `argument_tags`, which are `tmpl::list`s of the
23  * variables whose equations of motion require a source term, and the arguments
24  * required to compute those source terms, respectively. The source term must
25  * also hold a `public` `void` member function `apply` whose arguments are
26  * `gsl::not_null` pointers to the variables storing the source terms, followed
27  * by the arguments required to compute them.
28  * See NewtonianEuler::Sources::UniformAcceleration for an example.
29  *
30  * While most of physically relevant source terms for the Newtonian Euler
31  * equations do not add a source term for the mass density, this class allows
32  * for problems that source any set of conserved variables
33  * (at least one variable is required).
34  */
35 template <typename InitialDataType>
37  private:
38  using source_term_type = typename InitialDataType::source_term_type;
39 
40  template <typename SourcedVarsTagList, typename ArgTagsList>
41  struct apply_helper;
42 
43  template <typename... SourcedVarsTags, typename... ArgsTags>
44  struct apply_helper<tmpl::list<SourcedVarsTags...>, tmpl::list<ArgsTags...>> {
45  static void function(
46  const gsl::not_null<db::item_type<SourcedVarsTags>*>... sourced_vars,
48  const db::item_type<ArgsTags>&... args) noexcept {
49  source.apply(sourced_vars..., args...);
50  }
51  };
52 
53  public:
54  using return_tags =
56  typename source_term_type::sourced_variables>;
57 
58  using argument_tags =
59  tmpl::push_front<typename source_term_type::argument_tags,
61 
62  template <class... Args>
63  static void apply(const Args&... args) noexcept {
64  apply_helper<typename source_term_type::sourced_variables,
65  typename source_term_type::argument_tags>::function(args...);
66  }
67 };
68 
69 } // namespace NewtonianEuler
Prefix indicating a source term.
Definition: Prefixes.hpp:86
Define prefixes for DataBox tags.
tmpl::transform< TagList, tmpl::bind< Wrapper, tmpl::_1, tmpl::pin< Args >... > > wrap_tags_in
Create a new list of Tags by wrapping each tag in TagList using the Wrapper.
Definition: DataBoxTag.hpp:501
The source term in the evolution equations.
Definition: Tags.hpp:99
Compute the source terms for the NewtonianEuler evolution using a problem-specific source...
Definition: Sources.hpp:36
Defines classes and functions used for manipulating DataBox&#39;s.
Defines a list of useful type aliases for tensors.
Wraps the template metaprogramming library used (brigand)
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that can be written to the Tag. If it is a base tag then a TagList must be passed as a s...
Definition: DataBoxTag.hpp:461
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12
Items related to evolving the Newtonian Euler system.
Definition: EvolveNewtonianEulerFwd.hpp:8