1 #ifndef MUELU_CREATE_TPETRA_PRECONDITIONER_HPP
2 #define MUELU_CREATE_TPETRA_PRECONDITIONER_HPP
8 #include <Tpetra_Operator.hpp>
9 #include <Tpetra_RowMatrix.hpp>
11 #include <Tpetra_Experimental_BlockCrsMatrix.hpp>
19 #include <MueLu_Hierarchy.hpp>
21 #include <MueLu_MLParameterListInterpreter.hpp>
22 #include <MueLu_ParameterListInterpreter.hpp>
23 #include <MueLu_TpetraOperator.hpp>
25 #include <MueLu_Utilities.hpp>
26 #include <MueLu_HierarchyUtils.hpp>
29 #if defined(HAVE_MUELU_AMGX)
32 #include "cuda_runtime.h"
45 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
51 typedef LocalOrdinal
LO;
52 typedef GlobalOrdinal
GO;
60 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> crs_matrix_type;
61 typedef Tpetra::Experimental::BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> block_crs_matrix_type;
63 #if defined(HAVE_MUELU_AMGX)
64 std::string externalMG =
"use external multigrid package";
65 if (inParamList.
isParameter(externalMG) && inParamList.
get<std::string>(externalMG) ==
"amgx"){
76 if (crsA != Teuchos::null)
77 A = TpetraCrs_To_XpetraMatrix<SC,LO,GO,NO>(crsA);
78 else if (bcrsA != Teuchos::null) {
108 RCP<Hierarchy> H = MueLu::CreateXpetraPreconditioner<SC,LO,GO,NO>(A, inParamList);
122 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
125 const std::string& xmlFileName)
129 return CreateTpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(inA, paramList);
141 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
146 return CreateTpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(inA, paramList);
157 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
161 typedef LocalOrdinal
LO;
162 typedef GlobalOrdinal
GO;
169 RCP<Matrix> A = TpetraCrs_To_XpetraMatrix<SC,LO,GO,NO>(inA);
171 MueLu::ReuseXpetraPreconditioner<SC,LO,GO,NO>(A, H);
175 #ifdef HAVE_MUELU_DEPRECATED_CODE
186 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
192 const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& inNullspace)
195 typedef LocalOrdinal
LO;
196 typedef GlobalOrdinal
GO;
207 userList.
set<RCP<Tpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::coordinateType,LO,GO,NO> > >(
"Coordinates", inCoords);
210 userList.
set<RCP<Tpetra::MultiVector<SC,LO,GO,NO> > >(
"Nullspace", inNullspace);
213 return CreateTpetraPreconditioner<SC,LO,GO,NO>(inA, inParamList);
226 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
234 typedef LocalOrdinal LO;
235 typedef GlobalOrdinal GO;
246 userList.
set<RCP<Tpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::coordinateType,LO,GO,NO> > >(
"Coordinates", inCoords);
249 return CreateTpetraPreconditioner<SC,LO,GO,NO>(inA, inParamList);
264 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
268 const std::string& xmlFileName,
270 const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& inNullspace)
277 return CreateTpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(inA, paramList, inCoords, inNullspace);
291 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
295 const std::string& xmlFileName,
303 return CreateTpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(inA, paramList, inCoords, Teuchos::null);
317 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
322 const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& inNullspace)
328 userList.
set<RCP<Tpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::coordinateType, LocalOrdinal, GlobalOrdinal, Node> > >(
"Coordinates", inCoords);
331 userList.
set<RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > >(
"Nullspace", inNullspace);
335 return CreateTpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(inA, paramList, inCoords, inNullspace);
351 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
357 const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& inNullspace = Teuchos::null)
359 RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node>> opMat(inA);
360 return CreateTpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(opMat, inParamList, inCoords, inNullspace);
376 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
380 const std::string& xmlFileName,
382 const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& inNullspace = Teuchos::null)
387 RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node>> opMat(inA);
388 return CreateTpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(opMat, paramList, inCoords, inNullspace);
403 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
408 const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& inNullspace = Teuchos::null)
411 RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node>> opMat(inA);
412 return CreateTpetraPreconditioner<Scalar, LocalOrdinal, GlobalOrdinal, Node>(opMat, paramList, inCoords, inNullspace);
415 #endif // HAVE_MUELU_DEPRECATED_CODE
419 #endif //ifndef MUELU_CREATE_TPETRA_PRECONDITIONER_HPP
Various adapters that will create a MueLu preconditioner that is an Xpetra::Matrix.
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
bool nonnull(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
bool isParameter(const std::string &name) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node > > GetHierarchy() const
Direct access to the underlying MueLu::Hierarchy.
Wraps an existing MueLu::Hierarchy as a Tpetra::Operator.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Exception throws to report errors in the internal logical of the program.
void ReuseTpetraPreconditioner(const Teuchos::RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &inA, MueLu::TpetraOperator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
Helper function to reuse an existing MueLu preconditioner.
Teuchos::RCP< MueLu::TpetraOperator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > CreateTpetraPreconditioner(const Teuchos::RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &inA, Teuchos::ParameterList &inParamList)
Helper function to create a MueLu or AMGX preconditioner that can be used by Tpetra.Given a Tpetra::Operator, this function returns a constructed MueLu preconditioner.
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Adapter for AmgX library from Nvidia.