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 
00102   virtual ~Partitioner();
00103 
00104    /* Set the relative number of objects in each part.  The default is to
00105     * evenly divide objects across parts.  The numbers can be fractions of
00106     * one, or whole numbers.  Zoltan adds the values supplied and takes the sizes
00107     * as proportional to that whole.
00108     *
00109     * We make a copy of id and size lists.
00110     *
00111     * Caller should supply either global part IDs or local part IDs.
00112     * Part IDs are integers beginning at zero for the first part.
00113     *
00114     * No communication is done during this call.  One process can make the call
00115     * for all parts, or many processes can make the call.  Zoltan checks the
00116     * consistency of the information provided.
00117     */
00118 
00119   void setPartSizes(int len, int *global_part_id, float *part_size);
00120 
00121   /*
00122    * Free the memory allocated to store part sizes.
00123    */
00124   void clearPartSizes();
00125 
00137   void partition(bool force_repartitioning=false);
00138 
00139   virtual void compute(bool forceRecomputing=false);
00140 
00141   int numElemsInPart(int part) const {
00142     return (numElemsWithProperty(part));
00143   }
00144 
00145   void elemsInPart(int part, int* elementList, int len) const {
00146     elemsWithProperty(part, elementList, len);
00147   }
00148 
00159   Teuchos::RCP<Epetra_Map> createNewMap();
00160 
00161 private:
00162   int *partGIDs;
00163   float *partSizes;
00164   int numPartSizes;
00165 
00166 };//class Partitioner
00167 
00168 }//namespace Epetra
00169 }//namespace Isorropia
00170 
00171 #endif //HAVE_EPETRA
00172 
00173 #endif
00174