44 #include "Epetra_Map.h"
45 #include "Epetra_CrsMatrix.h"
47 # include "Epetra_MpiComm.h"
49 # include "Epetra_SerialComm.h"
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;
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)