Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_LinearOpWithSolveHelpers.hpp
1// @HEADER
2// *****************************************************************************
3// Thyra: Interfaces and Support for Abstract Numerical Algorithms
4//
5// Copyright 2004 NTESS and the Thyra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_SUBCLASS_HELPERS_HPP
11#define THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_SUBCLASS_HELPERS_HPP
12
13
14#include "Thyra_LinearOpWithSolveBase.hpp"
15#include "Teuchos_toString.hpp"
16
17
18namespace Thyra {
19
20
28template<class Scalar>
31 const EOpTransp M_trans,
32 const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
33 );
34
42template<class Scalar>
43void assertSupportsSolveMeasureType(
45 const EOpTransp M_trans,
46 const SolveMeasureType &solveMeasureType
47 );
48// 2010/08/22: rabartl: ToDo: Deprecate this bug 4915 is finished!
49
50} // namespace Thyra
51
52
53//
54// Implementations
55//
56
57
58template<class Scalar>
59void Thyra::assertSolveSupports(
61 const EOpTransp M_trans,
62 const Ptr<const SolveCriteria<Scalar> > solveCriteria
63 )
64{
67 !lows.solveSupports(M_trans, solveCriteria),
68 std::logic_error,
69 "Error, the LinearOpWithSolve object \"" << lows.description() << "\"\n"
70 "for M_trans = " << toString(M_trans) << " does not support the solve"
71 " criteria = "
72 << ( nonnull(solveCriteria) ? toString(*solveCriteria) : std::string("null") )
73 << "!"
74 );
75}
76// 2010/08/22: rabartl: Bug 4915 ToDo: Move the above into the NIV function
77// solve(...).
78
79template<class Scalar>
80void Thyra::assertSupportsSolveMeasureType(
81 const LinearOpWithSolveBase<Scalar> &lows,
82 const EOpTransp M_trans,
83 const SolveMeasureType &solveMeasureType
84 )
85{
87 !solveSupportsSolveMeasureType(lows,M_trans,solveMeasureType),
88 std::logic_error,
89 "Error, the LinearOpWithSolve object \"" << lows.description() << "\"\n"
90 "for M_trans = " << toString(M_trans) << " does not support the solve"
91 " measure = "
92 << toString(solveMeasureType.numerator)
93 << "/"
94 << toString(solveMeasureType.denominator)
95 << "!"
96 );
97}
98
99#endif // THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_SUBCLASS_HELPERS_HPP
virtual std::string description() const
Base class for all linear operators that can support a high-level solve operation.
bool solveSupports(EOpTransp transp) const
Return if solve() supports the argument transp.
void assertSolveSupports(const LinearOpWithSolveBase< Scalar > &lows, const EOpTransp M_trans, const Ptr< const SolveCriteria< Scalar > > solveCriteria=Teuchos::null)
Assert that a LOWSB object supports a particular solve type.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
T_To & dyn_cast(T_From &from)
std::string toString(const T &t)
Simple struct that defines the requested solution criteria for a solve.