<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. I did not see:</div><div><br></div><div> ierr = MatNullSpaceDestroy(&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> PetscFunctionBegin;</div><div> ierr = MatGetNearNullSpace( a_A, &mnull ); CHKERRQ(ierr);</div><div> if( !mnull ) {</div><div> ierr = PCSetCoordinates_AGG( pc, -1, PETSC_NULL ); CHKERRQ(ierr);</div><div> }</div><div> else {</div><div> PetscReal *nullvec;</div><div> PetscBool has_const;</div><div> PetscInt i,j,mlocal,nvec,bs;</div><div> const Vec *vecs; const PetscScalar *v;</div><div> ierr = MatGetLocalSize(a_A,&mlocal,PETSC_NULL);CHKERRQ(ierr);</div><div> ierr = MatNullSpaceGetVecs(mnull,&has_const,&nvec,&vecs);CHKERRQ(ierr);</div><div> ierr = MatGetBlockSize( a_A, &bs ); CHKERRQ( ierr );</div><div> ierr = PetscMalloc((nvec+!!has_const)*mlocal*sizeof *nullvec,&nullvec);CHKERRQ(ierr);</div><div> if (has_const) for (i=0; i<mlocal; i++) nullvec[i] = 1.0;</div><div> for (i=0; i<nvec; i++) {</div><div> ierr = VecGetArrayRead(vecs[i],&v);CHKERRQ(ierr);</div><div> for (j=0; j<mlocal; j++) nullvec[(i+!!has_const)*mlocal + j] = PetscRealPart(v[j]);</div><div> ierr = VecRestoreArrayRead(vecs[i],&v);CHKERRQ(ierr);</div><div> }</div><div> pc_gamg->data = nullvec;</div><div> pc_gamg->data_cell_cols = (nvec+!!has_const);</div><div> pc_gamg->data_cell_rows = bs;</div><div> }</div><div> 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&NiKo <span dir="ltr"><<a href="mailto:niko.karin@gmail.com">niko.karin@gmail.com</a>></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> ierr = DMDAGetCoordinates(elas_da,&vel_coords);CHKERRQ(ierr);</div><div> ierr = MatNullSpaceCreateRigidBody(vel_coords,&matnull);CHKERRQ(ierr);</div><div> ierr = MatSetNearNullSpace(A,matnull);CHKERRQ(ierr);</div>
<div> ierr = MatNullSpaceDestroy(&matnull);CHKERRQ(ierr);</div></div><div><br></div>
</blockquote></div><br></div></body></html>