| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Trilinos: An Object-Oriented Solver Framework |
| 4 |
// |
| 5 |
// Copyright 2001-2024 NTESS and the Trilinos contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#include <EpetraExt_Isorropia_CrsGraph.h> |
| 11 |
#include <Isorropia_Epetra.hpp> |
| 12 |
|
| 13 |
#include <Epetra_CrsGraph.h> |
| 14 |
#include <Epetra_Map.h> |
| 15 |
#include <Epetra_Comm.h> |
| 16 |
|
| 17 |
namespace EpetraExt { |
| 18 |
|
| 19 |
Isorropia_CrsGraph:: |
| 20 |
~Isorropia_CrsGraph() |
| 21 |
{ |
| 22 |
} |
| 23 |
|
| 24 |
Isorropia_CrsGraph::NewTypeRef |
| 25 |
Isorropia_CrsGraph:: |
| 26 |
operator()( OriginalTypeRef orig ) |
| 27 |
{ |
| 28 |
origObj_ = &orig; |
| 29 |
|
| 30 |
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES |
| 31 |
const Epetra_BlockMap & OldMap = orig.RowMap(); |
| 32 |
if(OldMap.GlobalIndicesLongLong()) { |
| 33 |
// There is nothing we can do since Isorropia does not support Epetra 64-bit integers, just create a copy of the original graph. |
| 34 |
NewGraph_ = Teuchos::rcp( new Epetra_CrsGraph( orig ) ); |
| 35 |
} |
| 36 |
else |
| 37 |
#endif |
| 38 |
if (orig.NumGlobalRows() == 0) |
| 39 |
{ |
| 40 |
// If there is nothing to do, just create a copy of the original empty graph. |
| 41 |
NewGraph_ = Teuchos::rcp( new Epetra_CrsGraph( orig ) ); |
| 42 |
} |
| 43 |
else { |
| 44 |
try { |
| 45 |
NewGraph_ = |
| 46 |
Teuchos::rcp( Isorropia::Epetra::createBalancedCopy( orig, partitionList_) ); |
| 47 |
} |
| 48 |
catch(std::exception& e) { |
| 49 |
std::cout << "Isorropia::create_balanced_copy threw exception '" << e.what() << "' on proc " << orig.Comm().MyPID() << std::endl; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
// Set the raw pointer to the new graph. |
| 54 |
// This should be OK, since the destructor does not attempt to destroy the raw pointer. |
| 55 |
newObj_ = NewGraph_.get(); |
| 56 |
|
| 57 |
return *NewGraph_; |
| 58 |
} |
| 59 |
|
| 60 |
} // namespace EpetraExt |
| 61 |
|