AddMeshVelocitySourceTerms.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <boost/optional.hpp>
7 #include <tuple>
8 
11 #include "Domain/TagsTimeDependent.hpp"
12 #include "Utilities/Gsl.hpp"
13 #include "Utilities/Requires.hpp"
14 #include "Utilities/TMPL.hpp"
15 #include "Utilities/TaggedTuple.hpp"
16 
17 /// \cond
18 namespace Frame {
19 struct Inertial;
20 } // namespace Frame
21 namespace Parallel {
22 template <typename Metavariables>
23 class GlobalCache;
24 } // namespace Parallel
25 // IWYU pragma: no_forward_declare db::DataBox
26 /// \endcond
27 
28 namespace evolution {
29 namespace Actions {
30 /*!
31  * \ingroup ActionsGroup
32  * \brief Compute and add the source term modification for moving meshes
33  *
34  * Adds to the time derivative *not* the source terms because some systems do
35  * not have source terms and so we optimize for that. The term being added to
36  * the time derivative is:
37  *
38  * \f{align}{
39  * -u_\alpha \partial_i v^i_g,
40  * \f}
41  *
42  * where \f$u_\alpha\f$ are the evolved variables and \f$v^i_g\f$ is the
43  * velocity of the mesh.
44  *
45  * Uses:
46  * - DataBox:
47  * - `System::variables_tags`
48  * - `domain::Tags::DivMeshVelocity`
49  *
50  * DataBox changes:
51  * - Adds: nothing
52  * - Removes: nothing
53  * - Modifies: `Tags::dt<system::variable_tags>`
54  */
56  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
57  typename ArrayIndex, typename ActionList,
58  typename ParallelComponent>
59  static std::tuple<db::DataBox<DbTagsList>&&> apply(
61  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
62  const Parallel::GlobalCache<Metavariables>& /*cache*/,
63  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
64  const ParallelComponent* const /*meta*/) noexcept { // NOLINT const
65  using variables_tag = typename Metavariables::system::variables_tag;
66  using dt_variables_tag = db::add_tag_prefix<Tags::dt, variables_tag>;
67  db::mutate<dt_variables_tag>(
68  make_not_null(&box),
69  [](const auto dt_vars_ptr, const auto& vars,
70  const boost::optional<Scalar<DataVector>>&
71  div_grid_velocity) noexcept {
72  if (div_grid_velocity) {
73  *dt_vars_ptr -= vars * get(*div_grid_velocity);
74  }
75  },
76  db::get<variables_tag>(box),
77  db::get<domain::Tags::DivMeshVelocity>(box));
78  return std::forward_as_tuple(std::move(box));
79  }
80 };
81 } // namespace Actions
82 } // namespace evolution
get
constexpr Tag::type & get(Variables< TagList > &v) noexcept
Return Tag::type pointing into the contiguous array.
Definition: Variables.hpp:639
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
evolution
Functionality for evolving hyperbolic partial differential equations.
Definition: AddMeshVelocityNonconservative.hpp:29
db::add_tag_prefix
typename detail::add_tag_prefix_impl< Prefix, Tag, Args... >::type add_tag_prefix
Definition: PrefixHelpers.hpp:52
tuple
evolution::Actions::AddMeshVelocitySourceTerms
Compute and add the source term modification for moving meshes.
Definition: AddMeshVelocitySourceTerms.hpp:55
DataBox.hpp
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Gsl.hpp
Frame
Definition: IndexType.hpp:36
Requires.hpp
make_not_null
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,...
Definition: Gsl.hpp:880
Prefixes.hpp
db::DataBox
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Parallel
Contains functions that forward to Charm++ parallel functions.
Definition: ElementReceiveInterpPoints.hpp:14
TMPL.hpp