47 #ifndef MUELU_SEGREGATEDAFACTORY_DEF_HPP
48 #define MUELU_SEGREGATEDAFACTORY_DEF_HPP
55 #include "MueLu_FactoryManager.hpp"
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
67 #undef SET_VALID_ENTRY
69 validParamList->
set<
RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A used for filtering");
71 validParamList->
set< std::string > (
"map: name",
"",
"Name of map (Xpetra::Map) provided by user containing the special DOFs.");
72 validParamList->
set< std::string > (
"map: factory",
"null",
"Name of generating factory for 'map: name'");
74 return validParamList;
77 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 Input(currentLevel,
"A");
82 std::string mapName = pL.
get<std::string> (
"map: name");
83 std::string mapFact = pL.
get<std::string> (
"map: factory");
84 if(mapFact ==
"NoFactory") {
86 }
else if (mapFact !=
"null") {
94 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
96 FactoryMonitor m(*
this,
"Matrix filtering (segregation)", currentLevel);
99 RCP<Matrix> Ain = Get< RCP<Matrix> >(currentLevel,
"A");
102 std::string mapName = pL.get<std::string> (
"map: name");
103 std::string mapFact = pL.get<std::string> (
"map: factory");
106 if(mapFact ==
"NoFactory") {
108 }
else if (mapFact !=
"null") {
109 mapFactory = currentLevel.GetFactoryManager()->GetFactory(mapFact);
117 size_t numLocalRows = Ain->getNodeNumRows();
118 for(
size_t row=0; row<numLocalRows; row++) {
119 GlobalOrdinal grid = Ain->getRowMap()->getGlobalElement(row);
120 bool isInMap = map->isNodeGlobalElement(grid);
125 Ain->getLocalRowView(row, indices, vals);
131 size_t nNonzeros = 0;
132 for(
size_t i=0; i<(size_t)indices.
size(); i++) {
133 GlobalOrdinal gcid = Ain->getColMap()->getGlobalElement(indices[i]);
134 bool isInMap2 = map->isNodeGlobalElement(gcid);
136 if (isInMap == isInMap2) {
137 indout [nNonzeros] = gcid;
138 valout [nNonzeros] = vals[i];
143 valout.resize(nNonzeros);
145 Aout->insertGlobalValues(Ain->getRowMap()->getGlobalElement(row), indout.view(0,indout.size()), valout.view(0,valout.size()));
148 Aout->fillComplete(Ain->getDomainMap(), Ain->getRangeMap());
151 Aout->SetFixedBlockSize(Ain->GetFixedBlockSize());
153 GetOStream(
Statistics0, 0) <<
"Nonzeros in A (input): " << Ain->getGlobalNumEntries() <<
", Nonzeros after filtering A: " << Aout->getGlobalNumEntries() << std::endl;
155 Set(currentLevel,
"A", Aout);
160 #endif // MUELU_SEGREGATEDAFACTORY_DEF_HPP
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
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)
Timer to be used in factories. Similar to Monitor but with additional timers.
void DeclareInput(Level ¤tLevel) const
Input.
static const NoFactory * get()
void resize(const size_type n, const T &val=T())
Print statistics that do not involve significant additional computation.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
void Build(Level ¤tLevel) const
Build method.
const RCP< const FactoryManagerBase > GetFactoryManager()
returns the current factory manager
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
static const RCP< const NoFactory > getRCP()
Static Get() functions.