// @HEADER // ***************************************************************************** // Trilinos: An Object-Oriented Solver Framework // // Copyright 2001-2024 NTESS and the Trilinos contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER // CrsGraph_BTF Test routine #include #include "EpetraExt_Version.h" #include "Epetra_Time.h" #ifdef EPETRA_MPI #include "Epetra_MpiComm.h" #include #endif #include "Epetra_SerialComm.h" #include "Epetra_Map.h" #include "Epetra_CrsGraph.h" #include "Epetra_CrsMatrix.h" #include "Epetra_MultiVector.h" #include "Epetra_LinearProblem.h" #include "EpetraExt_AmesosBTF_CrsGraph.h" #include "EpetraExt_LPTrans_From_GraphTrans.h" #include "EpetraExt_Reindex_LinearProblem.h" int main(int argc, char *argv[]) { int returnierr=0; using std::cout; using std::endl; using std::flush; #ifdef EPETRA_MPI // Initialize MPI MPI_Init(&argc,&argv); int size; // Number of MPI processes, My process ID MPI_Comm_size(MPI_COMM_WORLD, &size); if (size > 1) { cout << "This example cannot be run on more than one processor!" << endl; MPI_Finalize(); returnierr = -1; return returnierr; } #endif bool verbose = false; // Check if we should print results to standard out if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true; #ifdef EPETRA_MPI Epetra_MpiComm Comm(MPI_COMM_WORLD); #else Epetra_SerialComm Comm; #endif if (!verbose) Comm.SetTracebackMode(0); // This should shut down any error traceback reporting if (verbose) { cout << EpetraExt::EpetraExt_Version() << endl << endl; cout << Comm << endl << flush; } Comm.Barrier(); int NumMyElements = 3; Epetra_Map Map( NumMyElements, 0, Comm ); Epetra_CrsGraph Graph( Copy, Map, 1 ); int index[2]; index[0] = 2; Graph.InsertGlobalIndices( 0, 1, &index[0] ); index[0] = 0; index[1] = 2; Graph.InsertGlobalIndices( 1, 2, &index[0] ); index[0] = 1; Graph.InsertGlobalIndices( 2, 1, &index[0] ); Graph.FillComplete(); if (verbose) { cout << "***************** PERFORMING BTF TRANSFORM ON CRS_GRAPH *****************" <*>(&BTFTrans)) ); Epetra_LinearProblem* tProblem = &((*LPTrans)( problem )); LPTrans->fwd(); if (verbose) { cout << "CrsMatrix *after* BTF transform: " << endl << endl; dynamic_cast(tProblem->GetMatrix())->Print( cout ); cout << "MultiVector RHS *after* BTF transform: " << endl << endl; tProblem->GetRHS()->Print( cout ); } if (verbose) { cout << endl << "*************** PERFORMING REINDEXING ON LINEAR_PROBLEM **************" < * ReIdx_LPTrans = new EpetraExt::LinearProblem_Reindex( 0 ); Epetra_LinearProblem* tProblem2 = &((*ReIdx_LPTrans)( *tProblem )); ReIdx_LPTrans->fwd(); if (verbose) { cout << endl << "CrsMatrix *after* BTF transform *and* reindexing: " << endl << endl; dynamic_cast(tProblem2->GetMatrix())->Print( cout ); cout << endl <<"Column Map *before* reindexing: " << endl << endl; cout << dynamic_cast(tProblem->GetMatrix())->ColMap() << endl; cout << "Column Map *after* reindexing: " << endl << endl; cout << dynamic_cast(tProblem2->GetMatrix())->ColMap() << endl; } #ifdef EPETRA_MPI MPI_Finalize(); #endif return returnierr; }