Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_LinearOpWithSolveBase_decl.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Thyra: Interfaces and Support for Abstract Numerical Algorithms
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42#ifndef THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
43#define THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
44
45#include "Thyra_OperatorSolveTypes.hpp"
46#include "Thyra_LinearOpBase.hpp"
47#include "Thyra_MultiVectorBase.hpp"
48#include "Thyra_VectorSpaceBase.hpp"
49#include "Thyra_SolveSupportTypes.hpp"
50#include "Teuchos_VerboseObject.hpp"
51
52
53namespace Thyra {
54
55
307template<class Scalar>
309 : virtual public LinearOpBase<Scalar>
310 , virtual public Teuchos::VerboseObject<LinearOpWithSolveBase<Scalar> >
311{
312public:
313
316
317 // 2010/08/22: rabartl: To properly handle the new SolveCriteria struct with
318 // reduction functionals (bug 4915) the function solveSupports() must be
319 // refactored. Here is how this refactoring can be done incrementally and
320 // safely:
321 //
322 // (*) Create new override solveSupports(transp, solveCriteria) that calls
323 // virtual solveSupportsNewImpl(transp, solveCriteria).
324 //
325 // (*) One by one, refactor existing LOWSB subclasses to implement
326 // solveSupportsNewImpl(transp, solveCriteria). This can be done by
327 // basically copying the existing solveSupportsSolveMeasureTypeImpl()
328 // override. Then have each of the existing
329 // solveSupportsSolveMeasureTypeImpl() overrides call
330 // solveSupportsNewImpl(transp, solveCriteria) to make sure that
331 // solveSupportsNewImpl() is getting tested right away. Also, have the
332 // existing solveSupportsImpl(...) overrides call
333 // solveSupportsNewImpl(transp, null). This will make sure that all
334 // functionality is now going through solveSupportsNewImpl(...) and is
335 // getting tested.
336 //
337 // (*) Refactor Teko software.
338 //
339 // (*) Once all LOWSB subclasses implement solveSupportsNewImpl(transp,
340 // solveCriteria), finish off the refactoring in one shot:
341 //
342 // (-) Remove the function solveSupports(transp), give solveCriteria a
343 // default null in solveSupports(transp, solveCriteria).
344 //
345 // (-) Run all tests.
346 //
347 // (-) Remove all of the solveSupportsImpl(transp) overrides, rename solve
348 // solveSupportsNewImpl() to solveSupportsImpl(), and make
349 // solveSupportsImpl(...) pure virtual.
350 //
351 // (-) Run all tests.
352 //
353 // (-) Change solveSupportsSolveMeasureType(transp, solveMeasureType) to
354 // call solveSupportsImpl(transp, solveCriteria) by setting
355 // solveMeasureType on a temp SolveCriteria object. Also, deprecate the
356 // function solveSupportsSolveMeasureType(...).
357 //
358 // (-) Run all tests.
359 //
360 // (-) Remove all of the existing solveSupportsSolveMeasureTypeImpl()
361 // overrides.
362 //
363 // (-) Run all tests.
364 //
365 // (-) Clean up all deprecated warnings about calling
366 // solveSupportsSolveMeasureType() and instead have them call
367 // solveSupports(...) with a SolveCritera object.
368 //
369 // (*) Enter a release notes item about this breaking backward compatiblilty
370 // for existing subclasses of LOWSB.
371 //
372 // This refactoring will be done by and by has bug 4915 is implemented.
373 //
374
380 bool solveSupports(EOpTransp transp) const
381 { return solveSupportsImpl(transp); }
382
388 const Ptr<const SolveCriteria<Scalar> > solveCriteria) const
389 { return solveSupportsNewImpl(transp, solveCriteria); }
390
398 const SolveMeasureType& solveMeasureType
399 ) const
400 { return solveSupportsSolveMeasureTypeImpl(transp, solveMeasureType); }
401
451 const EOpTransp A_trans,
453 const Ptr<MultiVectorBase<Scalar> > &X,
454 const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
455 ) const
456 { return solveImpl(A_trans, B, X, solveCriteria); }
457
459
460protected:
461
464
466 virtual bool solveSupportsImpl(EOpTransp transp) const;
467
469 virtual bool solveSupportsNewImpl(EOpTransp /* transp */,
470 const Ptr<const SolveCriteria<Scalar> > /* solveCriteria */
471 ) const
472 {
475 }
476
479 const SolveMeasureType& solveMeasureType) const;
480
483 const EOpTransp transp,
485 const Ptr<MultiVectorBase<Scalar> > &X,
486 const Ptr<const SolveCriteria<Scalar> > solveCriteria
487 ) const = 0;
488
490
491private:
492
493private:
494
495 // Not defined and not to be called
497 operator=(const LinearOpWithSolveBase<Scalar>&);
498
499};
500
501
506template<class Scalar>
507inline
509{
510 return A.solveSupports(transp);
511}
512
513
518template<class Scalar>
519inline
522 const EOpTransp transp,
523 const Ptr<const SolveCriteria<Scalar> > solveCriteria
524 )
525{
526 return A.solveSupports(transp, solveCriteria);
527}
528
529
535template<class Scalar>
536inline
539 const EOpTransp transp,
540 const SolveMeasureType &solveMeasureType
541 )
542{
543 return A.solveSupportsSolveMeasureType(transp, solveMeasureType);
544}
545
546
551template<class Scalar>
552inline
555 const EOpTransp A_trans,
557 const Ptr<MultiVectorBase<Scalar> > &X,
558 const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
559 )
560{
561 return A.solve(A_trans, B, X, solveCriteria);
562}
563
564
565
566} // namespace Thyra
567
568
569#endif // THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
Base class for all linear operators.
Base class for all linear operators that can support a high-level solve operation.
bool solveSupportsSolveMeasureType(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp transp, const SolveMeasureType &solveMeasureType)
Call solveSupportsSolveMeasureType() as a non-member function.
SolveStatus< Scalar > solve(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp A_trans, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria=Teuchos::null)
Call solve() as a non-member function.
bool solveSupports(EOpTransp transp, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
Return if solve() supports a given transpose and solve criteria specification.
bool solveSupports(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp transp, const Ptr< const SolveCriteria< Scalar > > solveCriteria)
Call solveSupports() as a non-member function.
virtual SolveStatus< Scalar > solveImpl(const EOpTransp transp, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const =0
Virtual implementation for solve().
bool solveSupports(EOpTransp transp) const
Return if solve() supports the argument transp.
bool solveSupports(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp transp)
Call solveSupports() as a non-member function.
bool solveSupportsSolveMeasureType(EOpTransp transp, const SolveMeasureType &solveMeasureType) const
Return if solve() supports the given the solve measure type.
virtual bool solveSupportsImpl(EOpTransp transp) const
Virtual implementation for solveSupports().
virtual bool solveSupportsNewImpl(EOpTransp, const Ptr< const SolveCriteria< Scalar > >) const
Virtual implementation of solveSupports().
SolveStatus< Scalar > solve(const EOpTransp A_trans, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria=Teuchos::null) const
Request the solution of a block linear system.
virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp transp, const SolveMeasureType &solveMeasureType) const
Virtual implementation for solveSupportsSolveMeasureType().
Interface for a collection of column vectors called a multi-vector.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
Simple struct that defines the requested solution criteria for a solve.
Simple struct for the return status from a solve.