# [petsc-users] discontinuous viscosity stokes equation 3D staggered grid

Matthew Knepley knepley at gmail.com
Fri Jul 26 07:32:57 CDT 2013

```On Fri, Jul 26, 2013 at 7:28 AM, Bishesh Khanal <bisheshkh at gmail.com> wrote:

>
>
>
> On Wed, Jul 17, 2013 at 9:48 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
>
>> Bishesh Khanal <bisheshkh at gmail.com> writes:
>>
>> > Now, I implemented two different approaches, each for both 2D and 3D, in
>> > MATLAB. It works for the smaller sizes but I have problems solving it
>> for
>> > the problem size I need (250^3 grid size).
>> > I use staggered grid with p on cell centers, and components of v on cell
>> > faces. Similar split up of K to cell center and faces to account for the
>> > variable viscosity case)
>>
>> Okay, you're using a staggered-grid finite difference discretization of
>> variable-viscosity Stokes.  This is a common problem and I recommend
>> starting with PCFieldSplit with Schur complement reduction (make that
>> work first, then switch to block preconditioner).
>
>
> Ok, I made my 3D problem work with PCFieldSplit with Schur complement
> reduction using the options:
> -fieldsplit_1_ksp_constant_null_space
>
>
> You can use PCLSC or
>> (probably better for you), assemble a preconditioning matrix containing
>> the inverse viscosity in the pressure-pressure block.  This diagonal
>> matrix is a spectrally equivalent (or nearly so, depending on
>> discretization) approximation of the Schur complement.  The velocity
>> block can be solved with algebraic multigrid.  Read the PCFieldSplit
>> docs (follow papers as appropriate) and let us know if you get stuck.
>>
>
> Now,  I got a little confused in how exactly to use command line options
> to use multigrid for the velocity bock and PCLS for the pressure block.
> After going through the manual I tried the following:
>

You want Algebraic Multigrid

-pc_fieldsplit_type schur
-fieldsplit_0_pc_type gamg
-fieldsplit_1_ksp_type fgmres
-fieldsplit_1_ksp_constant_null_space
-fieldsplit_1_ksp_monitor_short
-fieldsplit_1_pc_type lsc
-ksp_converged_reason

Matt

> but I get the following errror:
>
> [0]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [0]PETSC ERROR: Null argument, when expecting valid pointer!
> [0]PETSC ERROR: Null Object: Parameter # 2!
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.4.2, Jul, 02, 2013
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: src/AdLemMain on a arch-linux2-cxx-debug named edwards by
> bkhanal Fri Jul 26 14:23:40 2013
> [0]PETSC ERROR: Libraries linked from
> /home/bkhanal/Documents/softwares/petsc-3.4.2/arch-linux2-cxx-debug/lib
> [0]PETSC ERROR: Configure run at Fri Jul 19 14:25:01 2013
> [0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=g77
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: MatPtAP() line 8166 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/mat/interface/matrix.c
> [0]PETSC ERROR: PCSetUp_MG() line 628 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/pc/impls/mg/mg.c
> [0]PETSC ERROR: PCSetUp() line 890 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/pc/interface/precon.c
> [0]PETSC ERROR: KSPSetUp() line 278 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/ksp/interface/itfunc.c
> [0]PETSC ERROR: KSPSolve() line 399 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/ksp/interface/itfunc.c
> [0]PETSC ERROR: PCApply_FieldSplit_Schur() line 807 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/pc/impls/fieldsplit/fieldsplit.c
> [0]PETSC ERROR: PCApply() line 442 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/pc/interface/precon.c
> [0]PETSC ERROR: KSP_PCApply() line 227 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/include/petsc-private/kspimpl.h
> [0]PETSC ERROR: KSPInitialResidual() line 64 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/ksp/interface/itres.c
> [0]PETSC ERROR: KSPSolve_GMRES() line 239 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/ksp/impls/gmres/gmres.c
> [0]PETSC ERROR: KSPSolve() line 441 in
> /home/bkhanal/Documents/softwares/petsc-3.4.2/src/ksp/ksp/interface/itfunc.c
>
>
>

--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their