MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_MueLuRefMaxwellPreconditionerFactory_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef THYRA_MUELU_REFMAXWELL_PRECONDITIONER_FACTORY_DEF_HPP
47 #define THYRA_MUELU_REFMAXWELL_PRECONDITIONER_FACTORY_DEF_HPP
48 
50 
51 #if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
52 
53 namespace Thyra {
54 
55  using Teuchos::RCP;
56  using Teuchos::rcp;
58 
59 
60  // Constructors/initializers/accessors
61 
62  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
63  MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::MueLuRefMaxwellPreconditionerFactory() :
64  paramList_(rcp(new ParameterList()))
65  {}
66 
67  // Overridden from PreconditionerFactoryBase
68 
69  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
70  bool MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::isCompatible(const LinearOpSourceBase<Scalar>& fwdOpSrc) const {
71  const RCP<const LinearOpBase<Scalar> > fwdOp = fwdOpSrc.getOp();
72 
73 #ifdef HAVE_MUELU_TPETRA
74  if (Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::isTpetra(fwdOp)) return true;
75 #endif
76 
77  if (Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::isBlockedOperator(fwdOp)) return true;
78 
79  return false;
80  }
81 
82 
83  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
84  RCP<PreconditionerBase<Scalar> > MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::createPrec() const {
85  return Teuchos::rcp(new DefaultPreconditioner<Scalar>);
86  }
87 
88  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
89  void MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::
90  initializePrec(const RCP<const LinearOpSourceBase<Scalar> >& fwdOpSrc, PreconditionerBase<Scalar>* prec, const ESupportSolveUse supportSolveUse) const {
91  using Teuchos::rcp_dynamic_cast;
92 
93  // we are using typedefs here, since we are using objects from different packages (Xpetra, Thyra,...)
94  typedef Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> XpMap;
95  typedef Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node> XpOp;
96  typedef Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node> XpThyUtils;
97  typedef Xpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> XpCrsMat;
98  typedef Xpetra::BlockedCrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> XpBlockedCrsMat;
99  typedef Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> XpMat;
100  typedef Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> XpMultVec;
101  typedef Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LocalOrdinal,GlobalOrdinal,Node> XpMultVecDouble;
102  typedef Thyra::LinearOpBase<Scalar> ThyLinOpBase;
103  typedef Thyra::DiagonalLinearOpBase<Scalar> ThyDiagLinOpBase;
104  Teuchos::TimeMonitor tM(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec")));
105 
106  // Check precondition
107  TEUCHOS_ASSERT(Teuchos::nonnull(fwdOpSrc));
108  TEUCHOS_ASSERT(this->isCompatible(*fwdOpSrc));
109  TEUCHOS_ASSERT(prec);
110 
111  // Create a copy, as we may remove some things from the list
112  ParameterList paramList = *paramList_;
113 
114  // Retrieve wrapped concrete Xpetra matrix from FwdOp
115  const RCP<const ThyLinOpBase> fwdOp = fwdOpSrc->getOp();
117 
118  // Check whether it is Epetra/Tpetra
119  bool bIsEpetra = XpThyUtils::isEpetra(fwdOp);
120  bool bIsTpetra = XpThyUtils::isTpetra(fwdOp);
121  bool bIsBlocked = XpThyUtils::isBlockedOperator(fwdOp);
122  TEUCHOS_TEST_FOR_EXCEPT((bIsEpetra == true && bIsTpetra == true));
123  TEUCHOS_TEST_FOR_EXCEPT((bIsEpetra == bIsTpetra) && bIsBlocked == false);
124  TEUCHOS_TEST_FOR_EXCEPT((bIsEpetra != bIsTpetra) && bIsBlocked == true);
125 
126  RCP<XpMat> A = Teuchos::null;
127  if(bIsBlocked) {
129  Teuchos::rcp_dynamic_cast<const Thyra::BlockedLinearOpBase<Scalar> >(fwdOp);
131 
132  TEUCHOS_TEST_FOR_EXCEPT(ThyBlockedOp->blockExists(0,0)==false);
133 
134  Teuchos::RCP<const LinearOpBase<Scalar> > b00 = ThyBlockedOp->getBlock(0,0);
136 
137  RCP<const XpCrsMat > xpetraFwdCrsMat00 = XpThyUtils::toXpetra(b00);
138  TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(xpetraFwdCrsMat00));
139 
140  // MueLu needs a non-const object as input
141  RCP<XpCrsMat> xpetraFwdCrsMatNonConst00 = Teuchos::rcp_const_cast<XpCrsMat>(xpetraFwdCrsMat00);
142  TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(xpetraFwdCrsMatNonConst00));
143 
144  // wrap the forward operator as an Xpetra::Matrix that MueLu can work with
145  RCP<XpMat> A00 = rcp(new Xpetra::CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node>(xpetraFwdCrsMatNonConst00));
147 
148  RCP<const XpMap> rowmap00 = A00->getRowMap();
149  RCP< const Teuchos::Comm< int > > comm = rowmap00->getComm();
150 
151  // create a Xpetra::BlockedCrsMatrix which derives from Xpetra::Matrix that MueLu can work with
152  RCP<XpBlockedCrsMat> bMat = Teuchos::rcp(new XpBlockedCrsMat(ThyBlockedOp, comm));
154 
155  // save blocked matrix
156  A = bMat;
157  } else {
158  RCP<const XpCrsMat > xpetraFwdCrsMat = XpThyUtils::toXpetra(fwdOp);
159  TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(xpetraFwdCrsMat));
160 
161  // MueLu needs a non-const object as input
162  RCP<XpCrsMat> xpetraFwdCrsMatNonConst = Teuchos::rcp_const_cast<XpCrsMat>(xpetraFwdCrsMat);
163  TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(xpetraFwdCrsMatNonConst));
164 
165  // wrap the forward operator as an Xpetra::Matrix that MueLu can work with
166  A = rcp(new Xpetra::CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node>(xpetraFwdCrsMatNonConst));
167  }
169 
170  // Retrieve concrete preconditioner object
171  const Teuchos::Ptr<DefaultPreconditioner<Scalar> > defaultPrec = Teuchos::ptr(dynamic_cast<DefaultPreconditioner<Scalar> *>(prec));
173 
174  // extract preconditioner operator
175  RCP<ThyLinOpBase> thyra_precOp = Teuchos::null;
176  thyra_precOp = rcp_dynamic_cast<Thyra::LinearOpBase<Scalar> >(defaultPrec->getNonconstUnspecifiedPrecOp(), true);
177 
178  // Variable for RefMaxwell preconditioner: either build a new one or reuse the existing preconditioner
179  RCP<MueLu::RefMaxwell<Scalar,LocalOrdinal,GlobalOrdinal,Node> > preconditioner = Teuchos::null;
180 
181  // make a decision whether to (re)build the multigrid preconditioner or reuse the old one
182  // rebuild preconditioner if startingOver == true
183  // reuse preconditioner if startingOver == false
184  const bool startingOver = (thyra_precOp.is_null() || !paramList.isParameter("reuse: type") || paramList.get<std::string>("reuse: type") == "none");
185 
186  if (startingOver == true) {
187  // extract coordinates from parameter list
188  Teuchos::RCP<XpMultVecDouble> coordinates = Teuchos::null;
189  {
190  Teuchos::TimeMonitor tM_coords(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec get coords")));
192  paramList.set<RCP<XpMultVecDouble> >("Coordinates", coordinates);
193  }
194 
195  // TODO check for Xpetra or Thyra vectors?
196 #ifdef HAVE_MUELU_TPETRA
197  if (bIsTpetra) {
198  typedef Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> tV;
199  typedef Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> tMV;
200  typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> TpCrsMat;
201  Teuchos::TimeMonitor tMwrap(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap objects")));
202  if (paramList.isType<Teuchos::RCP<tMV> >("Nullspace")) {
203  Teuchos::TimeMonitor tM_nullspace(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap nullspace")));
204  RCP<tMV> tpetra_nullspace = paramList.get<RCP<tMV> >("Nullspace");
205  paramList.remove("Nullspace");
206  RCP<XpMultVec> nullspace = MueLu::TpetraMultiVector_To_XpetraMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(tpetra_nullspace);
207  paramList.set<RCP<XpMultVec> >("Nullspace", nullspace);
209  }
210 
211  if (paramList.isParameter("M1")) {
212  if (paramList.isType<Teuchos::RCP<TpCrsMat> >("M1")) {
213  Teuchos::TimeMonitor tM_M1(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap M1")));
214  RCP<TpCrsMat> tM1 = paramList.get<RCP<TpCrsMat> >("M1");
215  paramList.remove("M1");
216  RCP<XpCrsMat> xM1 = rcp_dynamic_cast<XpCrsMat>(tM1, true);
217  paramList.set<RCP<XpCrsMat> >("M1", xM1);
218  } else if (paramList.isType<Teuchos::RCP<const ThyLinOpBase> >("M1")) {
219  Teuchos::TimeMonitor tM_M1(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap M1")));
220  RCP<const ThyLinOpBase> thyM1 = paramList.get<RCP<const ThyLinOpBase> >("M1");
221  paramList.remove("M1");
222  RCP<const XpCrsMat> crsM1 = XpThyUtils::toXpetra(thyM1);
224  // MueLu needs a non-const object as input
225  RCP<XpCrsMat> crsM1NonConst = Teuchos::rcp_const_cast<XpCrsMat>(crsM1);
227  // wrap as an Xpetra::Matrix that MueLu can work with
228  RCP<XpMat> M1 = rcp(new Xpetra::CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node>(crsM1NonConst));
229  paramList.set<RCP<XpMat> >("M1", M1);
230  } else if (paramList.isType<Teuchos::RCP<XpMat> >("M1")) {
231  // do nothing
232  } else
233  TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Parameter M1 has wrong type.");
234  } else
235  TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Need to specify matrix M1.");
236 
237  if (paramList.isParameter("Ms")) {
238  if (paramList.isType<Teuchos::RCP<TpCrsMat> >("Ms")) {
239  Teuchos::TimeMonitor tM_Ms(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap Ms")));
240  RCP<TpCrsMat> tMs = paramList.get<RCP<TpCrsMat> >("Ms");
241  paramList.remove("Ms");
242  RCP<XpCrsMat> xMs = rcp_dynamic_cast<XpCrsMat>(tMs, true);
243  paramList.set<RCP<XpCrsMat> >("Ms", xMs);
244  } else if (paramList.isType<Teuchos::RCP<const ThyLinOpBase> >("Ms")) {
245  Teuchos::TimeMonitor tM_Ms(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap Ms")));
246  RCP<const ThyLinOpBase> thyMs = paramList.get<RCP<const ThyLinOpBase> >("Ms");
247  paramList.remove("Ms");
248  RCP<const XpCrsMat> crsMs = XpThyUtils::toXpetra(thyMs);
250  // MueLu needs a non-const object as input
251  RCP<XpCrsMat> crsMsNonConst = Teuchos::rcp_const_cast<XpCrsMat>(crsMs);
253  // wrap as an Xpetra::Matrix that MueLu can work with
254  RCP<XpMat> Ms = rcp(new Xpetra::CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node>(crsMsNonConst));
255  paramList.set<RCP<XpMat> >("Ms", Ms);
256  } else if (paramList.isType<Teuchos::RCP<XpMat> >("Ms")) {
257  // do nothing
258  } else
259  TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Parameter Ms has wrong type.");
260  }
261 
262  if (paramList.isParameter("D0")) {
263  if (paramList.isType<Teuchos::RCP<TpCrsMat> >("D0")) {
264  Teuchos::TimeMonitor tM_D0(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap D0")));
265  RCP<TpCrsMat> tD0 = paramList.get<RCP<TpCrsMat> >("D0");
266  paramList.remove("D0");
267  RCP<XpCrsMat> xD0 = rcp_dynamic_cast<XpCrsMat>(tD0, true);
268  paramList.set<RCP<XpCrsMat> >("D0", xD0);
269  } else if (paramList.isType<Teuchos::RCP<const ThyLinOpBase> >("D0")) {
270  Teuchos::TimeMonitor tM_D0(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap D0")));
271  RCP<const ThyLinOpBase> thyD0 = paramList.get<RCP<const ThyLinOpBase> >("D0");
272  paramList.remove("D0");
273  RCP<const XpCrsMat> crsD0 = XpThyUtils::toXpetra(thyD0);
275  // MueLu needs a non-const object as input
276  RCP<XpCrsMat> crsD0NonConst = Teuchos::rcp_const_cast<XpCrsMat>(crsD0);
278  // wrap as an Xpetra::Matrix that MueLu can work with
279  RCP<XpMat> D0 = rcp(new Xpetra::CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node>(crsD0NonConst));
280  paramList.set<RCP<XpMat> >("D0", D0);
281  } else if (paramList.isType<Teuchos::RCP<XpMat> >("D0")) {
282  // do nothing
283  } else
284  TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Parameter D0 has wrong type.");
285  } else
286  TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Need to specify matrix D0.");
287 
288  if (paramList.isParameter("M0inv")) {
289  if (paramList.isType<Teuchos::RCP<TpCrsMat> >("M0inv")) {
290  Teuchos::TimeMonitor tM_M0inv(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap M0inv")));
291  RCP<TpCrsMat> tM0inv = paramList.get<RCP<TpCrsMat> >("M0inv");
292  paramList.remove("M0inv");
293  RCP<XpCrsMat> xM0inv = rcp_dynamic_cast<XpCrsMat>(tM0inv, true);
294  paramList.set<RCP<XpCrsMat> >("M0inv", xM0inv);
295  } else if (paramList.isType<Teuchos::RCP<const ThyDiagLinOpBase> >("M0inv")) {
296  Teuchos::TimeMonitor tM_M0inv(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap M0inv")));
297  RCP<const ThyDiagLinOpBase> thyM0inv = paramList.get<RCP<const ThyDiagLinOpBase> >("M0inv");
298  paramList.remove("M0inv");
299  RCP<const Thyra::VectorBase<Scalar> > diag = thyM0inv->getDiag();
300  RCP<const tV> tDiag = Thyra::TpetraOperatorVectorExtraction<Scalar,LocalOrdinal,GlobalOrdinal,Node>::getConstTpetraVector(diag);
301  RCP<XpMat> M0inv = Xpetra::MatrixFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Build(Xpetra::toXpetra(tDiag));
302  paramList.set<RCP<XpMat> >("M0inv", M0inv);
303  } else if (paramList.isType<Teuchos::RCP<const ThyLinOpBase> >("M0inv")) {
304  Teuchos::TimeMonitor tM_M0inv(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec wrap M0inv")));
305  RCP<const ThyLinOpBase> thyM0inv = paramList.get<RCP<const ThyLinOpBase> >("M0inv");
306  paramList.remove("M0inv");
307  RCP<const XpCrsMat> crsM0inv = XpThyUtils::toXpetra(thyM0inv);
309  // MueLu needs a non-const object as input
310  RCP<XpCrsMat> crsM0invNonConst = Teuchos::rcp_const_cast<XpCrsMat>(crsM0inv);
311  TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(crsM0invNonConst));
312  // wrap as an Xpetra::Matrix that MueLu can work with
313  RCP<XpMat> M0inv = rcp(new Xpetra::CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node>(crsM0invNonConst));
314  paramList.set<RCP<XpMat> >("M0inv", M0inv);
315  } else if (paramList.isType<Teuchos::RCP<XpMat> >("M0inv")) {
316  // do nothing
317  } else
318  TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Parameter M0inv has wrong type.");
319  } else
320  TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "Need to specify matrix M0inv.");
321 
322  }
323 #endif
324 
325  {
326  // build a new MueLu RefMaxwell preconditioner
327  Teuchos::TimeMonitor tMbuild(*Teuchos::TimeMonitor::getNewTimer(std::string("ThyraMueLuRefMaxwell::initializePrec build prec")));
328  paramList.set<bool>("refmaxwell: use as preconditioner", true);
329  preconditioner = rcp(new MueLu::RefMaxwell<Scalar,LocalOrdinal,GlobalOrdinal,Node>(A, paramList, true));
330  }
331 
332  } else {
333  // reuse old MueLu preconditioner stored in MueLu Xpetra operator and put in new matrix
334  preconditioner->resetMatrix(A);
335  }
336 
337  // wrap preconditioner in thyraPrecOp
338  RCP<ThyLinOpBase > thyraPrecOp = Teuchos::null;
339  RCP<const VectorSpaceBase<Scalar> > thyraRangeSpace = Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::toThyra(preconditioner->getRangeMap());
340  RCP<const VectorSpaceBase<Scalar> > thyraDomainSpace = Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::toThyra(preconditioner->getDomainMap());
341 
342  RCP<XpOp> xpOp = Teuchos::rcp_dynamic_cast<XpOp>(preconditioner);
343  thyraPrecOp = Thyra::xpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>(thyraRangeSpace, thyraDomainSpace,xpOp);
344 
346 
347  defaultPrec->initializeUnspecified(thyraPrecOp);
348 
349  }
350 
351  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
352  void MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::
353  uninitializePrec(PreconditionerBase<Scalar>* prec, RCP<const LinearOpSourceBase<Scalar> >* fwdOp, ESupportSolveUse* supportSolveUse) const {
354  TEUCHOS_ASSERT(prec);
355 
356  // Retrieve concrete preconditioner object
357  const Teuchos::Ptr<DefaultPreconditioner<Scalar> > defaultPrec = Teuchos::ptr(dynamic_cast<DefaultPreconditioner<Scalar> *>(prec));
359 
360  if (fwdOp) {
361  // TODO: Implement properly instead of returning default value
362  *fwdOp = Teuchos::null;
363  }
364 
365  if (supportSolveUse) {
366  // TODO: Implement properly instead of returning default value
367  *supportSolveUse = Thyra::SUPPORT_SOLVE_UNSPECIFIED;
368  }
369 
370  defaultPrec->uninitialize();
371  }
372 
373 
374  // Overridden from ParameterListAcceptor
375  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
376  void MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::setParameterList(RCP<ParameterList> const& paramList) {
378  paramList_ = paramList;
379  }
380 
381  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
382  RCP<ParameterList> MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::getNonconstParameterList() {
383  return paramList_;
384  }
385 
386  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
387  RCP<ParameterList> MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::unsetParameterList() {
388  RCP<ParameterList> savedParamList = paramList_;
389  paramList_ = Teuchos::null;
390  return savedParamList;
391  }
392 
393  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
394  RCP<const ParameterList> MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::getParameterList() const {
395  return paramList_;
396  }
397 
398  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
399  RCP<const ParameterList> MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::getValidParameters() const {
400  static RCP<const ParameterList> validPL;
401 
402  if (Teuchos::is_null(validPL))
403  validPL = rcp(new ParameterList());
404 
405  return validPL;
406  }
407 
408  // Public functions overridden from Teuchos::Describable
409  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
410  std::string MueLuRefMaxwellPreconditionerFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::description() const {
411  return "Thyra::MueLuRefMaxwellPreconditionerFactory";
412  }
413 } // namespace Thyra
414 
415 #endif // HAVE_MUELU_STRATIMIKOS
416 
417 #endif // ifdef THYRA_MUELU_REFMAXWELL_PRECONDITIONER_FACTORY_DEF_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
static RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LocalOrdinal, GlobalOrdinal, Node > > ExtractCoordinatesFromParameterList(ParameterList &paramList)
bool nonnull(const std::shared_ptr< T > &p)
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
MueLu::DefaultNode Node
Preconditioner (wrapped as a Xpetra::Operator) for Maxwell&#39;s equations in curl-curl form...
static RCP< Time > getNewTimer(const std::string &name)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Exception throws to report errors in the internal logical of the program.
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)