MueLu Version of the Day
Loading...
Searching...
No Matches
Stratimikos_MueLuHelpers.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef STRATIMIKOS_MUELU_TPETRA_HELPERS_HPP
11#define STRATIMIKOS_MUELU_TPETRA_HELPERS_HPP
12
14#include "Stratimikos_LinearSolverBuilder.hpp"
15
19
20#if defined(HAVE_MUELU_EXPERIMENTAL) && defined(HAVE_MUELU_TEKO)
22#endif
23
24#include "Teuchos_RCP.hpp"
25#include "Teuchos_ParameterList.hpp"
26#include "Teuchos_TestForException.hpp"
27#include "Teuchos_AbstractFactoryStd.hpp"
28
29#include <string>
30
31namespace Stratimikos {
32
33template <typename Scalar = MueLu::DefaultScalar, typename LocalOrdinal = MueLu::DefaultLocalOrdinal, typename GlobalOrdinal = MueLu::DefaultGlobalOrdinal, typename Node = MueLu::DefaultNode>
34void enableMueLu(LinearSolverBuilder<Scalar>& builder, const std::string& stratName = "MueLu") {
35#if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
36 const Teuchos::RCP<const Teuchos::ParameterList> precValidParams = Teuchos::sublist(builder.getValidParameters(), "Preconditioner Types");
37
38 TEUCHOS_TEST_FOR_EXCEPTION(precValidParams->isParameter(stratName), std::logic_error,
39 "Stratimikos::enableMueLu cannot add \"" + stratName + "\" because it is already included in builder!");
40
41 typedef Thyra::PreconditionerFactoryBase<Scalar> Base;
42 typedef Thyra::MueLuPreconditionerFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node> Impl;
43
44 builder.setPreconditioningStrategyFactory(Teuchos::abstractFactoryStd<Base, Impl>(), stratName);
45#endif
46}
47
48template <typename LocalOrdinal, typename GlobalOrdinal, typename Node>
49MUELU_DEPRECATED void enableMueLu(LinearSolverBuilder<double>& builder, const std::string& stratName = "MueLu") {
50 enableMueLu<double, LocalOrdinal, GlobalOrdinal, Node>(builder, stratName);
51}
52
53template <typename Scalar = MueLu::DefaultScalar, typename LocalOrdinal = MueLu::DefaultLocalOrdinal, typename GlobalOrdinal = MueLu::DefaultGlobalOrdinal, typename Node = MueLu::DefaultNode>
54void enableMueLuRefMaxwell(LinearSolverBuilder<Scalar>& builder, const std::string& stratName = "MueLuRefMaxwell") {
55#if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
56 const Teuchos::RCP<const Teuchos::ParameterList> precValidParams = Teuchos::sublist(builder.getValidParameters(), "Preconditioner Types");
57
58 TEUCHOS_TEST_FOR_EXCEPTION(precValidParams->isParameter(stratName), std::logic_error,
59 "Stratimikos::enableMueLuRefMaxwell cannot add \"" + stratName + "\" because it is already included in builder!");
60
61 typedef Thyra::PreconditionerFactoryBase<Scalar> Base;
62 typedef Thyra::MueLuRefMaxwellPreconditionerFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node> Impl;
63
64 builder.setPreconditioningStrategyFactory(Teuchos::abstractFactoryStd<Base, Impl>(), stratName);
65#endif
66}
67
68template <typename LocalOrdinal, typename GlobalOrdinal, typename Node>
69MUELU_DEPRECATED void enableMueLuRefMaxwell(LinearSolverBuilder<double>& builder, const std::string& stratName = "MueLuRefMaxwell") {
70 enableMueLuRefMaxwell<double, LocalOrdinal, GlobalOrdinal, Node>(builder, stratName);
71}
72
73template <typename Scalar = MueLu::DefaultScalar, typename LocalOrdinal = MueLu::DefaultLocalOrdinal, typename GlobalOrdinal = MueLu::DefaultGlobalOrdinal, typename Node = MueLu::DefaultNode>
74void enableMueLuMaxwell1(LinearSolverBuilder<Scalar>& builder, const std::string& stratName = "MueLuMaxwell1") {
75#if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
76 const Teuchos::RCP<const Teuchos::ParameterList> precValidParams = Teuchos::sublist(builder.getValidParameters(), "Preconditioner Types");
77
78 TEUCHOS_TEST_FOR_EXCEPTION(precValidParams->isParameter(stratName), std::logic_error,
79 "Stratimikos::enableMueLuRefMaxwell cannot add \"" + stratName + "\" because it is already included in builder!");
80
81 typedef Thyra::PreconditionerFactoryBase<Scalar> Base;
82 typedef Thyra::MueLuMaxwell1PreconditionerFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node> Impl;
83
84 builder.setPreconditioningStrategyFactory(Teuchos::abstractFactoryStd<Base, Impl>(), stratName);
85#endif
86}
87
88template <typename LocalOrdinal, typename GlobalOrdinal, typename Node>
89MUELU_DEPRECATED void enableMueLuMaxwell1(LinearSolverBuilder<double>& builder, const std::string& stratName = "MueLuMaxwell1") {
90 enableMueLuMaxwell1<double, LocalOrdinal, GlobalOrdinal, Node>(builder, stratName);
91}
92
93#if defined(HAVE_MUELU_EXPERIMENTAL) && defined(HAVE_MUELU_TEKO)
94#if 0
95 // Dynamically register MueLu Tpetra adapters in Stratimikos
96 void enableMueLuTpetraQ2Q1(DefaultLinearSolverBuilder &builder, const std::string &stratName = "MueLu");
97#endif
98
99template <typename Scalar = MueLu::DefaultScalar, typename LocalOrdinal = MueLu::DefaultLocalOrdinal, typename GlobalOrdinal = MueLu::DefaultGlobalOrdinal, typename Node = MueLu::DefaultNode>
100void enableMueLuTpetraQ2Q1(LinearSolverBuilder<Scalar>& builder, const std::string& stratName = "MueLu") {
101 const Teuchos::RCP<const Teuchos::ParameterList> precValidParams = Teuchos::sublist(builder.getValidParameters(), "Preconditioner Types");
102
103 TEUCHOS_TEST_FOR_EXCEPTION(precValidParams->isParameter(stratName), std::logic_error,
104 "Stratimikos::enableMueLuTpetraQ2Q1 cannot add \"" + stratName + "\" because it is already included in builder!");
105
106 typedef Thyra::PreconditionerFactoryBase<Scalar> Base;
108
109 builder.setPreconditioningStrategyFactory(Teuchos::abstractFactoryStd<Base, Impl>(), stratName);
110}
111
112template <typename LocalOrdinal, typename GlobalOrdinal, typename Node>
113MUELU_DEPRECATED void enableMueLuTpetraQ2Q1(LinearSolverBuilder<double>& builder, const std::string& stratName = "MueLu") {
114 enableMueLuTpetraQ2Q1<double, LocalOrdinal, GlobalOrdinal, Node>(builder, stratName);
115}
116#endif
117
118} // namespace Stratimikos
119
120#endif
Concrete preconditioner factory subclass based on MueLu.
void enableMueLuTpetraQ2Q1(LinearSolverBuilder< Scalar > &builder, const std::string &stratName="MueLu")
void enableMueLu(LinearSolverBuilder< Scalar > &builder, const std::string &stratName="MueLu")
void enableMueLuMaxwell1(LinearSolverBuilder< Scalar > &builder, const std::string &stratName="MueLuMaxwell1")
void enableMueLuRefMaxwell(LinearSolverBuilder< Scalar > &builder, const std::string &stratName="MueLuRefMaxwell")