LinearSolver.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 Initializes the DataBox tag related to the linear solver
29  *
30  * Uses the analytic solution to compute the linear solver source.
31  * Assumes the system fields are initialized to zero (see
32  * `Elliptic::Initialization::System`) so we don't have to apply the operator to
33  * the initial guess.
34  *
35  * With:
36  * - `sources_tag` = `db::add_tag_prefix<Tags::Source, system::fields_tag>`
37  *
38  * Uses:
39  * - Metavariables:
40  * - `linear_solver`
41  * - System:
42  * - `fields_tag`
43  * - DataBox:
44  * - `sources_tag`
45  *
46  * DataBox:
47  * - Adds:
48  * - All items in `linear_solver::tags`
49  */
50 template <typename Metavariables>
51 struct LinearSolver {
52  using linear_solver_tags = typename Metavariables::linear_solver::tags;
53  using system = typename Metavariables::system;
54 
55  using sources_tag =
57  using fields_operator_tag =
59  typename system::fields_tag>;
60 
61  using simple_tags = typename linear_solver_tags::simple_tags;
62  using compute_tags = typename linear_solver_tags::compute_tags;
63 
64  template <typename TagsList, typename ArrayIndex, typename ParallelComponent>
65  static auto initialize(
68  const ArrayIndex& array_index,
69  const ParallelComponent* const parallel_component_meta) noexcept {
70  const auto& sources = get<sources_tag>(box);
71 
72  // Starting with x_0 = 0 initial guess, so Ax_0=0
73  auto fields_operator =
74  make_with_value<db::item_type<fields_operator_tag>>(sources, 0.);
75 
76  return linear_solver_tags::initialize(std::move(box), cache, array_index,
77  parallel_component_meta, sources,
78  std::move(fields_operator));
79  }
80 };
81 } // namespace Initialization
82 } // 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
Functionality for solving linear systems of equations.
Definition: TerminateIfConverged.hpp:22
Definition: ComputeOperatorAction.hpp:28
Define prefixes for DataBox tags.
Defines classes and functions used for manipulating DataBox&#39;s.
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.
gmres_detail::InitializeElement< Metavariables > tags
Initialize the tags used by the GMRES linear solver.
Definition: Gmres.hpp:117
The Poisson equation formulated as a set of coupled first-order PDEs.
Definition: FirstOrderSystem.hpp:55
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 class template ConstGlobalCache.
Defines class IterationId.