FirstOrderOperator.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
11 #include "Utilities/Gsl.hpp"
12 #include "Utilities/TMPL.hpp"
13 
14 namespace elliptic {
15 
16 /*!
17  * \ingroup DiscontinuousGalerkinGroup
18  * \brief Compute the bulk contribution to the operator represented by the
19  * `OperatorTag` applied to the `VarsTag`.
20  *
21  * This invokable computes \f$A(u)=-\partial_i F^i(u) + S(u)\f$, where \f$F^i\f$
22  * and \f$S\f$ are the fluxes and sources of the system of first-order PDEs,
23  * respectively. They are defined such that \f$A(u(x))=f(x)\f$ is the full
24  * system of equations, with \f$f(x)\f$ representing sources that are
25  * independent of the variables \f$u\f$. In a DG setting, boundary contributions
26  * can be added to \f$A(u)\f$ to build the full DG operator.
27  *
28  * We generally build the operator \f$A(u)\f$ to perform elliptic solver
29  * iterations. This invokable can be used to build operators for both the linear
30  * solver and the nonlinear solver iterations by providing the appropriate
31  * `OperatorTag` and `VarsTag`. For example, the `OperatorTag` for the linear
32  * solver would typically be `LinearSolver::Tags::OperatorAppliedTo`. It is the
33  * elliptic equivalent to the time derivative in evolution schemes. Instead of
34  * using it to evolve the variables, the iterative linear solver uses it to
35  * compute a better approximation to the equation \f$A(u)=f\f$ (as detailed
36  * above).
37  *
38  * With:
39  * - `operator_tag` = `db::add_tag_prefix<OperatorTag, VarsTag>`
40  * - `fluxes_tag` = `db::add_tag_prefix<::Tags::Flux, VarsTag,
41  * tmpl::size_t<Dim>, Frame::Inertial>`
42  * - `div_fluxes_tag` = `db::add_tag_prefix<Tags::div, fluxes_tag>`
43  * - `sources_tag` = `db::add_tag_prefix<::Tags::Source, VarsTag>`
44  *
45  * Uses:
46  * - DataBox:
47  * - `div_fluxes_tag`
48  * - `sources_tag`
49  *
50  * DataBox changes:
51  * - Modifies:
52  * - `operator_tag`
53  */
54 template <size_t Dim, template <typename> class OperatorTag, typename VarsTag>
56  private:
57  using operator_tag = db::add_tag_prefix<OperatorTag, VarsTag>;
58  using fluxes_tag = db::add_tag_prefix<::Tags::Flux, VarsTag,
59  tmpl::size_t<Dim>, Frame::Inertial>;
60  using div_fluxes_tag = db::add_tag_prefix<::Tags::div, fluxes_tag>;
62 
63  public:
64  using return_tags = tmpl::list<operator_tag>;
65  using argument_tags = tmpl::list<div_fluxes_tag, sources_tag>;
66  static void apply(const gsl::not_null<db::item_type<operator_tag>*>
67  operator_applied_to_vars,
68  const db::const_item_type<div_fluxes_tag>& div_fluxes,
69  const db::const_item_type<sources_tag>& sources) noexcept {
70  *operator_applied_to_vars = sources - div_fluxes;
71  }
72 };
73 
74 } // namespace elliptic
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: InitializeAnalyticSolution.hpp:27
Define prefixes for DataBox tags.
Prefix indicating a flux.
Definition: Prefixes.hpp:54
Compute the bulk contribution to the operator represented by the OperatorTag applied to the VarsTag...
Definition: FirstOrderOperator.hpp:55
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 functions and classes from the GSL.
Definition: IndexType.hpp:44
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines functions and tags for taking a divergence.
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12