44 #include "Epetra_Map.h" 45 #include "Epetra_CrsMatrix.h" 47 # include "Epetra_MpiComm.h" 49 # include "Epetra_SerialComm.h" 52 Teuchos::RCP<Epetra_Operator>
58 ,
const double diagScale
71 if(verbose) out <<
"\nCreating Epetra_MpiComm ...\n";
72 Epetra_MpiComm epetra_comm(mpiComm);
74 if(verbose) out <<
"\nCreating Epetra_SerialComm ...\n";
75 Epetra_SerialComm epetra_comm;
78 const Epetra_Map epetra_map(globalDim,0,epetra_comm);
93 RCP<Epetra_CrsMatrix> A_epetra = rcp(
new Epetra_CrsMatrix(::Copy,epetra_map,3));
99 const int numMyElements = epetra_map.NumMyElements();
100 std::vector<int> myGlobalElements(numMyElements);
101 epetra_map.MyGlobalElements(&myGlobalElements[0]);
105 const double offDiag = -1.0, diag = 2.0*diagScale;
106 int numEntries;
double values[3];
int indexes[3];
107 for(
int k = 0; k < numMyElements; ++k ) {
108 const int rowIndex = myGlobalElements[k];
109 if( rowIndex == 0 ) {
111 values[0] = diag; values[1] = offDiag;
112 indexes[0] = 0; indexes[1] = 1;
114 else if( rowIndex == globalDim - 1 ) {
116 values[0] = offDiag; values[1] = diag;
117 indexes[0] = globalDim-2; indexes[1] = globalDim-1;
121 values[0] = offDiag; values[1] = diag; values[2] = offDiag;
122 indexes[0] = rowIndex-1; indexes[1] = rowIndex; indexes[2] = rowIndex+1;
124 TEUCHOS_TEST_FOR_EXCEPT( 0!=A_epetra->InsertGlobalValues(rowIndex,numEntries,values,indexes) );
128 TEUCHOS_TEST_FOR_EXCEPT( 0!=A_epetra->FillComplete() );
Teuchos::RCP< Epetra_Operator > createTridiagEpetraLinearOp(const int globalDim, const double diagScale, const bool verbose, std::ostream &out)
This function generates a tridiagonal linear operator using Epetra.