42#ifndef THYRA_SOLVE_SUPPORT_TYPES_HPP
43#define THYRA_SOLVE_SUPPORT_TYPES_HPP
45#include "Thyra_OperatorVectorTypes.hpp"
46#include "Teuchos_ParameterList.hpp"
47#include "Teuchos_FancyOStream.hpp"
48#include "Teuchos_Describable.hpp"
81 switch(solveMeasureNormType) {
83 return "SOLVE_MEASURE_ONE";
85 return "SOLVE_MEASURE_NORM_RESIDUAL";
87 return "SOLVE_MEASURE_NORM_SOLUTION";
89 return "SOLVE_MEASURE_NORM_INIT_RESIDUAL";
91 return "SOLVE_MEASURE_NORM_RHS";
160template<
class Scalar>
180 "Error, the vector v="<<v.
description()<<
" is not compatiable with"
181 " *this="<<this->description()<<
"!");
311template <
class Scalar>
360template<
class Scalar>
363 out <<
typeName(solveCriteria) <<
"{";
406 switch(solveStatus) {
422template <
class Scalar>
448 std::ostringstream oss; oss <<
achievedTol;
return oss.str();
457template <
class Scalar>
461 out = Teuchos::getFancyOStream(
Teuchos::rcp(&out_arg,
false));
467 if (solveStatus.
message.length()) {
469 *out <<
"\n" << solveStatus.
message <<
"\n";
471 *out <<
"extraParameters:";
511template <
class Scalar>
536template <
class Scalar>
549 overallSolveStatus->message = solveStatus.
message;
558 switch(overallSolveStatus->solveStatus) {
566 overallSolveStatus->message = solveStatus.
message;
578 if(overallSolveStatus->message ==
"")
579 overallSolveStatus->message = solveStatus.
message;
586 if( solveStatus.
achievedTol > overallSolveStatus->achievedTol ) {
587 overallSolveStatus->achievedTol = solveStatus.
achievedTol;
590 if(overallSolveStatus->message ==
"")
591 overallSolveStatus->message = solveStatus.
message;
593 if(overallSolveStatus->extraParameters.get()==NULL)
virtual std::string description() const
Exception type thrown on an catastrophic solve failure.
Thrown if vector spaces are incompatible.
A general reduction functional to be used in specialized solve convergence criteria.
virtual bool isCompatibleImpl(const VectorBase< Scalar > &v) const =0
ScalarTraits< Scalar >::magnitudeType reduce(const VectorBase< Scalar > &v) const
Compute the reduction over a vector.
bool isCompatible(const VectorBase< Scalar > &v) const
Returns true if v is compatible with *this.
virtual ScalarTraits< Scalar >::magnitudeType reduceImpl(const VectorBase< Scalar > &v) const =0
Abstract interface for finite-dimensional dense vectors.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
EPreconditionerInputType
Enum defining the status of a preconditioner object.
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
ESolveStatus
Solution status.
ESolveMeasureNormType
Type of solve measure norm.
@ PRECONDITIONER_INPUT_TYPE_AS_MATRIX
The input preconditioner should viewed as a matrix to be factored then backsolved as a preconditioner...
@ PRECONDITIONER_INPUT_TYPE_AS_OPERATOR
The input preconditioner should just be applied as an operator.
@ SUPPORT_SOLVE_FORWARD_ONLY
The output LOWSB object will only be used for forward solves.
@ SUPPORT_SOLVE_FORWARD_AND_TRANSPOSE
The output LOWSB object will used for forward and transpose solves.
@ SUPPORT_SOLVE_UNSPECIFIED
How the output LOWSB object will be useded for solves in unspecified.
@ SUPPORT_SOLVE_TRANSPOSE_ONLY
The output LOWSB object will only be used for transpose solves.
@ SOLVE_STATUS_UNCONVERGED
The requested solution criteria has likely not been achieved.
@ SOLVE_STATUS_CONVERGED
The requested solution criteria has likely been achieved.
@ SOLVE_STATUS_UNKNOWN
The final solution status is unknown but he solve did not totally fail.
@ SOLVE_MEASURE_NORM_INIT_RESIDUAL
Norm of the initial residual vector given a non-zero guess (i.e. ||A*xo-b||)
@ SOLVE_MEASURE_NORM_RESIDUAL
Norm of the current residual vector (i.e. ||A*x-b||)
@ SOLVE_MEASURE_NORM_RHS
Norm of the right-hand side (i.e. ||b||)
@ SOLVE_MEASURE_NORM_SOLUTION
Norm of the current solution vector (i.e. ||x||)
@ SOLVE_MEASURE_ONE
No solve measure (i.e. same as 1.0)
const char * toString(EConj conj)
Return a string name for a EOpTransp value. `*.
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
std::string typeName(const T &t)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Simple struct that defines the requested solution criteria for a solve.
ScalarMag requestedTol
The requested solve tolerance (what the client would like to see). Only significant if !...
RCP< const ReductionFunctional< Scalar > > denominatorReductionFunc
Reduction function to be used in place of the natural norm of the numerator.
static ScalarMag unspecifiedTolerance()
SolveCriteria(SolveMeasureType solveMeasureType_in, ScalarMag requestedTol_in, const RCP< ParameterList > &extraParameters_in=Teuchos::null, const RCP< ReductionFunctional< Scalar > > &numeratorReductionFunc_in=Teuchos::null, const RCP< ReductionFunctional< Scalar > > &denominatorReductionFunc_in=Teuchos::null)
Construct with a specified solve criteria.
SolveCriteria()
Default construction to use default solve criteria.
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
RCP< const ReductionFunctional< Scalar > > numeratorReductionFunc
Reduction function to be used in place of the natural norm of the numerator.
RCP< ParameterList > extraParameters
Any extra control parameters (e.g. max iterations).
SolveMeasureType solveMeasureType
The type of solve tolerance requested as given in this->requestedTol.
std::ostream & operator<<(std::ostream &out, const SolveCriteria< Scalar > &solveCriteria)
Output operator.
ESolveMeasureNormType numerator
void set(ESolveMeasureNormType _numerator, ESolveMeasureNormType _denominator)
bool useDefault() const
Return if this is a default solve measure (default constructed).
bool contains(ESolveMeasureNormType measure) const
bool operator()(ESolveMeasureNormType numerator_in, ESolveMeasureNormType denominator_in) const
Return if (numerator,denominataor) matches this.
std::ostream & operator<<(std::ostream &out, const SolveMeasureType &solveMeasureType)
Output operator.
SolveMeasureType(ESolveMeasureNormType _numerator, ESolveMeasureNormType _denominator)
ESolveMeasureNormType denominator
Simple struct for the return status from a solve.
static ScalarMag unknownTolerance()
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
std::ostream & operator<<(std::ostream &out_arg, const SolveStatus< Scalar > &solveStatus)
Print the solve status to a stream.
std::string message
A simple one-line message (i.e. no newlines) returned from the solver.
static std::string achievedTolToString(const ScalarMag &achievedTol)
Output the achieveTol field.
ESolveStatus solveStatus
The return status of the solve.
ScalarMag achievedTol
The maximum final tolerance actually achieved by the (block) linear solve. A value of unknownToleranc...
RCP< ParameterList > extraParameters
Any extra status parameters. Note that the contents of this parameter list is totally undefined.
void accumulateSolveStatusInit(const Ptr< SolveStatus< Scalar > > &overallSolveStatus)
Initial overallSolveStatus before calling accumulateSolveStatus().
void accumulateSolveStatus(const SolveCriteria< Scalar >, const SolveStatus< Scalar > &solveStatus, const Ptr< SolveStatus< Scalar > > &overallSolveStatus)
Accumulate solve status objects for solving a block of RHSs is smaller sub-blocks.