<div dir="ltr">On Tue, Aug 20, 2013 at 1:41 PM, Garth N. Wells <span dir="ltr"><<a href="mailto:gnw20@cam.ac.uk" target="_blank">gnw20@cam.ac.uk</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 20 August 2013 19:14, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br>

> On Tue, Aug 20, 2013 at 12:50 PM, Garth N. Wells <<a href="mailto:gnw20@cam.ac.uk">gnw20@cam.ac.uk</a>> wrote:<br>
>><br>
>> On 19 August 2013 14:03, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br>
>> > On Mon, Aug 19, 2013 at 7:40 AM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>> wrote:<br>
>> >><br>
>> >> "Garth N. Wells" <<a href="mailto:gnw20@cam.ac.uk">gnw20@cam.ac.uk</a>> writes:<br>
>> >><br>
>> >> > I'm using PCFIELDSPLIT for a mixed problem, with fields indicated via<br>
>> >> > an index set (using PCFieldSplitSetIS). I'd like to attach an<br>
>> >> > approximate null space to the A00 block of the system. Is there a way<br>
>> >> > to attach the null space to one block?<br>
>> ><br>
>> ><br>
>> > There is a better way. You can attach the null space to the IS that<br>
>> > forms<br>
>> > the split<br>
>> ><br>
>> >   PetscObjectAttach((PetscObject) is0, "nullspace", nullspace);<br>
>> ><br>
>> > and PCFIELDSPLIT will pull it out and attach it to the preconditioner<br>
>> > for<br>
>> > block 0.<br>
>> ><br>
>><br>
>> I tried this and it didn't seem to work - the solver didn't converge at<br>
>> all.<br>
><br>
><br>
> Is this helpless week :) Run with -ksp_view so we can see what actually<br>
> happened.<br>
<br>
</div>The string should be 'nearnullspace' in place of 'nullspace' as above, i.e.<br>
<br>
    PetscObjectCompose((PetscObject) is0, "nearnullspace",<br>
(PetscObject) nullspace);<br>
<br>
rather than<br>
<br>
    PetscObjectCompose((PetscObject) is0, "nullspace", (PetscObject) nullspace);<br>
<br>
With the former it works as expected.</blockquote><div><br></div><div>I did not realize you wanted the AMG starter. Glad it works.</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">
<span class="HOEnZb"><font color="#888888"><br>
Garth<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> Here is the code that gets out the null space:<br>
><br>
><br>
> <a href="https://bitbucket.org/petsc/petsc/src/d45619dec29bfb59cf96225a84e0a74106da50ca/src/ksp/pc/impls/fieldsplit/fieldsplit.c?at=master#cl-531" target="_blank">https://bitbucket.org/petsc/petsc/src/d45619dec29bfb59cf96225a84e0a74106da50ca/src/ksp/pc/impls/fieldsplit/fieldsplit.c?at=master#cl-531</a><br>

><br>
> You can break there and see if it gets it.<br>
><br>
>   Thanks,<br>
><br>
>       Matt<br>
><br>
>><br>
>> >    Matt<br>
>> ><br>
>> >><br>
>> >> With MatNest, you can use MatSetNearNullSpace on sub-blocks and it will<br>
>> >> be used automatically.  This is also the low-memory way to use<br>
>> >> PCFieldSplit.<br>
>><br>
>> We're working on support for this.<br>
>><br>
>> >> Note that if you use MatSetValuesLocal, you can use the<br>
>> >> NEST format with identical code in assembly; only matrix creation is<br>
>> >> different, see src/snes/example/tutorials/ex28.c for an example that<br>
>> >> works with both AIJ and NEST formats.<br>
>> >><br>
>><br>
>> Is there a reason why MatSetValues can't be used? We rely on PETSc<br>
>> caching and then communicating off-process entries.<br>
>><br>
>> >> Otherwise, you should be able to PCSetUp, then get out the sub-solvers<br>
>> >> PCFieldSplitGetSubKSP, pull out their matrices, and call<br>
>> >> MatSetNearNullSpace.  Those submatrices should not be overwritten as<br>
>> >> long as you use SAME_NONZERO_PATTERN, so the null space would still<br>
>> >> work<br>
>> >> in future iterations.<br>
>> ><br>
>><br>
>> I'm using the above and it's working great - thanks.<br>
>><br>
>> Garth<br>
>><br>
>> ><br>
>> ><br>
>> ><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <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
</div></div>