| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// ShyLU: Scalable Hybrid LU Preconditioner and Solver |
| 4 |
// |
| 5 |
// Copyright 2011 NTESS and the ShyLU contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#include <mpi.h> |
| 11 |
|
| 12 |
#include "Galeri_XpetraProblemFactory.hpp" |
| 13 |
#include "Galeri_XpetraMatrixTypes.hpp" |
| 14 |
#include "Galeri_XpetraParameters.hpp" |
| 15 |
#include "Galeri_XpetraUtils.hpp" |
| 16 |
#include "Galeri_XpetraMaps.hpp" |
| 17 |
|
| 18 |
#include <Teuchos_CommandLineProcessor.hpp> |
| 19 |
#include <Teuchos_XMLParameterListCoreHelpers.hpp> |
| 20 |
#include <Teuchos_StackedTimer.hpp> |
| 21 |
|
| 22 |
#include <Xpetra_CrsMatrixWrap.hpp> |
| 23 |
#include <Xpetra_DefaultPlatform.hpp> |
| 24 |
#include <Xpetra_MapFactory.hpp> |
| 25 |
#include <Xpetra_MatrixFactory.hpp> |
| 26 |
|
| 27 |
#ifdef HAVE_XPETRA_EPETRA |
| 28 |
#include <Xpetra_EpetraCrsMatrix.hpp> |
| 29 |
#endif |
| 30 |
|
| 31 |
#include "FROSch_Tools_def.hpp" |
| 32 |
|
| 33 |
|
| 34 |
using UN = unsigned; |
| 35 |
using SC = double; |
| 36 |
using LO = int; |
| 37 |
using GO = FROSch::DefaultGlobalOrdinal; |
| 38 |
using NO = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType; |
| 39 |
|
| 40 |
using namespace std; |
| 41 |
using namespace Teuchos; |
| 42 |
using namespace Xpetra; |
| 43 |
|
| 44 |
using namespace std; |
| 45 |
|
| 46 |
int main(int argc, char *argv[]) |
| 47 |
{ |
| 48 |
oblackholestream blackhole; |
| 49 |
GlobalMPISession mpiSession(&argc,&argv,&blackhole); |
| 50 |
|
| 51 |
RCP<const Comm<int> > CommWorld = DefaultPlatform::getDefaultPlatform().getComm(); |
| 52 |
|
| 53 |
CommandLineProcessor My_CLP; |
| 54 |
|
| 55 |
RCP<FancyOStream> out = VerboseObjectBase::getDefaultOStream(); |
| 56 |
|
| 57 |
bool useepetra = true; |
| 58 |
My_CLP.setOption("USEEPETRA","USETPETRA",&useepetra,"Use Epetra infrastructure for the linear algebra."); |
| 59 |
|
| 60 |
My_CLP.recogniseAllOptions(true); |
| 61 |
My_CLP.throwExceptions(false); |
| 62 |
CommandLineProcessor::EParseCommandLineReturn parseReturn = My_CLP.parse(argc,argv); |
| 63 |
if (parseReturn == CommandLineProcessor::PARSE_HELP_PRINTED) { |
| 64 |
return(EXIT_SUCCESS); |
| 65 |
} |
| 66 |
|
| 67 |
CommWorld->barrier(); |
| 68 |
RCP<StackedTimer> stackedTimer = rcp(new StackedTimer("Import Tpetra Test")); |
| 69 |
TimeMonitor::setStackedTimer(stackedTimer); |
| 70 |
|
| 71 |
UnderlyingLib xpetraLib = UseTpetra; |
| 72 |
if (useepetra) { |
| 73 |
xpetraLib = UseEpetra; |
| 74 |
} else { |
| 75 |
xpetraLib = UseTpetra; |
| 76 |
} |
| 77 |
|
| 78 |
assert(CommWorld->getSize()==8); |
| 79 |
|
| 80 |
CommWorld->barrier(); if (CommWorld->getRank()==0) cout << "#############\n# Assembly #\n#############\n" << endl; |
| 81 |
|
| 82 |
ParameterList GaleriList; |
| 83 |
GaleriList.set("nx",GO(8)); |
| 84 |
GaleriList.set("ny",GO(8)); |
| 85 |
GaleriList.set("nz",GO(8)); |
| 86 |
GaleriList.set("mx",GO(2)); |
| 87 |
GaleriList.set("my",GO(2)); |
| 88 |
GaleriList.set("mz",GO(2)); |
| 89 |
|
| 90 |
RCP<const Map<LO,GO,NO> > uniqueMap = Galeri::Xpetra::CreateMap<LO,GO,NO>(xpetraLib,"Cartesian3D",CommWorld,GaleriList); |
| 91 |
RCP<Galeri::Xpetra::Problem<Map<LO,GO,NO>,CrsMatrixWrap<SC,LO,GO,NO>,MultiVector<SC,LO,GO,NO> > > Problem = Galeri::Xpetra::BuildProblem<SC,LO,GO,Map<LO,GO,NO>,CrsMatrixWrap<SC,LO,GO,NO>,MultiVector<SC,LO,GO,NO> >("Laplace3D",uniqueMap,GaleriList); |
| 92 |
RCP<Matrix<SC,LO,GO,NO> > K = Problem->BuildMatrix(); |
| 93 |
|
| 94 |
RCP<const Matrix<SC,LO,GO,NO> > tmpMatrix; |
| 95 |
RCP<const Map<LO,GO,NO> > overlappingMap = MapFactory<LO,GO,NO>::Build(uniqueMap,1); |
| 96 |
FROSch::ExtendOverlapByOneLayer<SC,LO,GO,NO>(K.getConst(),overlappingMap,tmpMatrix,overlappingMap); |
| 97 |
|
| 98 |
K = MatrixFactory<SC,LO,GO,NO>::Build(overlappingMap,tmpMatrix->getGlobalMaxNumRowEntries()); |
| 99 |
|
| 100 |
CommWorld->barrier(); if (CommWorld->getRank()==0) cout << "#############\n# Performing Import #\n#############\n" << endl; |
| 101 |
RCP<Export<LO,GO,NO> > gather = ExportFactory<LO,GO,NO>::Build(overlappingMap,uniqueMap); |
| 102 |
K->doImport(*tmpMatrix,*gather,ADD); |
| 103 |
|
| 104 |
CommWorld->barrier(); if (CommWorld->getRank()==0) cout << "\n#############\n# Finished! #\n#############" << endl; |
| 105 |
|
| 106 |
CommWorld->barrier(); |
| 107 |
stackedTimer->stop("Import Tpetra Test"); |
| 108 |
StackedTimer::OutputOptions options; |
| 109 |
options.output_fraction = options.output_histogram = options.output_minmax = true; |
| 110 |
stackedTimer->report(*out,CommWorld,options); |
| 111 |
|
| 112 |
return(EXIT_SUCCESS); |
| 113 |
} |