[petsc-users] Customizing NASM subsnes

Takahashi, Tadanaga tt73 at njit.edu
Fri Jun 17 08:22:37 CDT 2022

I'm having some trouble pulling out the subsolver. I tried to use
SNESNASMGetSNES in a loop over each subdomain. However I get an error when
I run the code with more than one MPI processors. Here is a snippet from my

   SNES           snes, subsnes;
   PetscMPIInt    rank, size;
   ierr = SNESCreate(PETSC_COMM_WORLD,&snes); CHKERRQ(ierr);
   ierr = SNESSetType(snes,SNESNASM); CHKERRQ(ierr);
   ierr = SNESNASMSetType(snes,PC_ASM_RESTRICT); CHKERRQ(ierr);
   ierr = SNESSetFromOptions(snes); CHKERRQ(ierr);
   ierr = SNESSetUp(snes); CHKERRQ(ierr);
   PetscPrintf(PETSC_COMM_WORLD, "Size = %d\n",size);
   for (i=0; i<size; i++) {
      PetscPrintf(PETSC_COMM_WORLD, "rank = %d\n",i);
      // char prefix[10];
      // sprintf(prefix,"sub_%d_",i);
      // SNESSetOptionsPrefix(subsnes,prefix);
   ierr = SNESSolve(snes,NULL,u_initial); CHKERRQ(ierr);

And, here is the output of the code when I run with 2 MPI procs:

takahashi at ubuntu:~/Desktop/MA-DDM/C/Rectangle$ mpiexec -n 2 ./test1
Size = 2
rank = 0
rank = 1
[0]PETSC ERROR: --------------------- Error Message
[0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: No such subsolver
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.17.1, unknown
[0]PETSC ERROR: ./test1 on a linux-gnu-c-debug named ubuntu by takahashi
Fri Jun 17 06:06:38 2022
[0]PETSC ERROR: Configure options --with-mpi-dir=/usr --with-fc=0

=   RANK 0 PID 976566 RUNNING AT ubuntu
=   KILLED BY SIGNAL: 9 (Killed)

This error doesn't occur when I run this without MPI. However, I tried to
change the prefix of the subdomain to `sub_0_` but I am not able to change
the snes_type using this prefix. Running ./test1 -snes_view -help | grep
sub_0_snes_type prints nothing.

On Thu, Jun 16, 2022 at 6:23 PM Matthew Knepley <knepley at gmail.com> wrote:

> On Thu, Jun 16, 2022 at 5:57 PM tt73 <tt73 at njit.edu> wrote:
>> Hi,
>> I am using  NASM as the outer solver for a nonlinear problem. For one of
>> the subdomains, I want to run the local solve with a different set of
>> options form the others. Is there any way to set options for each
>> subdomain?
> I can see two ways:
>   1) Pull out the subsolver and set it using the API
>   2) Pull out the subsolver and give it a different prefix
>   Thanks,
>      Matt
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220617/f3d66e11/attachment.html>

More information about the petsc-users mailing list