Initialize.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
7 #include "DataStructures/Tensor/EagerMath/Norms.hpp"
9 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
10 #include "Evolution/Initialization/Evolution.hpp"
11 #include "Evolution/Systems/ScalarWave/Constraints.hpp"
14 #include "Parallel/GlobalCache.hpp"
15 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
17 
18 namespace ScalarWave {
19 namespace Actions {
20 /// \ingroup InitializationGroup
21 /// \brief Initialize items related to constraints of the ScalarWave system
22 ///
23 /// We add both constraints and the constraint damping parameter to the
24 /// evolution databox.
25 ///
26 /// DataBox changes:
27 /// - Adds:
28 /// * `ScalarWave::Tags::ConstraintGamma2`
29 /// * `ScalarWave::Tags::OneIndexConstraint<Dim>`
30 /// * `ScalarWave::Tags::TwoIndexConstraint<Dim>`
31 /// * `::Tags::PointwiseL2Norm<ScalarWave::Tags::OneIndexConstraint<Dim>>`
32 /// * `::Tags::PointwiseL2Norm<ScalarWave::Tags::TwoIndexConstraint<Dim>>`
33 /// - Removes: nothing
34 /// - Modifies: nothing
35 ///
36 /// \note This action relies on the `SetupDataBox` aggregated initialization
37 /// mechanism, so `Actions::SetupDataBox` must be present in the
38 /// `Initialization` phase action list prior to this action.
39 template <size_t Dim>
41  using simple_tags = tmpl::list<ScalarWave::Tags::ConstraintGamma2>;
42 
43  using compute_tags = tmpl::list<
49 
50  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
51  typename ArrayIndex, typename ActionList,
52  typename ParallelComponent>
53  static auto apply(db::DataBox<DbTagsList>& box,
54  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
55  const Parallel::GlobalCache<Metavariables>& /*cache*/,
56  const ArrayIndex& /*array_index*/,
57  const ActionList /*meta*/,
58  const ParallelComponent* const /*meta*/) noexcept {
59  const auto& mesh = db::get<domain::Tags::Mesh<Dim>>(box);
60  Scalar<DataVector> gamma_2{mesh.number_of_grid_points(), 0.};
61 
62  Initialization::mutate_assign<simple_tags>(make_not_null(&box),
63  std::move(gamma_2));
64 
65  return std::make_tuple(std::move(box));
66  }
67 };
68 } // namespace Actions
69 } // namespace ScalarWave
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
GlobalCache.hpp
System.hpp
Tags.hpp
ScalarWave::Tags::TwoIndexConstraint
Tag for the two-index constraint of the ScalarWave system.
Definition: Tags.hpp:59
DataBox.hpp
Assert.hpp
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Variables.hpp
ScalarWave::Actions::InitializeConstraints
Initialize items related to constraints of the ScalarWave system.
Definition: Initialize.hpp:40
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
ScalarWave::Tags::TwoIndexConstraintCompute
Compute item to get the two-index constraint for the scalar-wave evolution system.
Definition: Constraints.hpp:94
ScalarWave
Items related to evolving the scalar wave equation.
Definition: BoundaryCondition.hpp:24
ScalarWave::Tags::OneIndexConstraintCompute
Compute item to get the one-index constraint for the scalar-wave evolution system.
Definition: Constraints.hpp:72
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
Tags::PointwiseL2NormCompute
Definition: Norms.hpp:125