10 #ifndef MUELU_DROPNEGATIVEENTRIESFACTORY_DEF_HPP
11 #define MUELU_DROPNEGATIVEENTRIESFACTORY_DEF_HPP
26 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
30 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
31 #undef SET_VALID_ENTRY
33 validParamList->
set<
RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A used for filtering");
35 return validParamList;
38 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
40 Input(currentLevel,
"A");
43 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
45 FactoryMonitor m(*
this,
"Matrix filtering (springs)", currentLevel);
47 RCP<Matrix> Ain = Get<RCP<Matrix> >(currentLevel,
"A");
52 Teuchos::RCP<Matrix> Aout = MatrixFactory::Build(Ain->getRowMap(), Ain->getGlobalMaxNumRowEntries());
54 size_t numLocalRows = Ain->getLocalNumRows();
55 for (
size_t row = 0; row < numLocalRows; row++) {
58 int rDofID = Teuchos::as<int>(grid % nDofsPerNode);
63 Ain->getLocalRowView(row, indices, vals);
70 for (
size_t i = 0; i < (size_t)indices.size(); i++) {
71 GlobalOrdinal gcid = Ain->getColMap()->getGlobalElement(indices[i]);
73 int cDofID = Teuchos::as<int>(gcid % nDofsPerNode);
75 indout[nNonzeros] = gcid;
76 valout[nNonzeros] = vals[i];
81 valout.resize(nNonzeros);
83 Aout->insertGlobalValues(Ain->getRowMap()->getGlobalElement(row), indout.view(0, indout.size()), valout.view(0, valout.size()));
86 Aout->fillComplete(Ain->getDomainMap(), Ain->getRangeMap());
89 Aout->SetFixedBlockSize(nDofsPerNode);
91 GetOStream(
Statistics0, 0) <<
"Nonzeros in A (input): " << Ain->getGlobalNumEntries() <<
", Nonzeros after filtering A: " << Aout->getGlobalNumEntries() << std::endl;
93 Set(currentLevel,
"A", Aout);
98 #endif // MUELU_DROPNEGATIVEENTRIESFACTORY_DEF_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
Timer to be used in factories. Similar to Monitor but with additional timers.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.