47 #ifndef MUELU_MAPTRANSFERFACTORY_DEF_HPP_
48 #define MUELU_MAPTRANSFERFACTORY_DEF_HPP_
52 #include <Xpetra_Map.hpp>
53 #include <Xpetra_MapFactory.hpp>
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 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).");
72 return validParamList;
75 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
78 const std::string mapFactName = pL.
get<std::string>(
"map: factory");
79 const std::string mapName = pL.
get<std::string>(
"map: name");
86 if (mapFactName ==
"" || mapFactName ==
"NoFactory")
88 else if (mapFactName !=
"null")
98 if (tentPFact == Teuchos::null)
103 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 Monitor m(*
this,
"MapTransferFactory");
108 const std::string mapName = pL.
get<std::string>(
"map: name");
109 const int maxNumProlongCols = GetLimitOfProlongatorColumns(pL);
116 if (fineLevel.
IsAvailable(mapName, mapFact_.get()) ==
false)
117 GetOStream(
Runtime0) <<
"MapTransferFactory::Build: User provided map \"" << mapName <<
"\" not found in Level class on level " << fineLevel.
GetLevelID() <<
"." << std::endl;
124 if (tentPFact == Teuchos::null)
127 "MueLu::MapTransferFactory::Build(): P (generated by TentativePFactory) not available.");
134 int numColEntries = 0;
135 for (
size_t row = 0; row < Ptent->getLocalNumRows(); ++row) {
136 gRowID = Ptent->getRowMap()->getGlobalElement(row);
138 if (transferMap->isNodeGlobalElement(gRowID)) {
141 Ptent->getLocalRowView(row, indices, vals);
143 numColEntries = as<int>(indices.
size());
144 if (maxNumProlongCols > 0)
145 numColEntries = std::min(numColEntries, maxNumProlongCols);
147 for (
size_t col = 0; col < as<size_t>(numColEntries); ++col) {
149 GO gcid = prolongColMap->getGlobalElement(indices[col]);
150 coarseMapGids.push_back(gcid);
157 std::sort(coarseMapGids.begin(), coarseMapGids.end());
158 coarseMapGids.erase(std::unique(coarseMapGids.begin(), coarseMapGids.end()), coarseMapGids.end());
159 RCP<const Map> coarseTransferMap = MapFactory::Build(prolongColMap->lib(), INVALID, coarseMapGids(),
160 prolongColMap->getIndexBase(), prolongColMap->getComm());
164 const std::string mapFactName = pL.
get<std::string>(
"map: factory");
166 coarseLevel.
Set(mapName, coarseTransferMap, mapFact.
get());
168 coarseLevel.
Set(mapName, coarseTransferMap, mapFact_.
get());
171 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
173 const std::string useTheseNspVectors = pL.
get<std::string>(
"nullspace vectors: limit to");
176 if (useTheseNspVectors ==
"all" || useTheseNspVectors ==
"")
180 int maxNumProlongCols = -1;
181 if (useTheseNspVectors ==
"translations")
182 maxNumProlongCols = 1;
186 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)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
One-liner description of what is happening.
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.
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.
static const RCP< const NoFactory > getRCP()
Static Get() functions.