46 #ifndef MUELU_SAPFACTORY_DEF_HPP 47 #define MUELU_SAPFACTORY_DEF_HPP 49 #include <Xpetra_Matrix.hpp> 50 #include <Xpetra_IteratorOps.hpp> 59 #include "MueLu_PerfUtils.hpp" 61 #include "MueLu_TentativePFactory.hpp" 62 #include "MueLu_Utilities.hpp" 66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name)) 74 #undef SET_VALID_ENTRY 76 validParamList->
set<
RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A used during the prolongator smoothing process");
79 return validParamList;
82 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
84 Input(fineLevel,
"A");
89 if (initialPFact == Teuchos::null) { initialPFact = coarseLevel.
GetFactoryManager()->GetFactory(
"Ptent"); }
93 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
95 return BuildP(fineLevel, coarseLevel);
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
104 const std::string prefix =
"MueLu::SaPFactory(" + levelIDs +
"): ";
112 if (initialPFact == Teuchos::null) { initialPFact = coarseLevel.
GetFactoryManager()->GetFactory(
"Ptent"); }
115 RCP<Matrix> A = Get< RCP<Matrix> >(fineLevel,
"A");
118 if (restrictionMode_) {
128 if (coarseLevel.
IsAvailable(
"AP reuse data",
this)) {
129 GetOStream(static_cast<MsgType>(
Runtime0 |
Test)) <<
"Reusing previous AP data" << std::endl;
138 SC dampingFactor = as<SC>(pL.
get<
double>(
"sa: damping factor"));
139 LO maxEigenIterations = as<LO>(pL.
get<
int> (
"sa: eigenvalue estimate num iterations"));
140 bool estimateMaxEigen = pL.
get<
bool> (
"sa: calculate eigenvalue estimate");
146 lambdaMax = A->GetMaxEigenvalueEstimate();
148 GetOStream(
Statistics1) <<
"Calculating max eigenvalue estimate now (max iters = "<< maxEigenIterations <<
")" << std::endl;
149 Magnitude stopTol = 1e-4;
151 A->SetMaxEigenvalueEstimate(lambdaMax);
153 GetOStream(
Statistics1) <<
"Using cached max eigenvalue estimate" << std::endl;
155 GetOStream(
Statistics1) <<
"Prolongator damping factor = " << dampingFactor/lambdaMax <<
" (" << dampingFactor <<
" / " << lambdaMax <<
")" << std::endl;
162 SC omega = dampingFactor / lambdaMax;
165 finalP = Xpetra::IteratorOps<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Jacobi(omega, *invDiag, *A, *Ptent, finalP,
166 GetOStream(
Statistics2), std::string(
"MueLu::SaP-")+levelIDs, APparams);
174 if (!restrictionMode_) {
176 Set(coarseLevel,
"P", finalP);
178 APparams->
set(
"graph", finalP);
179 Set(coarseLevel,
"AP reuse data", APparams);
182 if (Ptent->IsView(
"stridedMaps"))
183 finalP->CreateView(
"stridedMaps", Ptent);
187 params->
set(
"printLoadBalancingInfo",
true);
188 params->
set(
"printCommInfo",
true);
200 Set(coarseLevel,
"R", R);
203 if (Ptent->IsView(
"stridedMaps"))
204 R->CreateView(
"stridedMaps", Ptent,
true);
208 params->
set(
"printLoadBalancingInfo",
true);
209 params->
set(
"printCommInfo",
true);
218 #endif // MUELU_SAPFACTORY_DEF_HPP static RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > GetMatrixDiagonalInverse(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, Magnitude tol=Teuchos::ScalarTraits< Scalar >::eps() *100)
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 Build(Level &fineLevel, Level &coarseLevel) const
Build method.
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())
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Timer to be used in factories. Similar to Monitor but with additional timers.
One-liner description of what is happening.
Namespace for MueLu classes and methods.
void BuildP(Level &fineLevel, Level &coarseLevel) const
Abstract Build method.
Print skeleton for the run, i.e. factory calls and used parameters.
Print even more statistics.
int GetLevelID() const
Return level number.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
Timer to be used in factories. Similar to SubMonitor but adds a timer level by level.
#define SET_VALID_ENTRY(name)
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
bool isParameter(const std::string &name) const
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(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
static Scalar PowerMethod(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, bool scaleByDiag=true, LocalOrdinal niters=10, Magnitude tolerance=1e-2, bool verbose=false, unsigned int seed=123)