46 #ifndef MUELU_REPARTITIONBLOCKDIAGONALFACTORY_DEF_HPP_ 47 #define MUELU_REPARTITIONBLOCKDIAGONALFACTORY_DEF_HPP_ 51 #include <Teuchos_Utils.hpp> 53 #include <Xpetra_BlockedCrsMatrix.hpp> 60 #include "MueLu_Utilities.hpp" 64 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 RCP<ParameterList> validParamList = rcp(
new ParameterList());
67 validParamList->set< RCP<const FactoryBase> > (
"A", Teuchos::null,
"Factory of the matrix A");
69 return validParamList;
73 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 Input(currentLevel,
"A");
78 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
81 typedef Xpetra::BlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> BlockCrs;
83 RCP<Matrix> originalA = Get< RCP<Matrix> >(currentLevel,
"A");
84 RCP<BlockCrs> A = Teuchos::rcp_dynamic_cast<BlockCrs>(originalA);
87 TEUCHOS_TEST_FOR_EXCEPTION(A==Teuchos::null,
Exceptions::BadCast,
"MueLu::RepartitionBlockDiagonalFactory::Build: input matrix A is not of type BlockedCrsMatrix! error.");
90 RCP<BlockCrs> DiagonalMatrix = Teuchos::rcp(
new BlockCrs(A->getBlockedRangeMap(),A->getBlockedDomainMap(),0,Xpetra::StaticProfile));
91 for(
size_t i=0; i< A->Rows(); i++)
92 DiagonalMatrix->setMatrix(i,i,A->getMatrix(i,i));
94 Set(currentLevel,
"A",Teuchos::rcp_dynamic_cast<Matrix>(DiagonalMatrix));
Exception indicating invalid cast attempted.
Timer to be used in factories. Similar to Monitor but with additional timers.
Namespace for MueLu classes and methods.
Class that holds all level-specific information.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void Build(Level &level) const
Build an object with this factory.
void DeclareInput(Level &level) const
Specifies the data that this class needs, and the factories that generate that data.