LCOV - code coverage report
Current view: top level - eps/impls/external/blopex - slepc-interface.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 29 29 100.0 %
Date: 2019-10-20 05:41:02 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-2019, 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             :    Modification of the *temp* implementation of the BLOPEX multivector in order
      12             :    to wrap created PETSc vectors as multivectors.
      13             : */
      14             : 
      15             : #include <slepc/private/bvimpl.h>
      16             : #include <stdlib.h>
      17             : #include <blopex_interpreter.h>
      18             : #include <blopex_temp_multivector.h>
      19             : #include "blopex.h"
      20             : 
      21          18 : static void* mv_TempMultiVectorCreateFromBV(void* ii_,BlopexInt n,void* sample)
      22             : {
      23             :   PetscErrorCode          ierr;
      24          18 :   BV                      bv = (BV)sample;
      25             :   Vec                     v;
      26          18 :   PetscInt                i,l,k,nc,useconstr=PETSC_FALSE,flg;
      27             :   mv_TempMultiVector      *x;
      28          18 :   mv_InterfaceInterpreter *ii = (mv_InterfaceInterpreter*)ii_;
      29             : 
      30          18 :   x = (mv_TempMultiVector*)malloc(sizeof(mv_TempMultiVector));
      31          18 :   if (!x) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x failed");
      32             : 
      33          18 :   x->interpreter = ii;
      34          18 :   x->numVectors  = n;
      35             : 
      36          18 :   x->vector = (void**)calloc(n,sizeof(void*));
      37          18 :   if (!x->vector) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x->vector failed");
      38             : 
      39          18 :   x->ownsVectors = 1;
      40          18 :   x->mask = NULL;
      41          18 :   x->ownsMask = 0;
      42             : 
      43          18 :   ierr = BVGetActiveColumns(bv,&l,&k);CHKERRABORT(PETSC_COMM_SELF,ierr);
      44          18 :   ierr = PetscObjectComposedDataGetInt((PetscObject)bv,slepc_blopex_useconstr,useconstr,flg);CHKERRABORT(PETSC_COMM_SELF,ierr);
      45          18 :   if (!l && useconstr) {
      46           9 :     ierr = BVGetNumConstraints(bv,&nc);CHKERRABORT(PETSC_COMM_SELF,ierr);
      47           9 :     l = -nc;
      48             :   }
      49          18 :   if (n != k-l) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"BV active columns plus constraints do not match argument n");
      50          43 :   for (i=0;i<n;i++) {
      51          43 :     ierr = BVGetColumn(bv,l+i,&v);CHKERRABORT(PETSC_COMM_SELF,ierr);
      52          43 :     ierr = PetscObjectReference((PetscObject)v);CHKERRABORT(PETSC_COMM_SELF,ierr);
      53          43 :     x->vector[i] = (void*)v;
      54          43 :     ierr = BVRestoreColumn(bv,l+i,&v);CHKERRABORT(PETSC_COMM_SELF,ierr);
      55             :   }
      56          18 :   return x;
      57             : }
      58             : 
      59             : /*
      60             :     Create an InterfaceInterpreter using the PETSc implementation
      61             :     but overloading CreateMultiVector that doesn't create any
      62             :     new vector.
      63             : */
      64           7 : int SLEPCSetupInterpreter(mv_InterfaceInterpreter *i)
      65             : {
      66           7 :   PETSCSetupInterpreter(i);
      67           7 :   i->CreateMultiVector = mv_TempMultiVectorCreateFromBV;
      68             : 
      69           7 :   return 0;
      70             : }
      71             : 

Generated by: LCOV version 1.13