LCOV - code coverage report
Current view: top level - eps/impls/external/blopex - slepc-interface.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 31 31 100.0 %
Date: 2024-04-19 00:53:38 Functions: 2 2 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             :    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 <interpreter.h>
      18             : #include <temp_multivector.h>
      19             : #include "blopex.h"
      20             : 
      21          18 : static void* mv_TempMultiVectorCreateFromBV(void* ii_,BlopexInt n,void* sample)
      22             : {
      23          18 :   BV                      bv = (BV)sample;
      24          18 :   Vec                     v;
      25          18 :   PetscInt                i,l,k,nc,useconstr=PETSC_FALSE,flg;
      26          18 :   mv_TempMultiVector      *x;
      27          18 :   mv_InterfaceInterpreter *ii = (mv_InterfaceInterpreter*)ii_;
      28             : 
      29          18 :   x = (mv_TempMultiVector*)malloc(sizeof(mv_TempMultiVector));
      30          18 :   if (!x) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x failed");
      31             : 
      32          18 :   x->interpreter = ii;
      33          18 :   x->numVectors  = n;
      34             : 
      35          18 :   x->vector = (void**)calloc(n,sizeof(void*));
      36          18 :   if (!x->vector) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x->vector failed");
      37             : 
      38          18 :   x->ownsVectors = 1;
      39          18 :   x->mask = NULL;
      40          18 :   x->ownsMask = 0;
      41             : 
      42          18 :   PetscCallAbort(PETSC_COMM_SELF,BVGetActiveColumns(bv,&l,&k));
      43          18 :   PetscCallAbort(PETSC_COMM_SELF,PetscObjectComposedDataGetInt((PetscObject)bv,slepc_blopex_useconstr,useconstr,flg));
      44          18 :   if (!l && flg && useconstr) {
      45           9 :     PetscCallAbort(PETSC_COMM_SELF,BVGetNumConstraints(bv,&nc));
      46           9 :     l = -nc;
      47             :   }
      48          18 :   if (n != k-l) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"BV active columns plus constraints do not match argument n");
      49          61 :   for (i=0;i<n;i++) {
      50          43 :     PetscCallAbort(PETSC_COMM_SELF,BVGetColumn(bv,l+i,&v));
      51          43 :     PetscCallAbort(PETSC_COMM_SELF,PetscObjectReference((PetscObject)v));
      52          43 :     x->vector[i] = (void*)v;
      53          43 :     PetscCallAbort(PETSC_COMM_SELF,BVRestoreColumn(bv,l+i,&v));
      54             :   }
      55          18 :   return x;
      56             : }
      57             : 
      58             : /*
      59             :     Create an InterfaceInterpreter using the PETSc implementation
      60             :     but overloading CreateMultiVector that doesn't create any
      61             :     new vector.
      62             : */
      63           7 : int SLEPCSetupInterpreter(mv_InterfaceInterpreter *i)
      64             : {
      65           7 :   PETSCSetupInterpreter(i);
      66           7 :   i->CreateMultiVector = mv_TempMultiVectorCreateFromBV;
      67             : 
      68           7 :   return 0;
      69             : }

Generated by: LCOV version 1.14