30 RCP<ParameterList> validParamList = rcp(
new ParameterList());
34 validParamList->set<std::string>(
"Reorder Type",
"",
"String describing the reordering of blocks");
37 validParamList->set<RCP<const FactoryBase> >(
"Map1", Teuchos::null,
"Generating factory of the fine level map associated with the (1,1) block in your n x n block matrix.");
38 validParamList->set<RCP<const FactoryBase> >(
"Map2", Teuchos::null,
"Generating factory of the fine level map associated with the (2,2) block in your n x n block matrix.");
39 validParamList->set<RCP<const FactoryBase> >(
"Map3", Teuchos::null,
"Generating factory of the fine level map associated with the (3,3) block in your n x n block matrix.");
40 validParamList->set<RCP<const FactoryBase> >(
"Map4", Teuchos::null,
"Generating factory of the fine level map associated with the (4,4) block in your n x n block matrix.");
41 validParamList->set<RCP<const FactoryBase> >(
"Map5", Teuchos::null,
"Generating factory of the fine level map associated with the (5,5) block in your n x n block matrix.");
42 validParamList->set<RCP<const FactoryBase> >(
"Map6", Teuchos::null,
"Generating factory of the fine level map associated with the (6,6) block in your n x n block matrix.");
43 validParamList->set<RCP<const FactoryBase> >(
"Map7", Teuchos::null,
"Generating factory of the fine level map associated with the (7,7) block in your n x n block matrix.");
44 validParamList->set<RCP<const FactoryBase> >(
"Map8", Teuchos::null,
"Generating factory of the fine level map associated with the (8,8) block in your n x n block matrix.");
45 validParamList->set<RCP<const FactoryBase> >(
"Map9", Teuchos::null,
"Generating factory of the fine level map associated with the (9,9) block in your n x n block matrix.");
47 return validParamList;
59 const ParameterList& pL = GetParameterList();
60 std::string reorderStr = pL.get<std::string>(
"Reorder Type");
62 RCP<Matrix> Ain = Get<RCP<Matrix> >(currentLevel,
"A");
64 RCP<BlockedCrsMatrix> A = rcp_dynamic_cast<BlockedCrsMatrix>(Ain);
68 if (A == Teuchos::null && currentLevel.
GetLevelID() == 0) {
69 GetOStream(
Warnings0) <<
"Split input matrix (Warning: this is a rather expensive operation)" << std::endl;
71 std::vector<Teuchos::RCP<const Map> > xmaps;
73 for (
int it = 1; it < 10; it++) {
77 RCP<const Map> submap = currentLevel.
Get<RCP<const Map> >(ss.str(),
NoFactory::get());
78 GetOStream(
Runtime1) <<
"Use user-given submap #" << it <<
": length dimension=" << submap->getGlobalNumElements() << std::endl;
79 xmaps.push_back(submap);
83 bool bThyraMode =
false;
84 RCP<const MapExtractor> map_extractor = Xpetra::MapExtractorFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(Ain->getRowMap(), xmaps, bThyraMode);
91 Teuchos::RCP<Xpetra::BlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > bOp =
92 Xpetra::MatrixUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::SplitMatrix(*Ain, map_extractor, map_extractor, Teuchos::null, bThyraMode);
94 TEUCHOS_TEST_FOR_EXCEPTION(Ain->getGlobalNumRows() != bOp->getGlobalNumRows(),
Exceptions::RuntimeError,
"Split operator not consistent with input operator (different number of rows).");
95 TEUCHOS_TEST_FOR_EXCEPTION(Ain->getLocalNumRows() != bOp->getLocalNumRows(),
Exceptions::RuntimeError,
"Split operator not consistent with input operator (different number of node rows).");
96 TEUCHOS_TEST_FOR_EXCEPTION(Ain->getLocalNumEntries() != bOp->getLocalNumEntries(),
Exceptions::RuntimeError,
"Split operator not consistent with input operator (different number of local entries).");
97 TEUCHOS_TEST_FOR_EXCEPTION(Ain->getGlobalNumEntries() != bOp->getGlobalNumEntries(),
Exceptions::RuntimeError,
"Split operator not consistent with input operator (different number of global entries).");
103 TEUCHOS_TEST_FOR_EXCEPTION(A.is_null(),
Exceptions::BadCast,
"Input matrix A is not a BlockedCrsMatrix.");
104 GetOStream(
Statistics1) <<
"Got a " << A->Rows() <<
"x" << A->Cols() <<
" blocked operator as input" << std::endl;
107 if (reorderStr.empty()) {
108 GetOStream(
Statistics1) <<
"No reordering information provided. Skipping reordering of A." << std::endl;
110 Teuchos::RCP<const Xpetra::BlockReorderManager> brm = Xpetra::blockedReorderFromString(reorderStr);
111 GetOStream(
Debug) <<
"Reordering A using " << brm->toString() << std::endl;
113 Teuchos::RCP<const ReorderedBlockedCrsMatrix> brop =
114 Teuchos::rcp_dynamic_cast<const ReorderedBlockedCrsMatrix>(
115 Xpetra::buildReorderedBlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(brm, A));
118 "Block reordering of " << A->Rows() <<
"x" << A->Cols()
119 <<
" blocked operator failed.");
121 GetOStream(
Statistics1) <<
"Reordering A using " << brm->toString() <<
" block gives a " << brop->Rows() <<
"x"
122 << brop->Cols() <<
" blocked operator" << std::endl;
123 GetOStream(
Debug) <<
"Reordered operator has " << brop->getRangeMap()->getGlobalNumElements() <<
" rows and "
124 << brop->getDomainMap()->getGlobalNumElements() <<
" columns" << std::endl;
125 GetOStream(
Debug) <<
"Reordered operator: Use of Thyra style gids = "
126 << brop->getRangeMapExtractor()->getThyraMode() << std::endl;
129 Teuchos::RCP<ReorderedBlockedCrsMatrix> bret =
130 Teuchos::rcp_const_cast<ReorderedBlockedCrsMatrix>(brop);
135 currentLevel.
Set(
"A", Teuchos::rcp_dynamic_cast<Matrix>(A),
this);