Skip to content
Snippets Groups Projects
Commit 02072bb8 authored by Van Dung Nguyen's avatar Van Dung Nguyen
Browse files

fix problem when working in case of number of procs > number of partitions

parent 9da42db4
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,17 @@ linearSystemPETSc<scalar>::~linearSystemPETSc() ...@@ -68,7 +68,17 @@ linearSystemPETSc<scalar>::~linearSystemPETSc()
template <class scalar> template <class scalar>
void linearSystemPETSc<scalar>::_assembleMatrixIfNeeded() void linearSystemPETSc<scalar>::_assembleMatrixIfNeeded()
{ {
// avoid to assemble the matrix when not needed since it destroy preallocation (e.g. in zeroMatrix) if (_comm == PETSC_COMM_WORLD){
if (Msg::GetCommSize()>1){
int value = _valuesNotAssembled ? 1 : 0;
int sumValue = 0;
MPI_Allreduce((void*)&value, (void*)&sumValue, 1, MPI_INT, MPI_SUM, _comm);
if ((sumValue > 0) &&(sumValue < Msg::GetCommSize())){
_valuesNotAssembled= 1;
}
}
}
if (_valuesNotAssembled) { if (_valuesNotAssembled) {
_try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY));
_try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY));
...@@ -402,7 +412,7 @@ std::vector<scalar> linearSystemPETSc<scalar>::getData() ...@@ -402,7 +412,7 @@ std::vector<scalar> linearSystemPETSc<scalar>::getData()
_try(MatRestoreArray(_a,&v)); _try(MatRestoreArray(_a,&v));
return data; return data;
}*/ }*/
/* /*
template <class scalar> template <class scalar>
std::vector<int> linearSystemPETSc<scalar>::getRowPointers() std::vector<int> linearSystemPETSc<scalar>::getRowPointers()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment