[petsc-users] Question about ksp ex3.c

Matija Kecman matijakecman at gmail.com
Tue Sep 20 04:45:37 CDT 2011


Hi all,

I have been playing around with ksp/examples/tutorials/ex3.c, a brief
summary of this example follows:

The Laplace equation in two-dimensions on a unit square [0,1]x[0,1] is
solved using a structured mesh of linear quadrilateral finite elements, m
elements in each direction. Dirichlet boundary conditions are specified:
u_hat = y on the boundary, which means the exact solution is u_star = y. The
global system matrix dimension is specified and PETSc decides how to split
the matrix amongst processors. The DOFs are numbered 'naturally' from the
origin, left to right, bottom to top. Boundary conditions are applied by
zeroing the rows of the matrix corresponding to the boundary DOFs, inserting
1's on the diagonal entries of these rows and inserting the boundary
conditions into the global RHS vector entries corresponding to these DOFs.

I ran the following uniprocess tests (to run the direct solve tests I had to
comment the line 'ierr =
KSPSetInitialGuessNonzero(ksp,PETSC_TRUE);CHKERRQ(ierr);' but otherwise I
made no changes to the example code):

---Tests with 5x5 element mesh (36 DOFs)---
$ mpirun -np 1 ./ex3 -ksp_type gmres
Norm of error 1.73622e-06 Iterations 3
$ mpirun -np 1 ./ex3 -ksp_type bcgs
Norm of error 1.5157e-07 Iterations 2
$ mpirun -np 1 ./ex3 -ksp_type cg
Norm of error 1.88557e-06 Iterations 3
$ mpirun -np 1 ./ex3 -ksp_type gmres -pc_type none
Norm of error < 1.e-12 Iterations 7
$ mpirun -np 1 ./ex3 -ksp_type bcgs -pc_type none
Norm of error 0.00109538 Iterations 6
$ mpirun -np 1 ./ex3 -ksp_type cg -pc_type none
Norm of error < 1.e-12 Iterations 7
$ mpirun -np 1 ./ex3 -ksp_type preonly -pc_type lu
Norm of error < 1.e-12 Iterations 1

---Tests with 100x100 element mesh (10201 DOFs)---
$ mpirun -np 1 ./ex3 -ksp_type gmres -m 100
Norm of error 2.90652e-05 Iterations 32
$ mpirun -np 1 ./ex3 -ksp_type bcgs -m 100
Norm of error 3.92733e-05 Iterations 24
$ mpirun -np 1 ./ex3 -ksp_type cg -m 100
Norm of error 2.4332e-05 Iterations 32
$ mpirun -np 1 ./ex3 -ksp_type gmres -pc_type none -m 100
Norm of error 0.570146 Iterations 0
$ mpirun -np 1 ./ex3 -ksp_type bcgs -pc_type none -m 100
Norm of error 0.570146 Iterations 0
$ mpirun -np 1 ./ex3 -ksp_type cg -pc_type none -m 100
Norm of error 0.570146 Iterations 0
$ mpirun -np 1 ./ex3 -ksp_type preonly -pc_type lu -m 100
Norm of error < 1.e-12 Iterations 1

I had two questions:

1. I was wondering if someone could explain why the system cannot be solved
using for a mesh of 100x100 elements without a using preconditioner? The way
the boundary conditions are applied causes the system matrix to lose
symmetry but GMRes and BiCGStab should work for non-symmetric systems.

2. I'm also unsure about why the CG method seems to be able to solve this
non-symmetric system in some cases, are there some cases where this is
possible?

Thanks,

Matija
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110920/8f987383/attachment.htm>


More information about the petsc-users mailing list