46 #ifndef MUELU_NULLSPACEFACTORY_DEF_HPP 47 #define MUELU_NULLSPACEFACTORY_DEF_HPP 49 #include <Xpetra_Matrix.hpp> 50 #include <Xpetra_VectorFactory.hpp> 51 #include <Xpetra_MultiVectorFactory.hpp> 59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 RCP<ParameterList> validParamList = rcp(
new ParameterList());
65 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\"");
67 validParamList->set< RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the fine level matrix (only needed if default null space is generated)");
68 validParamList->set< RCP<const FactoryBase> >(
"Nullspace", Teuchos::null,
"Generating factory of the fine level null space");
71 validParamList->set< RCP<const FactoryBase> >(
"Nullspace1", Teuchos::null,
"Generating factory of the fine level null space");
72 validParamList->set< RCP<const FactoryBase> >(
"Nullspace2", Teuchos::null,
"Generating factory of the fine level null space");
74 return validParamList;
77 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 const ParameterList & pL = GetParameterList();
81 std::string nspName = pL.get<std::string>(
"Fine level nullspace");
87 Input(currentLevel,
"A");
98 currentLevel.
DeclareInput(
"Nullspace", GetFactory(nspName).
get(),
this);
102 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 RCP<MultiVector> nullspace;
109 const ParameterList & pL = GetParameterList();
110 std::string nspName = pL.get<std::string>(
"Fine level nullspace");
119 GetOStream(
Runtime1) <<
"Use user-given nullspace " << nspName <<
": nullspace dimension=" << nullspace->getNumVectors() <<
" nullspace length=" << nullspace->getGlobalLength() << std::endl;
123 RCP<Matrix> A = Get< RCP<Matrix> >(currentLevel,
"A");
126 LocalOrdinal numPDEs = 1;
127 if(A->IsView(
"stridedMaps")==
true) {
128 Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps");
129 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap()) == Teuchos::null,
Exceptions::BadCast,
"MueLu::CoalesceFactory::Build: cast to strided row map failed.");
130 numPDEs = Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap())->getFixedBlockSize();
131 oldView = A->SwitchToView(oldView);
134 GetOStream(
Runtime1) <<
"Generating canonical nullspace: dimension = " << numPDEs << std::endl;
135 nullspace = MultiVectorFactory::Build(A->getDomainMap(), numPDEs);
137 for (
int i=0; i<numPDEs; ++i) {
138 ArrayRCP<Scalar> nsValues = nullspace->getDataNonConst(i);
139 int numBlocks = nsValues.size() / numPDEs;
140 for (
int j=0; j< numBlocks; ++j) {
141 nsValues[j*numPDEs + i] = 1.0;
149 nullspace = currentLevel.
Get< RCP<MultiVector> >(
"Nullspace", GetFactory(nspName).get());
154 Set(currentLevel,
"Nullspace", nullspace);
160 #endif // MUELU_NULLSPACEFACTORY_DEF_HPP Exception indicating invalid cast attempted.
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.
RCP< const ParameterList > GetValidParameterList() const
Define valid parameters for internal factory parameters.
Timer to be used in factories. Similar to Monitor but with additional timers.
Namespace for MueLu classes and methods.
static const NoFactory * get()
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
Class that holds all level-specific information.
int GetLevelID() const
Return level number.
Description of what is happening (more verbose)
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
void Build(Level ¤tLevel) const
Build an object with this factory.