1#ifndef MUELU_CREATE_EPETRA_PRECONDITIONER_CPP
2#define MUELU_CREATE_EPETRA_PRECONDITIONER_CPP
4#include <Teuchos_XMLParameterListHelpers.hpp>
5#include <Xpetra_CrsMatrix.hpp>
6#include <Xpetra_MultiVector.hpp>
7#include <Xpetra_MultiVectorFactory.hpp>
13#include <MueLu_Hierarchy.hpp>
16#include <MueLu_MLParameterListInterpreter.hpp>
17#include <MueLu_ParameterListInterpreter.hpp>
18#include <MueLu_Utilities.hpp>
19#include <MueLu_HierarchyUtils.hpp>
23#if defined(HAVE_MUELU_EPETRA)
33 Teuchos::RCP<MueLu::EpetraOperator>
36 Teuchos::ParameterList& paramListIn)
41 using NO = Xpetra::EpetraNode;
43 using Teuchos::ParameterList;
45 using MultiVector = Xpetra::MultiVector<SC, LO, GO, NO>;
46 using Matrix = Xpetra::Matrix<SC, LO, GO, NO>;
50 Teuchos::ParameterList& userList = paramListIn.sublist(
"user data");
51 if (userList.isParameter(
"Coordinates")) {
52 RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<SC>::coordinateType,LO,GO,NO> > coordinates = Teuchos::null;
54 coordinates = EpetraMultiVector_To_XpetraMultiVector<typename Teuchos::ScalarTraits<SC>::coordinateType,LO,GO,NO>(userList.get<RCP<Epetra_MultiVector> >(
"Coordinates"));
55 }
catch(Teuchos::Exceptions::InvalidParameterType&) {
56 coordinates = userList.get<RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<SC>::coordinateType, LO, GO, NO> > >(
"Coordinates");
58 if(Teuchos::nonnull(coordinates)){
59 userList.set<RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<SC>::coordinateType,LO,GO,NO> > >(
"Coordinates", coordinates);
62 if (userList.isParameter(
"Nullspace")) {
63 RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<SC>::coordinateType,LO,GO,NO> > nullspace = Teuchos::null;
65 nullspace = EpetraMultiVector_To_XpetraMultiVector<SC,LO,GO,NO>(userList.get<RCP<Epetra_MultiVector> >(
"Nullspace"));
66 }
catch(Teuchos::Exceptions::InvalidParameterType&) {
67 nullspace = userList.get<RCP<Xpetra::MultiVector<SC, LO, GO, NO> > >(
"Nullspace");
69 if(Teuchos::nonnull(nullspace)){
70 userList.set<RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<SC>::coordinateType,LO,GO,NO> > >(
"Nullspace", nullspace);
74 RCP<Matrix> A = EpetraCrs_To_XpetraMatrix<SC, LO, GO, NO>(inA);
75 RCP<Hierarchy> H = MueLu::CreateXpetraPreconditioner<SC,LO,GO,NO>(A, paramListIn);
76 return rcp(
new EpetraOperator(H));
86 Teuchos::RCP<MueLu::EpetraOperator>
88 const std::string& xmlFileName)
90 Teuchos::ParameterList paramList;
91 Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr<Teuchos::ParameterList>(¶mList), *Xpetra::toXpetra(A->Comm()));
102 Teuchos::RCP<MueLu::EpetraOperator>
105 Teuchos::ParameterList paramList;
113 using NO = Xpetra::EpetraNode;
115 using Teuchos::ParameterList;
117 using Matrix = Xpetra::Matrix<SC, LO, GO, NO>;
120 RCP<Hierarchy> H = Op.GetHierarchy();
121 RCP<Matrix> A = EpetraCrs_To_XpetraMatrix<SC,LO,GO,NO>(inA);
123 MueLu::ReuseXpetraPreconditioner<SC,LO,GO,NO>(A, H);
Various adapters that will create a MueLu preconditioner that is an Xpetra::Matrix.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Namespace for MueLu classes and methods.
void ReuseEpetraPreconditioner(const Teuchos::RCP< Epetra_CrsMatrix > &inA, MueLu::EpetraOperator &Op)
Teuchos::RCP< MueLu::EpetraOperator > CreateEpetraPreconditioner(const Teuchos::RCP< Epetra_CrsMatrix > &inA, Teuchos::ParameterList ¶mListIn)
Helper function to create a MueLu preconditioner that can be used by Epetra.Given a EpetraCrs_Matrix,...