46 #ifndef MUELU_SCALEDNULLSPACEFACTORY_DEF_HPP
47 #define MUELU_SCALEDNULLSPACEFACTORY_DEF_HPP
49 #include <Xpetra_Matrix.hpp>
50 #include <Xpetra_MatrixUtils.hpp>
51 #include <Xpetra_MultiVectorFactory.hpp>
52 #include <Xpetra_BlockedMultiVector.hpp>
53 #include <Xpetra_VectorFactory.hpp>
61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 validParamList->
set< std::string >(
"Fine level nullspace",
"Nullspace",
"Variable name which is used to store null space multi vector on the finest level (default=\"Nullspace\").");
66 validParamList->
set<
RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the fine level matrix (only needed if default null space is generated)");
67 validParamList->
set<
RCP<const FactoryBase> >(
"Nullspace", Teuchos::null,
"Generating factory of the fine level null space");
69 return validParamList;
72 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 Input(currentLevel,
"A");
76 Input(currentLevel,
"Nullspace");
79 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
94 tentativeNullspace = currentLevel.
Get<
RCP<MultiVector> >(
"Nullspace", GetFactory(
"Nullspace").get());
98 tentativeNullspace = currentLevel.
Get<
RCP<MultiVector> >(
"Nullspace", GetFactory(
"Nullspace").get());
103 RCP<Matrix> A = Get< RCP<Matrix> >(currentLevel,
"A");
107 if(A->IsView(
"stridedMaps")==
true) {
108 Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps");
110 numPDEs = Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap())->getFixedBlockSize();
111 oldView = A->SwitchToView(oldView);
114 GetOStream(
Runtime1) <<
"ScaledNullspaceFactory: Generating scaled nullspace, blocksize = "<< tentativeNullspace->getNumVectors() <<std::endl;
115 nullspace = MultiVectorFactory::Build(tentativeNullspace->getMap(), tentativeNullspace->getNumVectors());
116 *nullspace = *tentativeNullspace;
117 RCP<MultiVector> blockDiagonal = MultiVectorFactory::Build(A->getDomainMap(), numPDEs);
119 Xpetra::MatrixUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::extractBlockDiagonal(*A,*blockDiagonal);
120 Xpetra::MatrixUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::inverseScaleBlockDiagonal(*blockDiagonal,
true,*nullspace);
123 Set(currentLevel,
"Scaled Nullspace", nullspace);
129 #endif // MUELU_SCALEDNULLSPACEFACTORY_DEF_HPP
Exception indicating invalid cast attempted.
void Build(Level ¤tLevel) const
Build an object with this factory.
MueLu::DefaultLocalOrdinal LocalOrdinal
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
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)
static const NoFactory * get()
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
Define valid parameters for internal factory parameters.
int GetLevelID() const
Return level number.
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
Description of what is happening (more verbose)
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.