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
67#ifdef 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;
107 else if (myGblElts[i] == numGblElts - 1) {
110 tempGblInds[0] = myGblElts[i] - 1;
111 tempGblInds[1] = myGblElts[i];
124 tempGblInds[0] = myGblElts[i] - 1;
125 tempGblInds[1] = myGblElts[i];
126 tempGblInds[2] = myGblElts[i] + 1;
138 (void) comm.
MaxAll (&lclerr, &gblerr, 1);
143 throw std::runtime_error (
"Some process failed to insert an entry.");
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) ?
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 "
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.");
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 ();
std::string Epetra_Version()
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
long long * MyGlobalElements64() const
long long NumGlobalElements64() const
int NumGlobalElements() const
Number of elements across all processors.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
int NumMyElements() const
Number of elements on the calling processor.
Epetra_Comm: The Epetra Communication Abstract Base Class.
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
virtual int NumProc() const =0
Returns total number of processes.
virtual int MinAll(double *PartialMins, double *GlobalMins, int Count) const =0
Epetra_Comm Global Min function.
virtual int MyPID() const =0
Return my process ID.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Insert a list of elements in a given global row of the matrix.
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Exports an Epetra_DistObject using the Epetra_Import object.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements.
Epetra_Map: A class for partitioning vectors and matrices.
Epetra_MpiComm: The Epetra MPI Communication Class.
int NumProc() const
Returns total number of processes.
int MyPID() const
Return my process ID.
Epetra_SerialComm: The Epetra Serial Communication Class.
int main(int argc, char *argv[])
void example(const Epetra_Comm &comm)
long long global_ordinal_type
Epetra_CrsMatrix * createCrsMatrix(const Epetra_Map &map)