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 ();
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
Epetra_Map: A class for partitioning vectors and matrices.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
virtual int MinAll(double *PartialMins, double *GlobalMins, int Count) const =0
Epetra_Comm Global Min function.
Epetra_MpiComm: The Epetra MPI Communication Class.
long long NumGlobalElements64() const
std::string Epetra_Version()
long long * MyGlobalElements64() const
virtual int MyPID() const =0
Return my process ID.
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
Epetra_CrsMatrix * createCrsMatrix(const Epetra_Map &map)
Epetra_Comm: The Epetra Communication Abstract Base Class.
long long global_ordinal_type
int NumMyElements() const
Number of elements on the calling processor.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
Epetra_SerialComm: The Epetra Serial Communication Class.
void example(const Epetra_Comm &comm)
virtual int NumProc() const =0
Returns total number of processes.
int MyPID() const
Return my process ID.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
int NumGlobalElements() const
Number of elements across all processors.
int main(int argc, char *argv[])