Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d9d8d8

Browse files
committed
When restoring a subvector, we must make sure to update ghost entries
1 parent 4c47ad8 commit 5d9d8d8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/numerics/petsc_vector.C

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,8 @@ PetscVector<T>::get_subvector(const std::vector<numeric_index_type> & rows)
14261426
ierr = VecGetSubVector(_vec, parent_is, &subvec);
14271427
LIBMESH_CHKERR(ierr);
14281428

1429+
this->_is_closed = false;
1430+
14291431
return std::make_unique<PetscVector<T>>(subvec, this->comm());
14301432
}
14311433

@@ -1448,6 +1450,11 @@ PetscVector<T>::restore_subvector(std::unique_ptr<NumericVector<T>> && subvector
14481450
Vec subvec = petsc_subvector->vec();
14491451
ierr = VecRestoreSubVector(_vec, parent_is, &subvec);
14501452
LIBMESH_CHKERR(ierr);
1453+
1454+
if (this->type() == GHOSTED)
1455+
VecGhostUpdateBeginEnd(this->comm(), _vec, INSERT_VALUES, SCATTER_FORWARD);
1456+
1457+
this->_is_closed = true;
14511458
}
14521459

14531460
//------------------------------------------------------------------

0 commit comments

Comments
 (0)