8 #ifndef MUELU_ISORROPIAINTERFACE_DEF_HPP_ 9 #define MUELU_ISORROPIAINTERFACE_DEF_HPP_ 17 #include <Xpetra_MapFactory.hpp> 18 #include <Xpetra_CrsGraphFactory.hpp> 20 #ifdef HAVE_MUELU_ISORROPIA 21 #include <Isorropia_Exception.hpp> 24 #ifdef HAVE_MUELU_EPETRA 25 #include <Xpetra_EpetraCrsGraph.hpp> 26 #include <Epetra_CrsGraph.h> 27 #include <Isorropia_EpetraPartitioner.hpp> 30 #ifdef HAVE_MUELU_TPETRA 31 #include <Xpetra_TpetraCrsGraph.hpp> 32 #include <Tpetra_CrsGraph.hpp> 33 #ifdef HAVE_ISORROPIA_TPETRA 34 #include <Isorropia_TpetraPartitioner.hpp> 35 #endif // HAVE_ISORROPIA_TPETRA 37 #endif // ENDIF HAVE_MUELU_ISORROPIA 42 #include "MueLu_Graph.hpp" 43 #include "MueLu_AmalgamationFactory.hpp" 44 #include "MueLu_AmalgamationInfo.hpp" 45 #include "MueLu_Utilities.hpp" 49 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
54 validParamList->
set<
RCP<const FactoryBase> >(
"number of partitions", Teuchos::null,
"Instance of RepartitionHeuristicFactory.");
55 validParamList->
set<
RCP<const FactoryBase> >(
"UnAmalgamationInfo", Teuchos::null,
"Generating factory of UnAmalgamationInfo");
57 return validParamList;
61 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 Input(currentLevel,
"A");
64 Input(currentLevel,
"number of partitions");
65 Input(currentLevel,
"UnAmalgamationInfo");
68 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
74 GO numParts = Get< int >(level,
"number of partitions");
79 if (numParts == 1 || numParts == -1) {
82 Set(level,
"AmalgamatedPartition", decomposition);
99 GO indexBase = rowMap->getIndexBase();
102 LO nStridedOffset = 0;
103 LO stridedblocksize = blockdim;
107 if(A->IsView(
"stridedMaps") &&
108 Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
109 Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps");
112 blockdim = strMap->getFixedBlockSize();
113 offset = strMap->getOffset();
114 blockid = strMap->getStridedBlockId();
116 std::vector<size_t> stridingInfo = strMap->getStridingData();
117 for (
size_t j = 0; j < Teuchos::as<size_t>(blockid); j++)
118 nStridedOffset += stridingInfo[j];
119 stridedblocksize = Teuchos::as<LocalOrdinal>(stridingInfo[blockid]);
122 stridedblocksize = blockdim;
124 oldView = A->SwitchToView(oldView);
126 }
else GetOStream(
Statistics0) <<
"IsorropiaInterface::Build(): no striding information available. Use blockdim=1 with offset=0" << std::endl;
131 GetOStream(
Statistics0) <<
"IsorropiaInterface:Build(): nodeMap " << nodeMap->getNodeNumElements() <<
"/" << nodeMap->getGlobalNumElements() <<
" elements" << std::endl;
134 RCP<CrsGraph> crsGraph = CrsGraphFactory::Build(nodeMap, 10, Xpetra::DynamicProfile);
137 for(LO row=0; row<Teuchos::as<LO>(A->getRowMap()->getNodeNumElements()); row++) {
139 GO grid = rowMap->getGlobalElement(row);
144 size_t nnz = A->getNumEntriesInLocalRow(row);
147 A->getLocalRowView(row, indices, vals);
151 for(LO col=0; col<Teuchos::as<LO>(nnz); col++) {
152 GO gcid = colMap->getGlobalElement(indices[col]);
156 cnodeIds->push_back(cnodeId);
163 if(arr_cnodeIds.
size() > 0 )
164 crsGraph->insertGlobalIndices(nodeId, arr_cnodeIds());
167 crsGraph->fillComplete(nodeMap,nodeMap);
170 #ifdef HAVE_MUELU_ISORROPIA 183 sublist.
set(
"LB_APPROACH",
"PARTITION");
187 #ifdef HAVE_MUELU_EPETRA 189 if(epCrsGraph != Teuchos::null) {
195 const int* array = NULL;
196 isoPart->extractPartsView(size,array);
201 ArrayRCP<GO> decompEntries = decomposition->getDataNonConst(0);
204 for(
int i = 0; i<size; i++) {
205 decompEntries[i] = Teuchos::as<GO>(array[i]);
208 Set(level,
"AmalgamatedPartition", decomposition);
211 #endif // ENDIF HAVE_MUELU_EPETRA 213 #ifdef HAVE_MUELU_TPETRA 214 #ifdef HAVE_MUELU_INST_DOUBLE_INT_INT 217 if(tpCrsGraph != Teuchos::null) {
218 #ifdef HAVE_ISORROPIA_TPETRA 223 const int* array = NULL;
224 isoPart->extractPartsView(size,array);
229 ArrayRCP<GO> decompEntries = decomposition->getDataNonConst(0);
234 for(
int i = 0; i<size; i++) {
235 decompEntries[i] = Teuchos::as<GO>(array[i]);
238 Set(level,
"AmalgamatedPartition", decomposition);
242 #endif // ENDIF HAVE_ISORROPIA_TPETRA 246 #endif // ENDIF HAVE_MUELU_INST_DOUBLE_INT_INT 247 #endif // ENDIF HAVE_MUELU_TPETRA 248 #endif // HAVE_MUELU_ISORROPIA 249 #else // if we don't have MPI 254 Set(level,
"AmalgamatedPartition", decomposition);
Exception indicating invalid cast attempted.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void DeclareInput(Level &level) const
Specifies the data that this class needs, and the factories that generate that data.
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Build(Level &level) const
Build an object with this factory.
Namespace for MueLu classes and methods.
static const GlobalOrdinal DOFGid2NodeId(GlobalOrdinal gid, LocalOrdinal blockSize, const GlobalOrdinal offset, const GlobalOrdinal indexBase)
translate global (row/column) id to global amalgamation block id
Print statistics that do not involve significant additional computation.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Exception throws to report errors in the internal logical of the program.