Skip to content

Instantly share code, notes, and snippets.

@RATATATO
Last active September 17, 2016 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RATATATO/457f25c1e5960632378e7559cfeb0225 to your computer and use it in GitHub Desktop.
Save RATATATO/457f25c1e5960632378e7559cfeb0225 to your computer and use it in GitHub Desktop.
Set to Epetra_FEVector with Epetra_BlockMap
#include <algorithm>
#include <iterator>
#include <mpi.h>
#include <Epetra_FEVector.h>
#include <Epetra_MpiComm.h>
int main(void) {
MPI_Init(0, nullptr);
Epetra_MpiComm comm(MPI_COMM_WORLD);
int indices[] = { 0, 1 };
int block_size_list[] = { 3, 3 };
Epetra_BlockMap map(-1, 2, indices, block_size_list, 0, comm);
double copied[6];
// bug? or wrong usage?
Epetra_FEVector fe_vector(map);
double values[] = { 1, 2, 4, 8, 16, 32 };
fe_vector.SumIntoGlobalValues(2, indices, values);
fe_vector.GlobalAssemble();
fe_vector.ExtractCopy(copied, 0);
std::copy(
std::begin(copied), std::end(copied),
std::ostream_iterator<double>(
std::cout << "ReplaceGlobalValues: ", " "));
std::cout << std::endl;
// ok
Epetra_FEVector fe_vector2(map);
fe_vector2.ReplaceGlobalValue(0, 0, 0, 1);
fe_vector2.ReplaceGlobalValue(0, 1, 0, 2);
fe_vector2.ReplaceGlobalValue(0, 2, 0, 4);
fe_vector2.ReplaceGlobalValue(1, 0, 0, 8);
fe_vector2.ReplaceGlobalValue(1, 1, 0, 16);
fe_vector2.ReplaceGlobalValue(1, 2, 0, 32);
fe_vector2.GlobalAssemble();
fe_vector2.ExtractCopy(copied, 0);
std::copy(
std::begin(copied), std::end(copied),
std::ostream_iterator<double>(
std::cout << "ReplaceGlobalValue: ", " "));
std::cout << std::endl;
MPI_Finalize();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment