10#ifndef MUELU_SCALEDNULLSPACEFACTORY_DEF_HPP
11#define MUELU_SCALEDNULLSPACEFACTORY_DEF_HPP
13#include <Xpetra_Matrix.hpp>
14#include <Xpetra_MatrixUtils.hpp>
15#include <Xpetra_MultiVectorFactory.hpp>
16#include <Xpetra_BlockedMultiVector.hpp>
17#include <Xpetra_VectorFactory.hpp>
25template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
27 RCP<ParameterList> validParamList = rcp(
new ParameterList());
28 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\").");
30 validParamList->set<RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the fine level matrix (only needed if default null space is generated)");
31 validParamList->set<RCP<const FactoryBase> >(
"Nullspace", Teuchos::null,
"Generating factory of the fine level null space");
33 return validParamList;
36template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
39 Input(currentLevel,
"A");
40 Input(currentLevel,
"Nullspace");
43template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
47 RCP<MultiVector> nullspace, tentativeNullspace;
55 tentativeNullspace = currentLevel.
Get<RCP<MultiVector> >(
"Nullspace",
NoFactory::get());
58 tentativeNullspace = currentLevel.
Get<RCP<MultiVector> >(
"Nullspace",
GetFactory(
"Nullspace").get());
62 tentativeNullspace = currentLevel.
Get<RCP<MultiVector> >(
"Nullspace",
GetFactory(
"Nullspace").get());
70 if (A->IsView(
"stridedMaps") ==
true) {
71 Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps");
72 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap()) == Teuchos::null,
Exceptions::BadCast,
"MueLu::ScaledNullspaceFactory::Build: cast to strided row map failed.");
73 numPDEs = Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap())->getFixedBlockSize();
74 oldView = A->SwitchToView(oldView);
77 GetOStream(
Runtime1) <<
"ScaledNullspaceFactory: Generating scaled nullspace, blocksize = " << tentativeNullspace->getNumVectors() << std::endl;
78 nullspace = MultiVectorFactory::Build(tentativeNullspace->getMap(), tentativeNullspace->getNumVectors());
79 *nullspace = *tentativeNullspace;
80 RCP<MultiVector> blockDiagonal = MultiVectorFactory::Build(A->getDomainMap(), numPDEs);
82 Xpetra::MatrixUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::extractBlockDiagonal(*A, *blockDiagonal);
83 Xpetra::MatrixUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::inverseScaleBlockDiagonal(*blockDiagonal,
true, *nullspace);
86 Set(currentLevel,
"Scaled Nullspace", nullspace);
MueLu::DefaultLocalOrdinal LocalOrdinal
Exception indicating invalid cast attempted.
Timer to be used in factories. Similar to Monitor but with additional timers.
void Input(Level &level, const std::string &varName) const
T Get(Level &level, const std::string &varName) const
void Set(Level &level, const std::string &varName, const T &data) const
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Default implementation of FactoryAcceptor::GetFactory().
Class that holds all level-specific information.
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
int GetLevelID() const
Return level number.
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
static const NoFactory * get()
RCP< const ParameterList > GetValidParameterList() const
Define valid parameters for internal factory parameters.
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
void Build(Level ¤tLevel) const
Build an object with this factory.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Namespace for MueLu classes and methods.
@ Runtime1
Description of what is happening (more verbose).