Dear Barry:<br><br>Why do you call these two functions in your code? Because I have realized the same method with yours to calculate MPIDENSE_MPIAIJ. However, I didn't call MatAssemblyBegin and MatAssemblyEnd after I call MatTranspose for matrix C. <br>
In application, sometimes I don't know what do the functions I call in PETSc do? So, I don't know whether I should call these two functions although you give me these conditions. Regarding this example, which condition should it belong to? thanks a lot.<br>
<br>Regards,<br>Yujie <br><br><div><span class="gmail_quote">On 3/3/08, <b class="gmail_sendername">Barry Smith</b> <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:</span><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
<br> MatAssembly does<br> 1) moves any values set on one process that belongs on another<br> 2) finalizes the sparse matrix data structure (for example takes any<br> holes out of the CSR format)<br> doesn't need to do this for dense matrices<br>
3) sets up whatever VecScatters that are need to do matrix vector<br> products<br> 4) marks the matrix as assembled and ready to be used<br><br><br> Barry<br><br><br> On Mar 2, 2008, at 11:47 PM, Yujie wrote:<br><br> > Hi, everyone<br>
><br> > I just check the codes added by Barry for MPIDENSE_MPIAIJ. The codes<br> > is as follows. I am wondering what context one may call<br> > MatAssemblyBegin and MatAssemblyEnd?<br> > From the webpage, I can find some information about two functions:<br>
> "Begins assembling the matrix. This routine should be called after<br> > completing all calls to MatSetValues()."<br> > I mean that I don't know how to judge whether I should call two<br> > functions. Could you give me some advice? thanks a lot.<br>
><br> > 4723 */<br> > 4724 PetscErrorCode MatMatMultNumeric_MPIDense_MPIAIJ(Mat A,Mat<br> > B,Mat C)<br> > 4725 {<br> > 4726 PetscErrorCode ierr;<br> > 4727 Mat_MPIDense *sub_c = (Mat_MPIDense*)C->data;<br>
> 4728 Mat At,Bt,Ct;<br> > 4729<br> > 4730 PetscFunctionBegin;<br> > 4731 ierr = MatTranspose(A,MAT_INITIAL_MATRIX,&At);CHKERRQ(ierr);<br> > 4732 ierr = MatTranspose(B,MAT_INITIAL_MATRIX,&Bt);CHKERRQ(ierr);<br>
> 4733 ierr = MatMatMult(Bt,At,MAT_INITIAL_MATRIX,<br> > 1.0,&Ct);CHKERRQ(ierr);<br> > 4734 ierr = MatDestroy(At);CHKERRQ(ierr);<br> > 4735 ierr = MatDestroy(Bt);CHKERRQ(ierr);<br> > 4736 ierr = MatTranspose(Ct,MAT_REUSE_MATRIX,&C);CHKERRQ(ierr);<br>
> 4737 ierr = MatDestroy(Ct);CHKERRQ(ierr);<br> > 4738<br> > 4739 C->assembled = PETSC_TRUE;<br> > 4740 ierr = MatAssemblyBegin(sub_c-<br> > >A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br> > 4741 ierr = MatAssemblyEnd(sub_c->A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br>
> 4742 if (!C->was_assembled) {<br> > 4743 ierr = MatSetUpMultiply_MPIDense(C);CHKERRQ(ierr);<br> > 4744 }<br> > 4745 PetscFunctionReturn(0);<br> > 4746 }<br> ><br> ><br> ><br> > Regards,<br>
> Yujie<br><br></blockquote></div><br>