SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/NonlinearSolver/NewtonRaphson - ResidualMonitor.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 0.0 % 1 0
Test Date: 2026-10-22 17:29:42
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              :   static constexpr bool checkpoint_data = true;
      39              :   using const_global_cache_tags =
      40              :       tmpl::list<logging::Tags::Verbosity<OptionsGroup>,
      41              :                  Convergence::Tags::Criteria<OptionsGroup>,
      42              :                  NonlinearSolver::Tags::SufficientDecrease<OptionsGroup>,
      43              :                  NonlinearSolver::Tags::MaxGlobalizationSteps<OptionsGroup>>;
      44              :   using metavariables = Metavariables;
      45              :   using phase_dependent_action_list = tmpl::list<Parallel::PhaseActions<
      46              :       Parallel::Phase::Initialization,
      47              :       tmpl::list<InitializeResidualMonitor<FieldsTag, OptionsGroup>>>>;
      48              : 
      49              :   using simple_tags_from_options = Parallel::get_simple_tags_from_options<
      50              :       Parallel::get_initialization_actions_list<phase_dependent_action_list>>;
      51              : 
      52              :   static void initialize(
      53              :       Parallel::CProxy_GlobalCache<Metavariables>& /*global_cache*/) {}
      54              : 
      55              :   static void execute_next_phase(
      56              :       const Parallel::Phase next_phase,
      57              :       Parallel::CProxy_GlobalCache<Metavariables>& global_cache) {
      58              :     auto& local_cache = *Parallel::local_branch(global_cache);
      59              :     Parallel::get_parallel_component<ResidualMonitor>(local_cache)
      60              :         .start_phase(next_phase);
      61              :   }
      62              : };
      63              : 
      64              : template <typename FieldsTag, typename OptionsGroup>
      65              : struct InitializeResidualMonitor {
      66              :  private:
      67              :   using fields_tag = FieldsTag;
      68              :   using residual_tag =
      69              :       db::add_tag_prefix<NonlinearSolver::Tags::Residual, fields_tag>;
      70              :   using residual_magnitude_square_tag =
      71              :       LinearSolver::Tags::MagnitudeSquare<residual_tag>;
      72              :   using initial_residual_magnitude_tag =
      73              :       ::Tags::Initial<LinearSolver::Tags::Magnitude<residual_tag>>;
      74              :   using prev_residual_magnitude_square_tag =
      75              :       NonlinearSolver::Tags::Globalization<residual_magnitude_square_tag>;
      76              : 
      77              :  public:
      78              :   using simple_tags =
      79              :       db::AddSimpleTags<residual_magnitude_square_tag,
      80              :                         initial_residual_magnitude_tag,
      81              :                         NonlinearSolver::Tags::StepLength<OptionsGroup>,
      82              :                         prev_residual_magnitude_square_tag>;
      83              :   using compute_tags = tmpl::list<>;
      84              : 
      85              :   template <typename DbTagsList, typename... InboxTags, typename Metavariables,
      86              :             typename ArrayIndex, typename ActionList,
      87              :             typename ParallelComponent>
      88              :   static Parallel::iterable_action_return_t apply(
      89              :       db::DataBox<DbTagsList>& box,
      90              :       tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      91              :       const Parallel::GlobalCache<Metavariables>& /*cache*/,
      92              :       const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
      93              :       const ParallelComponent* const /*meta*/) {
      94              :     Initialization::mutate_assign<simple_tags>(
      95              :         make_not_null(&box), std::numeric_limits<double>::signaling_NaN(),
      96              :         std::numeric_limits<double>::signaling_NaN(),
      97              :         std::numeric_limits<double>::signaling_NaN(),
      98              :         std::numeric_limits<double>::signaling_NaN());
      99              :     return {Parallel::AlgorithmExecution::Pause, std::nullopt};
     100              :   }
     101              : };
     102              : 
     103              : }  // namespace NonlinearSolver::newton_raphson::detail
        

Generated by: LCOV version 2.0-1