[petsc-users] Attach approximate null space to a fieldsplit block
Garth N. Wells
gnw20 at cam.ac.uk
Tue Aug 20 13:41:04 CDT 2013
On 20 August 2013 19:14, Matthew Knepley <knepley at gmail.com> wrote:
> On Tue, Aug 20, 2013 at 12:50 PM, Garth N. Wells <gnw20 at cam.ac.uk> wrote:
>>
>> On 19 August 2013 14:03, Matthew Knepley <knepley at gmail.com> wrote:
>> > On Mon, Aug 19, 2013 at 7:40 AM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
>> >>
>> >> "Garth N. Wells" <gnw20 at cam.ac.uk> writes:
>> >>
>> >> > I'm using PCFIELDSPLIT for a mixed problem, with fields indicated via
>> >> > an index set (using PCFieldSplitSetIS). I'd like to attach an
>> >> > approximate null space to the A00 block of the system. Is there a way
>> >> > to attach the null space to one block?
>> >
>> >
>> > There is a better way. You can attach the null space to the IS that
>> > forms
>> > the split
>> >
>> > PetscObjectAttach((PetscObject) is0, "nullspace", nullspace);
>> >
>> > and PCFIELDSPLIT will pull it out and attach it to the preconditioner
>> > for
>> > block 0.
>> >
>>
>> I tried this and it didn't seem to work - the solver didn't converge at
>> all.
>
>
> Is this helpless week :) Run with -ksp_view so we can see what actually
> happened.
The string should be 'nearnullspace' in place of 'nullspace' as above, i.e.
PetscObjectCompose((PetscObject) is0, "nearnullspace",
(PetscObject) nullspace);
rather than
PetscObjectCompose((PetscObject) is0, "nullspace", (PetscObject) nullspace);
With the former it works as expected.
Garth
> Here is the code that gets out the null space:
>
>
> https://bitbucket.org/petsc/petsc/src/d45619dec29bfb59cf96225a84e0a74106da50ca/src/ksp/pc/impls/fieldsplit/fieldsplit.c?at=master#cl-531
>
> You can break there and see if it gets it.
>
> Thanks,
>
> Matt
>
>>
>> > Matt
>> >
>> >>
>> >> With MatNest, you can use MatSetNearNullSpace on sub-blocks and it will
>> >> be used automatically. This is also the low-memory way to use
>> >> PCFieldSplit.
>>
>> We're working on support for this.
>>
>> >> Note that if you use MatSetValuesLocal, you can use the
>> >> NEST format with identical code in assembly; only matrix creation is
>> >> different, see src/snes/example/tutorials/ex28.c for an example that
>> >> works with both AIJ and NEST formats.
>> >>
>>
>> Is there a reason why MatSetValues can't be used? We rely on PETSc
>> caching and then communicating off-process entries.
>>
>> >> Otherwise, you should be able to PCSetUp, then get out the sub-solvers
>> >> PCFieldSplitGetSubKSP, pull out their matrices, and call
>> >> MatSetNearNullSpace. Those submatrices should not be overwritten as
>> >> long as you use SAME_NONZERO_PATTERN, so the null space would still
>> >> work
>> >> in future iterations.
>> >
>>
>> I'm using the above and it's working great - thanks.
>>
>> Garth
>>
>> >
>> >
>> >
More information about the petsc-users
mailing list