93 RCP<BlockedCrsMatrix> bA = rcp_dynamic_cast<BlockedCrsMatrix>(A);
96 "MueLu::SchurComplementFactory::Build: input matrix A is not of type BlockedCrsMatrix!");
98 "MueLu::SchurComplementFactory::Build: input matrix A is a " << bA->Rows() <<
"x" << bA->Cols() <<
" block matrix. We expect a 2x2 blocked operator.");
101 RCP<Matrix> Ainv = currentLevel.
Get<RCP<Matrix> >(
"Ainv", this->
GetFactory(
"Ainv").get());
104 GetOStream(
Statistics1) <<
"S has " << S->getGlobalNumRows() <<
"x" << S->getGlobalNumCols() <<
" rows and columns." << std::endl;
108 Set(currentLevel,
"A", S);
112 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
115 using STS = Teuchos::ScalarTraits<SC>;
116 const SC zero = STS::zero(), one = STS::one();
118 RCP<Matrix> A01 = bA->getMatrix(0,1);
119 RCP<Matrix> A10 = bA->getMatrix(1,0);
120 RCP<Matrix> A11 = bA->getMatrix(1,1);
122 RCP<BlockedCrsMatrix> bA01 = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(A01);
123 const bool isBlocked = (bA01 == Teuchos::null ? false :
true);
126 const SC omega = pL.get<
Scalar>(
"omega");
129 "MueLu::SchurComplementFactory::Build: Scaling parameter omega must not be zero to avoid division by zero.");
131 RCP<Matrix> S = Teuchos::null;
132 RCP<Matrix> D = Teuchos::null;
135 if(A01.is_null() ==
false && A10.is_null() ==
false) {
137 Ainv->scale(Teuchos::as<Scalar>(-one/omega));
141 RCP<ParameterList> myparams = rcp(
new ParameterList);
142 myparams->set(
"compute global constants",
true);
145 TEUCHOS_TEST_FOR_EXCEPTION(A01->getRangeMap()->isSameAs(*(Ainv->getDomainMap())) ==
false,
Exceptions::RuntimeError,
146 "MueLu::SchurComplementFactory::Build: RangeMap of A01 and domain map of Ainv are not the same.");
147 RCP<Matrix> C = MatrixMatrix::Multiply(*Ainv,
false, *A01,
false,
GetOStream(
Statistics2),
true,
true, std::string(
"SchurComplementFactory"), myparams);
151 "MueLu::SchurComplementFactory::Build: RangeMap of A10 and domain map A01 are not the same.");
152 D = MatrixMatrix::Multiply(*A10,
false, *C,
false,
GetOStream(
Statistics2),
true,
true, std::string(
"SchurComplementFactory"), myparams);
156 auto bA10 = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(A10);
157 auto bAinv = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(Ainv);
159 "MueLu::SchurComplementFactory::Build: Casting Ainv to BlockedCrsMatrix not possible.");
163 "MueLu::SchurComplementFactory::Build: Block rows and cols of bA01 and bAinv are not compatible.");
164 RCP<BlockedCrsMatrix> C = MatrixMatrix::TwoMatrixMultiplyBlock(*bAinv,
false, *bA01,
false,
GetOStream(
Statistics2));
168 "MueLu::SchurComplementFactory::Build: Block rows and cols of bA10 and bA01 are not compatible.");
171 if (!A11.is_null()) {
176 "MueLu::SchurComplementFactory::Build: RangeMap of A11 and S are not the same.");
178 "MueLu::SchurComplementFactory::Build: DomainMap of A11 and S are not the same.");
181 S = MatrixFactory::BuildCopy(D);
185 if (!A11.is_null()) {
186 S = MatrixFactory::BuildCopy(A11);
188 S = MatrixFactory::Build(A11->getRowMap(), 10 );
189 S->fillComplete(A11->getDomainMap(),A11->getRangeMap());
200 RCP<BlockedCrsMatrix> bS = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(S);
202 if (bS != Teuchos::null && bS->Rows() == 1 && bS->Cols() == 1) {
203 RCP<Matrix> temp = bS->getCrsMatrix();
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput().
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....