46 #ifndef MUELU_SCHURCOMPLEMENTFACTORY_DEF_HPP_
47 #define MUELU_SCHURCOMPLEMENTFACTORY_DEF_HPP_
60 #include "MueLu_Utilities.hpp"
63 #include "MueLu_SchurComplementFactory.hpp"
67 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
74 "(must be a 2x2 blocked operator)");
75 validParamList->
set<
SC> (
"omega", one,
"Scaling parameter in S = A(1,1) - 1/omega A(1,0) diag{A(0,0)}^{-1} A(0,1)");
76 validParamList->
set<
bool> (
"lumping",
false,
"Use lumping to construct diag(A(0,0)), i.e. use row sum of the abs values on the diagonal "
77 "as approximation of A00 (and A00^{-1})");
78 validParamList->
set<
bool> (
"fixing",
false,
"Fix diagonal by replacing small entries with 1.0");
80 return validParamList;
83 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85 Input(currentLevel,
"A");
88 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93 SC zero = STS::zero(), one = STS::one();
95 RCP<Matrix> A = Get<RCP<Matrix> >(currentLevel,
"A");
98 "MueLu::SchurComplementFactory::Build: input matrix A is not of type BlockedCrsMatrix!");
101 "MueLu::SchurComplementFactory::Build: input matrix A is a " << bA->Rows() <<
"x" << bA->Cols() <<
" block matrix. We expect a 2x2 blocked operator.");
109 bool bIsBlocked = (bA01 == Teuchos::null ?
false :
true);
112 SC omega = pL.
get<Scalar>(
"omega");
115 "MueLu::SchurComplementFactory::Build: Scaling parameter omega must not be zero to avoid division by zero.");
120 bool lumping = pL.
get<
bool>(
"lumping");
121 bool fixing = pL.
get<
bool>(
"fixing");
124 diag = VectorFactory::Build(A00->getRangeMap(),
true);
125 A00->getLocalDiagCopy(*diag);
128 TEUCHOS_TEST_FOR_EXCEPTION(bA00.
is_null()==
false,
MueLu::Exceptions::RuntimeError,
"MueLu::SchurComplementFactory::Build: Mass lumping not implemented. Implement a mass lumping kernel!");
134 D->scale(Teuchos::as<Scalar>(-one/omega));
143 "MueLu::SchurComplementFactory::Build: RangeMap of A01 and domain map of A10 are not the same.");
145 S =
Xpetra::MatrixMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Multiply(*A10,
false, *T,
false, GetOStream(
Statistics2),
true,
true,std::string(
"SchurComplementFactory"),myparams);
153 "MueLu::SchurComplementFactory::Build: Block rows and cols of A01 and A10 are not compatible.");
155 "MueLu::SchurComplementFactory::Build: The scaled A01 operator has " << bT->Rows() <<
"x" << bT->Cols() <<
" blocks, "
156 "but should have " << bA01->Rows() <<
"x" << bA01->Cols() <<
" blocks.");
158 "MueLu::SchurComplementFactory::Build: Block rows and cols of A01 and A10 are not compatible.");
165 Xpetra::MatrixMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::TwoMatrixAdd(*A11,
false, one, *S,
false, one, T, GetOStream(
Statistics2));
170 "MueLu::SchurComplementFactory::Build: RangeMap of A11 and S are not the same.");
172 "MueLu::SchurComplementFactory::Build: DomainMap of A11 and S are not the same.");
178 S = MatrixFactory::BuildCopy(A11);
180 S = MatrixFactory::Build(A11->getRowMap(), 10 );
181 S->fillComplete(A11->getDomainMap(),A11->getRangeMap());
194 if (bS != Teuchos::null && bS->Rows() == 1 && bS->Cols() == 1) {
201 Set(currentLevel,
"A", S);
Exception indicating invalid cast attempted.
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)
void swap(RCP< T > &r_ptr)
static Teuchos::ArrayRCP< Scalar > GetLumpedMatrixDiagonal(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
void DeclareInput(Level ¤tLevel) const
Input.
Print even more statistics.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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 ¤tLevel) const
Build an object with this factory.
static RCP< BlockedCrsMatrix > TwoMatrixMultiplyBlock(const BlockedCrsMatrix &A, bool transposeA, const BlockedCrsMatrix &B, bool transposeB, Teuchos::FancyOStream &fos, bool doFillComplete=true, bool doOptimizeStorage=true)
static void TwoMatrixAdd(const Matrix &A, bool transposeA, SC alpha, Matrix &B, SC beta)
static void Multiply(const Matrix &A, bool transposeA, const Matrix &B, bool transposeB, Matrix &C, bool call_FillComplete_on_result=true, bool doOptimizeStorage=true, const std::string &label=std::string(), const RCP< ParameterList > ¶ms=null)
static Teuchos::RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > GetInverse(Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > v, Magnitude tol=Teuchos::ScalarTraits< Scalar >::eps()*100, Scalar tolReplacement=Teuchos::ScalarTraits< Scalar >::zero())
Exception throws to report errors in the internal logical of the program.
static const RCP< const NoFactory > getRCP()
Static Get() functions.