Skip to content

Commit

Permalink
Stokes example
Browse files Browse the repository at this point in the history
Signed-off-by: Umberto Zerbinati <[email protected]>
  • Loading branch information
Umberto Zerbinati committed Jun 4, 2024
1 parent 82a2c70 commit f90d700
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
61 changes: 56 additions & 5 deletions docs/src/PETScPC/stokes.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ We can also construct a multi-grid preconditioner for the top left block of the
C = BlockMatrix( [ [twolvpre, None], [None, mpre] ] )
gfu.vec.data[:] = 0; gfp.vec.data[:] = 0;
gfu.Set(uin, definedon=mesh.Boundaries("inlet"))
print("-----------|Mass & Two Level Additivew Schwarz|-----------")
print("-----------|Mass & Two Level Additive Schwarz|-----------")
solvers.MinRes (mat=K, pre=C, rhs=rhs, sol=sol, tol=1e-8,
maxsteps=100, printrates=True, initialize=False)
Expand All @@ -156,7 +156,7 @@ We can also construct a multi-grid preconditioner for the top left block of the
- 4 (9.15e-14)
* - Mass & LU
- 66 (2.45e-08)
* - Mass & Two Level Additivew Schwarz
* - Mass & Two Level Additive Schwarz
- 100 (4.68e-06)

The mass matrix as a preconditioner doesn't seem to be ideal, in fact, our Krylov solver took many iterations to converge with a direct LU factorization of the velocity block and did not converge at all with `HYPRE`.
Expand Down Expand Up @@ -188,21 +188,53 @@ This formulation can easily be constructed by adding a new velocity block in the
solvers.MinRes (mat=K, pre=C, rhs=rhs, sol=sol, tol=1e-10,
printrates=True, initialize=False)
Draw(gfu)
.. list-table:: Preconditioners performance
:widths: auto
:header-rows: 1

* - Preconditioner
- Iterations
* - Schur complement
- 4 (9.15e-14)
* - Mass & LU
- 66 (2.45e-08)
* - Mass & Two Level Additive Schwarz
- 100 (4.68e-06)
* - Augmented Lagrangian LU
- 2 (9.24e-8)

Notice that so far we have been inverting the matrix corresponding to the Laplacian block using a direct LU factorization.
This is not ideal for large problems, and we can use a `Hypre` preconditioner for the Laplacian block. ::

smoother = aG.mat.CreateBlockSmoother(blocks)
preHG = PETScPreconditioner(aG.mat, vertexdofs, solverParameters={"pc_type":"gamg"})
preHG = PETScPreconditioner(aG.mat, vertexdofs, solverParameters={"pc_type":"hypre"})
twolvpre = preHG + smoother
C = BlockMatrix( [ [twolvpre, None], [None, mGpre] ] )
gfu.vec.data[:] = 0; gfp.vec.data[:] = 0;
gfu.Set(uin, definedon=mesh.Boundaries("inlet"))
print("-----------|Augmented Two Level Additivew Schwarz|-----------")
print("-----------|Augmented Two Level Additive Schwarz|-----------")
solvers.MinRes (mat=K, pre=C, rhs=rhs, sol=sol, tol=1e-10,
printrates=True, initialize=False)
Draw(gfu)

.. list-table:: Preconditioners performance
:widths: auto
:header-rows: 1

* - Preconditioner
- Iterations
* - Schur complement
- 4 (9.15e-14)
* - Mass & LU
- 66 (2.45e-08)
* - Mass & Two Level Additive Schwarz
- 100 (4.68e-06)
* - Augmented Lagrangian LU
- 2 (9.24e-08)
* - Augmented Two Level Additive Schwarz
- 100 (1.06e-03)

Our first attempt at using a `HYPRE` preconditioner for the Laplacian block did not converge. This is because the top left block of the saddle point problem now contains the augmentation term, which has a very large kernel.
It is well known that algebraic multi-grid methods do not work well with indefinite problems, and this is what we are observing here. ::

Expand Down Expand Up @@ -264,4 +296,23 @@ In fact, since we know that the augmentation block has a lower rank than the Lap
print("-----------|Boffi--Lovadina Augmentation Sherman-Morrisson-Woodbory|-----------")
solvers.MinRes (mat=K, pre=C, rhs=rhs, sol=sol, tol=1e-13,
printrates=True, initialize=False)
Draw(gfu)
Draw(gfu)

.. list-table:: Preconditioners performance
:widths: auto
:header-rows: 1

* - Preconditioner
- Iterations
* - Schur complement
- 4 (9.15e-14)
* - Mass & LU
- 66 (2.45e-08)
* - Mass & Two Level Additive Schwarz
- 100 (4.68e-06)
* - Augmented Lagrangian LU
- 2 (9.24e-08)
* - Augmented Two Level Additive Schwarz
- 100 (1.06e-03)
* - Augmentation Schermon-Morrisson-Woodbory
- 84 (1.16e-07)
1 change: 1 addition & 0 deletions docs/src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Welcome to ngsPETSc's documentation!
:caption: PETSc PC

PETScPC/poisson.py
PETScPC/stokes.py

.. toctree::
:maxdepth: 1
Expand Down

0 comments on commit f90d700

Please sign in to comment.