// @HEADER // ***************************************************************************** // ShyLU: Scalable Hybrid LU Preconditioner and Solver // // Copyright 2011 NTESS and the ShyLU contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #include "mpi.h" #include "Galeri_XpetraProblemFactory.hpp" #include "Galeri_XpetraMatrixTypes.hpp" #include "Galeri_XpetraParameters.hpp" #include "Galeri_XpetraUtils.hpp" #include "Galeri_XpetraMaps.hpp" #include #include "Teuchos_CommandLineProcessor.hpp" #include #include #include #include "Xpetra_CrsMatrixWrap.hpp" #include "Xpetra_CrsMatrix.hpp" #include #include #include using UN = unsigned; using SC = double; using LO = int; using GO = FROSch::DefaultGlobalOrdinal; using NO = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType; int main(int argc, char *argv[]) { using namespace std; using namespace Teuchos; using namespace Xpetra; using namespace FROSch; oblackholestream blackhole; GlobalMPISession mpiSession(&argc,&argv,&blackhole); RCP > CommWorld = DefaultPlatform::getDefaultPlatform().getComm(); CommandLineProcessor My_CLP; RCP out = VerboseObjectBase::getDefaultOStream(); int M = 4; My_CLP.setOption("M",&M,"H / h."); int Dimension = 3; My_CLP.setOption("DIM",&Dimension,"Dimension."); bool useepetra = true; My_CLP.setOption("USEEPETRA","USETPETRA",&useepetra,"Use Epetra infrastructure for the linear algebra."); My_CLP.recogniseAllOptions(true); My_CLP.throwExceptions(false); CommandLineProcessor::EParseCommandLineReturn parseReturn = My_CLP.parse(argc,argv); if (parseReturn == CommandLineProcessor::PARSE_HELP_PRINTED) { return(EXIT_SUCCESS); } CommWorld->barrier(); RCP stackedTimer = rcp(new StackedTimer("Interface Partition of Unity Test")); TimeMonitor::setStackedTimer(stackedTimer); int N=4; int color=1; if (Dimension == 2) { N = (int) (pow(CommWorld->getSize(),1/2.) + 100*numeric_limits::epsilon()); // 1/H if (CommWorld->getRank()getSize(),1/3.) + 100*numeric_limits::epsilon()); // 1/H if (CommWorld->getRank() > comm = CommWorld->split(color,CommWorld->getRank()); if (color==0) { comm->barrier(); if (comm->getRank()==0) cout << "#############\n# Assembly #\n#############\n" << endl; ParameterList GaleriList; GaleriList.set("nx", GO(N*M)); GaleriList.set("ny", GO(N*M)); GaleriList.set("nz", GO(N*M)); GaleriList.set("mx", GO(N)); GaleriList.set("my", GO(N)); GaleriList.set("mz", GO(N)); RCP > UniqueMap; RCP > Coordinates; RCP > K; if (Dimension==2) { UniqueMap = Galeri::Xpetra::CreateMap(xpetraLib,"Cartesian2D",comm,GaleriList); // RCP fancy = fancyOStream(rcpFromRef(cout)); nodeMap->describe(*fancy,VERB_EXTREME); Coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates,MultiVector >("2D",UniqueMap,GaleriList); RCP,CrsMatrixWrap,MultiVector > > Problem = Galeri::Xpetra::BuildProblem,CrsMatrixWrap,MultiVector >("Laplace2D",UniqueMap,GaleriList); K = Problem->BuildMatrix(); } else if (Dimension==3) { UniqueMap = Galeri::Xpetra::CreateMap(xpetraLib,"Cartesian3D",comm,GaleriList); // RCP fancy = fancyOStream(rcpFromRef(cout)); nodeMap->describe(*fancy,VERB_EXTREME); Coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates,MultiVector >("3D",UniqueMap,GaleriList); RCP,CrsMatrixWrap,MultiVector > > Problem = Galeri::Xpetra::BuildProblem,CrsMatrixWrap,MultiVector >("Laplace3D",UniqueMap,GaleriList); K = Problem->BuildMatrix(); } comm->barrier(); if (comm->getRank()==0) cout << "#############\n# Constructing Repeated Map #\n#############\n" << endl; RCP > RepeatedMap = BuildRepeatedMap(K->getCrsGraph()); RCP > RepeatedNodesMap; ArrayRCP > > RepeatedDofMaps; BuildDofMaps(RepeatedMap,1,NodeWise,RepeatedNodesMap,RepeatedDofMaps); comm->barrier(); if (comm->getRank()==0) cout << "#############\n# Constructing Interface Partition of Unity #\n#############\n" << endl; RCP > SerialComm = createSerialComm(); RCP parameterList = getParametersFromXmlFile("ParametersIPOU.xml"); RCP > IPOU(new GDSWInterfacePartitionOfUnity(RepeatedMap->getComm(),SerialComm,Dimension,1,RepeatedNodesMap,RepeatedDofMaps,sublist(parameterList,"GDSW"),All,UN(1))); IPOU->sortInterface(K); IPOU->computePartitionOfUnity(); comm->barrier(); if (comm->getRank()==0) cout << "\n#############\n# Finished! #\n#############" << endl; } CommWorld->barrier(); stackedTimer->stop("Interface Partition of Unity Test"); StackedTimer::OutputOptions options; options.output_fraction = options.output_histogram = options.output_minmax = true; stackedTimer->report(*out,CommWorld,options); return(EXIT_SUCCESS); }