47 #ifndef MUELU_DROPNEGATIVEENTRIESFACTORY_DEF_HPP
48 #define MUELU_DROPNEGATIVEENTRIESFACTORY_DEF_HPP
63 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
68 #undef SET_VALID_ENTRY
70 validParamList->
set<
RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A used for filtering");
72 return validParamList;
75 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
77 Input(currentLevel,
"A");
80 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
82 FactoryMonitor m(*
this,
"Matrix filtering (springs)", currentLevel);
84 RCP<Matrix> Ain = Get<RCP<Matrix> >(currentLevel,
"A");
89 Teuchos::RCP<Matrix> Aout = MatrixFactory::Build(Ain->getRowMap(), Ain->getGlobalMaxNumRowEntries());
91 size_t numLocalRows = Ain->getLocalNumRows();
92 for (
size_t row = 0; row < numLocalRows; row++) {
95 int rDofID = Teuchos::as<int>(grid % nDofsPerNode);
100 Ain->getLocalRowView(row, indices, vals);
106 size_t nNonzeros = 0;
107 for (
size_t i = 0; i < (size_t)indices.size(); i++) {
108 GlobalOrdinal gcid = Ain->getColMap()->getGlobalElement(indices[i]);
110 int cDofID = Teuchos::as<int>(gcid % nDofsPerNode);
112 indout[nNonzeros] = gcid;
113 valout[nNonzeros] = vals[i];
118 valout.resize(nNonzeros);
120 Aout->insertGlobalValues(Ain->getRowMap()->getGlobalElement(row), indout.view(0, indout.size()), valout.view(0, valout.size()));
123 Aout->fillComplete(Ain->getDomainMap(), Ain->getRangeMap());
126 Aout->SetFixedBlockSize(nDofsPerNode);
128 GetOStream(
Statistics0, 0) <<
"Nonzeros in A (input): " << Ain->getGlobalNumEntries() <<
", Nonzeros after filtering A: " << Aout->getGlobalNumEntries() << std::endl;
130 Set(currentLevel,
"A", Aout);
135 #endif // MUELU_DROPNEGATIVEENTRIESFACTORY_DEF_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
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 resize(const size_type n, const T &val=T())
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Print statistics that do not involve significant additional computation.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
void Build(Level ¤tLevel) const
Build method.
static magnitudeType magnitude(T a)
void DeclareInput(Level ¤tLevel) const
Input.