10#ifndef MUELU_RAPFACTORY_DEF_HPP
11#define MUELU_RAPFACTORY_DEF_HPP
15#include <Xpetra_Matrix.hpp>
16#include <Xpetra_MatrixUtils.hpp>
21#include "MueLu_Utilities.hpp"
24#include "MueLu_PerfUtils.hpp"
26#include "Teuchos_TestForException.hpp"
30template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
34template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
37template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
39 RCP<ParameterList> validParamList = rcp(
new ParameterList());
41#define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
49 validParamList->set<RCP<const FactoryBase> >(
"A", null,
"Generating factory of the matrix A used during the prolongator smoothing process");
50 validParamList->set<RCP<const FactoryBase> >(
"P", null,
"Prolongator factory");
51 validParamList->set<RCP<const FactoryBase> >(
"R", null,
"Restrictor factory");
53 validParamList->set<
bool>(
"CheckMainDiagonal",
false,
"Check main diagonal for zeros");
54 validParamList->set<
bool>(
"RepairMainDiagonal",
false,
"Repair zeros on main diagonal");
57 ParameterList norecurse;
58 norecurse.disableRecursiveValidation();
59 validParamList->set<ParameterList>(
"matrixmatrix: kernel params", norecurse,
"MatrixMatrix kernel parameters");
61 return validParamList;
64template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 if (!pL.get<
bool>(
"transpose: use implicit"))
68 Input(coarseLevel,
"R");
70 Input(fineLevel,
"A");
71 Input(coarseLevel,
"P");
75 (*it)->CallDeclareInput(coarseLevel);
80template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88 "MueLu::RAPFactory::Build(): CallDeclareInput has not been called before Build!");
96 Set(coarseLevel,
"A", Ac);
102 const bool useImplicit = pL.get<
bool>(
"transpose: use implicit");
103 bool isGPU = Node::is_gpu;
105 Teuchos::RCP<Teuchos::ParameterList> APparams;
106 Teuchos::RCP<Teuchos::ParameterList> RAPparams;
107 if (coarseLevel.IsAvailable(
"AP reuse data",
this)) {
109 APparams = coarseLevel.Get<RCP<ParameterList> >(
"AP reuse data",
this);
111 APparams = Teuchos::rcp(
new Teuchos::ParameterList());
113 if (coarseLevel.IsAvailable(
"RAP reuse data",
this)) {
115 RAPparams = coarseLevel.Get<RCP<ParameterList> >(
"RAP reuse data",
this);
117 RAPparams = Teuchos::rcp(
new Teuchos::ParameterList());
119 RAPparams->set(
"compute global constants", computeGlobalConstantsForAc);
125 std::ostringstream oss;
126 oss <<
"A_" << coarseLevel.GetLevelID();
127 Ac->setObjectLabel(oss.str());
129 Set(coarseLevel,
"A", Ac);
131 if (!pL.get<
bool>(
"rap: triple product")) {
132 TEUCHOS_TEST_FOR_EXCEPTION(!APparams->isParameter(
"graph"), std::runtime_error,
"\"AP reuse data\" does not contain the expected reuse data.");
133 Set(coarseLevel,
"AP reuse data", APparams);
136 TEUCHOS_TEST_FOR_EXCEPTION(!RAPparams->isParameter(
"graph"), std::runtime_error,
"\"RAP reuse data\" does not contain the expected reuse data.");
137 Set(coarseLevel,
"RAP reuse data", RAPparams);
143 MatrixUtils::checkLocalRowMapMatchesColMap(*Ac);
150 RCP<const FactoryBase> fac = *it;
151 GetOStream(
Runtime0) <<
"RAPFactory: call transfer factory: " << fac->description() << std::endl;
152 fac->CallBuild(coarseLevel);
186template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
189 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::rcp_dynamic_cast<const TwoLevelFactoryBase>(factory) == Teuchos::null,
Exceptions::BadCast,
190 "MueLu::RAPFactory::AddTransferFactory: Transfer factory is not derived from TwoLevelFactoryBase. "
191 "This is very strange. (Note: you can remove this exception if there's a good reason for)");
198#define MUELU_RAPFACTORY_SHORT
#define SET_VALID_ENTRY(name)
static bool debug()
Whether MueLu is in debug mode.
Exception indicating invalid cast attempted.
Exception throws to report errors in the internal logical of the program.
void Input(Level &level, const std::string &varName) const
T Get(Level &level, const std::string &varName) const
void Set(Level &level, const std::string &varName, const T &data) const
Timer to be used in factories. Similar to Monitor but with additional timers.
Class that holds all level-specific information.
void Release(const FactoryBase &factory)
Decrement the storage counter for all the inputs of a factory.
virtual const Teuchos::ParameterList & GetParameterList() const
std::vector< RCP< const FactoryBase > > transferFacts_
list of user-defined transfer Factories
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
void AddTransferFactory(const RCP< const FactoryBase > &factory)
Add transfer factory in the end of list of transfer factories in RepartitionAcFactory.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
Timer to be used in factories. Similar to SubMonitor but adds a timer level by level.
static void TripleMatrixProduct(const Teuchos::RCP< Xpetra::Matrix< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > > &R, const Teuchos::RCP< Xpetra::Matrix< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > > &A, const Teuchos::RCP< Xpetra::Matrix< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > > &P, Teuchos::RCP< Xpetra::Matrix< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > > &Ac, const Teuchos::ParameterList &pL, const MueLu::BaseClass &verbObj, Teuchos::RCP< Teuchos::ParameterList > &APparams, Teuchos::RCP< Teuchos::ParameterList > &RAPparams, Level *coarseLevel=nullptr)
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
Namespace for MueLu classes and methods.
@ Statistics1
Print more statistics.
@ Runtime0
One-liner description of what is happening.