Isorropia: Partitioning, Load Balancing and more
Isorropia_Epetra.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_Epetra_hpp_
00041 #define _Isorropia_Epetra_hpp_
00042 
00043 #include <Isorropia_ConfigDefs.hpp>
00044 #include <Teuchos_RCP.hpp>
00045 #include <Teuchos_ParameterList.hpp>
00046 
00047 #ifdef HAVE_EPETRA
00048 class Epetra_Comm;
00049 class Epetra_Map;
00050 class Epetra_BlockMap;
00051 class Epetra_Import;
00052 class Epetra_Vector;
00053 class Epetra_MultiVector;
00054 class Epetra_RowMatrix;
00055 class Epetra_CrsGraph;
00056 class Epetra_CrsMatrix;
00057 class Epetra_LinearProblem;
00058 #endif
00059 
00060 namespace Isorropia {
00061 
00062 namespace Epetra {
00063 
00064   class Partitioner;
00065   class CostDescriber;
00066 
00067 #ifdef HAVE_EPETRA
00068 
00072 Epetra_MultiVector *
00073 createBalancedCopy(const Epetra_MultiVector& input_vector);
00074 
00078 Epetra_MultiVector *
00079 createBalancedCopy(const Epetra_MultiVector& input_vector,
00080                      const Teuchos::ParameterList& paramlist);
00081 
00085 Epetra_CrsGraph *
00086 createBalancedCopy(const Epetra_CrsGraph& input_graph);
00087 
00091 Epetra_CrsGraph *
00092 createBalancedCopy(const Epetra_CrsGraph& input_graph,
00093                      const Teuchos::ParameterList& paramlist);
00094 
00098 Epetra_CrsMatrix *
00099 createBalancedCopy(const Epetra_CrsMatrix& input_matrix);
00100 
00104 Epetra_CrsMatrix *
00105 createBalancedCopy(const Epetra_CrsMatrix& input_matrix,
00106                      const Teuchos::ParameterList& paramlist);
00107 
00112 Epetra_LinearProblem *
00113 createBalancedCopy(const Epetra_LinearProblem & input_problem);
00114 
00119 Epetra_LinearProblem *
00120 createBalancedCopy(const Epetra_LinearProblem & input_problem,
00121                      const Teuchos::ParameterList& paramlist);
00122 
00130 // Teuchos::RCP<Epetra_Map>
00131 // create_target_map(const Epetra_Comm& comm, Partitioner& partitioner);
00132 
00151 __deprecated Teuchos::RCP<Epetra_CrsMatrix>
00152   create_balanced_copy(const Epetra_CrsMatrix& input_matrix);
00153 
00170 __deprecated Teuchos::RCP<Epetra_CrsMatrix>
00171   create_balanced_copy(const Epetra_CrsMatrix& input_matrix,
00172                        const Epetra_Vector &row_weights);
00173 
00199 __deprecated Teuchos::RCP<Epetra_CrsMatrix>
00200   create_balanced_copy(const Epetra_CrsMatrix& input_matrix,
00201                      const Teuchos::ParameterList& paramlist);
00202 
00203 
00204 
00235 __deprecated Teuchos::RCP<Epetra_CrsMatrix>
00236   create_balanced_copy(const Epetra_CrsMatrix& input_matrix,
00237                      CostDescriber &costs,
00238                      const Teuchos::ParameterList& paramlist);
00239 
00258 __deprecated Teuchos::RCP<Epetra_RowMatrix>
00259   create_balanced_copy(const Epetra_RowMatrix& input_matrix);
00260 
00277 __deprecated Teuchos::RCP<Epetra_RowMatrix>
00278   create_balanced_copy(const Epetra_RowMatrix& input_matrix,
00279                        const Epetra_Vector &row_weights);
00280 
00307 __deprecated Teuchos::RCP<Epetra_RowMatrix>
00308   create_balanced_copy(const Epetra_RowMatrix& input_matrix,
00309                      const Teuchos::ParameterList& paramlist);
00310 
00342 __deprecated Teuchos::RCP<Epetra_RowMatrix>
00343   create_balanced_copy(const Epetra_RowMatrix& input_matrix,
00344                      CostDescriber &costs,
00345                      const Teuchos::ParameterList& paramlist);
00346 
00365 __deprecated Teuchos::RCP<Epetra_CrsGraph>
00366   create_balanced_copy(const Epetra_CrsGraph& input_graph);
00367 
00385 __deprecated Teuchos::RCP<Epetra_CrsGraph>
00386   create_balanced_copy(const Epetra_CrsGraph& input_matrix,
00387                        const Epetra_Vector &row_weights);
00388 
00414 __deprecated Teuchos::RCP<Epetra_CrsGraph>
00415   create_balanced_copy(const Epetra_CrsGraph& input_graph,
00416                      const Teuchos::ParameterList& paramlist);
00417 
00448 __deprecated Teuchos::RCP<Epetra_CrsGraph>
00449   create_balanced_copy(const Epetra_CrsGraph& input_graph,
00450                      CostDescriber &costs,
00451                      const Teuchos::ParameterList& paramlist);
00452 
00472 __deprecated Teuchos::RCP<Epetra_LinearProblem>
00473   create_balanced_copy(const Epetra_LinearProblem & input_problem);
00474 
00491 __deprecated Teuchos::RCP<Epetra_LinearProblem>
00492   create_balanced_copy(const Epetra_LinearProblem& input_matrix,
00493                        const Epetra_Vector &row_weights);
00494 
00521 __deprecated Teuchos::RCP<Epetra_LinearProblem>
00522   create_balanced_copy(const Epetra_LinearProblem& input_problem,
00523                      const Teuchos::ParameterList& paramlist);
00524 
00555 __deprecated Teuchos::RCP<Epetra_LinearProblem>
00556   create_balanced_copy(const Epetra_LinearProblem& input_problem,
00557                      CostDescriber &costs,
00558                      const Teuchos::ParameterList& paramlist);
00559 
00560 __deprecated Teuchos::RCP<Epetra_MultiVector>
00561 create_balanced_copy(const Epetra_MultiVector &coords,
00562                    const Teuchos::ParameterList& paramlist);
00563 
00564 __deprecated Teuchos::RCP<Epetra_MultiVector>
00565 create_balanced_copy(const Epetra_MultiVector &coords,
00566                      const Epetra_MultiVector &weights,
00567                    const Teuchos::ParameterList& paramlist);
00568 
00569 
00570 __deprecated Teuchos::RCP<Epetra_MultiVector>
00571 create_balanced_copy(const Epetra_MultiVector &coords);
00572 
00573 __deprecated Teuchos::RCP<Epetra_MultiVector>
00574 create_balanced_copy(const Epetra_MultiVector &coords,
00575                      const Epetra_MultiVector &weights);
00576 
00594 Teuchos::RCP<Epetra_CrsMatrix>
00595   redistribute_rows(const Epetra_CrsMatrix& input_matrix,
00596                     const Epetra_Map& target_rowmap,
00597                     Epetra_Import* importer=0);
00598 
00616 Teuchos::RCP<Epetra_CrsMatrix>
00617   redistribute_rows(const Epetra_RowMatrix& input_matrix,
00618                     const Epetra_Map& target_rowmap,
00619                     Epetra_Import* importer=0);
00620 
00633 Teuchos::RCP<Epetra_CrsGraph>
00634   redistribute_rows(const Epetra_CrsGraph& input_graph,
00635                     const Epetra_Map& target_rowmap,
00636                     Epetra_Import* importer=0);
00637 
00650 Teuchos::RCP<Epetra_MultiVector>
00651   redistribute(const Epetra_MultiVector& input,
00652                const Epetra_BlockMap& target_map,
00653                Epetra_Import* importer=0);
00654 
00667 Teuchos::RCP<Epetra_Vector>
00668   redistribute(const Epetra_Vector& input,
00669                const Epetra_Map& target_map,
00670                Epetra_Import* importer=0);
00671 
00672 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00673 
00678 Epetra_MultiVector* create_row_weights_nnz(const Epetra_RowMatrix& input_matrix);
00679 
00684 Epetra_MultiVector* create_row_weights_nnz(const Epetra_CrsGraph& input_graph);
00685 
00686 Epetra_MultiVector* create_unit_weights(const Epetra_MultiVector& input_coords);
00687 
00688 
00713 int
00714 repartition(const Epetra_BlockMap& input_map,
00715       const Epetra_MultiVector& weights,
00716       std::vector<int>& myNewElements,
00717       int& exportsSize,
00718       std::vector<int>& imports);
00719 
00728 void gather_all_proc_global_offsets(const Epetra_BlockMap& blkmap,
00729                                     std::vector<int>& all_proc_offsets);
00730 
00731 
00740 double compute_imbalance(int nprocs, std::vector<int> &offsets, 
00741                          double *wgts, double target);
00742 
00743 #endif //DOXYGEN_SHOULD_SKIP_THIS
00744 #endif //HAVE_EPETRA
00745 
00746 }//namespace Epetra
00747 }//namespace Isorropia
00748 
00749 #endif
00750