[petsc-users] Slow speed when using PETSc multigrid

TAY wee-beng zonexo at gmail.com
Mon Jun 4 16:11:37 CDT 2012


Hi,

I tried using PETSc multigrid on my 2D CFD code. I had converted ksp eg. 
ex29 to Fortran and then added into my code to solve the Poisson equation.

The main subroutines are:

call KSPCreate(PETSC_COMM_WORLD,ksp,ierr)

call 
DMDACreate2d(PETSC_COMM_WORLD,DMDA_BOUNDARY_NONE,DMDA_BOUNDARY_NONE,DMDA_STENCIL_STAR,i3,i3,PETSC_DECIDE,PETSC_DECIDE,i1,i1,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da,ierr)
call DMSetFunction(da,ComputeRHS,ierr)
call DMSetJacobian(da,ComputeMatrix,ierr)
call KSPSetDM(ksp,da,ierr)

call KSPSetFromOptions(ksp,ierr)
call KSPSetUp(ksp,ierr)
call KSPSolve(ksp,PETSC_NULL_OBJECT,PETSC_NULL_OBJECT,ierr)
call KSPGetSolution(ksp,x,ierr)
call VecView(x,PETSC_VIEWER_STDOUT_WORLD,ierr)
call KSPDestroy(ksp,ierr)
call DMDestroy(da,ierr)
call PetscFinalize(ierr)


Since the LHS matrix doesn't change, I only set up at the 1st time step, 
thereafter I only called ComputeRHS every time step.

I was using HYPRE's geometric multigrid and the speed was much faster.

What other options can I tweak to improve the speed? Or should I call 
the subroutines above at every timestep?

Thanks!


-- 
Yours sincerely,

TAY wee-beng



More information about the petsc-users mailing list