8 #ifndef MUELU_ISORROPIAINTERFACE_DEF_HPP_ 
    9 #define MUELU_ISORROPIAINTERFACE_DEF_HPP_ 
   17 #include <Xpetra_MapFactory.hpp> 
   18 #include <Xpetra_CrsGraphFactory.hpp> 
   19 #include <Xpetra_BlockedMap.hpp> 
   20 #include <Xpetra_BlockedCrsMatrix.hpp> 
   22 #ifdef HAVE_MUELU_ISORROPIA 
   23 #include <Isorropia_Exception.hpp> 
   26 #ifdef HAVE_MUELU_EPETRA 
   27 #include <Xpetra_EpetraCrsGraph.hpp> 
   28 #include <Epetra_CrsGraph.h> 
   29 #include <Isorropia_EpetraPartitioner.hpp> 
   32 #ifdef HAVE_MUELU_TPETRA 
   33 #include <Xpetra_TpetraCrsGraph.hpp> 
   35 #endif // ENDIF HAVE_MUELU_ISORROPIA 
   40 #include "MueLu_Graph.hpp" 
   41 #include "MueLu_AmalgamationInfo.hpp" 
   42 #include "MueLu_Utilities.hpp" 
   46  template <
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
   51     validParamList->
set< 
RCP<const FactoryBase> >(
"number of partitions", Teuchos::null, 
"Instance of RepartitionHeuristicFactory.");
 
   52     validParamList->
set< 
RCP<const FactoryBase> >(
"UnAmalgamationInfo",   Teuchos::null, 
"Generating factory of UnAmalgamationInfo");
 
   54     return validParamList;
 
   58   template <
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
   60     Input(currentLevel, 
"A");
 
   61     Input(currentLevel, 
"number of partitions");
 
   62     Input(currentLevel, 
"UnAmalgamationInfo");
 
   65   template <
class LocalOrdinal, 
class GlobalOrdinal, 
class Node>
 
   68     typedef Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>  BlockMap;
 
   72     GO          numParts           = Get< int >(level, 
"number of partitions");
 
   77     if (numParts == 1 || numParts == -1) {
 
   80       Set(level, 
"AmalgamatedPartition", decomposition);
 
   97     GO indexBase = rowMap->getIndexBase();    
 
  100     LO nStridedOffset   = 0;   
 
  105     if(A->IsView(
"stridedMaps") &&
 
  106        Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
 
  107       Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps"); 
 
  110       blockdim = strMap->getFixedBlockSize();
 
  111       offset   = strMap->getOffset();
 
  112       blockid  = strMap->getStridedBlockId();
 
  114         std::vector<size_t> stridingInfo = strMap->getStridingData();
 
  115         for (
size_t j = 0; j < Teuchos::as<size_t>(blockid); j++)
 
  116           nStridedOffset += stridingInfo[j];
 
  122       oldView = A->SwitchToView(oldView);
 
  124     } 
else GetOStream(
Statistics0) << 
"IsorropiaInterface::Build(): no striding information available. Use blockdim=1 with offset=0" << std::endl;
 
  130     if(!bnodeMap.
is_null()) nodeMap=bnodeMap->getMap();
 
  132     GetOStream(
Statistics0) << 
"IsorropiaInterface:Build(): nodeMap " << nodeMap->getNodeNumElements() << 
"/" << nodeMap->getGlobalNumElements() << 
" elements" << std::endl;
 
  136     RCP<CrsGraph> crsGraph = CrsGraphFactory::Build(nodeMap, A->getNodeMaxNumRowEntries()*blockdim);
 
  139     for(LO row=0; row<Teuchos::as<LO>(A->getRowMap()->getNodeNumElements()); row++) {
 
  141       GO grid = rowMap->getGlobalElement(row);
 
  146       GO nodeId = (grid - offset - indexBase) / blockdim + indexBase;
 
  148       size_t nnz = A->getNumEntriesInLocalRow(row);
 
  151       A->getLocalRowView(row, indices, vals);
 
  155       for(LO col=0; col<Teuchos::as<LO>(nnz); col++) {
 
  156         GO gcid = colMap->getGlobalElement(indices[col]); 
 
  161           GO cnodeId = (gcid - offset - indexBase) / blockdim + indexBase;
 
  162           cnodeIds->push_back(cnodeId);
 
  169       if(arr_cnodeIds.
size() > 0 )
 
  170         crsGraph->insertGlobalIndices(nodeId, arr_cnodeIds());
 
  173     crsGraph->fillComplete(nodeMap,nodeMap);
 
  176 #ifdef HAVE_MUELU_ISORROPIA 
  189     sublist.
set(
"LB_APPROACH", 
"PARTITION");
 
  193 #ifdef HAVE_MUELU_EPETRA 
  195     if(epCrsGraph != Teuchos::null) {
 
  201       const int* array = NULL;
 
  202       isoPart->extractPartsView(size,array);
 
  207       ArrayRCP<GO> decompEntries = decomposition->getDataNonConst(0);
 
  210       for(
int i = 0; i<size; i++) {
 
  211         decompEntries[i] = Teuchos::as<GO>(array[i]);
 
  214       Set(level, 
"AmalgamatedPartition", decomposition);
 
  217 #endif // ENDIF HAVE_MUELU_EPETRA 
  219 #ifdef HAVE_MUELU_TPETRA 
  220 #ifdef HAVE_MUELU_INST_DOUBLE_INT_INT 
  224     TEUCHOS_TEST_FOR_EXCEPTION(
false, 
Exceptions::RuntimeError, 
"Isorropia is an interface to Zoltan which only has support for LO=GO=int and SC=double.");
 
  225 #endif // ENDIF HAVE_MUELU_INST_DOUBLE_INT_INT 
  226 #endif // ENDIF HAVE_MUELU_TPETRA 
  227 #endif // HAVE_MUELU_ISORROPIA 
  228 #else  // if we don't have MPI 
  233     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. 
 
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.