Actual source code: dlregislme.c

slepc-3.22.2 2024-12-02
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/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: SlepcFinalize()
 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() when using dynamic libraries, and
 43:   on the first call to LMECreate() when using static libraries.

 45:   Level: developer

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

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

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

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