SpECTRE
v2024.06.18

Signals convergence or termination 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 .  
HasConverged (Reason reason, std::optional< std::string > error_message, size_t iteration_id)  
Construct a state manually. More...  
operator bool () const  
Reason  reason () const 
The reason the algorithm has converged. More...  
const std::string &  error_message () const 
Error message if reason is Reason::Error 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  check_for_error () const 
Throw an exception if the reason() is Reason::Error .  
void  pup (PUP::er &p) 
Friends  
bool  operator== (const HasConverged &lhs, const HasConverged &rhs) 
bool  operator!= (const HasConverged &lhs, const HasConverged &rhs) 
std::ostream &  operator<< (std::ostream &os, const HasConverged &has_converged) 
Signals convergence or termination of the algorithm.
Evaluates to true
if the algorithm has converged or terminated 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 humanreadable description of the convergence status.
This type defaultconstructs to a state that signals the algorithm has not yet converged.
Convergence::HasConverged::HasConverged  (  Reason  reason, 
std::optional< std::string >  error_message,  
size_t  iteration_id  
) 
Construct a state manually.
Currently only allows to construct a state with Reason::Error
. Use the other constructors for the other Reason
s.
const std::string & Convergence::HasConverged::error_message  (  )  const 
Error message if reason is Reason::Error
reason()
is Reason::Error
. Reason Convergence::HasConverged::reason  (  )  const 
The reason the algorithm has converged.