Last active
September 17, 2016 06:24
-
-
Save RATATATO/457f25c1e5960632378e7559cfeb0225 to your computer and use it in GitHub Desktop.
Set to Epetra_FEVector with Epetra_BlockMap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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