53 #ifndef MUELU_PERMUTATIONFACTORY_DEF_HPP_ 54 #define MUELU_PERMUTATIONFACTORY_DEF_HPP_ 61 #include <Xpetra_Map.hpp> 62 #include <Xpetra_StridedMap.hpp> 63 #include <Xpetra_Vector.hpp> 64 #include <Xpetra_VectorFactory.hpp> 65 #include <Xpetra_Matrix.hpp> 66 #include <Xpetra_CrsMatrixWrap.hpp> 67 #include <Xpetra_Export.hpp> 68 #include <Xpetra_ExportFactory.hpp> 69 #include <Xpetra_Import.hpp> 70 #include <Xpetra_ImportFactory.hpp> 73 #include "MueLu_Utilities.hpp" 76 #include "MueLu_AlgebraicPermutationStrategy.hpp" 77 #include "MueLu_LocalPermutationStrategy.hpp" 82 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
89 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
91 RCP<ParameterList> validParamList = rcp(
new ParameterList());
93 validParamList->set< RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A to be permuted.");
95 validParamList->set< std::string > (
"PermutationRowMapName",
"",
"Name of input row map for which rows the permutation shall be done. (default='')");
96 validParamList->set< RCP<const FactoryBase> >(
"PermutationRowMapFactory", Teuchos::null,
"Generating factory of the input row map for the permutation.");
98 validParamList->set< std::string > (
"PermutationStrategy",
"Algebraic",
"Permutation strategy (default = 'Algebraic', 'Local'");
100 return validParamList;
103 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 Input(currentLevel,
"A");
107 const ParameterList & pL = GetParameterList();
108 std::string mapName = pL.get<std::string> (
"PermutationRowMapName");
109 Teuchos::RCP<const FactoryBase> mapFactory = GetFactory (
"PermutationRowMapFactory");
111 if(mapName.length() > 0 ) {
112 currentLevel.
DeclareInput(mapName,mapFactory.get(),
this);
116 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 Teuchos::RCP<Matrix> A = Get< Teuchos::RCP<Matrix> > (currentLevel,
"A");
122 const ParameterList & pL = GetParameterList();
123 std::string mapName = pL.get<std::string> (
"PermutationRowMapName");
124 Teuchos::RCP<const FactoryBase> mapFactory = GetFactory (
"PermutationRowMapFactory");
126 Teuchos::RCP<const Map> permRowMap = Teuchos::null;
127 if(mapName.length() > 0 ) {
128 permRowMap = currentLevel.Get<RCP<const Map> >(mapName,mapFactory.get());
130 permRowMap = A->getRowMap();
133 std::string strStrategy = pL.get<std::string> (
"PermutationStrategy");
134 if( strStrategy ==
"Algebraic" ) {
136 permStrat->BuildPermutation(A,permRowMap,currentLevel,
this);
137 }
else if( strStrategy ==
"Local" ) {
139 permStrat->BuildPermutation(A,permRowMap,currentLevel,
this);
141 TEUCHOS_TEST_FOR_EXCEPTION(
true,
143 "`PermutationStrategy' has incorrect value (" << strStrategy <<
") in input to PermutationFactory." 144 <<
"Check the documentation for a list of valid choices");
146 GetOStream(
Runtime0) <<
"Using " << strStrategy <<
" permutation strategy." << std::endl;
Timer to be used in factories. Similar to Monitor but with additional timers.
One-liner description of what is happening.
Namespace for MueLu classes and methods.
virtual ~PermutationFactory()
Destructor.
Local permutation strategy.
PermutationFactory()
Constructor.
Class that holds all level-specific information.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Algebraic permutation strategy.
void Build(Level ¤tLevel) const
Build an object with this factory.
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()