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 #include <Isorropia_ConfigDefs.hpp>
00034 #include <Teuchos_RCP.hpp>
00035 #include <Teuchos_ParameterList.hpp>
00036 
00037 #include <Isorropia_EpetraCostDescriber.hpp>
00038 #include <Isorropia_EpetraOperator.hpp>
00039 #include <Isorropia_Partitioner.hpp>
00040 
00041 #ifdef HAVE_EPETRA
00042 class Epetra_Map;
00043 class Epetra_BlockMap;
00044 class Epetra_Import;
00045 class Epetra_Vector;
00046 class Epetra_MultiVector;
00047 class Epetra_CrsGraph;
00048 class Epetra_CrsMatrix;
00049 class Epetra_RowMatrix;
00050 class Epetra_LinearProblem;
00051 
00052 namespace Isorropia {
00053 
00054 namespace Epetra {
00055   class CostDescriber;
00056 
00062 class Partitioner : public Isorropia::Partitioner, public Isorropia::Epetra::Operator  {
00063 public:
00064   
00065   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00066               bool compute_partitioning_now=true);
00067 
00068   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00069               const Teuchos::ParameterList& paramlist,
00070               bool compute_partitioning_now=true);
00071   
00072   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00073               Teuchos::RCP<CostDescriber> costs,
00074               const Teuchos::ParameterList& paramlist,
00075               bool compute_partitioning_now=true);
00076 
00077   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00078               bool compute_partitioning_now=true);
00079 
00080   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00081               const Teuchos::ParameterList& paramlist,
00082               bool compute_partitioning_now=true);
00083 
00084   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00085               Teuchos::RCP<CostDescriber> costs,
00086               const Teuchos::ParameterList& paramlist,
00087               bool compute_partitioning_now=true);
00088 
00089   Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
00090               bool compute_partitioning_now=true);
00091 
00092   Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
00093               const Teuchos::ParameterList& paramlist,
00094               bool compute_partitioning_now=true);
00095 
00096   Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
00097               Teuchos::RCP<const Epetra_MultiVector> weights,
00098               const Teuchos::ParameterList& paramlist,
00099               bool compute_partitioning_now=true);
00100 
00101   Partitioner(Teuchos::RCP<const Epetra_BlockMap> input_map,
00102               bool compute_partitioning_now=true);
00103 
00104   Partitioner(Teuchos::RCP<const Epetra_BlockMap> input_map,
00105               const Teuchos::ParameterList& paramlist,
00106               bool compute_partitioning_now=true);
00107 
00108   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00109         Teuchos::RCP<const Epetra_MultiVector> coords,
00110               bool compute_partitioning_now=true);
00111 
00112   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00113         Teuchos::RCP<const Epetra_MultiVector> coords,
00114               const Teuchos::ParameterList& paramlist,
00115               bool compute_partitioning_now=true);
00116   
00117   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> input_graph,
00118               Teuchos::RCP<CostDescriber> costs,
00119         Teuchos::RCP<const Epetra_MultiVector> coords,
00120               Teuchos::RCP<const Epetra_MultiVector> weights,
00121               const Teuchos::ParameterList& paramlist,
00122               bool compute_partitioning_now=true);
00123 
00124   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00125         Teuchos::RCP<const Epetra_MultiVector> coords,
00126               bool compute_partitioning_now=true);
00127 
00128   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00129         Teuchos::RCP<const Epetra_MultiVector> coords,
00130               const Teuchos::ParameterList& paramlist,
00131               bool compute_partitioning_now=true);
00132 
00133   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> input_matrix,
00134               Teuchos::RCP<CostDescriber> costs,
00135         Teuchos::RCP<const Epetra_MultiVector> coords,
00136               Teuchos::RCP<const Epetra_MultiVector> weights,
00137               const Teuchos::ParameterList& paramlist,
00138               bool compute_partitioning_now=true);
00139 
00140 
00142   virtual ~Partitioner();
00143 
00144    /* Set the relative number of objects in each part.  The default is to
00145     * evenly divide objects across parts.  The numbers can be fractions of
00146     * one, or whole numbers.  Zoltan adds the values supplied and takes the sizes
00147     * as proportional to that whole.
00148     *
00149     * We make a copy of id and size lists.
00150     *
00151     * Caller should supply either global part IDs or local part IDs.
00152     * Part IDs are integers beginning at zero for the first part.
00153     *
00154     * No communication is done during this call.  One process can make the call
00155     * for all parts, or many processes can make the call.  Zoltan checks the
00156     * consistency of the information provided.
00157     */
00158 
00159   void setPartSizes(int len, int *global_part_id, float *part_size);
00160 
00161   /*
00162    * Free the memory allocated to store part sizes.
00163    */
00164   void clearPartSizes();
00165 
00177   void partition(bool force_repartitioning=false);
00178 
00179   virtual void compute(bool forceRecomputing=false);
00180 
00181   int numElemsInPart(int part) const {
00182     return (numElemsWithProperty(part));
00183   }
00184 
00185   void elemsInPart(int part, int* elementList, int len) const {
00186     elemsWithProperty(part, elementList, len);
00187   }
00188 
00199   Teuchos::RCP<Epetra_Map> createNewMap();
00200 
00201 private:
00202   int *partGIDs;
00203   float *partSizes;
00204   int numPartSizes;
00205 
00206 };//class Partitioner
00207 
00208 }//namespace Epetra
00209 }//namespace Isorropia
00210 
00211 #endif //HAVE_EPETRA
00212 
00213 #endif
00214