Actual source code: dlregislme.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/lmeimpl.h>

 13: static PetscBool LMEPackageInitialized = PETSC_FALSE;

 15: const char *LMEProblemTypes[] = {"LYAPUNOV","SYLVESTER","GEN_LYAPUNOV","GEN_SYLVESTER","DT_LYAPUNOV","STEIN","LMEProblemType","LME_",NULL};
 16: const char *const LMEConvergedReasons_Shifted[] = {"DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","LMEConvergedReason","LME_",NULL};
 17: const char *const*LMEConvergedReasons = LMEConvergedReasons_Shifted + 2;

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

 23:   Level: developer

 25: .seealso: [](ch:lme), `SlepcFinalize()`, `LMEInitializePackage()`
 26: @*/
 27: PetscErrorCode LMEFinalizePackage(void)
 28: {
 29:   PetscFunctionBegin;
 30:   PetscCall(PetscFunctionListDestroy(&LMEList));
 31:   PetscCall(PetscFunctionListDestroy(&LMEMonitorList));
 32:   PetscCall(PetscFunctionListDestroy(&LMEMonitorCreateList));
 33:   PetscCall(PetscFunctionListDestroy(&LMEMonitorDestroyList));
 34:   LMEPackageInitialized       = PETSC_FALSE;
 35:   LMERegisterAllCalled        = PETSC_FALSE;
 36:   LMEMonitorRegisterAllCalled = PETSC_FALSE;
 37:   PetscFunctionReturn(PETSC_SUCCESS);
 38: }

 40: /*@C
 41:    LMEInitializePackage - This function initializes everything in the `LME` package.
 42:    It is called from `PetscDLLibraryRegister_slepclme()` when using dynamic libraries, and
 43:    on the first call to `LMECreate()` when using shared or static libraries.

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

 48:    Level: developer

 50: .seealso: [](ch:lme), `LME`, `SlepcInitialize()`, `LMEFinalizePackage()`
 51: @*/
 52: PetscErrorCode LMEInitializePackage(void)
 53: {
 54:   char           logList[256];
 55:   PetscBool      opt,pkg;
 56:   PetscClassId   classids[1];

 58:   PetscFunctionBegin;
 59:   if (LMEPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
 60:   LMEPackageInitialized = PETSC_TRUE;
 61:   /* Register Classes */
 62:   PetscCall(PetscClassIdRegister("Lin. Matrix Equation",&LME_CLASSID));
 63:   /* Register Constructors */
 64:   PetscCall(LMERegisterAll());
 65:   /* Register Monitors */
 66:   PetscCall(LMEMonitorRegisterAll());
 67:   /* Register Events */
 68:   PetscCall(PetscLogEventRegister("LMESetUp",LME_CLASSID,&LME_SetUp));
 69:   PetscCall(PetscLogEventRegister("LMESolve",LME_CLASSID,&LME_Solve));
 70:   PetscCall(PetscLogEventRegister("LMEComputeError",LME_CLASSID,&LME_ComputeError));
 71:   /* Process Info */
 72:   classids[0] = LME_CLASSID;
 73:   PetscCall(PetscInfoProcessClass("lme",1,&classids[0]));
 74:   /* Process summary exclusions */
 75:   PetscCall(PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt));
 76:   if (opt) {
 77:     PetscCall(PetscStrInList("lme",logList,',',&pkg));
 78:     if (pkg) PetscCall(PetscLogEventDeactivateClass(LME_CLASSID));
 79:   }
 80:   /* Register package finalizer */
 81:   PetscCall(PetscRegisterFinalize(LMEFinalizePackage));
 82:   PetscFunctionReturn(PETSC_SUCCESS);
 83: }

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

 90:   This one registers all the LME methods that are in the basic SLEPc libslepclme
 91:   library.
 92:  */
 93: SLEPC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepclme(void)
 94: {
 95:   PetscFunctionBegin;
 96:   PetscCall(LMEInitializePackage());
 97:   PetscFunctionReturn(PETSC_SUCCESS);
 98: }
 99: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */