| 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 _THYRA_FROSCH_FACTORY_DECL_HPP |
| 11 |
#define _THYRA_FROSCH_FACTORY_DECL_HPP |
| 12 |
|
| 13 |
#include <ShyLU_DDFROSch_config.h> |
| 14 |
|
| 15 |
//Thyra |
| 16 |
#include "Thyra_DefaultPreconditioner.hpp" |
| 17 |
#include "Thyra_BlockedLinearOpBase.hpp" |
| 18 |
#include "Thyra_TpetraLinearOp.hpp" |
| 19 |
#ifdef HAVE_SHYLU_DDFROSCH_EPETRA |
| 20 |
#include "Thyra_EpetraLinearOp.hpp" |
| 21 |
#endif |
| 22 |
#include "Thyra_TpetraThyraWrappers.hpp" |
| 23 |
#include "Thyra_PreconditionerFactoryBase.hpp" |
| 24 |
|
| 25 |
//Teuchos |
| 26 |
#include "Teuchos_Ptr.hpp" |
| 27 |
#include "Teuchos_TestForException.hpp" |
| 28 |
#include "Teuchos_Assert.hpp" |
| 29 |
#include "Teuchos_Time.hpp" |
| 30 |
#include "Teuchos_ParameterList.hpp" |
| 31 |
#include "Teuchos_RCP.hpp" |
| 32 |
#include "Teuchos_ArrayRCP.hpp" |
| 33 |
#include "Teuchos_Array.hpp" |
| 34 |
#include <Teuchos_XMLParameterListCoreHelpers.hpp> |
| 35 |
|
| 36 |
//Xpetra |
| 37 |
#include <Xpetra_CrsMatrixWrap.hpp> |
| 38 |
#include <Xpetra_CrsMatrix.hpp> |
| 39 |
#include <Xpetra_Matrix.hpp> |
| 40 |
#include <Xpetra_ThyraUtils.hpp> |
| 41 |
#ifdef HAVE_SHYLU_DDFROSCH_EPETRA |
| 42 |
#include <Xpetra_EpetraCrsMatrix.hpp> |
| 43 |
#include <Xpetra_EpetraMap.hpp> |
| 44 |
#endif |
| 45 |
|
| 46 |
//Tpetra |
| 47 |
#if defined(HAVE_XPETRA_TPETRA) && defined(HAVE_TPETRA_INST_DOUBLE) && defined(HAVE_TPETRA_INST_FLOAT) |
| 48 |
#include <Xpetra_TpetraHalfPrecisionOperator.hpp> |
| 49 |
#endif |
| 50 |
|
| 51 |
//Epetra |
| 52 |
#ifdef HAVE_SHYLU_DDFROSCH_EPETRA |
| 53 |
#include <Epetra_Map.h> |
| 54 |
#include <Epetra_MpiComm.h> |
| 55 |
#include <Epetra_config.h> |
| 56 |
#endif |
| 57 |
|
| 58 |
//FROSch |
| 59 |
#include <Thyra_FROSchLinearOp_def.hpp> |
| 60 |
#include <FROSch_Tools_def.hpp> |
| 61 |
|
| 62 |
#include <FROSch_SchwarzPreconditioners_fwd.hpp> |
| 63 |
|
| 64 |
|
| 65 |
namespace Thyra { |
| 66 |
|
| 67 |
using namespace FROSch; |
| 68 |
using namespace std; |
| 69 |
using namespace Teuchos; |
| 70 |
using namespace Xpetra; |
| 71 |
|
| 72 |
template <class SC, |
| 73 |
class LO, |
| 74 |
class GO, |
| 75 |
class NO = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType> |
| 76 |
class FROSchFactory : public Thyra::PreconditionerFactoryBase<SC> { |
| 77 |
|
| 78 |
protected: |
| 79 |
|
| 80 |
using CommPtr = RCP<const Comm<int> >; |
| 81 |
|
| 82 |
using LinearOpBasePtr = RCP<LinearOpBase<SC> >; |
| 83 |
using ConstLinearOpBasePtr = RCP<const LinearOpBase<SC> >; |
| 84 |
using ConstLinearOpSourceBasePtr = RCP<const LinearOpSourceBase<SC> >; |
| 85 |
|
| 86 |
using ConstVectorSpaceBasePtr = RCP<const VectorSpaceBase<SC> >; |
| 87 |
|
| 88 |
using PreconditionerBasePtr = RCP<PreconditionerBase<SC> >; |
| 89 |
|
| 90 |
using XMap = Map<LO,GO,NO>; |
| 91 |
using ConstXMap = const XMap; |
| 92 |
using XMapPtr = RCP<XMap>; |
| 93 |
using ConstXMapPtr = RCP<ConstXMap>; |
| 94 |
using XMapPtrVecPtr = ArrayRCP<XMapPtr>; |
| 95 |
using ConstXMapPtrVecPtr = ArrayRCP<ConstXMapPtr>; |
| 96 |
|
| 97 |
using XMatrix = Matrix<SC,LO,GO,NO>; |
| 98 |
using XMatrixPtr = RCP<XMatrix>; |
| 99 |
using ConstXMatrixPtr = RCP<const XMatrix>; |
| 100 |
|
| 101 |
using XCrsMatrix = CrsMatrix<SC,LO,GO,NO>; |
| 102 |
using XCrsMatrixPtr = RCP<XCrsMatrix>; |
| 103 |
using ConstXCrsMatrixPtr = RCP<const XCrsMatrix>; |
| 104 |
|
| 105 |
using XMultiVector = MultiVector<SC,LO,GO,NO>; |
| 106 |
using ConstXMultiVector = const XMultiVector; |
| 107 |
using XMultiVectorPtr = RCP<XMultiVector>; |
| 108 |
using ConstXMultiVectorPtr = RCP<ConstXMultiVector>; |
| 109 |
using XMultiVectorPtrVecPtr = ArrayRCP<XMultiVectorPtr>; |
| 110 |
using ConstXMultiVectorPtrVecPtr = ArrayRCP<ConstXMultiVectorPtr>; |
| 111 |
|
| 112 |
#if defined(HAVE_XPETRA_TPETRA) && defined(HAVE_TPETRA_INST_DOUBLE) && defined(HAVE_TPETRA_INST_FLOAT) |
| 113 |
using HalfPrecOp = Xpetra::TpetraHalfPrecisionOperator<SC,LO,GO,NO>; |
| 114 |
using HalfSC = typename HalfPrecOp::HalfScalar; |
| 115 |
using HalfPrecMatrix = Matrix<HalfSC,LO,GO,NO>; |
| 116 |
using HalfPrecMultiVector = MultiVector<HalfSC,LO,GO,NO>; |
| 117 |
#endif |
| 118 |
|
| 119 |
using ParameterListPtr = RCP<ParameterList>; |
| 120 |
using ConstParameterListPtr = RCP<const ParameterList>; |
| 121 |
|
| 122 |
using DofOrderingVecPtr = ArrayRCP<DofOrdering>; |
| 123 |
|
| 124 |
using UN = unsigned; |
| 125 |
|
| 126 |
using GOVecPtr = ArrayRCP<GO> ; |
| 127 |
|
| 128 |
using SCVecPtr = ArrayRCP<SC>; |
| 129 |
|
| 130 |
using UNVecPtr = ArrayRCP<UN>; |
| 131 |
|
| 132 |
using LOVecPtr = ArrayRCP<LO>; |
| 133 |
|
| 134 |
public: |
| 135 |
|
| 136 |
//Constructor |
| 137 |
FROSchFactory(); |
| 138 |
|
| 139 |
//Overridden from PreconditionerFactory Base |
| 140 |
bool isCompatible(const LinearOpSourceBase<SC>& fwdOp) const; |
| 141 |
|
| 142 |
PreconditionerBasePtr createPrec() const; |
| 143 |
|
| 144 |
void initializePrec(const ConstLinearOpSourceBasePtr& fwdOpSrc, |
| 145 |
PreconditionerBase<SC>* prec, |
| 146 |
const ESupportSolveUse supportSolveUse) const; |
| 147 |
|
| 148 |
void uninitializePrec(PreconditionerBase<SC>* prec, |
| 149 |
ConstLinearOpSourceBasePtr* fwdOp, |
| 150 |
ESupportSolveUse* supportSolveUse) const; |
| 151 |
|
| 152 |
void setParameterList(const ParameterListPtr& paramList); |
| 153 |
|
| 154 |
ParameterListPtr unsetParameterList(); |
| 155 |
|
| 156 |
ParameterListPtr getNonconstParameterList(); |
| 157 |
|
| 158 |
ConstParameterListPtr getParameterList() const; |
| 159 |
|
| 160 |
ConstParameterListPtr getValidParameters() const; |
| 161 |
|
| 162 |
string description() const; |
| 163 |
|
| 164 |
private: |
| 165 |
|
| 166 |
ConstXMapPtr extractRepeatedMap(CommPtr comm, |
| 167 |
UnderlyingLib lib) const; |
| 168 |
|
| 169 |
ConstXMultiVectorPtr extractCoordinatesList(CommPtr comm, |
| 170 |
UnderlyingLib lib) const; |
| 171 |
|
| 172 |
ConstXMultiVectorPtr extractNullSpace(CommPtr comm, |
| 173 |
UnderlyingLib lib) const; |
| 174 |
|
| 175 |
|
| 176 |
ParameterListPtr paramList_ = rcp(new ParameterList()); |
| 177 |
}; |
| 178 |
|
| 179 |
} |
| 180 |
|
| 181 |
#endif |