Isorropia: Partitioning, Load Balancing and more
Isorropia_EpetraPartitioner.hpp
Go to the documentation of this file.
00001 //@HEADER
00002 //************************************************************************
00003 //
00004 //              Isorropia: Partitioning and Load Balancing Package
00005 //                Copyright (2006) Sandia Corporation
00006 //
00007 //Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 //license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 //************************************************************************
00038 //@HEADER
00039 
00040 #ifndef _Isorropia_EpetraPartitioner_hpp_
00041 #define _Isorropia_EpetraPartitioner_hpp_
00042 
00043 
00092 #include <Isorropia_ConfigDefs.hpp>
00093 #include <Teuchos_RCP.hpp>
00094 #include <Teuchos_ParameterList.hpp>
00095 
00096 #include <Isorropia_EpetraCostDescriber.hpp>
00097 #include <Isorropia_EpetraOperator.hpp>
00098 #include <Isorropia_Partitioner.hpp>
00099 
00100 #ifdef HAVE_EPETRA
00101 class Epetra_Map;
00102 class Epetra_BlockMap;
00103 class Epetra_Import;
00104 class Epetra_Vector;
00105 class Epetra_MultiVector;
00106 class Epetra_CrsGraph;
00107 class Epetra_CrsMatrix;
00108 class Epetra_RowMatrix;
00109 class Epetra_LinearProblem;
00110 
00111 namespace Isorropia {
00112 
00113 namespace Epetra {
00114   class CostDescriber;
00115 
00122 class Partitioner : public Isorropia::Partitioner, public Isorropia::Epetra::Operator  {
00123 public:
00124   
00127   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
00128               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),  
00129               bool compute_partitioning_now=true);
00130 
00134   Partitioner(const Epetra_CrsGraph *inputGraph,
00135               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),  
00136               bool compute_partitioning_now=true);
00137 
00141   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
00142               Teuchos::RCP<CostDescriber> costs,
00143               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00144               bool compute_partitioning_now=true);
00145 
00149   Partitioner(const Epetra_CrsGraph *inputGraph,
00150               CostDescriber* costs,
00151               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00152               bool compute_partitioning_now=true);
00153 
00157   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
00158               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00159               bool compute_partitioning_now=true);
00160 
00164   Partitioner(const Epetra_RowMatrix *inputMatrix,
00165               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00166               bool compute_partitioning_now=true);
00167 
00171   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
00172               Teuchos::RCP<CostDescriber> costs,
00173               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00174               bool compute_partitioning_now=true);
00175 
00179   Partitioner(const Epetra_RowMatrix *inputMatrix,
00180               CostDescriber *costs,
00181               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00182               bool compute_partitioning_now=true);
00183 
00187   Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
00188               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00189               bool compute_partitioning_now=true);
00190 
00194   Partitioner(const Epetra_MultiVector *coords,
00195               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00196               bool compute_partitioning_now=true);
00197 
00201   Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
00202               Teuchos::RCP<const Epetra_MultiVector> weights,
00203               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00204               bool compute_partitioning_now=true);
00205 
00208   Partitioner(const Epetra_MultiVector *coords,
00209               const Epetra_MultiVector *weights,
00210               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00211               bool compute_partitioning_now=true);
00212 
00215   Partitioner(Teuchos::RCP<const Epetra_BlockMap> inputMap,
00216               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00217               bool compute_partitioning_now=true);
00218 
00221   Partitioner(const Epetra_BlockMap *inputMap,
00222               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00223               bool compute_partitioning_now=true);
00224 
00227   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
00228         Teuchos::RCP<const Epetra_MultiVector> coords,
00229               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00230               bool compute_partitioning_now=true);
00231 
00234   Partitioner(const Epetra_CrsGraph *inputGraph,
00235         const Epetra_MultiVector *coords,
00236               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00237               bool compute_partitioning_now=true);
00238   
00239 
00242   Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
00243               Teuchos::RCP<CostDescriber> costs,
00244         Teuchos::RCP<const Epetra_MultiVector> coords,
00245               Teuchos::RCP<const Epetra_MultiVector> weights,
00246               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00247               bool compute_partitioning_now=true);
00248 
00251   Partitioner(const Epetra_CrsGraph *inputGraph,
00252               CostDescriber *costs,
00253         const Epetra_MultiVector *coords,
00254               const Epetra_MultiVector *weights,
00255               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00256               bool compute_partitioning_now=true);
00257 
00260   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
00261         Teuchos::RCP<const Epetra_MultiVector> coords,
00262               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00263               bool compute_partitioning_now=true);
00264 
00267   Partitioner(const Epetra_RowMatrix *inputMatrix,
00268         const Epetra_MultiVector *coords,
00269               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00270               bool compute_partitioning_now=true);
00271 
00274   Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
00275               Teuchos::RCP<CostDescriber> costs,
00276         Teuchos::RCP<const Epetra_MultiVector> coords,
00277               Teuchos::RCP<const Epetra_MultiVector> weights,
00278               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00279               bool compute_partitioning_now=true);
00280 
00283   Partitioner(const Epetra_RowMatrix *inputMatrix,
00284               CostDescriber *costs,
00285         const Epetra_MultiVector *coords,
00286               const Epetra_MultiVector *weights,
00287               const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
00288               bool compute_partitioning_now=true);
00289 
00290 
00294   virtual ~Partitioner();
00295 
00296    /* @ingroup partitioning_grp
00297     * Set the relative number of objects in each part.  The default is to
00298     * evenly divide objects across parts.  The numbers can be fractions of
00299     * one, or whole numbers.  Zoltan adds the values supplied and takes the sizes
00300     * as proportional to that whole.
00301     *
00302     * We make a copy of id and size lists.
00303     *
00304     * Caller should supply either global part IDs or local part IDs.
00305     * Part IDs are integers beginning at zero for the first part.
00306     *
00307     * No communication is done during this call.  One process can make the call
00308     * for all parts, or many processes can make the call.  Zoltan checks the
00309     * consistency of the information provided.
00310     */
00311 
00312   void setPartSizes(int len, int *global_part_id, float *part_size);
00313 
00314   /* @ingroup partitioning_grp
00315    * Free the memory allocated to store part sizes.
00316    */
00317   void clearPartSizes();
00318 
00331   void partition(bool force_repartitioning=false);
00332 
00335   virtual void compute(bool forceRecomputing=false);
00336 
00339   int numElemsInPart(int part) const {
00340     return (numElemsWithProperty(part));
00341   }
00342 
00345   void elemsInPart(int part, int* elementList, int len) const {
00346     elemsWithProperty(part, elementList, len);
00347   }
00348 
00360   Teuchos::RCP<Epetra_Map> createNewMap();
00361 
00373   void createNewMap(Epetra_Map *&outputMap);
00374 
00375   int printZoltanMetrics() { return printMetrics; }
00376 
00377 private:
00378   int *partGIDs;
00379   float *partSizes;
00380   int numPartSizes;
00381   int printMetrics;
00382 
00383 };//class Partitioner
00384 
00385 }//namespace Epetra
00386 }//namespace Isorropia
00387 
00388 #endif //HAVE_EPETRA
00389 
00390 #endif
00391