[petsc-users] Customizing NASM subsnes
Matthew Knepley
knepley at gmail.com
Fri Jun 17 08:35:09 CDT 2022
On Fri, Jun 17, 2022 at 9:22 AM Takahashi, Tadanaga <tt73 at njit.edu> wrote:
> 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
> code:
>
> 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);
> SNESNASMGetSNES(snes,i,&subsnes);
> // 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:
>
SNESNASMGetSNES() gets the local subsolvers. It seems you only have one per
process.
You can check
https://petsc.org/main/docs/manualpages/SNES/SNESNASMGetNumber/
Notice that your current code will not work because, according to your
explanation, you only want to change
the prefix on a single rank, so you need to check the rank when you do it.
Thanks,
Matt
> 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
> [0]PETSC ERROR: #1 SNESNASMGetSNES() at
> /home/takahashi/Desktop/petsc/src/snes/impls/nasm/nasm.c:923
>
>
> ===================================================================================
> = BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
> = 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/>
>>
>
--
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/7aec6ec5/attachment.html>
More information about the petsc-users
mailing list