46 #ifndef MUELU_THRESHOLDAFILTERFACTORY_DEF_HPP
47 #define MUELU_THRESHOLDAFILTERFACTORY_DEF_HPP
59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 : varName_(ename), threshold_(threshold), keepDiagonal_(keepDiagonal), expectedNNZperRow_(expectedNNZperRow)
64 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
69 Input(currentLevel, varName_);
72 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
81 RCP<OMatrix> Ain = Get< RCP<OMatrix> >(currentLevel, varName_);
88 for(
size_t row=0; row<Ain->getNodeNumRows(); row++)
90 size_t nnz = Ain->getNumEntriesInLocalRow(row);
94 Ain->getLocalRowView(row, indices, vals);
100 size_t nNonzeros = 0;
102 GlobalOrdinal glbRow = rowmap->getGlobalElement(row);
103 LocalOrdinal lclColIdx = colmap->getLocalElement(glbRow);
104 for(
size_t i=0; i<(size_t)indices.
size(); i++) {
106 indout[nNonzeros] = colmap->getGlobalElement(indices[i]);
107 valout[nNonzeros] = vals[i];
112 for(
size_t i=0; i<(size_t)indices.
size(); i++) {
114 indout[nNonzeros] = colmap->getGlobalElement(indices[i]);
115 valout[nNonzeros] = vals[i];
121 valout.resize(nNonzeros);
123 Aout->insertGlobalValues(Ain->getRowMap()->getGlobalElement(row), indout.view(0,indout.size()), valout.view(0,valout.size()));
126 Aout->fillComplete(Ain->getDomainMap(), Ain->getRangeMap());
128 GetOStream(
Statistics0) <<
"Nonzeros in " << varName_ <<
"(input): " << Ain->getGlobalNumEntries() <<
", Nonzeros after filtering " << varName_ <<
" (parameter: " << threshold_ <<
"): " << Aout->getGlobalNumEntries() << std::endl;
130 currentLevel.Set(varName_, Teuchos::rcp_dynamic_cast<OMatrix>(Aout),
this);
135 #endif // MUELU_THRESHOLDAFILTERFACTORY_DEF_HPP
void DeclareInput(Level ¤tLevel) const
Input.
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void resize(const size_type n, const T &val=T())
Print statistics that do not involve significant additional computation.
ThresholdAFilterFactory(const std::string &ename, const Scalar threshold, const bool keepDiagonal=true, const GlobalOrdinal expectedNNZperRow=-1)
Constructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
virtual ~ThresholdAFilterFactory()
Destructor.
static magnitudeType magnitude(T a)
void Build(Level ¤tLevel) const
Build an object with this factory.
Exception throws to report errors in the internal logical of the program.