10 #ifndef MUELU_REPLICATEPFACTORY_DEF_HPP
11 #define MUELU_REPLICATEPFACTORY_DEF_HPP
21 #include <Xpetra_CrsMatrixWrap.hpp>
24 #include <Xpetra_MapFactory.hpp>
25 #include <Xpetra_MultiVectorFactory.hpp>
36 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
41 return validParamList;
44 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
50 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
52 Level& coarseLevel)
const {
53 return BuildP(fineLevel, coarseLevel);
56 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
58 Level& coarseLevel)
const {
63 const LO dofPerNode = as<LO>(pL.
get<
int>(
"replicate: npdes"));
70 Psubblockcrs->getAllValues(amalgRowPtr, amalgCols, amalgVals);
72 size_t paddedNrows = Psubblock->getRowMap()->getLocalNumElements() * Teuchos::as<size_t>(dofPerNode);
77 for (decltype(amalgRowPtr.size()) i = 0; i < amalgRowPtr.size() - 1; i++) {
78 size_t rowLength = amalgRowPtr[i + 1] - amalgRowPtr[i];
79 for (
int j = 0; j < dofPerNode; j++) {
80 newPRowPtr[i * dofPerNode + j] = cnt;
81 for (
size_t k = 0; k < rowLength; k++) {
82 newPCols[cnt] = amalgCols[k + amalgRowPtr[i]] * dofPerNode + j;
83 newPVals[cnt++] = amalgVals[k + amalgRowPtr[i]];
88 newPRowPtr[paddedNrows] = cnt;
89 std::vector<size_t> stridingInfo(1, dofPerNode);
91 GlobalOrdinal nCoarseDofs = Psubblock->getDomainMap()->getLocalNumElements() * dofPerNode;
92 GlobalOrdinal indexBase = Psubblock->getDomainMap()->getIndexBase();
93 RCP<const Map> coarseDomainMap = StridedMapFactory::Build(Psubblock->getDomainMap()->lib(),
98 Psubblock->getDomainMap()->getComm(),
102 size_t nColCoarseDofs = Teuchos::as<size_t>(Psubblock->getColMap()->getLocalNumElements() * dofPerNode);
104 for (
size_t c = 0; c < Psubblock->getColMap()->getLocalNumElements(); ++c) {
105 GlobalOrdinal gid = (Psubblock->getColMap()->getGlobalElement(c) - indexBase) * dofPerNode + indexBase;
107 for (
int i = 0; i < dofPerNode; ++i) {
108 unsmooshColMapGIDs[c * dofPerNode + i] = gid + i;
111 Teuchos::RCP<Map> coarseColMap = MapFactory::Build(Psubblock->getDomainMap()->lib(),
113 unsmooshColMapGIDs(),
115 Psubblock->getDomainMap()->getComm());
118 for (
size_t c = 0; c < Psubblock->getRowMap()->getLocalNumElements(); ++c) {
119 GlobalOrdinal gid = (Psubblock->getRowMap()->getGlobalElement(c) - indexBase) * dofPerNode + indexBase;
121 for (
int i = 0; i < dofPerNode; ++i) {
122 unsmooshRowMapGIDs[c * dofPerNode + i] = gid + i;
125 Teuchos::RCP<Map> fineRowMap = MapFactory::Build(Psubblock->getDomainMap()->lib(),
127 unsmooshRowMapGIDs(),
129 Psubblock->getDomainMap()->getComm());
132 dofPerNode * Psubblock->getLocalMaxNumRowEntries());
133 for (
size_t i = 0; i < paddedNrows; i++) {
134 bigPCrs->insertLocalValues(i,
135 newPCols.view(newPRowPtr[i], newPRowPtr[i + 1] - newPRowPtr[i]),
136 newPVals.view(newPRowPtr[i], newPRowPtr[i + 1] - newPRowPtr[i]));
138 bigPCrs->fillComplete(coarseDomainMap, fineRowMap);
142 Set(coarseLevel,
"P", bigP);
147 #define MUELU_REPLICATEPFACTORY_SHORT
148 #endif // MUELU_REPLICATEPFACTORY_DEF_HPP
ParameterList & setEntry(const std::string &name, U &&entry)
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
void BuildP(Level &fineLevel, Level &coarseLevel) const
Abstract Build method.
Timer to be used in factories. Similar to Monitor but with additional timers.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
static const NoFactory * get()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.