8 #ifndef MUELU_ISORROPIAINTERFACE_DEF_HPP_
9 #define MUELU_ISORROPIAINTERFACE_DEF_HPP_
17 #include <Xpetra_MapFactory.hpp>
19 #include <Xpetra_BlockedMap.hpp>
22 #ifdef HAVE_MUELU_ISORROPIA
23 #include <Isorropia_Exception.hpp>
25 #ifdef HAVE_MUELU_EPETRA
27 #include <Epetra_CrsGraph.h>
28 #include <Isorropia_EpetraPartitioner.hpp>
31 #include <Xpetra_TpetraCrsGraph.hpp>
32 #endif // ENDIF HAVE_MUELU_ISORROPIA
38 #include "MueLu_AmalgamationInfo.hpp"
42 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
47 validParamList->
set<
RCP<const FactoryBase> >(
"number of partitions", Teuchos::null,
"Instance of RepartitionHeuristicFactory.");
48 validParamList->
set<
RCP<const FactoryBase> >(
"UnAmalgamationInfo", Teuchos::null,
"Generating factory of UnAmalgamationInfo");
50 return validParamList;
53 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
55 Input(currentLevel,
"A");
56 Input(currentLevel,
"number of partitions");
57 Input(currentLevel,
"UnAmalgamationInfo");
60 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 GO numParts = Get<int>(level,
"number of partitions");
72 if (numParts == 1 || numParts == -1) {
75 Set(level,
"AmalgamatedPartition", decomposition);
92 GO indexBase = rowMap->getIndexBase();
95 LO nStridedOffset = 0;
100 if (A->IsView(
"stridedMaps") &&
101 Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
105 blockdim = strMap->getFixedBlockSize();
106 offset = strMap->getOffset();
107 blockid = strMap->getStridedBlockId();
109 std::vector<size_t> stridingInfo = strMap->getStridingData();
110 for (
size_t j = 0; j < Teuchos::as<size_t>(blockid); j++)
111 nStridedOffset += stridingInfo[j];
117 oldView = A->SwitchToView(oldView);
120 GetOStream(
Statistics0) <<
"IsorropiaInterface::Build(): no striding information available. Use blockdim=1 with offset=0" << std::endl;
126 if (!bnodeMap.
is_null()) nodeMap = bnodeMap->getMap();
128 GetOStream(
Statistics0) <<
"IsorropiaInterface:Build(): nodeMap " << nodeMap->getLocalNumElements() <<
"/" << nodeMap->getGlobalNumElements() <<
" elements" << std::endl;
131 RCP<CrsGraph> crsGraph = CrsGraphFactory::Build(nodeMap, A->getLocalMaxNumRowEntries() * blockdim);
134 for (
LO row = 0; row < Teuchos::as<LO>(A->getRowMap()->getLocalNumElements()); row++) {
136 GO grid = rowMap->getGlobalElement(row);
141 GO nodeId = (grid - offset - indexBase) / blockdim + indexBase;
143 size_t nnz = A->getNumEntriesInLocalRow(row);
146 A->getLocalRowView(row, indices, vals);
150 for (
LO col = 0; col < Teuchos::as<LO>(nnz); col++) {
151 GO gcid = colMap->getGlobalElement(indices[col]);
153 if (vals[col] != 0.0) {
156 GO cnodeId = (gcid - offset - indexBase) / blockdim + indexBase;
157 cnodeIds->push_back(cnodeId);
164 if (arr_cnodeIds.
size() > 0)
165 crsGraph->insertGlobalIndices(nodeId, arr_cnodeIds());
168 crsGraph->fillComplete(nodeMap, nodeMap);
171 #ifdef HAVE_MUELU_ISORROPIA
184 sublist.
set(
"LB_APPROACH",
"PARTITION");
186 #ifdef HAVE_MUELU_EPETRA
188 if (epCrsGraph != Teuchos::null) {
194 const int* array = NULL;
195 isoPart->extractPartsView(size, array);
200 ArrayRCP<GO> decompEntries = decomposition->getDataNonConst(0);
203 for (
int i = 0; i < size; i++) {
204 decompEntries[i] = Teuchos::as<GO>(array[i]);
207 Set(level,
"AmalgamatedPartition", decomposition);
209 #endif // ENDIF HAVE_MUELU_EPETRA
211 #ifdef HAVE_MUELU_INST_DOUBLE_INT_INT
215 TEUCHOS_TEST_FOR_EXCEPTION(
false,
Exceptions::RuntimeError,
"Isorropia is an interface to Zoltan which only has support for LO=GO=int and SC=double.");
216 #endif // ENDIF HAVE_MUELU_INST_DOUBLE_INT_INT
217 #endif // HAVE_MUELU_ISORROPIA
218 #else // if we don't have MPI
222 Set(level,
"AmalgamatedPartition", decomposition);
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Exception indicating invalid cast attempted.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
void Build(Level &level) const
Build an object with this factory.
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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.
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
void DeclareInput(Level &level) const
Specifies the data that this class needs, and the factories that generate that data.
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.