10 #ifndef THYRA_SOLVE_SUPPORT_TYPES_HPP
11 #define THYRA_SOLVE_SUPPORT_TYPES_HPP
13 #include "Thyra_OperatorVectorTypes.hpp"
14 #include "Teuchos_ParameterList.hpp"
15 #include "Teuchos_FancyOStream.hpp"
16 #include "Teuchos_Describable.hpp"
49 switch(solveMeasureNormType) {
51 return "SOLVE_MEASURE_ONE";
53 return "SOLVE_MEASURE_NORM_RESIDUAL";
55 return "SOLVE_MEASURE_NORM_SOLUTION";
57 return "SOLVE_MEASURE_NORM_INIT_RESIDUAL";
59 return "SOLVE_MEASURE_NORM_RHS";
128 template<
class Scalar>
148 "Error, the vector v="<<v.
description()<<
" is not compatiable with"
279 template <
class Scalar>
328 template<
class Scalar>
329 std::ostream& operator<<(std::ostream &out, const SolveCriteria<Scalar> &solveCriteria)
331 out <<
typeName(solveCriteria) <<
"{";
332 out <<
"solveMeasureType="<<solveCriteria.solveMeasureType;
333 out <<
", requestedTol="<<solveCriteria.requestedTol;
334 if (
nonnull(solveCriteria.extraParameters)) {
335 out <<
", extraParameters="<<solveCriteria.extraParameters;
337 if (
nonnull(solveCriteria.numeratorReductionFunc)) {
338 out <<
", numeratorReductionFunc="<<solveCriteria.numeratorReductionFunc->description();
340 if (
nonnull(solveCriteria.denominatorReductionFunc)) {
341 out <<
", denominatorReductionFunc="<<solveCriteria.denominatorReductionFunc->description();
374 switch(solveStatus) {
390 template <
class Scalar>
416 std::ostringstream oss; oss <<
achievedTol;
return oss.str();
425 template <
class Scalar>
426 std::ostream& operator<<( std::ostream& out_arg, const SolveStatus<Scalar> &solveStatus )
429 out = Teuchos::getFancyOStream(
Teuchos::rcp(&out_arg,
false));
432 <<
"solveStatus = " <<
toString(solveStatus.solveStatus) << std::endl
435 if (solveStatus.message.length()) {
437 *out <<
"\n" << solveStatus.message <<
"\n";
439 *out <<
"extraParameters:";
440 if(solveStatus.extraParameters.get()) {
443 solveStatus.extraParameters->print(*out, 10,
true);
479 template <
class Scalar>
504 template <
class Scalar>
517 overallSolveStatus->message = solveStatus.
message;
526 switch(overallSolveStatus->solveStatus) {
534 overallSolveStatus->message = solveStatus.
message;
546 if(overallSolveStatus->message ==
"")
547 overallSolveStatus->message = solveStatus.
message;
554 if( solveStatus.
achievedTol > overallSolveStatus->achievedTol ) {
555 overallSolveStatus->achievedTol = solveStatus.
achievedTol;
558 if(overallSolveStatus->message ==
"")
559 overallSolveStatus->message = solveStatus.
message;
561 if(overallSolveStatus->extraParameters.get()==NULL)
569 #endif // THYRA_SOLVE_SUPPORT_TYPES_HPP
How the output LOWSB object will be useded for solves in unspecified.
SolveCriteria()
Default construction to use default solve criteria.
Norm of the current solution vector (i.e. ||x||)
ScalarMag requestedTol
The requested solve tolerance (what the client would like to see). Only significant if !this->solveMe...
virtual ScalarTraits< Scalar >::magnitudeType reduceImpl(const VectorBase< Scalar > &v) const =0
bool useDefault() const
Return if this is a default solve measure (default constructed).
Thrown if vector spaces are incompatible.
bool contains(ESolveMeasureNormType measure) const
The output LOWSB object will only be used for forward solves.
std::string message
A simple one-line message (i.e. no newlines) returned from the solver.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
The output LOWSB object will used for forward and transpose solves.
The final solution status is unknown but he solve did not totally fail.
bool operator()(ESolveMeasureNormType numerator_in, ESolveMeasureNormType denominator_in) const
Return if (numerator,denominataor) matches this.
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.
void accumulateSolveStatusInit(const Ptr< SolveStatus< Scalar > > &overallSolveStatus)
Initial overallSolveStatus before calling accumulateSolveStatus().
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.
SolveMeasureType(ESolveMeasureNormType _numerator, ESolveMeasureNormType _denominator)
ESolveMeasureNormType numerator
std::ostream & operator<<(std::ostream &out, const SolveMeasureType &solveMeasureType)
Output operator.
ESolveMeasureNormType
Type of solve measure norm.
The output LOWSB object will only be used for transpose solves.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
ESolveStatus
Solution status.
static ScalarMag unknownTolerance()
virtual std::string description() const
Abstract interface for finite-dimensional dense vectors.
TEUCHOSCORE_LIB_DLL_EXPORT std::string toString(const EVerbosityLevel verbLevel)
Simple struct for the return status from a solve.
ScalarTraits< Scalar >::magnitudeType reduce(const VectorBase< Scalar > &v) const
Compute the reduction over a vector.
Norm of the right-hand side (i.e. ||b||)
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
ESolveStatus solveStatus
The return status of the solve.
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
static ScalarMag unspecifiedTolerance()
void set(ESolveMeasureNormType _numerator, ESolveMeasureNormType _denominator)
No solve measure (i.e. same as 1.0)
bool nonnull(const boost::shared_ptr< T > &p)
ScalarMag achievedTol
The maximum final tolerance actually achieved by the (block) linear solve. A value of unknownToleranc...
static std::string achievedTolToString(const ScalarMag &achievedTol)
Output the achieveTol field.
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
RCP< ParameterList > extraParameters
Any extra control parameters (e.g. max iterations).
virtual bool isCompatibleImpl(const VectorBase< Scalar > &v) const =0
bool isCompatible(const VectorBase< Scalar > &v) const
Returns true if v is compatible with *this.
RCP< const ReductionFunctional< Scalar > > numeratorReductionFunc
Reduction function to be used in place of the natural norm of the numerator.
The input preconditioner should just be applied as an operator.
A general reduction functional to be used in specialized solve convergence criteria.
RCP< const ReductionFunctional< Scalar > > denominatorReductionFunc
Reduction function to be used in place of the natural norm of the numerator.
EPreconditionerInputType
Enum defining the status of a preconditioner object.
RCP< ParameterList > extraParameters
Any extra status parameters. Note that the contents of this parameter list is totally undefined...
SolveMeasureType solveMeasureType
The type of solve tolerance requested as given in this->requestedTol.
The requested solution criteria has likely been achieved.
Exception type thrown on an catastrophic solve failure.
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
The requested solution criteria has likely not been achieved.
Simple struct that defines the requested solution criteria for a solve.
The input preconditioner should viewed as a matrix to be factored then backsolved as a preconditioner...
ESolveMeasureNormType denominator
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
std::string typeName(const T &t)
Norm of the initial residual vector given a non-zero guess (i.e. ||A*xo-b||)
Norm of the current residual vector (i.e. ||A*x-b||)