SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/NonlinearSolver/NewtonRaphson - ResidualMonitor.hpp Hit Total Coverage
Commit: 9ddc33268b29014a4956c8f0c24ca90b397463e1 Lines: 0 1 0.0 %
Date: 2024-04-26 20:00:04
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <limits>
       7             : #include <optional>
       8             : 
       9             : #include "DataStructures/DataBox/DataBox.hpp"
      10             : #include "DataStructures/DataBox/Prefixes.hpp"
      11             : #include "IO/Logging/Tags.hpp"
      12             : #include "NumericalAlgorithms/Convergence/Tags.hpp"
      13             : #include "Parallel/AlgorithmExecution.hpp"
      14             : #include "Parallel/Algorithms/AlgorithmSingleton.hpp"
      15             : #include "Parallel/GlobalCache.hpp"
      16             : #include "Parallel/Local.hpp"
      17             : #include "Parallel/Phase.hpp"
      18             : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      19             : #include "ParallelAlgorithms/LinearSolver/Tags.hpp"
      20             : #include "ParallelAlgorithms/NonlinearSolver/Tags.hpp"
      21             : 
      22             : /// \cond
      23             : namespace tuples {
      24             : template <typename...>
      25             : class TaggedTuple;
      26             : }  // namespace tuples
      27             : namespace NonlinearSolver::newton_raphson::detail {
      28             : template <typename Metavariables, typename FieldsTag>
      29             : struct InitializeResidualMonitor;
      30             : }  // namespace NonlinearSolver::newton_raphson::detail
      31             : /// \endcond
      32             : 
      33             : namespace NonlinearSolver::newton_raphson::detail {
      34             : 
      35             : template <typename Metavariables, typename FieldsTag, typename OptionsGroup>
      36             : struct ResidualMonitor {
      37             :   using chare_type = Parallel::Algorithms::Singleton;
      38             :   using const_global_cache_tags =
      39             :       tmpl::list<logging::Tags::Verbosity<OptionsGroup>,
      40             :                  Convergence::Tags::Criteria<OptionsGroup>,
      41             :                  NonlinearSolver::Tags::SufficientDecrease<OptionsGroup>,
      42             :                  NonlinearSolver::Tags::MaxGlobalizationSteps<OptionsGroup>>;
      43             :   using metavariables = Metavariables;
      44             :   using phase_dependent_action_list = tmpl::list<Parallel::PhaseActions<
      45             :       Parallel::Phase::Initialization,
      46             :       tmpl::list<InitializeResidualMonitor<FieldsTag, OptionsGroup>>>>;
      47             : 
      48             :   using simple_tags_from_options = Parallel::get_simple_tags_from_options<
      49             :       Parallel::get_initialization_actions_list<phase_dependent_action_list>>;
      50             : 
      51             :   static void initialize(
      52             :       Parallel::CProxy_GlobalCache<Metavariables>& /*global_cache*/) {}
      53             : 
      54             :   static void execute_next_phase(
      55             :       const Parallel::Phase next_phase,
      56             :       Parallel::CProxy_GlobalCache<Metavariables>& global_cache) {
      57             :     auto& local_cache = *Parallel::local_branch(global_cache);
      58             :     Parallel::get_parallel_component<ResidualMonitor>(local_cache)
      59             :         .start_phase(next_phase);
      60             :   }
      61             : };
      62             : 
      63             : template <typename FieldsTag, typename OptionsGroup>
      64             : struct InitializeResidualMonitor {
      65             :  private:
      66             :   using fields_tag = FieldsTag;
      67             :   using residual_tag =
      68             :       db::add_tag_prefix<NonlinearSolver::Tags::Residual, fields_tag>;
      69             :   using residual_magnitude_square_tag =
      70             :       LinearSolver::Tags::MagnitudeSquare<residual_tag>;
      71             :   using initial_residual_magnitude_tag =
      72             :       ::Tags::Initial<LinearSolver::Tags::Magnitude<residual_tag>>;
      73             :   using prev_residual_magnitude_square_tag =
      74             :       NonlinearSolver::Tags::Globalization<residual_magnitude_square_tag>;
      75             : 
      76             :  public:
      77             :   using simple_tags =
      78             :       db::AddSimpleTags<residual_magnitude_square_tag,
      79             :                         initial_residual_magnitude_tag,
      80             :                         NonlinearSolver::Tags::StepLength<OptionsGroup>,
      81             :                         prev_residual_magnitude_square_tag>;
      82             :   using compute_tags = tmpl::list<>;
      83             : 
      84             :   template <typename DbTagsList, typename... InboxTags, typename Metavariables,
      85             :             typename ArrayIndex, typename ActionList,
      86             :             typename ParallelComponent>
      87             :   static Parallel::iterable_action_return_t apply(
      88             :       db::DataBox<DbTagsList>& box,
      89             :       tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      90             :       const Parallel::GlobalCache<Metavariables>& /*cache*/,
      91             :       const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
      92             :       const ParallelComponent* const /*meta*/) {
      93             :     Initialization::mutate_assign<simple_tags>(
      94             :         make_not_null(&box), std::numeric_limits<double>::signaling_NaN(),
      95             :         std::numeric_limits<double>::signaling_NaN(),
      96             :         std::numeric_limits<double>::signaling_NaN(),
      97             :         std::numeric_limits<double>::signaling_NaN());
      98             :     return {Parallel::AlgorithmExecution::Pause, std::nullopt};
      99             :   }
     100             : };
     101             : 
     102             : }  // namespace NonlinearSolver::newton_raphson::detail

Generated by: LCOV version 1.14