SpECTRE  v2021.11.01
Convergence::HasConverged Struct Reference

Signals convergence of the algorithm. More...

#include <HasConverged.hpp>

Public Member Functions

 HasConverged (const Criteria &criteria, size_t iteration_id, double residual_magnitude, double initial_residual_magnitude)
 Determine whether the criteria are met by means of Convergence::criteria_match.
 
 HasConverged (size_t num_iterations, size_t iteration_id)
 Construct at a state where iteration_id iterations of a total of num_iterations have completed. Use when the algorithm is intended to run for a fixed number of iterations. The convergence reason() will be Convergence::Reason::NumIterations.
 
 operator bool () const
 
Reason reason () const
 The reason the algorithm has converged. More...
 
size_t num_iterations () const
 The number of iterations the algorithm has completed.
 
double residual_magnitude () const
 The residual magnitude after the last iteration. NaN if no iteration has completed yet.
 
double initial_residual_magnitude () const
 The residual magnitude before the first iteration. NaN if this information is not available yet.
 
void pup (PUP::er &p)
 

Friends

bool operator== (const HasConverged &lhs, const HasConverged &rhs)
 
bool operator!= (const HasConverged &lhs, const HasConverged &rhs)
 
std::ostreamoperator<< (std::ostream &os, const HasConverged &has_converged)
 

Detailed Description

Signals convergence of the algorithm.

Details

Evaluates to true if the algorithm has converged and no further iterations should be performed. In this case, the reason() member function provides more information. If false, calling reason() is an error.

The stream operator provides a human-readable description of the convergence status.

This type default-constructs to a state that signals the algorithm has not yet converged.

Member Function Documentation

◆ reason()

Reason Convergence::HasConverged::reason ( ) const

The reason the algorithm has converged.

Warning
Calling this function is an error if the algorithm has not yet converged.

The documentation for this struct was generated from the following file: