<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Jed,<div><br></div><div>I've added the appended code to get the null space from the Mat. &nbsp;I did not see:</div><div><br></div><div>&nbsp;ierr = MatNullSpaceDestroy(&amp;matnull);CHKERRQ(ierr);</div><div><br></div><div>in your ML code ... shouldn't that be here?</div><div><br></div><div>Mark</div><div><br></div><div><br></div><div><div>&nbsp; PetscFunctionBegin;</div><div>&nbsp; ierr = MatGetNearNullSpace( a_A, &amp;mnull ); CHKERRQ(ierr);</div><div>&nbsp; if( !mnull ) {</div><div>&nbsp; &nbsp; ierr = PCSetCoordinates_AGG( pc, -1, PETSC_NULL ); CHKERRQ(ierr);</div><div>&nbsp; }</div><div>&nbsp; else {</div><div>&nbsp; &nbsp; PetscReal *nullvec;</div><div>&nbsp; &nbsp; PetscBool has_const;</div><div>&nbsp; &nbsp; PetscInt i,j,mlocal,nvec,bs;</div><div>&nbsp; &nbsp; const Vec *vecs; const PetscScalar *v;</div><div>&nbsp; &nbsp; ierr = MatGetLocalSize(a_A,&amp;mlocal,PETSC_NULL);CHKERRQ(ierr);</div><div>&nbsp; &nbsp; ierr = MatNullSpaceGetVecs(mnull,&amp;has_const,&amp;nvec,&amp;vecs);CHKERRQ(ierr);</div><div>&nbsp; &nbsp; &nbsp;ierr &nbsp;= MatGetBlockSize( a_A, &amp;bs ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CHKERRQ( ierr );</div><div>&nbsp; &nbsp; ierr = PetscMalloc((nvec+!!has_const)*mlocal*sizeof *nullvec,&amp;nullvec);CHKERRQ(ierr);</div><div>&nbsp; &nbsp; if (has_const) for (i=0; i&lt;mlocal; i++) nullvec[i] = 1.0;</div><div>&nbsp; &nbsp; for (i=0; i&lt;nvec; i++) {</div><div>&nbsp; &nbsp; &nbsp; ierr = VecGetArrayRead(vecs[i],&amp;v);CHKERRQ(ierr);</div><div>&nbsp; &nbsp; &nbsp; for (j=0; j&lt;mlocal; j++) nullvec[(i+!!has_const)*mlocal + j] = PetscRealPart(v[j]);</div><div>&nbsp; &nbsp; &nbsp; ierr = VecRestoreArrayRead(vecs[i],&amp;v);CHKERRQ(ierr);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; pc_gamg-&gt;data = nullvec;</div><div>&nbsp; &nbsp; pc_gamg-&gt;data_cell_cols = (nvec+!!has_const);</div><div>&nbsp; &nbsp; pc_gamg-&gt;data_cell_rows = bs;</div><div>&nbsp; }</div><div>&nbsp; PetscFunctionReturn(0);</div><div>}</div><div><br></div><div><br></div><div><div>On Apr 3, 2012, at 9:21 AM, Jed Brown wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Tue, Apr 3, 2012 at 01:02, Karin&amp;NiKo <span dir="ltr">&lt;<a href="mailto:niko.karin@gmail.com">niko.karin@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":13f">I am not sure if the definition of the near null space of the operator suffice in order to get an optimal preconditioner for linear elasticity. <br>Considering ML, one must also set the "num_PDEs" attribute, mustn't he? But it seems to me that this attribute cannot be set in the PETSc interface.<br>

Am I wrong?</div></blockquote></div><br><div>It is set using the "block size" of the matrix (MatSetBlockSize()). But that is only part of the game. For robustness, you should also provide null space information. Here is an example of using a coordinate Vec to create a MatNullSpace defining the rigid body modes and passing it along (from src/ksp/ksp/examples/tutorials/ex49.c).</div>
<div><br></div><div><div>&nbsp; ierr = DMDAGetCoordinates(elas_da,&amp;vel_coords);CHKERRQ(ierr);</div><div>&nbsp; ierr = MatNullSpaceCreateRigidBody(vel_coords,&amp;matnull);CHKERRQ(ierr);</div><div>&nbsp; ierr = MatSetNearNullSpace(A,matnull);CHKERRQ(ierr);</div>
<div>&nbsp; ierr = MatNullSpaceDestroy(&amp;matnull);CHKERRQ(ierr);</div></div><div><br></div>
</blockquote></div><br></div></body></html>