Isorropia: Partitioning, Load Balancing and more Version 3.0
Isorropia_EpetraPartitioner.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_EpetraPartitioner_hpp_
00031 #define _Isorropia_EpetraPartitioner_hpp_
00032 
00033 
00082 #include <Isorropia_ConfigDefs.hpp>
00083 #include <Teuchos_RCP.hpp>
00084 #include <Teuchos_ParameterList.hpp>
00085 
00086 #include <Isorropia_EpetraCostDescriber.hpp>
00087 #include <Isorropia_EpetraOperator.hpp>
00088 #include <Isorropia_Partitioner.hpp>
00089 
00090 #ifdef HAVE_EPETRA
00091 class Epetra_Map;
00092 class Epetra_BlockMap;
00093 class Epetra_Import;
00094 class Epetra_Vector;
00095 class Epetra_MultiVector;
00096 class Epetra_CrsGraph;
00097 class Epetra_CrsMatrix;
00098 class Epetra_RowMatrix;
00099 class Epetra_LinearProblem;
00100 
00101 namespace Isorropia {
00102 
00103 namespace Epetra {
00104   class CostDescriber;
00105 
00112 class Partitioner : public Isorropia::Partitioner, public Isorropia::Epetra::Operator  {
00113 public:
00114   
00117   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
00118               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),  
00119               bool compute_partitioning_now=true);
00120 
00124   Partitioner(const Epetra_CrsGraph *inputGraph,
00125               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),  
00126               bool compute_partitioning_now=true);
00127 
00131   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
00132               Teuchos::RCP<CostDescriber> costs,
00133               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00134               bool compute_partitioning_now=true);
00135 
00139   Partitioner(const Epetra_CrsGraph *inputGraph,
00140               CostDescriber* costs,
00141               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00142               bool compute_partitioning_now=true);
00143 
00147   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
00148               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00149               bool compute_partitioning_now=true);
00150 
00154   Partitioner(const Epetra_RowMatrix *inputMatrix,
00155               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00156               bool compute_partitioning_now=true);
00157 
00161   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
00162               Teuchos::RCP<CostDescriber> costs,
00163               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00164               bool compute_partitioning_now=true);
00165 
00169   Partitioner(const Epetra_RowMatrix *inputMatrix,
00170               CostDescriber *costs,
00171               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00172               bool compute_partitioning_now=true);
00173 
00177   Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
00178               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00179               bool compute_partitioning_now=true);
00180 
00184   Partitioner(const Epetra_MultiVector *coords,
00185               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00186               bool compute_partitioning_now=true);
00187 
00191   Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
00192               Teuchos::RCP<const Epetra_MultiVector> weights,
00193               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00194               bool compute_partitioning_now=true);
00195 
00198   Partitioner(const Epetra_MultiVector *coords,
00199               const Epetra_MultiVector *weights,
00200               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00201               bool compute_partitioning_now=true);
00202 
00205   Partitioner(Teuchos::RCP<const Epetra_BlockMap> inputMap,
00206               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00207               bool compute_partitioning_now=true);
00208 
00211   Partitioner(const Epetra_BlockMap *inputMap,
00212               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00213               bool compute_partitioning_now=true);
00214 
00217   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
00218         Teuchos::RCP<const Epetra_MultiVector> coords,
00219               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00220               bool compute_partitioning_now=true);
00221 
00224   Partitioner(const Epetra_CrsGraph *inputGraph,
00225         const Epetra_MultiVector *coords,
00226               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00227               bool compute_partitioning_now=true);
00228   
00229 
00232   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
00233               Teuchos::RCP<CostDescriber> costs,
00234         Teuchos::RCP<const Epetra_MultiVector> coords,
00235               Teuchos::RCP<const Epetra_MultiVector> weights,
00236               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00237               bool compute_partitioning_now=true);
00238 
00241   Partitioner(const Epetra_CrsGraph *inputGraph,
00242               CostDescriber *costs,
00243         const Epetra_MultiVector *coords,
00244               const Epetra_MultiVector *weights,
00245               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00246               bool compute_partitioning_now=true);
00247 
00250   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
00251         Teuchos::RCP<const Epetra_MultiVector> coords,
00252               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00253               bool compute_partitioning_now=true);
00254 
00257   Partitioner(const Epetra_RowMatrix *inputMatrix,
00258         const Epetra_MultiVector *coords,
00259               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00260               bool compute_partitioning_now=true);
00261 
00264   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
00265               Teuchos::RCP<CostDescriber> costs,
00266         Teuchos::RCP<const Epetra_MultiVector> coords,
00267               Teuchos::RCP<const Epetra_MultiVector> weights,
00268               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00269               bool compute_partitioning_now=true);
00270 
00273   Partitioner(const Epetra_RowMatrix *inputMatrix,
00274               CostDescriber *costs,
00275         const Epetra_MultiVector *coords,
00276               const Epetra_MultiVector *weights,
00277               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00278               bool compute_partitioning_now=true);
00279 
00280 
00284   virtual ~Partitioner();
00285 
00286    /* @ingroup partitioning_grp
00287     * Set the relative number of objects in each part.  The default is to
00288     * evenly divide objects across parts.  The numbers can be fractions of
00289     * one, or whole numbers.  Zoltan adds the values supplied and takes the sizes
00290     * as proportional to that whole.
00291     *
00292     * We make a copy of id and size lists.
00293     *
00294     * Caller should supply either global part IDs or local part IDs.
00295     * Part IDs are integers beginning at zero for the first part.
00296     *
00297     * No communication is done during this call.  One process can make the call
00298     * for all parts, or many processes can make the call.  Zoltan checks the
00299     * consistency of the information provided.
00300     */
00301 
00302   void setPartSizes(int len, int *global_part_id, float *part_size);
00303 
00304   /* @ingroup partitioning_grp
00305    * Free the memory allocated to store part sizes.
00306    */
00307   void clearPartSizes();
00308 
00321   void partition(bool force_repartitioning=false);
00322 
00325   virtual void compute(bool forceRecomputing=false);
00326 
00329   int numElemsInPart(int part) const {
00330     return (numElemsWithProperty(part));
00331   }
00332 
00335   void elemsInPart(int part, int* elementList, int len) const {
00336     elemsWithProperty(part, elementList, len);
00337   }
00338 
00350   Teuchos::RCP<Epetra_Map> createNewMap();
00351 
00363   void createNewMap(Epetra_Map *&outputMap);
00364 
00365 private:
00366   int *partGIDs;
00367   float *partSizes;
00368   int numPartSizes;
00369 
00370 };//class Partitioner
00371 
00372 }//namespace Epetra
00373 }//namespace Isorropia
00374 
00375 #endif //HAVE_EPETRA
00376 
00377 #endif
00378