46#ifndef MUELU_NULLSPACEPRESMOOTHFACTORY_DEF_HPP
47#define MUELU_NULLSPACEPRESMOOTHFACTORY_DEF_HPP
49#include <Xpetra_Matrix.hpp>
50#include <Xpetra_MultiVector.hpp>
51#include <Xpetra_MultiVectorFactory.hpp>
54#include "MueLu_Utilities.hpp"
60 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
62 RCP<ParameterList> validParamList = rcp(
new ParameterList());
64 validParamList->set< RCP<const FactoryBase> >(
"A" , Teuchos::null,
"Generating factory for A");
65 validParamList->set< RCP<const FactoryBase> >(
"Nullspace", Teuchos::null,
"Generating factory for the nonsmoothed nullspace");
67 return validParamList;
70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 Input(currentLevel,
"Nullspace");
75 Input(currentLevel,
"A");
78 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 FactoryMonitor m(*
this,
"Nullspace presmooth factory", currentLevel);
82 RCP<MultiVector> newB;
84 RCP<Matrix> A = Get< RCP<Matrix> > (currentLevel,
"A");
85 RCP<MultiVector> B = Get< RCP<MultiVector> >(currentLevel,
"Nullspace");
86 newB = MultiVectorFactory::Build(B->getMap(), B->getNumVectors());
93 A->apply(*B, *newB, Teuchos::NO_TRANS);
95 size_t numVec = newB->getNumVectors();
96 LO numElements = newB->getLocalLength();
97 for (
size_t j = 0; j < numVec; j++) {
98 Teuchos::ArrayRCP<const SC> Bj = B->getData(j);
99 Teuchos::ArrayRCP<SC> newBj = newB->getDataNonConst(j);
101 for (LO i = 0; i < numElements; i++)
102 newBj[i] = Bj[i] - damping*newBj[i]/D[i];
105 newB = Get< RCP<MultiVector> >(currentLevel,
"Nullspace");
109 Set(currentLevel,
"Nullspace", newB);
Timer to be used in factories. Similar to Monitor but with additional timers.
Class that holds all level-specific information.
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.
void Build(Level ¤tLevel) const
Build an object with this factory.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
static Teuchos::ArrayRCP< Scalar > GetMatrixDiagonal(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
static Scalar PowerMethod(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, bool scaleByDiag=true, LocalOrdinal niters=10, Magnitude tolerance=1e-2, bool verbose=false, unsigned int seed=123)
Namespace for MueLu classes and methods.