Isorropia: Partitioning, Load Balancing and more Version 3.0
Isorropia_TpetraPartitioner.hpp
Go to the documentation of this file.
00001 //@HEADER
00002 /*
00003 ************************************************************************
00004 
00005               Isorropia: Partitioning and Load Balancing Package
00006                 Copyright (2006) Sandia Corporation
00007 
00008 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 license for use of this work by or on behalf of the U.S. Government.
00010 
00011 This library is free software; you can redistribute it and/or modify
00012 it under the terms of the GNU Lesser General Public License as
00013 published by the Free Software Foundation; either version 2.1 of the
00014 License, or (at your option) any later version.
00015 
00016 This library is distributed in the hope that it will be useful, but
00017 WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 Lesser General Public License for more details.
00020 
00021 You should have received a copy of the GNU Lesser General Public
00022 License along with this library; if not, write to the Free Software
00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 USA
00025 
00026 ************************************************************************
00027 */
00028 //@HEADER
00029 
00030 #ifndef _Isorropia_TpetraPartitioner_hpp_
00031 #define _Isorropia_TpetraPartitioner_hpp_
00032 
00033 
00041 #include <Isorropia_ConfigDefs.hpp>
00042 #include <Teuchos_RCP.hpp>
00043 #include <Teuchos_ParameterList.hpp>
00044 
00045 
00046 
00047 #ifdef HAVE_ISORROPIA_TPETRA
00048 #include <Isorropia_TpetraOperator.hpp>
00049 #include <Isorropia_Partitioner.hpp>
00050 #include <Isorropia_TpetraZoltanLib.hpp>
00051 
00052 
00053 #include <Kokkos_DefaultNode.hpp>
00054 #include <Tpetra_CrsGraph_decl.hpp>
00055 #include <Tpetra_RowMatrix.hpp>
00056 #include <Tpetra_MultiVector_decl.hpp>
00057 
00058 namespace Isorropia {
00059 
00060 namespace Tpetra {
00061 
00062 
00063 
00064 
00065 template <class Node=Kokkos::DefaultNode::DefaultNodeType>
00066 class Partitioner : public Isorropia::Partitioner, public Isorropia::Tpetra::Operator<Node>  {
00067 public:
00068   
00069 
00070   Partitioner(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > inputGraph,
00071               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),  
00072               bool compute_partitioning_now=true);
00073 
00074   Partitioner(const ::Tpetra::CrsGraph<int,int,Node> *inputGraph,
00075               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),  
00076               bool compute_partitioning_now=true);
00077 
00078   Partitioner(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > inputGraph,
00079               Teuchos::RCP<CostDescriber<Node> > costs,
00080               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00081               bool compute_partitioning_now=true);
00082 
00083   Partitioner(const ::Tpetra::CrsGraph<int,int,Node> *inputGraph,
00084               CostDescriber<Node> * costs,
00085               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00086               bool compute_partitioning_now=true);
00087 
00088   Partitioner(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > inputMatrix,
00089               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00090               bool compute_partitioning_now=true);
00091 
00092   Partitioner(const ::Tpetra::RowMatrix<double,int,int,Node> *inputMatrix,
00093               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00094               bool compute_partitioning_now=true);
00095 
00096   Partitioner(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > inputMatrix,
00097               Teuchos::RCP<CostDescriber<Node> > costs,
00098               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00099               bool compute_partitioning_now=true);
00100 
00101   Partitioner(const ::Tpetra::RowMatrix<double,int,int,Node> *inputMatrix,
00102               CostDescriber<Node>  *costs,
00103               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00104               bool compute_partitioning_now=true);
00105 
00106   Partitioner(Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
00107               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00108               bool compute_partitioning_now=true);
00109 
00110   Partitioner(const ::Tpetra::MultiVector<double,int,int,Node> *coords,
00111               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00112               bool compute_partitioning_now=true);
00113 
00114   Partitioner(Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
00115               Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights,
00116               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00117               bool compute_partitioning_now=true);
00118 
00119   Partitioner(const ::Tpetra::MultiVector<double,int,int,Node> *coords,
00120               const ::Tpetra::MultiVector<double,int,int,Node> *weights,
00121               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00122               bool compute_partitioning_now=true);
00123 
00124   Partitioner(Teuchos::RCP<const ::Tpetra::Map<int,int,Node> > inputMap,
00125               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00126               bool compute_partitioning_now=true);
00127 
00128   Partitioner(const ::Tpetra::Map<int,int,Node> *inputMap,
00129               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00130               bool compute_partitioning_now=true);
00131 
00132 
00133   // MMW: currently not supporting hiearchical partitioning
00134 
00135 
00136 
00137 
00138 
00139   virtual ~Partitioner();
00140 
00141    /* @ingroup partitioning_grp
00142     * Set the relative number of objects in each part.  The default is to
00143     * evenly divide objects across parts.  The numbers can be fractions of
00144     * one, or whole numbers.  Zoltan adds the values supplied and takes the sizes
00145     * as proportional to that whole.
00146     *
00147     * We make a copy of id and size lists.
00148     *
00149     * Caller should supply either global part IDs or local part IDs.
00150     * Part IDs are integers beginning at zero for the first part.
00151     *
00152     * No communication is done during this call.  One process can make the call
00153     * for all parts, or many processes can make the call.  Zoltan checks the
00154     * consistency of the information provided.
00155     */
00156 
00157   void setPartSizes(int len, int *global_part_id, float *part_size);
00158 
00159   /* @ingroup partitioning_grp
00160    * Free the memory allocated to store part sizes.
00161    */
00162   void clearPartSizes();
00163 
00176   void partition(bool force_repartitioning=false);
00177 
00180   virtual void compute(bool forceRecomputing=false);
00181 
00184   int numElemsInPart(int part) const {
00185     return (numElemsWithProperty(part));
00186   }
00187 
00190   void elemsInPart(int part, int* elementList, int len) const {
00191     elemsWithProperty(part, elementList, len);
00192   }
00193 
00205   Teuchos::RCP< ::Tpetra::Map<int,int,Node> > createNewMap();
00206 
00218   void createNewMap(::Tpetra::Map<int,int,Node> *&outputMap);
00219 
00220 private:
00221   int *partGIDs;
00222   float *partSizes;
00223   int numPartSizes;
00224 
00225 };//class Partitioner
00226 
00227 }//namespace Tpetra
00228 }//namespace Isorropia
00229 
00230 #endif //HAVE_ISORROPIA_TPETRA
00231 
00232 #endif
00233