00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <EpetraExt_ConfigDefs.h>
00032 #include "EpetraExt_Version.h"
00033
00034 #include "Epetra_SerialComm.h"
00035 #include "Epetra_Time.h"
00036
00037 #ifdef EPETRA_MPI
00038 #include "Epetra_MpiComm.h"
00039 #include <mpi.h>
00040 #endif
00041
00042 #include "Epetra_Map.h"
00043 #include "Epetra_CrsGraph.h"
00044 #include "Epetra_CrsMatrix.h"
00045 #include "Epetra_Vector.h"
00046 #include "Epetra_LinearProblem.h"
00047
00048 #include "EpetraExt_Transform_Composite.h"
00049 #include "EpetraExt_LPTrans_From_GraphTrans.h"
00050 #include "EpetraExt_SymmRCM_CrsGraph.h"
00051 #include "EpetraExt_Reindex_LinearProblem.h"
00052
00053
00054 #ifdef EPETRA_MPI
00055 #include "EpetraExt_Overlap_CrsGraph.h"
00056 #endif
00057
00058 #include "../epetra_test_err.h"
00059
00060 int main(int argc, char *argv[]) {
00061
00062 int i, ierr=0, returnierr=0;
00063
00064 #ifdef EPETRA_MPI
00065
00066
00067
00068 MPI_Init(&argc,&argv);
00069 int size, rank;
00070
00071 MPI_Comm_size(MPI_COMM_WORLD, &size);
00072 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
00073
00074 #else
00075
00076 int size = 1;
00077 int rank = 0;
00078
00079 #endif
00080
00081 bool verbose = false;
00082
00083
00084 if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true;
00085
00086
00087 #ifdef EPETRA_MPI
00088 Epetra_MpiComm Comm(MPI_COMM_WORLD);
00089 #else
00090 Epetra_SerialComm Comm;
00091 #endif
00092 if (!verbose) Comm.SetTracebackMode(0);
00093
00094 int MyPID = Comm.MyPID();
00095 int NumProc = Comm.NumProc();
00096
00097 bool verbose1 = verbose;
00098 if( verbose ) verbose = (MyPID==0);
00099
00100 if ( verbose )
00101 cout << EpetraExt::EpetraExt_Version() << endl << endl;
00102
00103 Comm.Barrier();
00104
00105 if( verbose1 ) cout << Comm << endl << flush;
00106
00107 int NumMyElements = 3;
00108 int NumGlobalElements = NumProc*NumMyElements;
00109 int IndexBase = 0;
00110
00111 Epetra_Map Map( NumGlobalElements, NumMyElements, 0, Comm );
00112 if( verbose1 ) cout << Map << endl << flush;
00113
00114 Epetra_CrsGraph Graph( Copy, Map, 1 );
00115
00116 int PIDFac = 10*MyPID;
00117 int index = PIDFac+2;
00118 Graph.InsertGlobalIndices( PIDFac+0, 1, &index );
00119 index = PIDFac+0;
00120 Graph.InsertGlobalIndices( PIDFac+1, 1, &index );
00121 index = PIDFac+1;
00122 Graph.InsertGlobalIndices( PIDFac+2, 1, &index );
00123
00124 Graph.FillComplete();
00125 if( verbose1 ) cout << Graph << endl << flush;
00126
00127 EpetraExt::Transform_Composite<Epetra_LinearProblem> CompTrans;
00128
00129
00130
00131
00132
00133 EpetraExt::LinearProblem_Reindex * RI_Trans = new EpetraExt::LinearProblem_Reindex(0);
00134 EpetraExt::SameTypeTransform<Epetra_LinearProblem> * RI_LPTrans = RI_Trans;
00135 CompTrans.addTransform( RI_LPTrans );
00136
00137 EpetraExt::CrsGraph_SymmRCM RCM_Trans;
00138 EpetraExt::SameTypeTransform<Epetra_LinearProblem> *
00139 RCM_LPTrans = new EpetraExt::LinearProblem_GraphTrans( RCM_Trans );
00140 CompTrans.addTransform( RCM_LPTrans );
00141
00142 #ifdef EPETRA_MPI
00143 EpetraExt::CrsGraph_Overlap Overlap_Trans(1);
00144 EpetraExt::SameTypeTransform<Epetra_LinearProblem> *
00145 Overlap_LPTrans = new EpetraExt::LinearProblem_GraphTrans( Overlap_Trans );
00146 CompTrans.addTransform( Overlap_LPTrans );
00147 #endif
00148
00149 Epetra_CrsMatrix Matrix( Copy, Graph );
00150 index = 2;
00151 double val = 2;
00152 Matrix.ReplaceMyValues( 0, 1, &val, &index );
00153 index = 0;
00154 val = 0;
00155 Matrix.ReplaceMyValues( 1, 1, &val, &index );
00156 index = 1;
00157 val = 1;
00158 Matrix.ReplaceMyValues( 2, 1, &val, &index);
00159
00160 vector<double> valA(3);
00161 valA[0]=0; valA[1]=1; valA[2]=2;
00162 Epetra_BlockMap & MapRef = Map;
00163 Epetra_Vector LHS( Copy, MapRef, &valA[0] );
00164 Epetra_Vector RHS( Copy, MapRef, &valA[0] );
00165
00166 Epetra_LinearProblem Prob( &Matrix, &LHS, &RHS );
00167
00168 Epetra_LinearProblem & NewProb = CompTrans( Prob );
00169
00170 CompTrans.fwd();
00171 CompTrans.rvs();
00172
00173 #ifdef EPETRA_MPI
00174 MPI_Finalize();
00175 #endif
00176
00177 return ierr;
00178 }
00179