LCOV - code coverage report
Current view: top level - eps/tests - test20.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 36 36 100.0 %
Date: 2024-12-18 00:42:09 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
       5             : 
       6             :    This file is part of SLEPc.
       7             :    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
       8             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       9             : */
      10             : 
      11             : static char help[] = "Tests multiple calls to EPSSolve changing ncv.\n\n";
      12             : 
      13             : #include <slepceps.h>
      14             : 
      15           8 : int main(int argc,char **argv)
      16             : {
      17           8 :   Mat            A;
      18           8 :   EPS            eps;
      19           8 :   PetscReal      tol=PetscMax(1000*PETSC_MACHINE_EPSILON,1e-9);
      20           8 :   PetscInt       n=30,i,Istart,Iend,nev,ncv;
      21             : 
      22           8 :   PetscFunctionBeginUser;
      23           8 :   PetscCall(SlepcInitialize(&argc,&argv,NULL,help));
      24           8 :   PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL));
      25           8 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem, n=%" PetscInt_FMT "\n\n",n));
      26             : 
      27             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      28             :      Compute the operator matrix that defines the eigensystem, Ax=kx
      29             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      30             : 
      31           8 :   PetscCall(MatCreate(PETSC_COMM_WORLD,&A));
      32           8 :   PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n));
      33           8 :   PetscCall(MatSetFromOptions(A));
      34           8 :   PetscCall(MatGetOwnershipRange(A,&Istart,&Iend));
      35         152 :   for (i=Istart;i<Iend;i++) {
      36         144 :     if (i>0) PetscCall(MatSetValue(A,i,i-1,-1.0,INSERT_VALUES));
      37         144 :     if (i<n-1) PetscCall(MatSetValue(A,i,i+1,-1.0,INSERT_VALUES));
      38         144 :     PetscCall(MatSetValue(A,i,i,2.0,INSERT_VALUES));
      39             :   }
      40           8 :   PetscCall(MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY));
      41           8 :   PetscCall(MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY));
      42             : 
      43             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      44             :              Create the solver, call EPSSolve() twice
      45             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      46           8 :   PetscCall(EPSCreate(PETSC_COMM_WORLD,&eps));
      47           8 :   PetscCall(EPSSetOperators(eps,A,NULL));
      48           8 :   PetscCall(EPSSetProblemType(eps,EPS_HEP));
      49           8 :   PetscCall(EPSSetTolerances(eps,tol,PETSC_CURRENT));
      50           8 :   PetscCall(EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL));
      51           8 :   PetscCall(EPSSetFromOptions(eps));
      52             : 
      53             :   /* First solve */
      54           8 :   PetscCall(EPSSolve(eps));
      55           8 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD," - - - First solve, default subspace dimension - - -\n"));
      56           8 :   PetscCall(EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL));
      57             : 
      58             :   /* Second solve */
      59           8 :   PetscCall(EPSGetDimensions(eps,&nev,&ncv,NULL));
      60           8 :   PetscCall(EPSSetDimensions(eps,nev,ncv+2,PETSC_DETERMINE));
      61           8 :   PetscCall(EPSSolve(eps));
      62           8 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD," - - - Second solve, subspace of increased size - - -\n"));
      63           8 :   PetscCall(EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL));
      64             : 
      65           8 :   PetscCall(EPSDestroy(&eps));
      66           8 :   PetscCall(MatDestroy(&A));
      67           8 :   PetscCall(SlepcFinalize());
      68             :   return 0;
      69             : }
      70             : 
      71             : /*TEST
      72             : 
      73             :    test:
      74             :       suffix: 1
      75             :       args: -n 18 -eps_type {{krylovschur arnoldi gd jd rqcg lobpcg lapack}} -eps_max_it 1500
      76             :       output_file: output/test20_1.out
      77             : 
      78             :    test:
      79             :       suffix: 1_lanczos
      80             :       args: -n 18 -eps_type lanczos -eps_lanczos_reorthog full -eps_max_it 1500
      81             :       output_file: output/test20_1.out
      82             : 
      83             : TEST*/

Generated by: LCOV version 1.14