46 #ifndef MUELU_RFROMP_OR_TRANSP_DEF_HPP 47 #define MUELU_RFROMP_OR_TRANSP_DEF_HPP 49 #include <Teuchos_ParameterList.hpp> 50 #include <Teuchos_Time.hpp> 52 #include <Xpetra_Matrix.hpp> 59 #include "MueLu_PFactory.hpp" 60 #include "MueLu_PgPFactory.hpp" 61 #include "MueLu_TogglePFactory.hpp" 63 #include "MueLu_PerfUtils.hpp" 64 #include "MueLu_Utilities.hpp" 68 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 RCP<ParameterList> validParamList = rcp(
new ParameterList());
71 validParamList->set< RCP<const FactoryBase> >(
"P", Teuchos::null,
"Generating factory of the matrix P");
72 validParamList->set< RCP<const FactoryBase> >(
"RfromPfactory", Teuchos::null,
"Generating factory of the matrix R");
75 ParameterList norecurse;
76 norecurse.disableRecursiveValidation();
77 validParamList->set<ParameterList> (
"matrixmatrix: kernel params", norecurse,
"MatrixMatrix kernel parameters");
79 return validParamList;
82 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
84 Input(coarseLevel,
"RfromPfactory");
101 if (PFact == Teuchos::null) { PFact = GetFactory(
"P"); }
104 if (myToggleFact != Teuchos::null) {
105 for (
size_t ii = 0; ii < myToggleFact->NumProlongatorFactories(); ii++) {
107 if (actualPFact != Teuchos::null) {
108 RCP<PFactory> subFactory = Teuchos::rcp_const_cast<
PFactory>(rcp_dynamic_cast<
const PFactory>(myToggleFact->getProlongatorFactory(ii)));;
109 bool rmode = subFactory->isRestrictionModeSet();
110 subFactory->setRestrictionMode(
true);
114 subFactory->setRestrictionMode(rmode);
120 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
125 const Teuchos::ParameterList& pL = GetParameterList();
128 RCP<ParameterList> Tparams;
129 if(pL.isSublist(
"matrixmatrix: kernel params"))
130 Tparams=rcp(
new ParameterList(pL.sublist(
"matrixmatrix: kernel params")));
132 Tparams= rcp(
new ParameterList);
135 Tparams->set(
"compute global constants: temporaries",Tparams->get(
"compute global constants: temporaries",
false));
136 Tparams->set(
"compute global constants",Tparams->get(
"compute global constants",
false));
140 if (PFact == Teuchos::null) { PFact = GetFactory(
"P"); }
142 RCP<Matrix> P = coarseLevel.
Get< RCP<Matrix> >(
"P", PFact.get());
144 if (coarseLevel.
IsAvailable(
"RfromPfactory", PFact.get()))
146 std::string strType = coarseLevel.
GetTypeName(
"RfromPfactory", PFact.get());
152 if (strType ==
"int") {
154 if (myToggleFact != Teuchos::null) {
156 RCP<PFactory> actualPFact = Teuchos::rcp_const_cast<
PFactory>(rcp_dynamic_cast<
const PFactory>(myToggleFact->getProlongatorFactory((
size_t) coarseLevel.
Get<
int>(
"RfromPfactory", PFact.get()))));
159 bool rmode = actualPFact->isRestrictionModeSet();
160 actualPFact->setRestrictionMode(
true);
161 R = coarseLevel.
Get<RCP<Matrix> >(
"R",actualPFact.get());
162 actualPFact->setRestrictionMode(rmode);
166 else R = coarseLevel.
Get< RCP<Matrix> >(
"RfromPfactory", PFact.get());
172 RCP<ParameterList> params = rcp(
new ParameterList());
173 params->set(
"printLoadBalancingInfo",
true);
174 params->set(
"printCommInfo",
true);
178 Set(coarseLevel,
"R", R);
181 if (P->IsView(
"stridedMaps"))
182 R->CreateView(
"stridedMaps", P,
true);
189 #endif // MUELU_RFROMP_OR_TRANSP_DEF_HPP T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
void DeclareDependencies(const FactoryBase *factory, bool bRequestOnly=false, bool bReleaseOnly=false)
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput() to declare factory depe...
Timer to be used in factories. Similar to Monitor but with additional timers.
Namespace for MueLu classes and methods.
Print even more statistics.
int GetLevelID() const
Return level number.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
Class that holds all level-specific information.
std::string GetTypeName(const std::string &ename, const FactoryBase *factory=NoFactory::get())
GetTypeName returns type string of variable stored using ename and factory.
Prolongator factory which allows switching between two different prolongator strategies.
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Transpose(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, bool optimizeTranspose=false, const std::string &label=std::string(), const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
An exception safe way to call the method TwoLevelFactoryBase::DisableMultipleCallCheck.
const RCP< const FactoryManagerBase > GetFactoryManager()
returns the current factory manager
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
Factory that provides an interface for a concrete implementation of a prolongation operator...
Factory for building Petrov-Galerkin Smoothed Aggregation prolongators.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()