8 #ifndef PACKAGES_MUELU_ADAPTERS_XPETRA_MUELU_CREATEXPETRAPRECONDITIONER_HPP_ 9 #define PACKAGES_MUELU_ADAPTERS_XPETRA_MUELU_CREATEXPETRAPRECONDITIONER_HPP_ 19 #include <MueLu_Hierarchy.hpp> 21 #include <MueLu_MLParameterListInterpreter.hpp> 22 #include <MueLu_ParameterListInterpreter.hpp> 23 #include <MueLu_Utilities.hpp> 24 #include <MueLu_HierarchyUtils.hpp> 28 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
41 std::string timerName =
"MueLu setup time";
47 bool hasParamList = paramList.
numParams();
51 std::string syntaxStr =
"parameterlist: syntax";
52 if (hasParamList && paramList.
isParameter(syntaxStr) && paramList.
get<std::string>(syntaxStr) ==
"ml") {
53 paramList.
remove(syntaxStr);
60 H->
setlib(op->getDomainMap()->lib());
67 if (coords != Teuchos::null) {
68 H->
GetLevel(0)->Set(
"Coordinates", coords);
72 if (nullspace == Teuchos::null) {
73 int nPDE = MueLu::MasterList::getDefault<int>(
"number of equations");
78 nPDE = operatorList.
get<
int>(
"PDE equations");
80 }
else if (paramList.
isParameter(
"number of equations")) {
82 nPDE = paramList.
get<
int>(
"number of equations");
85 nullspace = MultiVectorFactory::Build(op->getDomainMap(), nPDE);
90 for (
int i = 0; i < nPDE; i++) {
92 for (
int j = 0; j < nsData.
size(); j++) {
93 GlobalOrdinal GID = op->getDomainMap()->getGlobalElement(j) - op->getDomainMap()->getIndexBase();
95 if ((GID-i) % nPDE == 0)
101 H->
GetLevel(0)->Set(
"Nullspace", nullspace);
114 const bool alwaysWriteLocal =
true;
115 const bool writeGlobalStats =
true;
116 const bool writeZeroTimers =
false;
117 const bool ignoreZeroTimers =
true;
118 const std::string filter = timerName;
120 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
135 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
138 std::string timerName =
"MueLu setup time";
143 typedef LocalOrdinal
LO;
144 typedef GlobalOrdinal
GO;
151 "MueLu::ReuseXpetraPreconditioner: Hierarchy has no levels in it");
153 "MueLu::ReuseXpetraPreconditioner: Hierarchy has no fine level operator");
157 RCP<Matrix> A0 = Teuchos::rcp_dynamic_cast<Matrix>(O0);
163 A->SetFixedBlockSize(A0->GetFixedBlockSize());
173 const bool alwaysWriteLocal =
true;
174 const bool writeGlobalStats =
true;
175 const bool writeZeroTimers =
false;
176 const bool ignoreZeroTimers =
true;
177 const std::string filter = timerName;
179 writeZeroTimers, Teuchos::Union, filter, ignoreZeroTimers);
void ReuseXpetraPreconditioner(const Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &A, Teuchos::RCP< MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &H)
Helper function to reuse an existing MueLu preconditioner.
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
bool isSublist(const std::string &name) const
Teuchos::RCP< MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node > > CreateXpetraPreconditioner(Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > op, const Teuchos::ParameterList &inParamList, Teuchos::RCP< Xpetra::MultiVector< double, LocalOrdinal, GlobalOrdinal, Node > > coords=Teuchos::null, Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > nullspace=Teuchos::null)
Ordinal numParams() const
Namespace for MueLu classes and methods.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
static RCP< Time > getNewTimer(const std::string &name)
Print statistics that do not involve significant additional computation.
bool remove(std::string const &name, bool throwIfNotExists=true)
void start(bool reset=false)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
Class that accepts ML-style parameters and builds a MueLu preconditioner. This interpreter uses the s...
virtual RCP< Hierarchy > CreateHierarchy() const
Create an empty Hierarchy object.
bool isParameter(const std::string &name) const
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
VerbLevel GetVerbLevel() const
Get the verbosity level.
Exception throws to report errors in the internal logical of the program.
void setlib(Xpetra::UnderlyingLib inlib)
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)