[petsc-users] MatZeroRows costly while applying 1st-kind Boundary Conditions

Qiyue Lu qiyuelu1 at gmail.com
Fri Nov 29 20:56:14 CST 2024


Hello,
In the MPI context, after assembling the distributed matrix A (matmpiaij)
and the right-hand-side b, I am trying to apply the 1st kind boundary
condition using MatZeroRows() and VecSetValues(), for A and b respectively.
The pseudo-code is:
=========
for (int key = 0; key < BCNodes_Length; key++){
      // retrieving the global row position
      pos = BCNodes[key];
      // Set all elements in that row 0 except the one on the diagonal to
be 1.0
      MatZeroRows(A, 1, &pos, 1.0, NULL, NULL);
}
MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
=========

For BCNodes_Length = 10^4, the FOR loop timing is 8 seconds.
For BCNodes_Length = 15*10^4, the FOR loop timing is 3000 seconds.
I am using two computational nodes and each having 12 cores.

My questions are:
1) Is the timing plausible? Is the MatZeroRows() function so costly?
2) Any suggestions to apply the 1st kind boundary conditions for a better
performance?

Thanks,
Qiyue Lu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241129/152d4910/attachment.html>


More information about the petsc-users mailing list