| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// ShyLU: Scalable Hybrid LU Preconditioner and Solver |
| 4 |
// |
| 5 |
// Copyright 2011 NTESS and the ShyLU contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef _FROSCH_SOLVER_DECL_HPP |
| 11 |
#define _FROSCH_SOLVER_DECL_HPP |
| 12 |
|
| 13 |
#include <ShyLU_DDFROSch_config.h> |
| 14 |
|
| 15 |
//Teuchos |
| 16 |
#include "Teuchos_ParameterList.hpp" |
| 17 |
#include "Teuchos_RCP.hpp" |
| 18 |
|
| 19 |
// FROSch |
| 20 |
#include <FROSch_Tools_def.hpp> |
| 21 |
|
| 22 |
|
| 23 |
namespace FROSch { |
| 24 |
|
| 25 |
using namespace Teuchos; |
| 26 |
using namespace Xpetra; |
| 27 |
|
| 28 |
template <class SC = double, |
| 29 |
class LO = int, |
| 30 |
class GO = DefaultGlobalOrdinal, |
| 31 |
class NO = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType> |
| 32 |
class SolverFactory; |
| 33 |
|
| 34 |
template <class SC = double, |
| 35 |
class LO = int, |
| 36 |
class GO = DefaultGlobalOrdinal, |
| 37 |
class NO = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType> |
| 38 |
class Solver : public Operator<SC,LO,GO,NO> { |
| 39 |
|
| 40 |
protected: |
| 41 |
|
| 42 |
// Xpetra |
| 43 |
using XMap = Map<LO,GO,NO>; |
| 44 |
using XMapPtr = RCP<XMap>; |
| 45 |
using ConstXMapPtr = RCP<const XMap>; |
| 46 |
|
| 47 |
using XMatrix = Matrix<SC,LO,GO,NO>; |
| 48 |
using XMatrixPtr = RCP<XMatrix>; |
| 49 |
using ConstXMatrixPtr = RCP<const XMatrix>; |
| 50 |
|
| 51 |
using XMultiVector = MultiVector<SC,LO,GO,NO>; |
| 52 |
using XMultiVectorPtr = RCP<XMultiVector>; |
| 53 |
using ConstXMultiVectorPtr = RCP<const XMultiVector>; |
| 54 |
|
| 55 |
using XMultiVectorFactory = MultiVectorFactory<SC,LO,GO,NO>; |
| 56 |
|
| 57 |
// Teuchos |
| 58 |
using ParameterListPtr = RCP<ParameterList>; |
| 59 |
|
| 60 |
public: |
| 61 |
|
| 62 |
//! Initialize the internal solver |
| 63 |
virtual int initialize() = 0; |
| 64 |
|
| 65 |
//! Compute the internal solver |
| 66 |
virtual int compute() = 0; |
| 67 |
|
| 68 |
/*! |
| 69 |
\brief Computes the operator-multivector application. |
| 70 |
|
| 71 |
Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation |
| 72 |
vary according to the values of \c alpha and \c beta. Specifically |
| 73 |
- if <tt>beta == 0</tt>, apply() <b>must</b> overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. |
| 74 |
- if <tt>alpha == 0</tt>, apply() <b>may</b> short-circuit the operator, so that any values in \c X (including NaNs) are ignored. |
| 75 |
*/ |
| 76 |
virtual void apply(const XMultiVector &x, |
| 77 |
XMultiVector &y, |
| 78 |
ETransp mode=NO_TRANS, |
| 79 |
SC alpha=ScalarTraits<SC>::one(), |
| 80 |
SC beta=ScalarTraits<SC>::zero()) const = 0; |
| 81 |
|
| 82 |
//! Get domain map |
| 83 |
virtual const ConstXMapPtr getDomainMap() const; |
| 84 |
|
| 85 |
//! Get range map |
| 86 |
virtual const ConstXMapPtr getRangeMap() const; |
| 87 |
|
| 88 |
//! Get #IsInitialized_ |
| 89 |
bool isInitialized() const; |
| 90 |
|
| 91 |
//! Get #IsComputed_ |
| 92 |
bool isComputed() const; |
| 93 |
|
| 94 |
virtual int updateMatrix(ConstXMatrixPtr k, |
| 95 |
bool reuseInitialize=false) = 0; |
| 96 |
|
| 97 |
/*! |
| 98 |
\brief Computes a residual using the operator |
| 99 |
*/ |
| 100 |
virtual void residual(const XMultiVector & X, |
| 101 |
const XMultiVector & B, |
| 102 |
XMultiVector& R) const; |
| 103 |
|
| 104 |
protected: |
| 105 |
|
| 106 |
//! Constructor |
| 107 |
Solver(ConstXMatrixPtr k, |
| 108 |
ParameterListPtr parameterList, |
| 109 |
string description); |
| 110 |
|
| 111 |
//! Matrix |
| 112 |
ConstXMatrixPtr K_; |
| 113 |
|
| 114 |
//! Parameter list |
| 115 |
ParameterListPtr ParameterList_; |
| 116 |
|
| 117 |
//! Description of the solver |
| 118 |
string Description_; |
| 119 |
|
| 120 |
bool IsInitialized_ = false; |
| 121 |
|
| 122 |
bool IsComputed_ = false; |
| 123 |
|
| 124 |
friend class SolverFactory<SC,LO,GO,NO>; |
| 125 |
}; |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
#endif |