1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
4 #pragma once
11 #include "Parallel/Info.hpp"
12 #include "Parallel/Invoke.hpp"
13 #include "Parallel/Reduction.hpp"
16 /// \cond
17 namespace tuples {
18 template <typename...>
19 class TaggedTuple;
20 } // namespace tuples
21 namespace LinearSolver {
22 namespace gmres_detail {
23 template <typename Metavariables>
24 struct ResidualMonitor;
25 template <typename BroadcastTarget>
26 struct InitializeResidualMagnitude;
27 } // namespace gmres_detail
28 } // namespace LinearSolver
29 /// \endcond
31 namespace LinearSolver {
32 namespace gmres_detail {
34 template <typename Metavariables>
35 struct InitializeElement {
36  private:
37  using fields_tag = typename Metavariables::system::fields_tag;
38  using initial_fields_tag =
40  using operand_tag =
42  using orthogonalization_iteration_id_tag =
47  public:
48  using simple_tags =
49  db::AddSimpleTags<LinearSolver::Tags::IterationId,
51  initial_fields_tag, orthogonalization_iteration_id_tag,
52  basis_history_tag, LinearSolver::Tags::HasConverged>;
53  using compute_tags = db::AddComputeTags<>;
55  template <typename TagsList, typename ArrayIndex, typename ParallelComponent>
56  static auto initialize(
59  const ArrayIndex& array_index, const ParallelComponent* const /*meta*/,
62  LinearSolver::Tags::OperatorAppliedTo, fields_tag>>& Ax) noexcept {
63  db::mutate<operand_tag>(make_not_null(&box), [
64  &b, &Ax
65  ](const gsl::not_null<db::item_type<operand_tag>*> q) noexcept {
66  *q = b - Ax;
67  });
68  const auto& q = get<operand_tag>(box);
71  gmres_detail::InitializeResidualMagnitude<ParallelComponent>>(
72  Parallel::ReductionData<
74  inner_product(q, q)},
75  Parallel::get_parallel_component<ParallelComponent>(cache)[array_index],
76  Parallel::get_parallel_component<ResidualMonitor<Metavariables>>(
77  cache));
79  db::item_type<initial_fields_tag> x0(get<fields_tag>(box));
80  db::item_type<basis_history_tag> basis_history{};
82  return db::create_from<db::RemoveTags<>, simple_tags, compute_tags>(
83  std::move(box), IterationId{0}, IterationId{1}, std::move(x0),
84  IterationId{0}, std::move(basis_history),
86  }
87 };
89 } // namespace gmres_detail
90 } // namespace LinearSolver
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
Definition: Variables.hpp:46
Defines functions for interfacing with the parallelization framework.
Defines DataBox tags for the linear solver.
Functionality for solving linear systems of equations.
Definition: TerminateIfConverged.hpp:22
Definition: TaggedTuple.hpp:25
Define prefixes for DataBox tags.
Holds a LinearSolver::HasConverged flag that signals the linear solver has converged, along with the reason for convergence.
Definition: Tags.hpp:204
void contribute_to_reduction(ReductionData< Ts... > reduction_data, const SenderProxy &sender_component, const TargetProxy &target_component) noexcept
Perform a reduction from the sender_component (typically your own parallel component) to the target_c...
Definition: Reduction.hpp:243
A set of vectors that form a basis of the -th Krylov subspace .
Definition: Tags.hpp:179
Holds an IterationId that identifies a step in the linear solver algorithm.
Definition: Tags.hpp:66
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
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
double inner_product(const Lhs &lhs, const Rhs &rhs) noexcept
The local part of the Euclidean inner product on the vector space w.r.t. which the addition and scala...
Definition: InnerProduct.hpp:71
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
The prefix for tags related to an orthogonalization procedurce.
Definition: Tags.hpp:143
Functional for computing sqrt on an object.
Definition: Functional.hpp:269
auto get_parallel_component(ConstGlobalCache< Metavariables > &cache) noexcept -> Parallel::proxy_from_parallel_component< ConstGlobalCache_detail::get_component_if_mocked< typename Metavariables::component_list, ParallelComponentTag >> &
Access the Charm++ proxy associated with a ParallelComponent.
Definition: ConstGlobalCache.hpp:163
Prefix indicating the value a quantity will take on the next iteration of the algorithm.
Definition: Prefixes.hpp:98
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
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, but it may be necessary to perform the conversion explicitly when type deduction is desired.
Definition: Gsl.hpp:863
The linear operator applied to the data in Tag
Definition: Tags.hpp:53
Defines class template ConstGlobalCache.
The data to be reduced, and invokables to be called whenever two reduction messages are combined and ...
Definition: Reduction.hpp:64
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12
Defines make_with_value.
Defines class IterationId.
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1234