diff options
Diffstat (limited to 'src/petsc_confmetric_solver.c')
-rw-r--r-- | src/petsc_confmetric_solver.c | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/src/petsc_confmetric_solver.c b/src/petsc_confmetric_solver.c index 0219ed3..59441d3 100644 --- a/src/petsc_confmetric_solver.c +++ b/src/petsc_confmetric_solver.c @@ -15,8 +15,8 @@ #include "assert.h" #include "mpi.h" -#include "sles.h" - +#include "petscsles.h" +#include "ellpetsc.h" #include "CactusPUGH/PUGH/src/include/pugh.h" static const char *rcsid = "$Header$"; @@ -200,7 +200,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, /* Set the PETSc communicator to set of PUGH and initialzie PETSc */ - ierr = PetscSetCommWorld(pughGH->PUGH_COMM_WORLD); CHKERRA(ierr); + ierr = PetscSetCommWorld(pughGH->PUGH_COMM_WORLD); CHKERRQ(ierr); PetscInitialize(&argc,&argv,NULL,NULL); CCTK_INFO("PETSc initialized"); @@ -371,11 +371,11 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, 19,PETSC_NULL, /* Diagonal */ 19,PETSC_NULL, /* Off diagonal */ &A[0]); /* The output */ - CHKERRA(ierr); + CHKERRQ(ierr); ierr = VecCreateMPI(pughGH->PUGH_COMM_WORLD,(endpoint-startpoint),rank,&soln); - CHKERRA(ierr); + CHKERRQ(ierr); ierr = VecCreateMPI(pughGH->PUGH_COMM_WORLD,(endpoint-startpoint),rank,&b); - CHKERRA(ierr); + CHKERRQ(ierr); /* Compare the PETSc layout to Cactus, this better be a match */ ierr = VecGetOwnershipRange(soln,&pvstart,&pvend); @@ -819,7 +819,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, else { J = wsp[DATINDEX(pEx,i+l,j+m,k+n)]; ierr = MatSetValues(A[0],1,&I,1,&J,&(a(l,m,n)),INSERT_VALUES); - CHKERRA(ierr); + CHKERRQ(ierr); } } } @@ -828,7 +828,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, rhsval = -rhsval - Nlin[ijk] / ac; ierr = VecSetValues(b,1,&I,&rhsval,INSERT_VALUES); - CHKERRA(ierr); + CHKERRQ(ierr); } } @@ -836,13 +836,13 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, } if (verbose) CCTK_INFO ("Assembling the vectors"); - ierr = MatAssemblyBegin(A[0],MAT_FINAL_ASSEMBLY); CHKERRA(ierr); - ierr = VecAssemblyBegin(soln); CHKERRA(ierr); - ierr = VecAssemblyBegin(b); CHKERRA(ierr) - ierr = MatAssemblyEnd(A[0],MAT_FINAL_ASSEMBLY); CHKERRA(ierr); - ierr = VecAssemblyEnd(soln); CHKERRA(ierr); - ierr = VecAssemblyEnd(b); CHKERRA(ierr); - ierr = MatSetOption(A[0],MAT_NO_NEW_NONZERO_LOCATIONS); CHKERRA(ierr); + ierr = MatAssemblyBegin(A[0],MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); + ierr = VecAssemblyBegin(soln); CHKERRQ(ierr); + ierr = VecAssemblyBegin(b); CHKERRQ(ierr); + ierr = MatAssemblyEnd(A[0],MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); + ierr = VecAssemblyEnd(soln); CHKERRQ(ierr); + ierr = VecAssemblyEnd(b); CHKERRQ(ierr); + ierr = MatSetOption(A[0],MAT_NO_NEW_NONZERO_LOCATIONS); CHKERRQ(ierr); if (nabla_form == 3) { if (verbose) @@ -855,10 +855,16 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, free(uzz3); } if (trips==0) - OptionsSetValue("-ksp_monitor",""); - - if (verbose) CCTK_INFO("CREATING SLES"); - ierr = SLESCreate(pughGH->PUGH_COMM_WORLD,&sles); CHKERRA(ierr); + { + PetscOptionsSetValue("-ksp_monitor",""); + } + + if (verbose) + { + CCTK_INFO("CREATING SLES"); + } + + ierr = SLESCreate(pughGH->PUGH_COMM_WORLD,&sles); CHKERRQ(ierr); /* @@ -871,15 +877,15 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, means, we'll leave it for now. */ if (verbose) CCTK_INFO("CREATING SLES OPERATOR"); - ierr = SLESSetOperators(sles,A[0],A[0],DIFFERENT_NONZERO_PATTERN); CHKERRA(ierr); + ierr = SLESSetOperators(sles,A[0],A[0],DIFFERENT_NONZERO_PATTERN); CHKERRQ(ierr); /* Set linear solver defaults for this problem. Later this should be replaced/modified with appropriate parsing from the parameter parser. For now it is not. These defaults are reasonable, I hope. */ if (verbose) CCTK_INFO("SLESGet KSP/PC"); - ierr = SLESGetKSP(sles,&ksp); CHKERRA(ierr); - ierr = SLESGetPC(sles,&pc); CHKERRA(ierr); + ierr = SLESGetKSP(sles,&ksp); CHKERRQ(ierr); + ierr = SLESGetPC(sles,&pc); CHKERRQ(ierr); /* Get the PC Type */ if (CCTK_Equals(petsc_PC_type,"PCJACOBI")) @@ -900,7 +906,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, CCTK_WARN(1,"Don't understand petsc_PC_type. Using PCNONE\n"); ierr = PCSetType(pc,PCNONE); } - CHKERRA(ierr); + CHKERRQ(ierr); /* Now the same thing for the KSP Type */ @@ -928,7 +934,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, CCTK_WARN (1,"I don't understand petsc_KSP_type. Using BiCGSTAB\n"); ierr = KSPSetType(ksp,KSPBCGS); } - CHKERRA(ierr); + CHKERRQ(ierr); @@ -950,7 +956,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, ierr = KSPSetTolerances(ksp,rtol,atol,PETSC_DEFAULT, PETSC_DEFAULT); - CHKERRA(ierr); + CHKERRQ(ierr); /* We are warned in the manual that @@ -977,7 +983,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, */ /*$ierr = KSPGMRESSetOrthogonalization(ksp, KSPGMRESUnmodifiedGramSchmidtOrthogonalization); - CHKERRA(ierr);$*/ + CHKERRQ(ierr);$*/ /* We also learn that ... @@ -989,7 +995,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, */ if (verbose) CCTK_INFO("KSPSetInitialGuess\n"); - ierr = KSPSetInitialGuessNonzero(ksp); CHKERRA(ierr); + ierr = KSPSetInitialGuessNonzero(ksp); CHKERRQ(ierr); /* Set runtime options. Since we don't use PETSC runtime options @@ -997,7 +1003,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, we parse things out. But that may not be such a good idea. So lets put it here. */ - ierr = SLESSetFromOptions(sles); CHKERRA(ierr); + ierr = SLESSetFromOptions(sles); CHKERRQ(ierr); /* OK so finally we are able to ... */ @@ -1006,7 +1012,7 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, Solve the linear system - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (verbose) CCTK_INFO("SLES solve..."); - ierr = SLESSolve(sles,b,soln,&its); CHKERRA(ierr); + ierr = SLESSolve(sles,b,soln,&its); CHKERRQ(ierr); /* Here we can form a "res = Ax - b" and find its norm to get an idea of how well we've converged. Put this in later @@ -1047,14 +1053,14 @@ void petsc_confmetric_solver(cGH *GH, int *MetricPsiI, int MetricPsiISize, PUGH_SyncGroup(GH,"ellpetsc::petscworkspace"); /* And finally free up the matrix memory FIXME - ierr = MatReleaseValuesMemory(A); CHKERRA(ierr); */ + ierr = MatReleaseValuesMemory(A); CHKERRQ(ierr); */ /* This code is not used anymore */ if (verbose) CCTK_INFO("Destroying Matrices"); - ierr = SLESDestroy(sles); CHKERRA(ierr); - ierr = VecDestroy(soln); CHKERRA(ierr); - ierr = VecDestroy(b); CHKERRA(ierr); - ierr = MatDestroy(A[0]); CHKERRA(ierr); + ierr = SLESDestroy(sles); CHKERRQ(ierr); + ierr = VecDestroy(soln); CHKERRQ(ierr); + ierr = VecDestroy(b); CHKERRQ(ierr); + ierr = MatDestroy(A[0]); CHKERRQ(ierr); free(A); /*$PetscFinalize();$*/ |