# Parallelize zeroing rows operation

**URL:** <https://fenicsproject.discourse.group/t/parallelize-zeroing-rows-operation/19310>\
**Category:** General\
**Created:** [January 6, 2026, 2:36pm UTC](https://fenicsproject.discourse.group/t/parallelize-zeroing-rows-operation/19310 "2026-01-06T14:36:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 6, 2026, 3:00pm UTC](https://fenicsproject.discourse.group/t/parallelize-zeroing-rows-operation/19310/2 "2026-01-06T15:00:49Z")

</div>

see:

> [@Modify matrix diagonal -- dolfinx version for A.ident\_zeros()](https://fenicsproject.discourse.group/t/modify-matrix-diagonal-dolfinx-version-for-a-ident-zeros/9918):
>
> Hi all, I have an assembled matrix with zero rows, where I’d like to insert ones on the diagonal. In older versions there was the A.ident\_zeros() function which did exactly that, and fast. Such a function seems not to be implemented in dolfinx, so I tried to find a workaround with PETSc, using: A.setValueLocal() A.setValuesLocalCSR/RCV/IJV() A.setDiagonal() While they all seem to work, they are extremely (and equally) slow. I assume because the diagonal NNZ have to be allocated and added aft…

and the more efficient version which is leveraging a priori information about where the non-zeros are, as shown in: [Modify matrix diagonal -- dolfinx version for A.ident\_zeros() - #3 by dokken](https://fenicsproject.discourse.group/t/modify-matrix-diagonal-dolfinx-version-for-a-ident-zeros/9918/3)

---

_[View the full topic](https://fenicsproject.discourse.group/t/parallelize-zeroing-rows-operation/19310)._
