Date: 2026-01-20T11:35:33+00:00

Actual source code: dlregisnep.c

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain

      6:    This file is part of SLEPc.
      7:    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
      8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      9: */

     11: #include <slepc/private/nepimpl.h>

     13: static PetscBool NEPPackageInitialized = PETSC_FALSE;

     15: const char *NEPErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","NEPErrorType","NEP_ERROR_",NULL};
     16: const char *NEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","NEPRefine","NEP_REFINE_",NULL};
     17: const char *NEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","NEPRefineScheme","NEP_REFINE_SCHEME_",NULL};
     18: const char *NEPCISSExtractions[] = {"RITZ","HANKEL","CAA","NEPCISSExtraction","NEP_CISS_EXTRACTION_",NULL};
     19: const char *const NEPConvergedReasons_Shifted[] = {"DIVERGED_SUBSPACE_EXHAUSTED","DIVERGED_LINEAR_SOLVE","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","NEPConvergedReason","NEP_",NULL};
     20: const char *const*NEPConvergedReasons = NEPConvergedReasons_Shifted + 5;

     22: /*@C
     23:   NEPFinalizePackage - This function destroys everything in the SLEPc interface
     24:   to the `NEP` package. It is called from `SlepcFinalize()`.

     26:   Level: developer

     28: .seealso: [](ch:nep), `SlepcFinalize()`, `NEPInitializePackage()`
     29: @*/
     30: PetscErrorCode NEPFinalizePackage(void)
     31: {
     32:   PetscFunctionBegin;
     33:   PetscCall(PetscFunctionListDestroy(&NEPList));
     34:   PetscCall(PetscFunctionListDestroy(&NEPMonitorList));
     35:   PetscCall(PetscFunctionListDestroy(&NEPMonitorCreateList));
     36:   PetscCall(PetscFunctionListDestroy(&NEPMonitorDestroyList));
     37:   NEPPackageInitialized       = PETSC_FALSE;
     38:   NEPRegisterAllCalled        = PETSC_FALSE;
     39:   NEPMonitorRegisterAllCalled = PETSC_FALSE;
     40:   PetscFunctionReturn(PETSC_SUCCESS);
     41: }

     43: /*@C
     44:    NEPInitializePackage - This function initializes everything in the `NEP` package.
     45:    It is called from `PetscDLLibraryRegister_slepcnep()` when using dynamic libraries, and
     46:    on the first call to `NEPCreate()` when using shared or static libraries.

     48:    Note:
     49:    This function never needs to be called by SLEPc users.

     51:    Level: developer

     53: .seealso: [](ch:nep), `NEP`, `SlepcInitialize()`, `NEPFinalizePackage()`
     54: @*/
     55: PetscErrorCode NEPInitializePackage(void)
     56: {
     57:   char           logList[256];
     58:   PetscBool      opt,pkg;
     59:   PetscClassId   classids[1];

     61:   PetscFunctionBegin;
     62:   if (NEPPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
     63:   NEPPackageInitialized = PETSC_TRUE;
     64:   /* Register Classes */
     65:   PetscCall(PetscClassIdRegister("NEP Solver",&NEP_CLASSID));
     66:   /* Register Constructors */
     67:   PetscCall(NEPRegisterAll());
     68:   /* Register Monitors */
     69:   PetscCall(NEPMonitorRegisterAll());
     70:   /* Register Events */
     71:   PetscCall(PetscLogEventRegister("NEPSetUp",NEP_CLASSID,&NEP_SetUp));
     72:   PetscCall(PetscLogEventRegister("NEPSolve",NEP_CLASSID,&NEP_Solve));
     73:   PetscCall(PetscLogEventRegister("NEPRefine",NEP_CLASSID,&NEP_Refine));
     74:   PetscCall(PetscLogEventRegister("NEPFunctionEval",NEP_CLASSID,&NEP_FunctionEval));
     75:   PetscCall(PetscLogEventRegister("NEPJacobianEval",NEP_CLASSID,&NEP_JacobianEval));
     76:   PetscCall(PetscLogEventRegister("NEPResolvent",NEP_CLASSID,&NEP_Resolvent));
     77:   PetscCall(PetscLogEventRegister("NEPCISS_SVD",NEP_CLASSID,&NEP_CISS_SVD));
     78:   /* Process Info */
     79:   classids[0] = NEP_CLASSID;
     80:   PetscCall(PetscInfoProcessClass("nep",1,&classids[0]));
     81:   /* Process summary exclusions */
     82:   PetscCall(PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt));
     83:   if (opt) {
     84:     PetscCall(PetscStrInList("nep",logList,',',&pkg));
     85:     if (pkg) PetscCall(PetscLogEventDeactivateClass(NEP_CLASSID));
     86:   }
     87:   /* Register package finalizer */
     88:   PetscCall(PetscRegisterFinalize(NEPFinalizePackage));
     89:   PetscFunctionReturn(PETSC_SUCCESS);
     90: }

     92: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
     93: /*
     94:   PetscDLLibraryRegister - This function is called when the dynamic library
     95:   it is in is opened.

     97:   This one registers all the NEP methods that are in the basic SLEPc libslepcnep
     98:   library.
     99:  */
    100: SLEPC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcnep(void)
    101: {
    102:   PetscFunctionBegin;
    103:   PetscCall(NEPInitializePackage());
    104:   PetscFunctionReturn(PETSC_SUCCESS);
    105: }
    106: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */