From 40590b8aa9d4090d36351fe5994b695c9775db3e Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 14 Feb 2012 21:13:29 -0800 Subject: [PATCH] Added HYPRE parallel preconditiong, default is parallel algebraic multigrid. Also cleaned up solver routines --- src/Makefile | 4 ++-- src/cmfd_execute.F90 | 4 ++-- src/cmfd_input.F90 | 3 ++- src/cmfd_jacobian_operator.F90 | 1 - src/cmfd_output.F90 | 3 ++- src/cmfd_slepc_solver.F90 | 30 +++++++++++++++--------------- src/cmfd_snes_solver.F90 | 21 +++++++-------------- 7 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/Makefile b/src/Makefile index 445cc5df02..71fde3b360 100644 --- a/src/Makefile +++ b/src/Makefile @@ -15,14 +15,14 @@ include OBJECTS # User Options #=============================================================================== -F90X = /home/bherman/petsc/release/bin/mpif90 +F90X = /home/bherman/petsc/release-ifort/bin/mpif90 F90XFLAGS = -Wall -Wno-unused-variable COMPILER = petsc DEBUG = no PROFILE = no OPTIMIZE = no USE_MPI = no -USE_HDF5 = yes +USE_HDF5 = no #=============================================================================== # GNU Fortran compiler options diff --git a/src/cmfd_execute.F90 b/src/cmfd_execute.F90 index f1905d34ce..008d299708 100644 --- a/src/cmfd_execute.F90 +++ b/src/cmfd_execute.F90 @@ -41,7 +41,7 @@ contains if (master) then ! begin timer -! call timer_start(time_cmfd) + call timer_start(time_cmfd) ! set up cmfd if(.not. cmfd_only) call set_up_cmfd() @@ -57,7 +57,7 @@ contains #endif ! stop timer -! call timer_stop(time_cmfd) + call timer_stop(time_cmfd) ! write vtk file !if(.not. cmfd_only) call write_cmfd_vtk() diff --git a/src/cmfd_input.F90 b/src/cmfd_input.F90 index a575332968..5654ad5806 100644 --- a/src/cmfd_input.F90 +++ b/src/cmfd_input.F90 @@ -323,7 +323,6 @@ contains use global, only: hdf5_output_file,hdf5_err use hdf5 use hdf5_interface, only: hdf5_open_output, hdf5_close_output -#endif ! integer(HID_T) :: file_id ! File identifier integer(HID_T) :: dataset_id ! Dataset identifier @@ -474,6 +473,8 @@ contains ! close output file call hdf5_close_output() +#endif + end subroutine read_cmfd_hdf5 end module cmfd_input diff --git a/src/cmfd_jacobian_operator.F90 b/src/cmfd_jacobian_operator.F90 index 1ada9797ce..e47468bd0c 100644 --- a/src/cmfd_jacobian_operator.F90 +++ b/src/cmfd_jacobian_operator.F90 @@ -210,7 +210,6 @@ contains real(8), pointer :: sptr(:) ! pointer to source vector real(8), allocatable :: vals(:) ! vector of row values real(8), allocatable :: phi_tmp(:) ! temp buffer for flux -print *,'In Jacobian' ! create operators call build_loss_matrix(ctx%loss) diff --git a/src/cmfd_output.F90 b/src/cmfd_output.F90 index f104887bf3..8d0e6ae836 100644 --- a/src/cmfd_output.F90 +++ b/src/cmfd_output.F90 @@ -135,7 +135,6 @@ contains #ifdef HDF5 use hdf5 use global, only: hdf5_output_file,hdf5_err -#endif ! character(LEN=7), parameter :: filename = "cmfd.h5" ! File name ! character(LEN=4) :: grpname = "cmfd" ! Group name @@ -328,6 +327,8 @@ contains ! close the cycle call h5gclose_f(cycle_id,hdf5_err) +#endif + end subroutine write_cmfd_hdf5 !=============================================================================== diff --git a/src/cmfd_slepc_solver.F90 b/src/cmfd_slepc_solver.F90 index 9fcffedf93..d76afce478 100644 --- a/src/cmfd_slepc_solver.F90 +++ b/src/cmfd_slepc_solver.F90 @@ -40,17 +40,17 @@ call timer_start(time_cmfd) ! initialize solver call init_solver() -call timer_stop(time_cmfd) -if(master) print *,'Init Time:',time_cmfd%elapsed -call timer_reset(time_cmfd) -call timer_start(time_cmfd) +!all timer_stop(time_cmfd) +!f(master) print *,'Init Time:',time_cmfd%elapsed +!all timer_reset(time_cmfd) +!all timer_start(time_cmfd) ! build operators call build_loss_matrix(loss) call build_prod_matrix(prod) -call timer_stop(time_cmfd) -if(master) print *,'Build Time',time_cmfd%elapsed -call timer_reset(time_cmfd) -call timer_start(time_cmfd) +!all timer_stop(time_cmfd) +!f(master) print *,'Build Time',time_cmfd%elapsed +!all timer_reset(time_cmfd) +!all timer_start(time_cmfd) ! set operators to EPS object call EPSSetOperators(eps,prod%F,loss%M,ierr) @@ -59,15 +59,15 @@ call timer_start(time_cmfd) ! solve the system call EPSSolve(eps,ierr) -call timer_stop(time_cmfd) -if(master) print *,'Solve Time:',time_cmfd%elapsed -call timer_reset(time_cmfd) -call timer_start(time_cmfd) +!all timer_stop(time_cmfd) +!f(master) print *,'Solve Time:',time_cmfd%elapsed +!all timer_reset(time_cmfd) +!all timer_start(time_cmfd) ! extracts results to cmfd object call extract_results() -call timer_stop(time_cmfd) -if(master) print *,'Extraction Time:',time_cmfd%elapsed -call timer_reset(time_cmfd) +!all timer_stop(time_cmfd) +!f(master) print *,'Extraction Time:',time_cmfd%elapsed +!all timer_reset(time_cmfd) ! deallocate all slepc data call finalize() diff --git a/src/cmfd_snes_solver.F90 b/src/cmfd_snes_solver.F90 index d8d1979cf3..51a2a314e8 100644 --- a/src/cmfd_snes_solver.F90 +++ b/src/cmfd_snes_solver.F90 @@ -33,20 +33,16 @@ contains !=============================================================================== subroutine cmfd_snes_execute() -print *,'executing slepc' - call MPI_Barrier(MPI_COMM_WORLD,ierr) + ! call slepc solver call cmfd_slepc_execute() -print *,'initing data' - call MPI_Barrier(MPI_COMM_WORLD,ierr) + ! initialize data call init_data() -print *,'initing solver' - call MPI_Barrier(MPI_COMM_WORLD,ierr) + ! initialize solver call init_solver() -print *,'solving system' - call MPI_Barrier(MPI_COMM_WORLD,ierr) + ! solve the system call SNESSolve(snes,PETSC_NULL,xvec,ierr) @@ -80,8 +76,7 @@ print *,'solving system' ! get problem size n = jac_prec%n -print *,cmfd%phi -print *,cmfd%keff + ! create PETSc vectors call VecCreateMPI(PETSC_COMM_WORLD,jac_prec%localn,PETSC_DECIDE,resvec,ierr) call VecCreateMPI(PETSC_COMM_WORLD,jac_prec%localn,PETSC_DECIDE,xvec,ierr) @@ -129,9 +124,8 @@ print *,cmfd%keff ! set preconditioner call KSPGetPC(ksp,pc,ierr) -! call PCSetType(pc,PCILU,ierr) -! call PCFactorSetLevels(pc,25,ierr) - call PCSetType(pc,PCBJACOBI,ierr) + call PCSetType(pc,PCHYPRE,ierr) + call PCSetFromOptions(pc,ierr) call KSPSetFromOptions(ksp,ierr) ! create matrix free jacobian @@ -192,7 +186,6 @@ print *,cmfd%keff real(8), pointer :: xptr(:) ! pointer to solution vector real(8), pointer :: rptr(:) ! pointer to residual vector PetscViewer :: viewer -print *,'In residual' ! create operators call build_loss_matrix(ctx%loss)