10 #ifndef MUELU_MAPTRANSFERFACTORY_DEF_HPP_
11 #define MUELU_MAPTRANSFERFACTORY_DEF_HPP_
15 #include <Xpetra_Map.hpp>
16 #include <Xpetra_MapFactory.hpp>
25 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
33 validParamList->
set<std::string>(
"nullspace vectors: limit to",
"all",
"Limit the number of nullspace vectors to be used for the map transfer (especially to exclude rotational vectors).");
35 return validParamList;
38 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
41 const std::string mapFactName = pL.
get<std::string>(
"map: factory");
42 const std::string mapName = pL.
get<std::string>(
"map: name");
49 if (mapFactName ==
"" || mapFactName ==
"NoFactory")
51 else if (mapFactName !=
"null")
61 if (tentPFact == Teuchos::null)
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 Monitor m(*
this,
"MapTransferFactory");
71 const std::string mapName = pL.
get<std::string>(
"map: name");
72 const int maxNumProlongCols = GetLimitOfProlongatorColumns(pL);
79 if (fineLevel.
IsAvailable(mapName, mapFact_.get()) ==
false)
80 GetOStream(
Runtime0) <<
"MapTransferFactory::Build: User provided map \"" << mapName <<
"\" not found in Level class on level " << fineLevel.
GetLevelID() <<
"." << std::endl;
87 if (tentPFact == Teuchos::null)
90 "MueLu::MapTransferFactory::Build(): P (generated by TentativePFactory) not available.");
97 int numColEntries = 0;
98 for (
size_t row = 0; row < Ptent->getLocalNumRows(); ++row) {
99 gRowID = Ptent->getRowMap()->getGlobalElement(row);
101 if (transferMap->isNodeGlobalElement(gRowID)) {
104 Ptent->getLocalRowView(row, indices, vals);
106 numColEntries = as<int>(indices.
size());
107 if (maxNumProlongCols > 0)
108 numColEntries = std::min(numColEntries, maxNumProlongCols);
110 for (
size_t col = 0; col < as<size_t>(numColEntries); ++col) {
112 GO gcid = prolongColMap->getGlobalElement(indices[col]);
113 coarseMapGids.push_back(gcid);
120 std::sort(coarseMapGids.begin(), coarseMapGids.end());
121 coarseMapGids.erase(std::unique(coarseMapGids.begin(), coarseMapGids.end()), coarseMapGids.end());
122 RCP<const Map> coarseTransferMap = MapFactory::Build(prolongColMap->lib(), INVALID, coarseMapGids(),
123 prolongColMap->getIndexBase(), prolongColMap->getComm());
127 const std::string mapFactName = pL.
get<std::string>(
"map: factory");
129 coarseLevel.
Set(mapName, coarseTransferMap, mapFact.
get());
131 coarseLevel.
Set(mapName, coarseTransferMap, mapFact_.
get());
134 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136 const std::string useTheseNspVectors = pL.
get<std::string>(
"nullspace vectors: limit to");
139 if (useTheseNspVectors ==
"all" || useTheseNspVectors ==
"")
143 int maxNumProlongCols = -1;
144 if (useTheseNspVectors ==
"translations")
145 maxNumProlongCols = 1;
149 return maxNumProlongCols;
ParameterList & setEntry(const std::string &name, U &&entry)
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const override
Input.
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
One-liner description of what is happening.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static const NoFactory * get()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
RCP< const ParameterList > GetValidParameterList() const override
Input.
int GetLimitOfProlongatorColumns(const ParameterList &pL) const
Get the max number of entries per row of P to be considered for map transfer.
static const RCP< const NoFactory > getRCP()
Static Get() functions.
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
Timer to be used in non-factories.
void Build(Level &fineLevel, Level &coarseLevel) const override
Build an object with this factory.
const RCP< const FactoryManagerBase > GetFactoryManager()
returns the current factory manager
int GetLevelID() const
Return level number.
Exception throws to report errors in the internal logical of the program.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
Exception throws to report invalid user entry.