// @HEADER // ***************************************************************************** // ShyLU: Scalable Hybrid LU Preconditioner and Solver // // Copyright 2011 NTESS and the ShyLU contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef _FROSCH_SUBDOMAINSOLVER_DECL_HPP #define _FROSCH_SUBDOMAINSOLVER_DECL_HPP #include #include #include #include #ifdef HAVE_SHYLU_DDFROSCH_EPETRA #include "Epetra_LinearProblem.h" #endif #ifdef HAVE_SHYLU_DDFROSCH_AMESOS #include "Amesos_ConfigDefs.h" #include "Amesos.h" #include "Amesos_BaseSolver.h" #endif #include "Amesos2.hpp" #ifdef HAVE_SHYLU_DDFROSCH_BELOS #include #include #include #include #endif #ifdef HAVE_SHYLU_DDFROSCH_MUELU //#include #include #include #include #endif #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 #include #endif #ifdef HAVE_SHYLU_DDFROSCH_THYRA #include "Stratimikos_LinearSolverBuilder.hpp" #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 #include "Teuchos_AbstractFactoryStd.hpp" #include "Thyra_Ifpack2PreconditionerFactory.hpp" #endif #endif namespace FROSch { using namespace std; using namespace Teuchos; using namespace Xpetra; template class OneLevelPreconditioner; template class TwoLevelPreconditioner; template class TwoLevelBlockPreconditioner; template class SubdomainSolver : public Operator { protected: using XMap = Map; using XMapPtr = RCP; using ConstXMapPtr = RCP; using XMapPtrVecPtr = ArrayRCP; using XMatrix = Matrix; using XMatrixPtr = RCP; using ConstXMatrixPtr = RCP; #ifdef HAVE_SHYLU_DDFROSCH_EPETRA using ECrsMatrix = Epetra_CrsMatrix; using ECrsMatrixPtr = RCP; using ConstECrsMatrixPtr = RCP; #endif using TCrsMatrix = Tpetra::CrsMatrix; using TCrsMatrixPtr = RCP; using ConstTCrsMatrixPtr = RCP; using TRowMatrix = Tpetra::RowMatrix; using TRowMatrixPtr = RCP; using ConstTRowMatrixPtr = RCP; using XMultiVector = MultiVector; using ConstXMultiVector = const MultiVector; using XMultiVectorPtr = RCP; using ConstXMultiVectorPtr = RCP; using ConstXMultiVectorPtrVecPtr = ArrayRCP; using TMultiVector = Tpetra::MultiVector; using TMultiVectorPtr = RCP; #ifdef HAVE_SHYLU_DDFROSCH_EPETRA using EMultiVector = Epetra_MultiVector; using EMultiVectorPtr = RCP; #endif using XMultiVectorFactory = MultiVectorFactory; using ParameterListPtr = RCP; #ifdef HAVE_SHYLU_DDFROSCH_EPETRA using ELinearProblem = Epetra_LinearProblem; using ELinearProblemPtr = RCP; #endif #ifdef HAVE_SHYLU_DDFROSCH_AMESOS using AmesosSolverPtr = RCP; #endif #ifdef HAVE_SHYLU_DDFROSCH_EPETRA using Amesos2SolverEpetraPtr = RCP >; #endif using Amesos2SolverTpetraPtr = RCP >; #ifdef HAVE_SHYLU_DDFROSCH_MUELU using MueLuFactoryPtr = RCP >; using MueLuHierarchyPtr = RCP >; #endif using UN = unsigned; using UNVec = Teuchos::Array; using UNVecPtr = Teuchos::ArrayRCP; using GOVecPtr = ArrayRCP; public: /*! \brief Constructor Create the subdomain solver object. A subdomain solver might require further Trilinos packages at runtime. Availability of required packages is tested and an error is thrown if required packages are not part of the build configuration. @param k Matrix @param parameterList Parameter list @param blockCoarseSize */ SubdomainSolver(ConstXMatrixPtr k, ParameterListPtr parameterList, string description = "undefined", GOVecPtr blockCoarseSize=null); //! Destructor virtual ~SubdomainSolver(); //! Initialize member variables virtual int initialize(); /*! \brief Compute/setup this operator/solver \pre Routine initialize() has been called and #isInitialized_ is set to \c true. @return Integer error code */ virtual int compute(); /*! \brief Apply subdomain solver to input \c x * * y = alpha * A^mode * X + beta * Y * * \param[in] x Input vector * \param[out] y result vector * \param[in] mode */ /*! \brief Computes the operator-multivector application. Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation vary according to the values of \c alpha and \c beta. Specifically - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. */ virtual void apply(const XMultiVector &x, XMultiVector &y, ETransp mode=NO_TRANS, SC alpha=ScalarTraits::one(), SC beta=ScalarTraits::zero()) const; //! Get domain map virtual ConstXMapPtr getDomainMap() const; //! Get range map virtual ConstXMapPtr getRangeMap() const; /*! \brief Print description of this object to given output stream \param out Output stream to be used \param Verbosity level used for printing */ virtual void describe(FancyOStream &out, const EVerbosityLevel verbLevel=Describable::verbLevel_default) const; /*! \brief Get description of this operator \return String describing this operator */ virtual string description() const; //! @name Access to class members //!@{ //! Get #IsInitialized_ bool isInitialized() const; //! Get #IsComputed_ bool isComputed() const; int resetMatrix(ConstXMatrixPtr k, bool reuseInitialize); /*! \brief Computes a residual using the operator */ virtual void residual(const XMultiVector & X, const XMultiVector & B, XMultiVector& R) const; //!@} protected: //! Matrix ConstXMatrixPtr K_; //! Paremter list ParameterListPtr ParameterList_; //! Description of the solver string Description_; mutable XMultiVectorPtr YTmp_; #ifdef HAVE_SHYLU_DDFROSCH_EPETRA ELinearProblemPtr EpetraLinearProblem_; #endif #ifdef HAVE_SHYLU_DDFROSCH_AMESOS AmesosSolverPtr AmesosSolver_; #endif #ifdef HAVE_SHYLU_DDFROSCH_EPETRA Amesos2SolverEpetraPtr Amesos2SolverEpetra_; #endif Amesos2SolverTpetraPtr Amesos2SolverTpetra_; #ifdef HAVE_SHYLU_DDFROSCH_MUELU //! Factory to create a MueLu hierarchy MueLuFactoryPtr MueLuFactory_; //! MueLu hierarchy object MueLuHierarchyPtr MueLuHierarchy_; #endif #ifdef HAVE_SHYLU_DDFROSCH_BELOS RCP,Belos::OperatorT > > > BelosLinearProblem_; RCP,Belos::OperatorT > > > BelosSolverManager_; #endif #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 RCP > Ifpack2Preconditioner_; #endif #ifdef HAVE_SHYLU_DDFROSCH_THYRA mutable RCP > ThyraYTmp_; RCP > LOWS_; #endif RCP > TLBP; RCP > TLP; bool IsInitialized_ = false; //! Flag to indicated whether this subdomain solver has been setup/computed bool IsComputed_ = false; }; } #endif