| 1 |
//@HEADER |
| 2 |
//************************************************************************ |
| 3 |
// |
| 4 |
// Isorropia: Partitioning and Load Balancing Package |
| 5 |
// Copyright (2006) Sandia Corporation |
| 6 |
// |
| 7 |
//Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive |
| 8 |
//license for use of this work by or on behalf of the U.S. Government. |
| 9 |
// |
| 10 |
// Redistribution and use in source and binary forms, with or without |
| 11 |
// modification, are permitted provided that the following conditions are |
| 12 |
// met: |
| 13 |
// |
| 14 |
// 1. Redistributions of source code must retain the above copyright |
| 15 |
// notice, this list of conditions and the following disclaimer. |
| 16 |
// |
| 17 |
// 2. Redistributions in binary form must reproduce the above copyright |
| 18 |
// notice, this list of conditions and the following disclaimer in the |
| 19 |
// documentation and/or other materials provided with the distribution. |
| 20 |
// |
| 21 |
// 3. Neither the name of the Corporation nor the names of the |
| 22 |
// contributors may be used to endorse or promote products derived from |
| 23 |
// this software without specific prior written permission. |
| 24 |
// |
| 25 |
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY |
| 26 |
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 27 |
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 28 |
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE |
| 29 |
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 30 |
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 31 |
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 32 |
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 33 |
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 34 |
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 35 |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 |
// |
| 37 |
//************************************************************************ |
| 38 |
//@HEADER |
| 39 |
|
| 40 |
#include <Isorropia_EpetraOrderer.hpp> |
| 41 |
#ifdef HAVE_ISORROPIA_ZOLTAN |
| 42 |
#include <Isorropia_EpetraZoltanLib.hpp> |
| 43 |
#endif |
| 44 |
#include <Isorropia_Exception.hpp> |
| 45 |
#include <Isorropia_Epetra.hpp> |
| 46 |
#include <Isorropia_EpetraCostDescriber.hpp> |
| 47 |
|
| 48 |
#include <Teuchos_RCP.hpp> |
| 49 |
#include <Teuchos_ParameterList.hpp> |
| 50 |
|
| 51 |
#ifdef HAVE_EPETRA |
| 52 |
#include <Epetra_Comm.h> |
| 53 |
#include <Epetra_Map.h> |
| 54 |
#include <Epetra_Import.h> |
| 55 |
#include <Epetra_Vector.h> |
| 56 |
#include <Epetra_MultiVector.h> |
| 57 |
#include <Epetra_CrsGraph.h> |
| 58 |
#include <Epetra_CrsMatrix.h> |
| 59 |
#include <Epetra_LinearProblem.h> |
| 60 |
|
| 61 |
#endif |
| 62 |
|
| 63 |
#include <cstring> |
| 64 |
#include <iostream> |
| 65 |
#include <sstream> |
| 66 |
#include <string> |
| 67 |
#include <ctype.h> |
| 68 |
|
| 69 |
namespace Isorropia { |
| 70 |
|
| 71 |
#ifdef HAVE_EPETRA |
| 72 |
|
| 73 |
namespace Epetra { |
| 74 |
|
| 75 |
|
| 76 |
//////////////////////////////////////////////////////////////////////////////// |
| 77 |
//////////////////////////////////////////////////////////////////////////////// |
| 78 |
Orderer::Orderer(Teuchos::RCP<const Epetra_CrsGraph> input_graph, |
| 79 |
const Teuchos::ParameterList& paramlist, |
| 80 |
bool compute_now): |
| 81 |
Operator (input_graph, paramlist, 0) { |
| 82 |
#ifdef HAVE_ISORROPIA_ZOLTAN |
| 83 |
lib_ = Teuchos::rcp(new ZoltanLibClass(input_graph, Library::graph_input_)); |
| 84 |
#else /* HAVE_ISORROPIA_ZOLTAN */ |
| 85 |
throw Isorropia::Exception("Ordering only available in Zoltan"); |
| 86 |
return ; |
| 87 |
#endif /* HAVE_ISORROPIA_ZOLTAN */ |
| 88 |
|
| 89 |
if (compute_now) |
| 90 |
order(true); |
| 91 |
} |
| 92 |
//////////////////////////////////////////////////////////////////////////////// |
| 93 |
|
| 94 |
//////////////////////////////////////////////////////////////////////////////// |
| 95 |
//////////////////////////////////////////////////////////////////////////////// |
| 96 |
Orderer::Orderer(const Epetra_CrsGraph *input_graph, |
| 97 |
const Teuchos::ParameterList& paramlist, |
| 98 |
bool compute_now): |
| 99 |
Operator (Teuchos::RCP<const Epetra_CrsGraph>(input_graph,false), paramlist, 0) |
| 100 |
{ |
| 101 |
#ifdef HAVE_ISORROPIA_ZOLTAN |
| 102 |
lib_ = Teuchos::rcp(new ZoltanLibClass(input_graph_, Library::graph_input_)); |
| 103 |
#else /* HAVE_ISORROPIA_ZOLTAN */ |
| 104 |
throw Isorropia::Exception("Ordering only available in Zoltan"); |
| 105 |
return ; |
| 106 |
#endif /* HAVE_ISORROPIA_ZOLTAN */ |
| 107 |
|
| 108 |
if (compute_now) |
| 109 |
order(true); |
| 110 |
} |
| 111 |
//////////////////////////////////////////////////////////////////////////////// |
| 112 |
|
| 113 |
//////////////////////////////////////////////////////////////////////////////// |
| 114 |
//////////////////////////////////////////////////////////////////////////////// |
| 115 |
Orderer::Orderer(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, |
| 116 |
const Teuchos::ParameterList& paramlist, |
| 117 |
bool compute_now): |
| 118 |
Operator (input_matrix, paramlist, 0) { |
| 119 |
#ifdef HAVE_ISORROPIA_ZOLTAN |
| 120 |
lib_ = Teuchos::rcp(new ZoltanLibClass(input_matrix, Library::graph_input_)); |
| 121 |
#else /* HAVE_ISORROPIA_ZOLTAN */ |
| 122 |
throw Isorropia::Exception("Ordering only available in Zoltan"); |
| 123 |
return ; |
| 124 |
#endif /* HAVE_ISORROPIA_ZOLTAN */ |
| 125 |
|
| 126 |
if (compute_now) |
| 127 |
order(true); |
| 128 |
} |
| 129 |
//////////////////////////////////////////////////////////////////////////////// |
| 130 |
|
| 131 |
//////////////////////////////////////////////////////////////////////////////// |
| 132 |
//////////////////////////////////////////////////////////////////////////////// |
| 133 |
Orderer::Orderer(const Epetra_RowMatrix *input_matrix, |
| 134 |
const Teuchos::ParameterList& paramlist, |
| 135 |
bool compute_now): |
| 136 |
Operator (Teuchos::RCP<const Epetra_RowMatrix>(input_matrix,false), paramlist, 0) |
| 137 |
{ |
| 138 |
#ifdef HAVE_ISORROPIA_ZOLTAN |
| 139 |
lib_ = Teuchos::rcp(new ZoltanLibClass(input_matrix_, Library::graph_input_)); |
| 140 |
#else /* HAVE_ISORROPIA_ZOLTAN */ |
| 141 |
throw Isorropia::Exception("Ordering only available in Zoltan"); |
| 142 |
return ; |
| 143 |
#endif /* HAVE_ISORROPIA_ZOLTAN */ |
| 144 |
|
| 145 |
if (compute_now) |
| 146 |
order(true); |
| 147 |
} |
| 148 |
//////////////////////////////////////////////////////////////////////////////// |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
//////////////////////////////////////////////////////////////////////////////// |
| 153 |
//////////////////////////////////////////////////////////////////////////////// |
| 154 |
void Orderer::order(bool force_ordering) |
| 155 |
{ |
| 156 |
if (alreadyComputed() && !force_ordering) |
| 157 |
return; |
| 158 |
lib_->order(paramlist_.sublist("ZOLTAN"), properties_); |
| 159 |
operation_already_computed_ = true; |
| 160 |
} |
| 161 |
//////////////////////////////////////////////////////////////////////////////// |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
} // namespace EPETRA |
| 166 |
|
| 167 |
#endif //HAVE_EPETRA |
| 168 |
|
| 169 |
}//namespace Isorropia |
| 170 |
|