NonconservativeSystem.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <tuple>
8 #include <utility>
9 
14 #include "Domain/Mesh.hpp"
15 #include "Domain/Tags.hpp"
16 #include "Evolution/Initialization/Tags.hpp"
18 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
19 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
20 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
21 
22 /// \cond
23 namespace Frame {
24 struct Inertial;
25 } // namespace Frame
26 /// \endcond
27 
28 namespace Initialization {
29 namespace Actions {
30 /// \ingroup InitializationGroup
31 /// \brief Allocate and set variables needed for evolution of nonconservative
32 /// systems
33 ///
34 /// Uses:
35 /// - DataBox:
36 /// * `Tags::Mesh<Dim>`
37 ///
38 /// DataBox changes:
39 /// - Adds:
40 /// * System::variables_tag
41 ///
42 /// - Removes: nothing
43 /// - Modifies: nothing
45  using initialization_tags = tmpl::list<Initialization::Tags::InitialTime>;
46 
47  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
48  typename ArrayIndex, typename ActionList,
49  typename ParallelComponent>
50  static auto apply(db::DataBox<DbTagsList>& box,
51  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
53  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
54  const ParallelComponent* const /*meta*/) noexcept {
55  using system = typename Metavariables::system;
56  static_assert(not system::is_in_flux_conservative_form,
57  "System is in flux conservative form");
58  static constexpr size_t dim = system::volume_dim;
59  using variables_tag = typename system::variables_tag;
60  using simple_tags = db::AddSimpleTags<variables_tag>;
61  using compute_tags = db::AddComputeTags<>;
62  using Vars = typename variables_tag::type;
63 
64  const size_t num_grid_points =
65  db::get<::Tags::Mesh<dim>>(box).number_of_grid_points();
66  const double initial_time = db::get<Initialization::Tags::InitialTime>(box);
67  const auto& inertial_coords =
68  db::get<::Tags::Coordinates<dim, Frame::Inertial>>(box);
69 
70  // Set initial data from analytic solution
71  using solution_tag = ::Tags::AnalyticSolutionBase;
72  Vars vars{num_grid_points};
73  vars.assign_subset(Parallel::get<solution_tag>(cache).variables(
74  inertial_coords, initial_time, typename Vars::tags_list{}));
75 
76  return std::make_tuple(
77  merge_into_databox<NonconservativeSystem, simple_tags, compute_tags>(
78  std::move(box), std::move(vars)));
79  }
80 };
81 } // namespace Actions
82 } // namespace Initialization
Definition: ConservativeSystem.hpp:34
Can be used to retrieve the analytic solution from the cache without having to know the template para...
Definition: Tags.hpp:40
Define prefixes for DataBox tags.
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:273
Defines classes and functions used for manipulating DataBox&#39;s.
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1222
Indicates the Frame that a TensorIndexType is in.
Definition: IndexType.hpp:36
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Defines class Variables.
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
Defines the class template Mesh.
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1623
Defines tags related to domain quantities.
Allocate and set variables needed for evolution of nonconservative systems.
Definition: NonconservativeSystem.hpp:44
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines class template ConstGlobalCache.
Definition: ComputeTimeDerivative.hpp:28
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1243