10#ifndef MUELU_NULLSPACEPRESMOOTHFACTORY_DEF_HPP
11#define MUELU_NULLSPACEPRESMOOTHFACTORY_DEF_HPP
13#include <Xpetra_Matrix.hpp>
14#include <Xpetra_MultiVector.hpp>
15#include <Xpetra_MultiVectorFactory.hpp>
18#include "MueLu_Utilities.hpp"
24template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
26 RCP<ParameterList> validParamList = rcp(
new ParameterList());
28 validParamList->set<RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory for A");
29 validParamList->set<RCP<const FactoryBase> >(
"Nullspace", Teuchos::null,
"Generating factory for the nonsmoothed nullspace");
31 return validParamList;
34template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
36 Input(currentLevel,
"Nullspace");
39 Input(currentLevel,
"A");
42template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
44 FactoryMonitor m(*
this,
"Nullspace presmooth factory", currentLevel);
46 RCP<MultiVector> newB;
50 newB = MultiVectorFactory::Build(B->getMap(), B->getNumVectors());
57 A->apply(*B, *newB, Teuchos::NO_TRANS);
59 size_t numVec = newB->getNumVectors();
60 LO numElements = newB->getLocalLength();
61 for (
size_t j = 0; j < numVec; j++) {
62 Teuchos::ArrayRCP<const SC> Bj = B->getData(j);
63 Teuchos::ArrayRCP<SC> newBj = newB->getDataNonConst(j);
65 for (LO i = 0; i < numElements; i++)
66 newBj[i] = Bj[i] - damping * newBj[i] / D[i];
73 Set(currentLevel,
"Nullspace", newB);
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
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_arcp(const Matrix &A)
static Scalar PowerMethod(const Matrix &A, bool scaleByDiag=true, DefaultLocalOrdinal niters=10, Magnitude tolerance=1e-2, bool verbose=false, unsigned int seed=123)
Namespace for MueLu classes and methods.