47 #ifndef MUELU_DROPNEGATIVEENTRIESFACTORY_DEF_HPP
48 #define MUELU_DROPNEGATIVEENTRIESFACTORY_DEF_HPP
50 #include <Xpetra_CrsGraph.hpp>
51 #include <Xpetra_Matrix.hpp>
52 #include <Xpetra_Vector.hpp>
53 #include <Xpetra_MatrixFactory.hpp>
54 #include <Xpetra_CrsGraphFactory.hpp>
58 #include "MueLu_FactoryManager.hpp"
61 #include "MueLu_Graph.hpp"
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
71 #undef SET_VALID_ENTRY
73 validParamList->
set<
RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A used for filtering");
75 return validParamList;
78 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 Input(currentLevel,
"A");
83 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85 FactoryMonitor m(*
this,
"Matrix filtering (springs)", currentLevel);
87 RCP<Matrix> Ain = Get< RCP<Matrix> >(currentLevel,
"A");
92 Teuchos::RCP<Matrix> Aout = MatrixFactory::Build(Ain->getRowMap(), Ain->getGlobalMaxNumRowEntries());
94 size_t numLocalRows = Ain->getNodeNumRows();
95 for(
size_t row=0; row<numLocalRows; row++) {
98 int rDofID = Teuchos::as<int>(grid % nDofsPerNode);
103 Ain->getLocalRowView(row, indices, vals);
109 size_t nNonzeros = 0;
110 for(
size_t i=0; i<(size_t)indices.size(); i++) {
111 GlobalOrdinal gcid = Ain->getColMap()->getGlobalElement(indices[i]);
113 int cDofID = Teuchos::as<int>(gcid % nDofsPerNode);
115 indout [nNonzeros] = gcid;
116 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());
129 Aout->SetFixedBlockSize(nDofsPerNode);
131 GetOStream(
Statistics0, 0) <<
"Nonzeros in A (input): " << Ain->getGlobalNumEntries() <<
", Nonzeros after filtering A: " << Aout->getGlobalNumEntries() << std::endl;
133 Set(currentLevel,
"A", Aout);
138 #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.