Source.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 /// \cond
19 namespace Frame {
20 struct Inertial;
21 } // namespace Frame
22 /// \endcond
23 
24 namespace Elliptic {
25 namespace Initialization {
26 
27 /*!
28  * \brief Computes the sources of the elliptic equations and adds them to the
29  * DataBox
30  *
31  * \note Currently the sources are always retrieved from an analytic solution.
32  *
33  * With:
34  * - `sources_tag` = `db::add_tag_prefix<Tags::Source, system::fields_tag>`
35  *
36  * Uses:
37  * - Metavariables:
38  * - `analytic_solution_tag`
39  * - ConstGlobalCache:
40  * - `analytic_solution_tag`
41  * - System:
42  * - `volume_dim`
43  * - `fields_tag`
44  * - DataBox:
45  * - `Tags::Mesh<volume_dim>`
46  * - `Tags::Coordinates<volume_dim, Frame::Inertial>`
47  *
48  * DataBox:
49  * - Adds:
50  * - `sources_tag`
51  */
52 template <typename Metavariables>
53 struct Source {
54  using system = typename Metavariables::system;
55 
56  using sources_tag =
58 
59  using simple_tags = db::AddSimpleTags<sources_tag>;
60  using compute_tags = db::AddComputeTags<>;
61 
62  template <typename TagsList>
63  static auto initialize(
65  const Parallel::ConstGlobalCache<Metavariables>& cache) noexcept {
66  const auto& inertial_coords =
67  get<Tags::Coordinates<system::volume_dim, Frame::Inertial>>(box);
68  const auto num_grid_points =
69  get<Tags::Mesh<system::volume_dim>>(box).number_of_grid_points();
70 
71  db::item_type<sources_tag> sources(num_grid_points, 0.);
72  // This actually sets the complete set of tags in the Variables, but there
73  // is no Variables constructor from a TaggedTuple (yet)
74  sources.assign_subset(
75  Parallel::get<typename Metavariables::analytic_solution_tag>(cache)
76  .variables(inertial_coords,
77  db::get_variables_tags_list<sources_tag>{}));
78 
79  return db::create_from<db::RemoveTags<>, simple_tags, compute_tags>(
80  std::move(box), std::move(sources));
81  }
82 };
83 } // namespace Initialization
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
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.
Computes the sources of the elliptic equations and adds them to the DataBox.
Definition: Source.hpp:53
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
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:76
Defines the class template Mesh.
The Poisson equation formulated as a set of coupled first-order PDEs.
Definition: FirstOrderSystem.hpp:55
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
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines class template ConstGlobalCache.
Defines class IterationId.
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1234