1 #define TAO_DLL 2 3 #include <petsc-private/taoimpl.h> 4 #include <petsc-private/taodmimpl.h> 5 6 static PetscBool TaoPackageInitialized = PETSC_FALSE; 7 8 #undef __FUNCT__ 9 #define __FUNCT__ "TaoFinalizePackage" 10 /*@C 11 TaoFinalizePackage - This function destroys everything in the PETSc/TAO 12 interface to the Tao package. It is called from PetscFinalize(). 13 14 Level: developer 15 @*/ 16 PetscErrorCode TaoFinalizePackage(void) 17 { 18 PetscErrorCode ierr; 19 20 PetscFunctionBegin; 21 ierr = PetscFunctionListDestroy(&TaoList);CHKERRQ(ierr); 22 TaoPackageInitialized = PETSC_FALSE; 23 PetscFunctionReturn(0); 24 } 25 26 #undef __FUNCT__ 27 #define __FUNCT__ "TaoInitializePackage" 28 /*@C 29 TaoInitializePackage - This function sets up PETSc to use the Tao 30 package. When using static libraries, this function is called from the 31 first entry to TaoCreate(); when using shared libraries, it is called 32 from PetscDLLibraryRegister() 33 34 Level: developer 35 36 .seealso: TaoCreate() 37 @*/ 38 PetscErrorCode TaoInitializePackage(void) 39 { 40 PetscErrorCode ierr; 41 42 PetscFunctionBegin; 43 44 if (TaoPackageInitialized) PetscFunctionReturn(0); 45 TaoPackageInitialized = PETSC_TRUE; 46 47 ierr = PetscClassIdRegister("Tao",&TAO_CLASSID);CHKERRQ(ierr); 48 49 /* Tell PETSc what solvers are available */ 50 ierr = TaoRegisterAll();CHKERRQ(ierr); 51 52 /* Tell PETSc what events are associated with Tao */ 53 ierr = PetscLogEventRegister("TaoSolve",TAO_CLASSID,&Tao_Solve);CHKERRQ(ierr); 54 ierr = PetscLogEventRegister("TaoObjectiveEval",TAO_CLASSID,&Tao_ObjectiveEval);CHKERRQ(ierr); 55 ierr = PetscLogEventRegister("TaoGradientEval",TAO_CLASSID,&Tao_GradientEval);CHKERRQ(ierr); 56 ierr = PetscLogEventRegister("TaoHessianEval",TAO_CLASSID,&Tao_HessianEval);CHKERRQ(ierr); 57 ierr = PetscLogEventRegister("TaoConstraintsEval",TAO_CLASSID,&Tao_ConstraintsEval);CHKERRQ(ierr); 58 ierr = PetscLogEventRegister("TaoJacobianEval",TAO_CLASSID,&Tao_JacobianEval);CHKERRQ(ierr); 59 60 ierr = PetscRegisterFinalize(TaoFinalizePackage);CHKERRQ(ierr); 61 PetscFunctionReturn(0); 62 } 63 64 #ifdef PETSC_USE_DYNAMIC_LIBRARIES 65 #undef __FUNCT__ 66 #define __FUNCT__ "PetscDLLibraryRegister_tao" 67 /* 68 PetscDLLibraryRegister - this function is called when the dynamic library it 69 is in is opened. 70 71 This registers all of the Tao methods that are in the libtao 72 library. 73 74 Input Parameter: 75 . path - library path 76 */ 77 78 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_tao(void) 79 { 80 PetscErrorCode ierr; 81 82 PetscFunctionBegin; 83 ierr = TaoInitializePackage();CHKERRQ(ierr); 84 ierr = TaoLineSearchInitializePackage();CHKERRQ(ierr); 85 PetscFunctionReturn(0); 86 } 87 88 #endif /* PETSC_USE_DYNAMIC_LIBRARIES */ 89