ComputeOperatorAction.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <tuple>
7 
11 #include "Utilities/Gsl.hpp"
12 #include "Utilities/Requires.hpp"
13 #include "Utilities/TMPL.hpp"
14 
15 /// \cond
16 // IWYU pragma: no_forward_declare db::DataBox
17 namespace tuples {
18 template <typename...>
19 class TaggedTuple; // IWYU pragma: keep
20 } // namespace tuples
21 
22 namespace Parallel {
23 template <typename Metavariables>
24 class ConstGlobalCache;
25 } // namespace Parallel
26 /// \endcond
27 
28 namespace Elliptic {
29 namespace Actions {
30 /*!
31  * \ingroup ActionsGroup
32  * \ingroup DiscontinuousGalerkinGroup
33  * \brief Compute the bulk contribution to the linear operator applied to the
34  * variables
35  *
36  * The `system::compute_operator_action` operator is invoked with its
37  * `argument_tags`. The result of this computation is stored in
38  * `db::add_tag_prefix<step_prefix, variables_tag>`, where `step_prefix` is
39  * retrieved from the `Metavariables::temporal_id`. For elliptic systems this
40  * prefix is generally `LinearSolver::Tags::OperatorAppliedTo`.
41  *
42  * Uses:
43  * - Metavariables:
44  * - `temporal_id::step_prefix`
45  * - System:
46  * - `variables_tag`
47  * - `compute_operator_action`
48  * - DataBox:
49  * - db::add_tag_prefix<step_prefix, variables_tag>
50  * - All elements in `compute_operator_action::argument_tags`
51  *
52  * DataBox changes:
53  * - Modifies:
54  * - `db::add_tag_prefix<step_prefix, variables_tag>`
55  */
57  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
58  typename ArrayIndex, typename ActionList,
59  typename ParallelComponent,
61  static auto apply(db::DataBox<DbTagsList>& box,
64  const ArrayIndex& /*array_index*/,
65  const ActionList /*meta*/,
66  const ParallelComponent* const /*meta*/) noexcept {
67  using system = typename Metavariables::system;
68  using computer = typename system::compute_operator_action;
69  // Notes:
70  // - step_variables is not zeroed and the operator cannot assume this.
71  // - We retrieve the `step_prefix` from the `Metavariables` (as opposed to
72  // hard-coding `LinearSolver::Tags::OperatorAppliedTo`) to retain
73  // consistency with other actions that do the same (for instance
74  // `dg::Actions::ApplyFluxes` that is not specific to elliptic systems)
76  Metavariables::temporal_id::template step_prefix,
77  typename system::variables_tag>>,
78  typename computer::argument_tags>(computer{},
79  make_not_null(&box));
80  return std::forward_as_tuple(std::move(box));
81  }
82 };
83 } // namespace Actions
84 } // 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:533
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: ComputeOperatorAction.hpp:28
Definition: TaggedTuple.hpp:25
Define prefixes for DataBox tags.
tmpl::conditional_t< tmpl::size< typename Subitems< TagList, Tag >::type >::value==0, tmpl::list< Tag >, typename Subitems< TagList, Tag >::type > split_tag
Split a tag into its subitems. Tag cannot be a base tag.
Definition: DataBoxTag.hpp:657
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
Defines the type alias Requires.
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1595
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
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
The Poisson equation formulated as a set of coupled first-order PDEs.
Definition: FirstOrderSystem.hpp:55
Wraps the template metaprogramming library used (brigand)
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
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t ...
Definition: Requires.hpp:67
Compute the bulk contribution to the linear operator applied to the variables.
Definition: ComputeOperatorAction.hpp:56
Definition: SolvePoissonProblem.hpp:38
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Definition: ComputeTimeDerivative.hpp:28