On Mon, May 10, 2010 at 1:20 PM, <span dir="ltr"><<a href="mailto:irfan.khan@gatech.edu">irfan.khan@gatech.edu</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I get the following error at the call for MatMatMult(Mat A,Mat B,MatReuse scall, PetscReal fill,Mat *C).<br>
<br>
Error: Container does not exit!<br></blockquote><div><br></div><div>The idea here is that you use MAT_INITIAL_MATRIX the first time, so C will be created, and then</div><div>the same C and MAT_REUSE_MATRIX the next time.</div>
<div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Is the probable cause of this error an invalid C matrix?. Can I use MAT_REUSE_MATRIX in MatMatMult() and use an existing C matrix. The call works fine when I use MAT_INITIAL_MATRIX and use a new matrix.<br>
<br>
Here are the sequence of steps.<br>
<br>
/* Generating A & B matrices by copying the global stiffness matrix */<br>
ierr = MatConvert(global->Amat, MATSAME, MAT_INITIAL_MATRIX, &A);CHKERRQ(ierr);<br>
ierr = MatConvert(global->Amat, MATSAME, MAT_INITIAL_MATRIX, &B);CHKERRQ(ierr);<br>
<br>
/* Zero all the entries of the A matrix */<br>
ierr = MatZeroEntries(A);CHKERRQ(ierr);<br>
<br>
/* Fill in the diagonal entry and one off-diagonal entry of A matrix */<br>
for(i = 0; i < bc.numPeriodic; i++){<br>
if(bc.periodNode[i] > -1){<br>
for(j = 0; j < dofn; j++){<br>
row = local2Petsc[bc.periodNode[i]*dofn+j];<br>
col = bc.periodPair[i]*dofn+j;<br>
/* The diagonal Entry */<br>
ierr =MatSetValue(A,row,row,1.0,ADD_VALUES);CHKERRQ(ierr);<br>
/* The entry for periodic node */<br>
ierr =MatSetValue(A,row,col,1.0,ADD_VALUES);CHKERRQ(ierr);<br>
}<br>
}<br>
}<br>
<br>
/* Assemble the new matrices */<br>
ierr = MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br>
ierr = MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br>
ierr = MatAssemblyBegin(B, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br>
ierr = MatAssemblyEnd(B, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br>
<br>
/* Perform matrix multiplication of A and B(Amat) to add rows of periodic<br>
* nodes. Save the new matrix in Amat */<br>
ierr = MatMatMult(A,B,MAT_REUSE_MATRIX,PETSC_DEFAULT,&global->Amat);CHKERRQ(ierr);<br>
<br>
ierr = MatDestroy(A);CHKERRQ(ierr);<br>
ierr = MatDestroy(B);CHKERRQ(ierr);<br>
<div class="im"><br>
<br>
Thank you<br>
Irfan<br>
<br>
----- Original Message -----<br>
From: "Matthew Knepley" <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>><br>
To: "PETSc users list" <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
</div><div><div></div><div class="h5">Sent: Monday, May 10, 2010 12:26:14 PM GMT -05:00 US/Canada Eastern<br>
Subject: Re: [petsc-users] MAT_REUSE_MATRIX<br>
<br>
On Mon, May 10, 2010 at 12:07 PM, < <a href="mailto:irfan.khan@gatech.edu">irfan.khan@gatech.edu</a> > wrote:<br>
<br>
<br>
<br>
Hi Petsc Team,<br>
<br>
When using the subroutine MatMatMult(Mat A,Mat B,PetscReal fill,Mat *C) with option MAT_REUSE_MATRIX, Can the C matrix be any one of A or B?<br>
<br>
<br>
<br>
I do not think that is safe. I believe C needs to be another matrix, but it can be<br>
reused for successive multiplies.<br>
<br>
<br>
Matt<br>
<br>
<br>
Thank you<br>
Irfan<br>
<br>
----- Original Message -----<br>
From: "Matthew Knepley" < <a href="mailto:knepley@gmail.com">knepley@gmail.com</a> ><br>
To: "PETSc users list" < <a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a> ><br>
Sent: Friday, May 7, 2010 4:03:42 PM GMT -05:00 US/Canada Eastern<br>
Subject: Re: [petsc-users] Adding MatAij rows<br>
<br>
On Fri, May 7, 2010 at 3:57 PM, < <a href="mailto:irfan.khan@gatech.edu">irfan.khan@gatech.edu</a> > wrote:<br>
<br>
<br>
<br>
<br>
<br>
<br>
Petsc Team,<br>
<br>
Is there a function that can be used to add two rows and put the results into a third row of the same parallel matrix (MPIAIJ)? i.e<br>
<br>
A[k][l] = A[i][l] + A[j][l]<br>
<br>
<br>
<br>
No, since it would entail messing with the nonzero structure. You could easily<br>
use a second matrix to get this effect from subsequent MatMult() calls.<br>
<br>
<br>
Matt<br>
<br>
<br>
<br>
<br>
<br>
Thank you<br>
Irfan<br>
<br>
--<br>
PhD Candidate<br>
G.W. Woodruff School of Mechanical Engineering<br>
Georgia Institute of Technology<br>
Atlanta, GA (30332)<br>
<br>
<br>
<br>
--<br>
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
<br>
<br>
--<br>
PhD Candidate<br>
G.W. Woodruff School of Mechanical Engineering<br>
Georgia Institute of Technology<br>
Atlanta, GA (30332)<br>
<br>
<br>
<br>
--<br>
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div class="h5">PhD Candidate<br>
G.W. Woodruff School of Mechanical Engineering<br>
Georgia Institute of Technology<br>
Atlanta, GA (30332)<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>