10 #include <Epetra_config.h>
33 #ifdef EPETRA_NO_32BIT_GLOBAL_INDICES
36 # define EXAMPLE_USES_64BIT_GLOBAL_INDICES 1
39 # ifdef EPETRA_NO_64BIT_GLOBAL_INDICES
44 # define EXAMPLE_USES_64BIT_GLOBAL_INDICES 1
48 # endif // EPETRA_NO_64BIT_GLOBAL_INDICES
49 #endif // EPETRA_NO_32BIT_GLOBAL_INDICES
67 #ifdef EXAMPLE_USES_64BIT_GLOBAL_INDICES
73 #endif // EXAMPLE_USES_64BIT_GLOBAL_INDICES
82 if (numMyElts > 0 && myGblElts == NULL) {
83 throw std::logic_error (
"Failed to get the list of global indices");
92 for (
int i = 0; i < numMyElts; ++i) {
94 if (myGblElts[i] == 0) {
97 tempGblInds[0] = myGblElts[i];
98 tempGblInds[1] = myGblElts[i] + 1;
100 lclerr =
A->InsertGlobalValues (myGblElts[i], 2, tempVals, tempGblInds);
107 else if (myGblElts[i] == numGblElts - 1) {
110 tempGblInds[0] = myGblElts[i] - 1;
111 tempGblInds[1] = myGblElts[i];
113 lclerr =
A->InsertGlobalValues (myGblElts[i], 2, tempVals, tempGblInds);
124 tempGblInds[0] = myGblElts[i] - 1;
125 tempGblInds[1] = myGblElts[i];
126 tempGblInds[2] = myGblElts[i] + 1;
128 lclerr =
A->InsertGlobalValues (myGblElts[i], 3, tempVals, tempGblInds);
138 (void) comm.
MaxAll (&lclerr, &gblerr, 1);
143 throw std::runtime_error (
"Some process failed to insert an entry.");
147 gblerr =
A->FillComplete ();
152 std::ostringstream os;
153 os <<
"A->FillComplete() failed with error code " << gblerr <<
".";
154 throw std::runtime_error (os.str ());
191 const int procZeroMapNumLclElts = (comm.
MyPID () == 0) ?
193 static_cast<global_ordinal_type> (0);
194 Epetra_Map procZeroMap (numGblElts, procZeroMapNumLclElts, indexBase, comm);
198 Epetra_Map globalMap (numGblElts, indexBase, comm);
212 (void) comm.
MaxAll (&lclerr, &gblerr, 1);
214 throw std::runtime_error (
"createCrsMatrix returned NULL on at least one "
250 lclerr =
B.Export (*
A, exporter,
Insert);
257 (void) comm.
MinAll (&lclerr, &gblerr, 1);
259 throw std::runtime_error (
"Export() failed on at least one process.");
261 (void) comm.
MaxAll (&lclerr, &gblerr, 1);
263 throw std::runtime_error (
"Export() failed on at least one process.");
269 lclerr =
B.FillComplete ();
276 (void) comm.
MinAll (&lclerr, &gblerr, 1);
278 throw std::runtime_error (
"B.FillComplete() failed on at least one process.");
280 (void) comm.
MaxAll (&lclerr, &gblerr, 1);
282 throw std::runtime_error (
"B.FillComplete() failed on at least one process.");
298 MPI_Init (&argc, &argv);
304 const int myRank = comm.
MyPID ();
305 const int numProcs = comm.
NumProc ();
310 <<
"Total number of processes: " << numProcs << endl;
317 cout <<
"End Result: TEST PASSED" << endl;
321 (void) MPI_Finalize ();