System.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <utility>
8 
13 #include "Domain/Mesh.hpp"
17 
18 namespace Elliptic {
19 namespace Initialization {
20 
21 /*!
22  * \brief Initializes the DataBox tags related to the system
23  *
24  * The system fields are initially set to zero here.
25  *
26  * Uses:
27  * - System:
28  * - `volume_dim`
29  * - `fields_tag`
30  * - `variables_tag`
31  * - DataBox:
32  * - `Tags::Mesh<volume_dim>`
33  *
34  * DataBox:
35  * - Adds:
36  * - `fields_tag`
37  * - `variables_tag`
38  * - `db::add_tag_prefix<LinearSolver::Tags::OperatorAppliedTo,
39  * variables_tag>`
40  */
41 template <typename SystemType>
42 struct System {
43  static constexpr size_t Dim = SystemType::volume_dim;
44  using simple_tags = db::AddSimpleTags<
45  typename SystemType::fields_tag, typename SystemType::variables_tag,
47  typename SystemType::variables_tag>>;
48  using compute_tags = db::AddComputeTags<>;
49 
50  template <typename TagsList>
51  static auto initialize(db::DataBox<TagsList>&& box) noexcept {
52  const size_t num_grid_points =
53  db::get<Tags::Mesh<Dim>>(box).number_of_grid_points();
54 
55  // Set initial data to zero. Non-zero initial data would require the
56  // linear solver initialization to also compute the Ax term.
57  db::item_type<typename SystemType::fields_tag> fields{num_grid_points, 0.};
58 
59  // Initialize the variables for the elliptic solve. Their initial value is
60  // determined by the linear solver. The value is also updated by the linear
61  // solver in every step.
63 
64  // Initialize the linear operator applied to the variables. It needs no
65  // initial value, but is computed in every step of the elliptic solve.
66  db::item_type<db::add_tag_prefix<::LinearSolver::Tags::OperatorAppliedTo,
67  typename SystemType::variables_tag>>
68  operator_applied_to_vars{num_grid_points};
69 
70  return db::create_from<db::RemoveTags<>, simple_tags, compute_tags>(
71  std::move(box), std::move(fields), std::move(vars),
72  std::move(operator_applied_to_vars));
73  }
74 };
75 
76 } // namespace Initialization
77 } // 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
Defines DataBox tags for the linear solver.
Items for initializing the DataBoxes of parallel components.
Definition: ConservativeSystem.hpp:21
Definition: ComputeOperatorAction.hpp:28
Define prefixes for DataBox tags.
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:1227
Defines functions computing partial derivatives.
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Defines class Variables.
Initializes the DataBox tags related to the system.
Definition: System.hpp:42
Defines the class template Mesh.
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
The linear operator applied to the data in Tag
Definition: Tags.hpp:53
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines functions and tags for taking a divergence.
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1234