38 MPI_Comm_size(MPI_COMM_WORLD, &n_proc);
44 MPI_Comm_rank(MPI_COMM_WORLD, &my_id);
50 const int entries_per_process = 10;
52 const int begin_index = my_id*entries_per_process;
53 const int end_index = (my_id+1)*entries_per_process;
55 const int local_begin = std::max(0, begin_index-entries_per_process/2);
56 const int local_end = entries_per_process*n_proc;
59 std::vector<unsigned int> ghosted_indices;
60 ghosted_indices.reserve(local_end-local_begin);
61 for (
int i = local_begin; i< local_end; ++i)
62 ghosted_indices.push_back(i);
65 local_end-local_begin,
66 reinterpret_cast<int*>(&ghosted_indices[0]),
74 std::vector<unsigned int> distributed_indices;
75 distributed_indices.reserve(entries_per_process*n_proc);
76 for (
int i = begin_index; i< end_index; ++i)
77 distributed_indices.push_back(i);
79 (entries_per_process*n_proc,
81 reinterpret_cast<int*>(&distributed_indices[0]),
98 std::cout <<
"Distributed:" << std::endl;
99 for (
int i=begin_index; i<end_index; ++i)
102 = v_distributed.
Map().
LID(i);
103 double value = v_distributed[0][trilinos_i];
104 std::cout<<
"proc "<<my_id<<
" "<< i <<
": " << value << std::endl;
106 std::cerr <<
"tests FAILED: value = " << value << std::endl;
112 int main (
int argc,
char **argv)
115 MPI_Init(&argc, &argv);
Epetra_Map: A class for partitioning vectors and matrices.
int PutScalar(double ScalarConstant)
Initialize all values in a multi-vector with constant value.
Epetra_MpiComm: The Epetra MPI Communication Class.
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
int LID(int GID) const
Returns local ID of global ID, return -1 if not found on this processor.
Epetra_SerialComm: The Epetra Serial Communication Class.
Epetra Finite-Element Vector.
int main(int argc, char *argv[])
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Imports an Epetra_DistObject using the Epetra_Import object.
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.