46 #ifndef MUELU_BLOCKEDRAPFACTORY_DEF_HPP
47 #define MUELU_BLOCKEDRAPFACTORY_DEF_HPP
60 #include "MueLu_PerfUtils.hpp"
62 #include "MueLu_Utilities.hpp"
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 : checkAc_(false), repairZeroDiagonals_(false)
71 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
77 #undef SET_VALID_ENTRY
78 validParamList->
set<
RCP<const FactoryBase> >(
"A", null,
"Generating factory of the matrix A used during the prolongator smoothing process");
82 return validParamList;
85 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
88 if (pL.
get<
bool>(
"transpose: use implicit") ==
false)
89 Input(coarseLevel,
"R");
91 Input(fineLevel,
"A");
92 Input(coarseLevel,
"P");
95 for (std::vector<
RCP<const FactoryBase> >::const_iterator it = transferFacts_.begin(); it != transferFacts_.end(); ++it)
96 (*it)->CallDeclareInput(coarseLevel);
99 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 RCP<Matrix> A = Get< RCP<Matrix> >(fineLevel,
"A");
106 RCP<Matrix> P = Get< RCP<Matrix> >(coarseLevel,
"P");
121 "Block matrix dimensions do not match: "
122 "A is " << bA->Rows() <<
"x" << bA->Cols() <<
123 "P is " << bP->Rows() <<
"x" << bP->Cols());
125 bAP = MatrixMatrix::TwoMatrixMultiplyBlock(*bA,
false, *bP,
false, GetOStream(
Statistics2),
true,
true);
131 bool doOptimizeStorage = !checkAc_;
133 const bool doTranspose =
true;
134 const bool doFillComplete =
true;
135 if (pL.
get<
bool>(
"transpose: use implicit") ==
true) {
137 bAc = MatrixMatrix::TwoMatrixMultiplyBlock(*bP, doTranspose, *bAP, !doTranspose, GetOStream(
Statistics2), doFillComplete, doOptimizeStorage);
140 RCP<Matrix> R = Get< RCP<Matrix> >(coarseLevel,
"R");
145 "Block matrix dimensions do not match: "
146 "R is " << bR->Rows() <<
"x" << bR->Cols() <<
147 "A is " << bA->Rows() <<
"x" << bA->Cols());
150 bAc = MatrixMatrix::TwoMatrixMultiplyBlock(*bR, !doTranspose, *bAP, !doTranspose, GetOStream(
Statistics2), doFillComplete, doOptimizeStorage);
155 CheckMainDiagonal(bAc);
170 Set<RCP <Matrix> >(coarseLevel,
"A", bAc);
172 if (transferFacts_.begin() != transferFacts_.end()) {
176 for (std::vector<
RCP<const FactoryBase> >::const_iterator it = transferFacts_.begin(); it != transferFacts_.end(); ++it) {
179 GetOStream(
Runtime0) <<
"BlockRAPFactory: call transfer factory: " << fac->
description() << std::endl;
185 coarseLevel.Release(*fac);
191 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
196 RCP<Vector> diagVec = VectorFactory::Build(c00->getRowMap());
197 c00->getLocalDiagCopy(*diagVec);
201 for (
size_t row = 0; row < c00->getNodeNumRows(); row++) {
203 GO grid = c00->getRowMap()->getGlobalElement(row);
207 c00->getLocalRowView(row, indices, vals);
214 for (
size_t i = 0; i < as<size_t>(indices.
size()); i++) {
215 GO gcid = c00->getColMap()->getGlobalElement(indices[i]);
217 valout [i] = vals[i];
220 Aout->insertGlobalValues(grid, indout.view(0, indout.size()), valout.view(0, valout.size()));
223 Aout->insertGlobalValues(grid, Teuchos::tuple<GO>(grid), Teuchos::tuple<SC>(1.0));
227 Aout->fillComplete(c00->getDomainMap(), c00->getRangeMap());
229 bAc->setMatrix(0, 0, Aout);
232 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
236 "Transfer factory is not derived from TwoLevelFactoryBase. This is very strange. "
237 "(Note: you can remove this exception if there's a good reason for)");
238 transferFacts_.push_back(factory);
243 #define MUELU_BLOCKEDRAPFACTORY_SHORT
244 #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)
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
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.
Print even more statistics.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
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 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)
virtual std::string description() const
Return a simple one-line description of this object.