Debian Codegraph @

packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_decl.hpp

raw
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_LINEAR_OP_DECL_HPP
11 #define _THYRA_FROSCH_LINEAR_OP_DECL_HPP
12
13 #include <ShyLU_DDFROSch_config.h>
14
15 #ifdef HAVE_SHYLU_DDFROSCH_THYRA
16
17 //Thyra
18 #ifdef HAVE_SHYLU_DDFROSCH_EPETRA
19 #include "Thyra_EpetraLinearOp.hpp"
20 #include "Thyra_EpetraThyraWrappers.hpp"
21 #include "Thyra_EpetraLinearOpBase.hpp"
22 #endif
23 #include "Thyra_SpmdMultiVectorBase.hpp"
24 #include "Thyra_MultiVectorStdOps.hpp"
25 #include "Thyra_AssertOp.hpp"
26 #include "Thyra_LinearOpBase.hpp"
27 #include "Thyra_LinearOpDefaultBase.hpp"
28 #include "Thyra_ScaledLinearOpBase.hpp"
29 #include "Thyra_RowStatLinearOpBase.hpp"
30 #include "Thyra_SpmdVectorSpaceBase.hpp"
31
32 //Teuchos
33 #include "Teuchos_dyn_cast.hpp"
34 #include "Teuchos_Assert.hpp"
35 #include "Teuchos_getConst.hpp"
36 #include "Teuchos_as.hpp"
37 #include "Teuchos_TimeMonitor.hpp"
38 #include "Teuchos_ScalarTraits.hpp"
39 #include <Teuchos_PtrDecl.hpp>
40 #include "Teuchos_TypeNameTraits.hpp"
41 #include "Teuchos_ConstNonconstObjectContainer.hpp"
42
43 //FROSch
44 #include <FROSch_Tools_def.hpp>
45
46 //Xpetra
47 #include "Xpetra_MapExtractor.hpp"
48 #include <Xpetra_CrsMatrixWrap.hpp>
49 #ifdef HAVE_SHYLU_DDFROSCH_EPETRA
50 #include <Xpetra_EpetraCrsMatrix.hpp>
51 #endif
52 #include <Xpetra_Parameters.hpp>
53 #include "Xpetra_Operator.hpp"
54 #include "Xpetra_ThyraUtils.hpp"
55
56 //Epetra
57 #ifdef HAVE_SHYLU_DDFROSCH_EPETRA
58 #include <Epetra_MpiComm.h>
59 #include "Epetra_Map.h"
60 #include "Epetra_Vector.h"
61 #include "Epetra_Operator.h"
62 #include "Epetra_CrsMatrix.h"
63 #include "Epetra_RowMatrix.h"
64 #endif
65
66
67 namespace Thyra {
68
69 using namespace FROSch;
70 using namespace Teuchos;
71 using namespace Thyra;
72 using namespace Xpetra;
73
74 /** \brief Concrete Thyra::LinearOpBase subclass for Operator.**/
75 template <class SC = double,
76 class LO = int,
77 class GO = DefaultGlobalOrdinal,
78 class NO = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
79 class FROSchLinearOp : virtual public LinearOpDefaultBase<SC> {
80 public:
81
82 /** \name Constructors/initializers. */
83 //@{
84
85 /** \brief Construct to uninitialized. */
86 FROSchLinearOp();
87
88 /** \brief Initialize. */
89 void initialize(const RCP<const VectorSpaceBase<SC> > &rangeSpace,
90 const RCP<const VectorSpaceBase<SC> > &domainSpace,
91 const RCP<Operator<SC,LO,GO,NO> > &xpetraOperator,
92 bool bIsEpetra,
93 bool bIsTpetra);
94
95 /** \brief Initialize. */
96 void constInitialize(const RCP<const VectorSpaceBase<SC> > &rangeSpace,
97 const RCP<const VectorSpaceBase<SC> > &domainSpace,
98 const RCP<const Operator<SC,LO,GO,NO> > &xpetraOperator,
99 bool bIsEpetra,
100 bool bIsTpetra);
101
102 /** \brief Get embedded non-const Operator. */
103 RCP<Operator<SC,LO,GO,NO> > getXpetraOperator();
104
105 /** \brief Get embedded const Operator. */
106 RCP<const Operator<SC,LO,GO,NO> > getConstXpetraOperator() const;
107
108 //@}
109
110 /** \name Public Overridden functions from LinearOpBase. */
111 //@{
112
113 /** \brief . */
114 RCP<const VectorSpaceBase<SC> > range() const;
115
116 /** \brief . */
117 RCP<const VectorSpaceBase<SC> > domain() const;
118
119 //@}
120
121 protected:
122
123 /** \name Protected Overridden functions from LinearOpBase. */
124 //@{
125
126 /** \brief . */
127 bool opSupportedImpl(EOpTransp M_trans) const;
128
129 /** \brief . */
130 void applyImpl(const EOpTransp M_trans,
131 const MultiVectorBase<SC> &X_in,
132 const Ptr<MultiVectorBase<SC> > &Y_inout,
133 const SC alpha,
134 const SC beta
135 ) const;
136
137 //@}
138
139 private:
140
141 RCP<const VectorSpaceBase<SC> >
142 rangeSpace_;
143
144 RCP<const VectorSpaceBase<SC> >
145 domainSpace_;
146
147
148 bool bIsEpetra_;
149 bool bIsTpetra_;
150 ConstNonconstObjectContainer<Operator<SC,LO,GO,NO> >
151 xpetraOperator_;
152
153 template<class XpetraOperator_t>
154 void initializeImpl(const RCP<const VectorSpaceBase<SC> > &rangeSpace,
155 const RCP<const VectorSpaceBase<SC> > &domainSpace,
156 const RCP<XpetraOperator_t> &xpetraOperator,
157 bool bIsEpetra,
158 bool bIsTpetra);
159 };
160
161
162 /** \brief Nonmmeber constructor for XpetraLinearOp.
163 *
164 * \relates XpetraLinearOp
165 */
166 template <class SC, class LO, class GO, class NO>
167 RCP<FROSchLinearOp<SC,LO,GO,NO> > fROSchLinearOp(const RCP<const VectorSpaceBase<SC> > &rangeSpace,
168 const RCP<const VectorSpaceBase<SC> > &domainSpace,
169 const RCP<Operator<SC,LO,GO,NO> > &xpetraOperator,
170 bool bIsEpetra,
171 bool bIsTpetra)
172 {
173 const RCP<FROSchLinearOp<SC,LO,GO,NO> > op =
174 rcp(new FROSchLinearOp<SC,LO,GO,NO>);
175 op->initialize(rangeSpace,domainSpace,xpetraOperator,bIsEpetra,bIsTpetra);
176 return op;
177 }
178
179
180 /** \brief Nonmmeber constructor for XpetraLinearOp.
181 *
182 * \relates XpetraLinearOp
183 */
184 template <class SC, class LO, class GO, class NO>
185 RCP<const FROSchLinearOp<SC,LO,GO,NO> > constFROSchLinearOp(const RCP<const VectorSpaceBase<SC> > &rangeSpace,
186 const RCP<const VectorSpaceBase<SC> > &domainSpace,
187 const RCP<const Operator<SC,LO,GO,NO> > &xpetraOperator,
188 bool bIsEpetra,
189 bool bIsTpetra)
190 {
191 const RCP<FROSchLinearOp<SC,LO,GO,NO> > op =
192 rcp(new FROSchLinearOp<SC,LO,GO,NO>);
193 op->constInitialize(rangeSpace, domainSpace, xpetraOperator,bIsEpetra,bIsTpetra);
194 return op;
195 }
196
197 } // namespace Thyra
198
199 #endif
200
201 #endif // THYRA_XPETRA_LINEAR_OP_DECL_HPP