Line data Source code
1 : /* 2 : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 : SLEPc - Scalable Library for Eigenvalue Problem Computations 4 : Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain 5 : 6 : This file is part of SLEPc. 7 : SLEPc is distributed under a 2-clause BSD license (see LICENSE). 8 : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9 : */ 10 : 11 : #include <slepc/private/mfnimpl.h> 12 : 13 : static PetscBool MFNPackageInitialized = PETSC_FALSE; 14 : 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; 17 : 18 : /*@C 19 : MFNFinalizePackage - This function destroys everything in the SLEPc interface 20 : to the MFN package. It is called from SlepcFinalize(). 21 : 22 : Level: developer 23 : 24 : .seealso: SlepcFinalize() 25 : @*/ 26 17 : PetscErrorCode MFNFinalizePackage(void) 27 : { 28 17 : PetscFunctionBegin; 29 17 : PetscCall(PetscFunctionListDestroy(&MFNList)); 30 17 : PetscCall(PetscFunctionListDestroy(&MFNMonitorList)); 31 17 : PetscCall(PetscFunctionListDestroy(&MFNMonitorCreateList)); 32 17 : PetscCall(PetscFunctionListDestroy(&MFNMonitorDestroyList)); 33 17 : MFNPackageInitialized = PETSC_FALSE; 34 17 : MFNRegisterAllCalled = PETSC_FALSE; 35 17 : MFNMonitorRegisterAllCalled = PETSC_FALSE; 36 17 : PetscFunctionReturn(PETSC_SUCCESS); 37 : } 38 : 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. 43 : 44 : Level: developer 45 : 46 : .seealso: SlepcInitialize() 47 : @*/ 48 87 : PetscErrorCode MFNInitializePackage(void) 49 : { 50 87 : char logList[256]; 51 87 : PetscBool opt,pkg; 52 87 : PetscClassId classids[1]; 53 : 54 87 : PetscFunctionBegin; 55 87 : if (MFNPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS); 56 17 : MFNPackageInitialized = PETSC_TRUE; 57 : /* Register Classes */ 58 17 : PetscCall(PetscClassIdRegister("Matrix Function",&MFN_CLASSID)); 59 : /* Register Constructors */ 60 17 : PetscCall(MFNRegisterAll()); 61 : /* Register Monitors */ 62 17 : PetscCall(MFNMonitorRegisterAll()); 63 : /* Register Events */ 64 17 : PetscCall(PetscLogEventRegister("MFNSetUp",MFN_CLASSID,&MFN_SetUp)); 65 17 : PetscCall(PetscLogEventRegister("MFNSolve",MFN_CLASSID,&MFN_Solve)); 66 : /* Process Info */ 67 17 : classids[0] = MFN_CLASSID; 68 17 : PetscCall(PetscInfoProcessClass("mfn",1,&classids[0])); 69 : /* Process summary exclusions */ 70 17 : PetscCall(PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt)); 71 17 : if (opt) { 72 2 : PetscCall(PetscStrInList("mfn",logList,',',&pkg)); 73 2 : if (pkg) PetscCall(PetscLogEventDeactivateClass(MFN_CLASSID)); 74 : } 75 : /* Register package finalizer */ 76 17 : PetscCall(PetscRegisterFinalize(MFNFinalizePackage)); 77 17 : PetscFunctionReturn(PETSC_SUCCESS); 78 : } 79 : 80 : #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) 81 : /* 82 : PetscDLLibraryRegister - This function is called when the dynamic library 83 : it is in is opened. 84 : 85 : This one registers all the MFN methods that are in the basic SLEPc libslepcmfn 86 : library. 87 : */ 88 1 : SLEPC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcmfn(void) 89 : { 90 1 : PetscFunctionBegin; 91 1 : PetscCall(MFNInitializePackage()); 92 1 : PetscFunctionReturn(PETSC_SUCCESS); 93 : } 94 : #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */