// @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 "Teuchos_CommandLineProcessor.hpp" #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; using namespace std; using namespace Teuchos; using namespace Xpetra; using namespace FROSch; 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."); int communicationStrategy = 0; My_CLP.setOption("COMMSTRAT",&communicationStrategy,"Communication strategy for the domain decomposition interface."); 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("InterfaceSets Test")); TimeMonitor::setStackedTimer(stackedTimer); int N = 0; 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; //stackedTimer->start("Assembly Time"); FROSCH_TIMER_START(assemblyTimer,"Assembly"); 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(); } FROSCH_TIMER_STOP(assemblyTimer); Comm->barrier(); if (Comm->getRank()==0) cout << "#############\n# Constructing Repeated Map #\n#############\n" << endl; FROSCH_TIMER_START(repMapTimer,"Construct RepeatedMap"); RCP > RepeatedMap = BuildRepeatedMap(K->getCrsGraph()); FROSCH_TIMER_STOP(repMapTimer); Comm->barrier(); if (Comm->getRank()==0) cout << "#############\n# Identification of Interface Sets #\n#############\n" << endl; FROSCH_TIMER_START(intSetsTimer,"Identification of Interface Sets"); RCP > vertices,shortEdges,straightEdges,edges,faces,interface,interior; //RCP > verticesMap,shortEdgesMap,straightEdgesMap,edgesMap,facesMap; DDInterface dDInterface(Dimension,1,RepeatedMap,All,(CommunicationStrategy) communicationStrategy); dDInterface.divideUnconnectedEntities(K); dDInterface.sortVerticesEdgesFaces(); dDInterface.buildEntityHierarchy(); dDInterface.buildEntityMaps(true, true, true, true, true, true); FROSCH_TIMER_STOP(intSetsTimer); Comm->barrier(); if (Comm->getRank()==0) cout << "\n#############\n# Finished! #\n#############" << endl; } CommWorld->barrier(); stackedTimer->stop("InterfaceSets Test"); StackedTimer::OutputOptions options; options.output_fraction = options.output_histogram = options.output_minmax = true; stackedTimer->report(*out,CommWorld,options); return(EXIT_SUCCESS); }