From: Daniel Arndt Date: Tue, 22 Jan 2019 22:59:38 +0000 (+0100) Subject: Use MueLU::CreateEpetraPreconditioner X-Git-Tag: v9.1.0-rc1~403^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e915771316141f2f03d35f8c6232be72b14cf9fc;p=dealii.git Use MueLU::CreateEpetraPreconditioner --- diff --git a/source/lac/trilinos_precondition_muelu.cc b/source/lac/trilinos_precondition_muelu.cc index 375a465e7e..f36f7cbd67 100644 --- a/source/lac/trilinos_precondition_muelu.cc +++ b/source/lac/trilinos_precondition_muelu.cc @@ -26,6 +26,7 @@ # include # include +# include # include # include # include @@ -205,38 +206,10 @@ namespace TrilinosWrappers PreconditionAMGMueLu::initialize(const Epetra_CrsMatrix &matrix, Teuchos::ParameterList &muelu_parameters) { - // We cannot use MueLu::CreateEpetraOperator directly because, we cannot - // transfer ownership of MueLu::EpetraOperator from Teuchos::RCP to - // std::shared_ptr. - - // For now, just use serial node, i.e. no multithreaing or GPU. - using node = KokkosClassic::DefaultNode::DefaultNodeType; - preconditioner.reset(); - - // Cast matrix into a MueLu::Matrix. The constness needs to be cast away. - // MueLu uses Teuchos::RCP which are Trilinos version of std::shared_ptr. - Teuchos::RCP rcp_matrix = - Teuchos::rcpFromRef(*(const_cast(&matrix))); - Teuchos::RCP> muelu_crs_matrix = - Teuchos::rcp(new Xpetra::EpetraCrsMatrix(rcp_matrix)); - Teuchos::RCP> muelu_matrix = - Teuchos::rcp( - new Xpetra::CrsMatrixWrap(muelu_crs_matrix)); - - // Create the multigrid hierarchy using ML parameters. - Teuchos::RCP> - hierarchy_factory; - hierarchy_factory = Teuchos::rcp( - new MueLu::MLParameterListInterpreter( - muelu_parameters)); - Teuchos::RCP> hierarchy = - hierarchy_factory->CreateHierarchy(); - hierarchy->GetLevel(0)->Set("A", muelu_matrix); - hierarchy_factory->SetupHierarchy(*hierarchy); - - // MueLu::EpetraOperator is just a wrapper around a "standard" - // Epetra_Operator. - preconditioner = std::make_shared(hierarchy); + const auto teuchos_wrapped_matrix = + Teuchos::rcp(const_cast(&matrix), false); + preconditioner = MueLu::CreateEpetraPreconditioner(teuchos_wrapped_matrix, + muelu_parameters); }