<div dir="ltr"><div>Hi,</div><div> </div><div>I have some confusion related to NONZERO in the matrix.</div><div>In my application I created Matrix using following procedure.<br clear="all"><br> MatCreate(* comm_, & J_);</div>
<div> PetscInt * d_nnz = NULL;<br> PetscInt * o_nnz = NULL;<br> PetscMalloc(local_size * sizeof(PetscInt), & d_nnz);<br> PetscMalloc(local_size * sizeof(PetscInt), & o_nnz);<br> for (int i = 0; i < local_size; i++) {<br>
d_nnz[i] = d_nnz_v[i];<br> o_nnz[i] = o_nnz_v[i];<br> }<br> MatSetType(J_, MATAIJ);<br> MatSetSizes(J_,<br> local_size,<br> local_size,<br> PETSC_DECIDE,<br> PETSC_DECIDE);<br> <br> <br>
if (comm_->Get_size() > 1) {<br> // MPI<br> MatMPIAIJSetPreallocation(J_,<br> max_d_nz,<br> d_nnz,<br> max_o_nz,<br> o_nnz);<br> } else {<br> // Seq<br> MatSeqAIJSetPreallocation(J_,<br>
PETSC_DEFAULT, <br> d_nnz);<br> }<br> PetscFree(d_nnz);<br> PetscFree(o_nnz);</div><div> </div><div>The sructure of the matrix changes from time to time during the application (as the connectivity list is varying) however o_nnz d_nnz are made based on the densest possible scenario.</div>
<div><br>In a recently test I noticed that matrix consturcion time become extremely long when the sturucture changes (form less dense to denser). I dug a little and found out it become very slow in </div><div> MatSetValues(J_,<br>
NumRows,<br> idxm,<br> NumCols,<br> idxn,<br> data,<br> ADD_VALUES);<br>and it becomes normal again after the first chanaged matrix has been assembled.</div><div> </div><div>In my case I didn't do MatSetValues for the connection doesn't exisit in on time connectivity list although I count them in d_nnz and o_nnz but I started to suspect that PETSC was allocating memory for the new additional entries base on previous matrix structure. </div>
<div> </div><div>Any suggestions?<br></div><div> </div><p><strong>Cheers</strong></p>
</div>