17#ifndef MUELU_PERMUTATIONFACTORY_DEF_HPP_
18#define MUELU_PERMUTATIONFACTORY_DEF_HPP_
25#include <Xpetra_Map.hpp>
26#include <Xpetra_StridedMap.hpp>
27#include <Xpetra_Vector.hpp>
28#include <Xpetra_VectorFactory.hpp>
29#include <Xpetra_Matrix.hpp>
30#include <Xpetra_CrsMatrixWrap.hpp>
31#include <Xpetra_Export.hpp>
32#include <Xpetra_ExportFactory.hpp>
33#include <Xpetra_Import.hpp>
34#include <Xpetra_ImportFactory.hpp>
39#include "MueLu_AlgebraicPermutationStrategy.hpp"
40#include "MueLu_LocalPermutationStrategy.hpp"
45template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
48template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
51template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
53 RCP<ParameterList> validParamList = rcp(
new ParameterList());
55 validParamList->set<RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A to be permuted.");
57 validParamList->set<std::string>(
"PermutationRowMapName",
"",
"Name of input row map for which rows the permutation shall be done. (default='')");
58 validParamList->set<RCP<const FactoryBase> >(
"PermutationRowMapFactory", Teuchos::null,
"Generating factory of the input row map for the permutation.");
60 validParamList->set<std::string>(
"PermutationStrategy",
"Algebraic",
"Permutation strategy (default = 'Algebraic', 'Local'");
62 return validParamList;
65template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 Input(currentLevel,
"A");
70 std::string mapName = pL.get<std::string>(
"PermutationRowMapName");
71 Teuchos::RCP<const FactoryBase> mapFactory =
GetFactory(
"PermutationRowMapFactory");
73 if (mapName.length() > 0) {
74 currentLevel.
DeclareInput(mapName, mapFactory.get(),
this);
78template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85 std::string mapName = pL.get<std::string>(
"PermutationRowMapName");
86 Teuchos::RCP<const FactoryBase> mapFactory =
GetFactory(
"PermutationRowMapFactory");
88 Teuchos::RCP<const Map> permRowMap = Teuchos::null;
89 if (mapName.length() > 0) {
90 permRowMap = currentLevel.
Get<RCP<const Map> >(mapName, mapFactory.get());
92 permRowMap = A->getRowMap();
95 std::string strStrategy = pL.get<std::string>(
"PermutationStrategy");
96 if (strStrategy ==
"Algebraic") {
98 permStrat->BuildPermutation(A, permRowMap, currentLevel,
this);
99 }
else if (strStrategy ==
"Local") {
101 permStrat->BuildPermutation(A, permRowMap, currentLevel,
this);
103 TEUCHOS_TEST_FOR_EXCEPTION(
true,
105 "`PermutationStrategy' has incorrect value (" << strStrategy <<
") in input to PermutationFactory."
106 <<
"Check the documentation for a list of valid choices");
108 GetOStream(
Runtime0) <<
"Using " << strStrategy <<
" permutation strategy." << std::endl;
Algebraic permutation strategy.
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
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Default implementation of FactoryAcceptor::GetFactory().
Class that holds all level-specific information.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput().
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
Local permutation strategy.
virtual const Teuchos::ParameterList & GetParameterList() const
PermutationFactory()
Constructor.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
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.
virtual ~PermutationFactory()
Destructor.
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.
@ Runtime0
One-liner description of what is happening.