12 #include "Epetra_Map.h"
13 #include "Epetra_CrsMatrix.h"
15 # include "Epetra_MpiComm.h"
17 # include "Epetra_SerialComm.h"
26 ,
const double diagScale
39 if(verbose) out <<
"\nCreating Epetra_MpiComm ...\n";
40 Epetra_MpiComm epetra_comm(mpiComm);
42 if(verbose) out <<
"\nCreating Epetra_SerialComm ...\n";
43 Epetra_SerialComm epetra_comm;
46 const Epetra_Map epetra_map(globalDim,0,epetra_comm);
61 RCP<Epetra_CrsMatrix> A_epetra =
rcp(
new Epetra_CrsMatrix(::
Copy,epetra_map,3));
67 const int numMyElements = epetra_map.NumMyElements();
68 std::vector<int> myGlobalElements(numMyElements);
69 epetra_map.MyGlobalElements(&myGlobalElements[0]);
73 const double offDiag = -1.0, diag = 2.0*diagScale;
74 int numEntries;
double values[3];
int indexes[3];
75 for(
int k = 0; k < numMyElements; ++k ) {
76 const int rowIndex = myGlobalElements[k];
79 values[0] = diag; values[1] = offDiag;
80 indexes[0] = 0; indexes[1] = 1;
82 else if( rowIndex == globalDim - 1 ) {
84 values[0] = offDiag; values[1] = diag;
85 indexes[0] = globalDim-2; indexes[1] = globalDim-1;
89 values[0] = offDiag; values[1] = diag; values[2] = offDiag;
90 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)