Actual source code: dlregismfn.c

slepc-main 2024-11-22
Report Typos and Errors
  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: SlepcFinalize()
 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() when using dynamic libraries, and
 42:   on the first call to MFNCreate() when using static libraries.

 44:   Level: developer

 46: .seealso: SlepcInitialize()
 47: @*/
 48: PetscErrorCode MFNInitializePackage(void)
 49: {
 50:   char           logList[256];
 51:   PetscBool      opt,pkg;
 52:   PetscClassId   classids[1];

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

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

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