8 #ifndef MUELU_ISORROPIAINTERFACE_DEF_HPP_
9 #define MUELU_ISORROPIAINTERFACE_DEF_HPP_
22 #ifdef HAVE_MUELU_ISORROPIA
23 #include <Isorropia_Exception.hpp>
26 #ifdef HAVE_MUELU_EPETRA
28 #include <Epetra_CrsGraph.h>
29 #include <Isorropia_EpetraPartitioner.hpp>
32 #ifdef HAVE_MUELU_TPETRA
35 #endif // ENDIF HAVE_MUELU_ISORROPIA
40 #include "MueLu_Graph.hpp"
41 #include "MueLu_AmalgamationFactory.hpp"
42 #include "MueLu_AmalgamationInfo.hpp"
43 #include "MueLu_Utilities.hpp"
47 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
52 validParamList->
set<
RCP<const FactoryBase> >(
"number of partitions", Teuchos::null,
"Instance of RepartitionHeuristicFactory.");
53 validParamList->
set<
RCP<const FactoryBase> >(
"UnAmalgamationInfo", Teuchos::null,
"Generating factory of UnAmalgamationInfo");
55 return validParamList;
59 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 Input(currentLevel,
"A");
62 Input(currentLevel,
"number of partitions");
63 Input(currentLevel,
"UnAmalgamationInfo");
66 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
73 GO numParts = Get< int >(level,
"number of partitions");
78 if (numParts == 1 || numParts == -1) {
81 Set(level,
"AmalgamatedPartition", decomposition);
98 GO indexBase = rowMap->getIndexBase();
101 LO nStridedOffset = 0;
106 if(A->IsView(
"stridedMaps") &&
107 Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
111 blockdim = strMap->getFixedBlockSize();
112 offset = strMap->getOffset();
113 blockid = strMap->getStridedBlockId();
115 std::vector<size_t> stridingInfo = strMap->getStridingData();
116 for (
size_t j = 0; j < Teuchos::as<size_t>(blockid); j++)
117 nStridedOffset += stridingInfo[j];
123 oldView = A->SwitchToView(oldView);
125 }
else GetOStream(
Statistics0) <<
"IsorropiaInterface::Build(): no striding information available. Use blockdim=1 with offset=0" << std::endl;
131 if(!bnodeMap.
is_null()) nodeMap=bnodeMap->getMap();
133 GetOStream(
Statistics0) <<
"IsorropiaInterface:Build(): nodeMap " << nodeMap->getNodeNumElements() <<
"/" << nodeMap->getGlobalNumElements() <<
" elements" << std::endl;
140 for(
LO row=0; row<Teuchos::as<LO>(A->getRowMap()->getNodeNumElements()); row++) {
142 GO grid = rowMap->getGlobalElement(row);
147 size_t nnz = A->getNumEntriesInLocalRow(row);
150 A->getLocalRowView(row, indices, vals);
154 for(
LO col=0; col<Teuchos::as<LO>(nnz); col++) {
155 GO gcid = colMap->getGlobalElement(indices[col]);
159 cnodeIds->push_back(cnodeId);
166 if(arr_cnodeIds.
size() > 0 )
167 crsGraph->insertGlobalIndices(nodeId, arr_cnodeIds());
170 crsGraph->fillComplete(nodeMap,nodeMap);
173 #ifdef HAVE_MUELU_ISORROPIA
186 sublist.
set(
"LB_APPROACH",
"PARTITION");
190 #ifdef HAVE_MUELU_EPETRA
192 if(epCrsGraph != Teuchos::null) {
198 const int* array = NULL;
199 isoPart->extractPartsView(size,array);
204 ArrayRCP<GO> decompEntries = decomposition->getDataNonConst(0);
207 for(
int i = 0; i<size; i++) {
208 decompEntries[i] = Teuchos::as<GO>(array[i]);
211 Set(level,
"AmalgamatedPartition", decomposition);
214 #endif // ENDIF HAVE_MUELU_EPETRA
216 #ifdef HAVE_MUELU_TPETRA
217 #ifdef HAVE_MUELU_INST_DOUBLE_INT_INT
221 TEUCHOS_TEST_FOR_EXCEPTION(
false,
Exceptions::RuntimeError,
"Isorropia is an interface to Zoltan which only has support for LO=GO=int and SC=double.");
222 #endif // ENDIF HAVE_MUELU_INST_DOUBLE_INT_INT
223 #endif // ENDIF HAVE_MUELU_TPETRA
224 #endif // HAVE_MUELU_ISORROPIA
225 #else // if we don't have MPI
230 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)
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.
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.