Actual source code: dlregismfn.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/mfnimpl.h>

 13: static PetscBool MFNPackageInitialized = PETSC_FALSE;

 15: const char *const MFNConvergedReasons_Shifted[] = {"DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_ITS","MFNConvergedReason","MFN_",NULL};
 16: const char *const*MFNConvergedReasons = MFNConvergedReasons_Shifted + 2;

 18: /*@C
 19:   MFNFinalizePackage - This function destroys everything in the SLEPc interface
 20:   to the `MFN` package. It is called from `SlepcFinalize()`.

 22:   Level: developer

 24: .seealso: [](ch:mfn), `SlepcFinalize()`, `MFNInitializePackage()`
 25: @*/
 26: PetscErrorCode MFNFinalizePackage(void)
 27: {
 28:   PetscFunctionBegin;
 29:   PetscCall(PetscFunctionListDestroy(&MFNList));
 30:   PetscCall(PetscFunctionListDestroy(&MFNMonitorList));
 31:   PetscCall(PetscFunctionListDestroy(&MFNMonitorCreateList));
 32:   PetscCall(PetscFunctionListDestroy(&MFNMonitorDestroyList));
 33:   MFNPackageInitialized       = PETSC_FALSE;
 34:   MFNRegisterAllCalled        = PETSC_FALSE;
 35:   MFNMonitorRegisterAllCalled = PETSC_FALSE;
 36:   PetscFunctionReturn(PETSC_SUCCESS);
 37: }

 39: /*@C
 40:    MFNInitializePackage - This function initializes everything in the `MFN` package.
 41:    It is called from `PetscDLLibraryRegister_slepcmfn()` when using dynamic libraries, and
 42:    on the first call to `MFNCreate()` when using shared or static libraries.

 44:    Note:
 45:    This function never needs to be called by SLEPc users.

 47:    Level: developer

 49: .seealso: [](ch:mfn), `MFN`, `SlepcInitialize()`, `MFNFinalizePackage()`
 50: @*/
 51: PetscErrorCode MFNInitializePackage(void)
 52: {
 53:   char           logList[256];
 54:   PetscBool      opt,pkg;
 55:   PetscClassId   classids[1];

 57:   PetscFunctionBegin;
 58:   if (MFNPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
 59:   MFNPackageInitialized = PETSC_TRUE;
 60:   /* Register Classes */
 61:   PetscCall(PetscClassIdRegister("Matrix Function",&MFN_CLASSID));
 62:   /* Register Constructors */
 63:   PetscCall(MFNRegisterAll());
 64:   /* Register Monitors */
 65:   PetscCall(MFNMonitorRegisterAll());
 66:   /* Register Events */
 67:   PetscCall(PetscLogEventRegister("MFNSetUp",MFN_CLASSID,&MFN_SetUp));
 68:   PetscCall(PetscLogEventRegister("MFNSolve",MFN_CLASSID,&MFN_Solve));
 69:   /* Process Info */
 70:   classids[0] = MFN_CLASSID;
 71:   PetscCall(PetscInfoProcessClass("mfn",1,&classids[0]));
 72:   /* Process summary exclusions */
 73:   PetscCall(PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt));
 74:   if (opt) {
 75:     PetscCall(PetscStrInList("mfn",logList,',',&pkg));
 76:     if (pkg) PetscCall(PetscLogEventDeactivateClass(MFN_CLASSID));
 77:   }
 78:   /* Register package finalizer */
 79:   PetscCall(PetscRegisterFinalize(MFNFinalizePackage));
 80:   PetscFunctionReturn(PETSC_SUCCESS);
 81: }

 83: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
 84: /*
 85:   PetscDLLibraryRegister - This function is called when the dynamic library
 86:   it is in is opened.

 88:   This one registers all the MFN methods that are in the basic SLEPc libslepcmfn
 89:   library.
 90:  */
 91: SLEPC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcmfn(void)
 92: {
 93:   PetscFunctionBegin;
 94:   PetscCall(MFNInitializePackage());
 95:   PetscFunctionReturn(PETSC_SUCCESS);
 96: }
 97: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */