46 #ifndef MUELU_BLOCKEDRAPFACTORY_DEF_HPP
47 #define MUELU_BLOCKEDRAPFACTORY_DEF_HPP
58 #include "MueLu_PerfUtils.hpp"
63 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 , repairZeroDiagonals_(false) {}
68 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
74 #undef SET_VALID_ENTRY
75 validParamList->
set<
RCP<const FactoryBase> >(
"A", 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>
85 if (pL.
get<
bool>(
"transpose: use implicit") ==
false)
86 Input(coarseLevel,
"R");
88 Input(fineLevel,
"A");
89 Input(coarseLevel,
"P");
92 for (std::vector<
RCP<const FactoryBase> >::const_iterator it = transferFacts_.begin(); it != transferFacts_.end(); ++it)
93 (*it)->CallDeclareInput(coarseLevel);
96 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 RCP<Matrix> P = Get<RCP<Matrix> >(coarseLevel,
"P");
116 "Block matrix dimensions do not match: "
118 << bA->Rows() <<
"x" << bA->Cols() <<
"P is " << bP->Rows() <<
"x" << bP->Cols());
120 bAP = MatrixMatrix::TwoMatrixMultiplyBlock(*bA,
false, *bP,
false, GetOStream(
Statistics2),
true,
true);
125 bool doOptimizeStorage = !checkAc_;
127 const bool doTranspose =
true;
128 const bool doFillComplete =
true;
129 if (pL.
get<
bool>(
"transpose: use implicit") ==
true) {
131 bAc = MatrixMatrix::TwoMatrixMultiplyBlock(*bP, doTranspose, *bAP, !doTranspose, GetOStream(
Statistics2), doFillComplete, doOptimizeStorage);
134 RCP<Matrix> R = Get<RCP<Matrix> >(coarseLevel,
"R");
139 "Block matrix dimensions do not match: "
141 << bR->Rows() <<
"x" << bR->Cols() <<
"A is " << bA->Rows() <<
"x" << bA->Cols());
144 bAc = MatrixMatrix::TwoMatrixMultiplyBlock(*bR, !doTranspose, *bAP, !doTranspose, GetOStream(
Statistics2), doFillComplete, doOptimizeStorage);
148 CheckMainDiagonal(bAc);
152 Set<RCP<Matrix> >(coarseLevel,
"A", bAc);
154 if (transferFacts_.begin() != transferFacts_.end()) {
158 for (std::vector<
RCP<const FactoryBase> >::const_iterator it = transferFacts_.begin(); it != transferFacts_.end(); ++it) {
161 GetOStream(
Runtime0) <<
"BlockRAPFactory: call transfer factory: " << fac->
description() << std::endl;
167 coarseLevel.Release(*fac);
172 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
175 RCP<Matrix> Aout = MatrixFactory::Build(c00->getRowMap(), c00->getGlobalMaxNumRowEntries());
177 RCP<Vector> diagVec = VectorFactory::Build(c00->getRowMap());
178 c00->getLocalDiagCopy(*diagVec);
182 for (
size_t row = 0; row < c00->getLocalNumRows(); row++) {
184 GO grid = c00->getRowMap()->getGlobalElement(row);
188 c00->getLocalRowView(row, indices, vals);
195 for (
size_t i = 0; i < as<size_t>(indices.
size()); i++) {
196 GO gcid = c00->getColMap()->getGlobalElement(indices[i]);
201 Aout->insertGlobalValues(grid, indout.view(0, indout.size()), valout.view(0, valout.size()));
204 Aout->insertGlobalValues(grid, Teuchos::tuple<GO>(grid), Teuchos::tuple<SC>(1.0));
208 Aout->fillComplete(c00->getDomainMap(), c00->getRangeMap());
210 bAc->setMatrix(0, 0, Aout);
213 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
217 "Transfer factory is not derived from TwoLevelFactoryBase. This is very strange. "
218 "(Note: you can remove this exception if there's a good reason for)");
219 transferFacts_.push_back(factory);
224 #define MUELU_BLOCKEDRAPFACTORY_SHORT
225 #endif // MUELU_BLOCKEDRAPFACTORY_DEF_HPP
Exception indicating invalid cast attempted.
virtual void CallBuild(Level &requestedLevel) const =0
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
One-liner description of what is happening.
RCP< const ParameterList > GetValidParameterList() const override
Return a const parameter list of valid parameters that setParameterList() will accept.
Print even more statistics.
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.
void Build(Level &fineLevel, Level &coarseLevel) const override
Build an object with this factory.
void AddTransferFactory(const RCP< const FactoryBase > &factory)
Add transfer factory in the end of list of transfer factories in RepartitionAcFactory.
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
static void CheckMainDiagonal(RCP< BlockedCrsMatrix > &bAc, bool repairZeroDiagonals=false)
#define SET_VALID_ENTRY(name)
void DeclareInput(Level &fineLevel, Level &coarseLevel) const override
Input.
virtual std::string description() const
Return a simple one-line description of this object.