1e8597998SBarry Smith 24035e84dSBarry Smith #include <petsc-private/dmdaimpl.h> 334541f0dSBarry Smith #include <petsc-private/dmpleximpl.h> 4e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 5e8597998SBarry Smith #include <petsc-private/meshimpl.h> 6e8597998SBarry Smith #endif 7e8597998SBarry Smith 8e8597998SBarry Smith static PetscBool DMPackageInitialized = PETSC_FALSE; 9e8597998SBarry Smith #undef __FUNCT__ 10e8597998SBarry Smith #define __FUNCT__ "DMFinalizePackage" 11e8597998SBarry Smith /*@C 12e8597998SBarry Smith DMFinalizePackage - This function finalizes everything in the DM package. It is called 13e8597998SBarry Smith from PetscFinalize(). 14e8597998SBarry Smith 15e8597998SBarry Smith Level: developer 16e8597998SBarry Smith 17e8597998SBarry Smith .keywords: AO, initialize, package 18e8597998SBarry Smith .seealso: PetscInitialize() 19e8597998SBarry Smith @*/ 20e8597998SBarry Smith PetscErrorCode DMFinalizePackage(void) 21e8597998SBarry Smith { 22e8597998SBarry Smith PetscErrorCode ierr; 23e8597998SBarry Smith 24e8597998SBarry Smith PetscFunctionBegin; 2537e93019SBarry Smith ierr = PetscFunctionListDestroy(&DMList);CHKERRQ(ierr); 26e8597998SBarry Smith DMPackageInitialized = PETSC_FALSE; 27e8597998SBarry Smith DMRegisterAllCalled = PETSC_FALSE; 28e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 29e8597998SBarry Smith ierr = DMMeshFinalize();CHKERRQ(ierr); 30e8597998SBarry Smith #endif 31e8597998SBarry Smith PetscFunctionReturn(0); 32e8597998SBarry Smith } 33e8597998SBarry Smith 34e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE) 358cc058d9SJed Brown PETSC_EXTERN PetscErrorCode MatCreate_HYPREStruct(Mat); 36e8597998SBarry Smith #endif 37e8597998SBarry Smith 38e8597998SBarry Smith #undef __FUNCT__ 39e8597998SBarry Smith #define __FUNCT__ "DMInitializePackage" 40e8597998SBarry Smith /*@C 41e8597998SBarry Smith DMInitializePackage - This function initializes everything in the DM package. It is called 42e8597998SBarry Smith from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to AOCreate() 43e8597998SBarry Smith or DMDACreate() when using static libraries. 44e8597998SBarry Smith 45e8597998SBarry Smith Level: developer 46e8597998SBarry Smith 47e8597998SBarry Smith .keywords: AO, initialize, package 48e8597998SBarry Smith .seealso: PetscInitialize() 49e8597998SBarry Smith @*/ 50607a6623SBarry Smith PetscErrorCode DMInitializePackage(void) 51e8597998SBarry Smith { 52e8597998SBarry Smith char logList[256]; 53e8597998SBarry Smith char *className; 54e8597998SBarry Smith PetscBool opt; 55e8597998SBarry Smith PetscErrorCode ierr; 56e8597998SBarry Smith 57e8597998SBarry Smith PetscFunctionBegin; 58e8597998SBarry Smith if (DMPackageInitialized) PetscFunctionReturn(0); 59e8597998SBarry Smith DMPackageInitialized = PETSC_TRUE; 60e8597998SBarry Smith 61e8597998SBarry Smith /* Register Classes */ 62e8597998SBarry Smith ierr = PetscClassIdRegister("Distributed Mesh",&DM_CLASSID);CHKERRQ(ierr); 63e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 64e8597998SBarry Smith ierr = PetscClassIdRegister("SectionReal",&SECTIONREAL_CLASSID);CHKERRQ(ierr); 65e8597998SBarry Smith ierr = PetscClassIdRegister("SectionInt",&SECTIONINT_CLASSID);CHKERRQ(ierr); 66e8597998SBarry Smith #endif 67e8597998SBarry Smith 68e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE) 69bdf89e91SBarry Smith ierr = MatRegister(MATHYPRESTRUCT, MatCreate_HYPREStruct);CHKERRQ(ierr); 70e8597998SBarry Smith #endif 71e8597998SBarry Smith 72e8597998SBarry Smith /* Register Constructors */ 73607a6623SBarry Smith ierr = DMRegisterAll();CHKERRQ(ierr); 74e8597998SBarry Smith /* Register Events */ 75e8597998SBarry Smith ierr = PetscLogEventRegister("DMConvert", DM_CLASSID,&DM_Convert);CHKERRQ(ierr); 76e8597998SBarry Smith ierr = PetscLogEventRegister("DMGlobalToLocal", DM_CLASSID,&DM_GlobalToLocal);CHKERRQ(ierr); 77e8597998SBarry Smith ierr = PetscLogEventRegister("DMLocalToGlobal", DM_CLASSID,&DM_LocalToGlobal);CHKERRQ(ierr); 78e8597998SBarry Smith 79e8597998SBarry Smith ierr = PetscLogEventRegister("DMDALocalADFunc", DM_CLASSID,&DMDA_LocalADFunction);CHKERRQ(ierr); 80e8597998SBarry Smith 81e8597998SBarry Smith ierr = PetscLogEventRegister("DMPlexDistribute", DM_CLASSID,&DMPLEX_Distribute);CHKERRQ(ierr); 82e8597998SBarry Smith ierr = PetscLogEventRegister("DMPlexStratify", DM_CLASSID,&DMPLEX_Stratify);CHKERRQ(ierr); 83*a0845e3aSMatthew G. Knepley ierr = PetscLogEventRegister("DMPlexResidualFEM", DM_CLASSID,&DMPLEX_ResidualFEM);CHKERRQ(ierr); 84e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 85e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshView", DM_CLASSID,&DMMesh_View);CHKERRQ(ierr); 86e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshGetGlobalScatter", DM_CLASSID,&DMMesh_GetGlobalScatter);CHKERRQ(ierr); 87e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshRestrictVector", DM_CLASSID,&DMMesh_restrictVector);CHKERRQ(ierr); 88e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshAssembleVector", DM_CLASSID,&DMMesh_assembleVector);CHKERRQ(ierr); 89e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshAssemVecComplete", DM_CLASSID,&DMMesh_assembleVectorComplete);CHKERRQ(ierr); 90e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshAssembleMatrix", DM_CLASSID,&DMMesh_assembleMatrix);CHKERRQ(ierr); 91e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshUpdateOperator", DM_CLASSID,&DMMesh_updateOperator);CHKERRQ(ierr); 92e8597998SBarry Smith ierr = PetscLogEventRegister("SectionRealView", SECTIONREAL_CLASSID,&SectionReal_View);CHKERRQ(ierr); 93e8597998SBarry Smith ierr = PetscLogEventRegister("SectionIntView", SECTIONINT_CLASSID,&SectionInt_View);CHKERRQ(ierr); 94e8597998SBarry Smith #endif 95e8597998SBarry Smith /* Process info exclusions */ 96e8597998SBarry Smith ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 97e8597998SBarry Smith if (opt) { 98e8597998SBarry Smith ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr); 99e8597998SBarry Smith if (className) { 100e8597998SBarry Smith ierr = PetscInfoDeactivateClass(DM_CLASSID);CHKERRQ(ierr); 101e8597998SBarry Smith } 102e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 103e8597998SBarry Smith ierr = PetscStrstr(logList, "sectionreal", &className);CHKERRQ(ierr); 104e8597998SBarry Smith if (className) { 105e8597998SBarry Smith ierr = PetscInfoDeactivateClass(SECTIONREAL_CLASSID);CHKERRQ(ierr); 106e8597998SBarry Smith } 107e8597998SBarry Smith ierr = PetscStrstr(logList, "sectionint", &className);CHKERRQ(ierr); 108e8597998SBarry Smith if (className) { 109e8597998SBarry Smith ierr = PetscInfoDeactivateClass(SECTIONINT_CLASSID);CHKERRQ(ierr); 110e8597998SBarry Smith } 111e8597998SBarry Smith #endif 112e8597998SBarry Smith } 113e8597998SBarry Smith /* Process summary exclusions */ 114e8597998SBarry Smith ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr); 115e8597998SBarry Smith if (opt) { 116e8597998SBarry Smith ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr); 117e8597998SBarry Smith if (className) { 118e8597998SBarry Smith ierr = PetscLogEventDeactivateClass(DM_CLASSID);CHKERRQ(ierr); 119e8597998SBarry Smith } 120e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 121e8597998SBarry Smith ierr = PetscStrstr(logList, "sectionreal", &className);CHKERRQ(ierr); 122e8597998SBarry Smith if (className) { 123e8597998SBarry Smith ierr = PetscLogEventDeactivateClass(SECTIONREAL_CLASSID);CHKERRQ(ierr); 124e8597998SBarry Smith } 125e8597998SBarry Smith ierr = PetscStrstr(logList, "sectionint", &className);CHKERRQ(ierr); 126e8597998SBarry Smith if (className) { 127e8597998SBarry Smith ierr = PetscLogEventDeactivateClass(SECTIONINT_CLASSID);CHKERRQ(ierr); 128e8597998SBarry Smith } 129e8597998SBarry Smith #endif 130e8597998SBarry Smith } 131e8597998SBarry Smith ierr = PetscRegisterFinalize(DMFinalizePackage);CHKERRQ(ierr); 132e8597998SBarry Smith PetscFunctionReturn(0); 133e8597998SBarry Smith } 13406759e06SMatthew G. Knepley #include <petscfe.h> 135e8597998SBarry Smith 13606759e06SMatthew G. Knepley static PetscBool PetscFEPackageInitialized = PETSC_FALSE; 13706759e06SMatthew G. Knepley #undef __FUNCT__ 13806759e06SMatthew G. Knepley #define __FUNCT__ "PetscFEFinalizePackage" 13906759e06SMatthew G. Knepley /*@C 14006759e06SMatthew G. Knepley PetscFEFinalizePackage - This function finalizes everything in the PetscFE package. It is called 14106759e06SMatthew G. Knepley from PetscFinalize(). 142e8597998SBarry Smith 14306759e06SMatthew G. Knepley Level: developer 14406759e06SMatthew G. Knepley 14506759e06SMatthew G. Knepley .keywords: PetscFE, initialize, package 14606759e06SMatthew G. Knepley .seealso: PetscInitialize() 14706759e06SMatthew G. Knepley @*/ 14806759e06SMatthew G. Knepley PetscErrorCode PetscFEFinalizePackage(void) 14906759e06SMatthew G. Knepley { 15006759e06SMatthew G. Knepley PetscErrorCode ierr; 15106759e06SMatthew G. Knepley 15206759e06SMatthew G. Knepley PetscFunctionBegin; 15306759e06SMatthew G. Knepley ierr = PetscFunctionListDestroy(&PetscSpaceList);CHKERRQ(ierr); 15406759e06SMatthew G. Knepley ierr = PetscFunctionListDestroy(&PetscDualSpaceList);CHKERRQ(ierr); 15506759e06SMatthew G. Knepley PetscFEPackageInitialized = PETSC_FALSE; 15606759e06SMatthew G. Knepley PetscSpaceRegisterAllCalled = PETSC_FALSE; 15706759e06SMatthew G. Knepley PetscDualSpaceRegisterAllCalled = PETSC_FALSE; 15806759e06SMatthew G. Knepley PetscFunctionReturn(0); 15906759e06SMatthew G. Knepley } 16006759e06SMatthew G. Knepley 16106759e06SMatthew G. Knepley #undef __FUNCT__ 16206759e06SMatthew G. Knepley #define __FUNCT__ "PetscFEInitializePackage" 16306759e06SMatthew G. Knepley /*@C 16406759e06SMatthew G. Knepley PetscFEInitializePackage - This function initializes everything in the FE package. It is called 16506759e06SMatthew G. Knepley from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscSpaceCreate() 16606759e06SMatthew G. Knepley when using static libraries. 16706759e06SMatthew G. Knepley 16806759e06SMatthew G. Knepley Level: developer 16906759e06SMatthew G. Knepley 17006759e06SMatthew G. Knepley .keywords: PetscFE, initialize, package 17106759e06SMatthew G. Knepley .seealso: PetscInitialize() 17206759e06SMatthew G. Knepley @*/ 17306759e06SMatthew G. Knepley PetscErrorCode PetscFEInitializePackage(void) 17406759e06SMatthew G. Knepley { 17506759e06SMatthew G. Knepley char logList[256]; 17606759e06SMatthew G. Knepley char *className; 17706759e06SMatthew G. Knepley PetscBool opt; 17806759e06SMatthew G. Knepley PetscErrorCode ierr; 17906759e06SMatthew G. Knepley 18006759e06SMatthew G. Knepley PetscFunctionBegin; 18106759e06SMatthew G. Knepley if (PetscFEPackageInitialized) PetscFunctionReturn(0); 18206759e06SMatthew G. Knepley PetscFEPackageInitialized = PETSC_TRUE; 18306759e06SMatthew G. Knepley 18406759e06SMatthew G. Knepley /* Register Classes */ 18506759e06SMatthew G. Knepley ierr = PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID);CHKERRQ(ierr); 18606759e06SMatthew G. Knepley ierr = PetscClassIdRegister("Dual Space", &PETSCDUALSPACE_CLASSID);CHKERRQ(ierr); 18706759e06SMatthew G. Knepley ierr = PetscClassIdRegister("FE Space", &PETSCFE_CLASSID);CHKERRQ(ierr); 18806759e06SMatthew G. Knepley 18906759e06SMatthew G. Knepley /* Register Constructors */ 19006759e06SMatthew G. Knepley ierr = PetscSpaceRegisterAll();CHKERRQ(ierr); 19106759e06SMatthew G. Knepley /* Register Events */ 19206759e06SMatthew G. Knepley /* Process info exclusions */ 19306759e06SMatthew G. Knepley ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 19406759e06SMatthew G. Knepley if (opt) { 19506759e06SMatthew G. Knepley ierr = PetscStrstr(logList, "fe", &className);CHKERRQ(ierr); 19606759e06SMatthew G. Knepley if (className) { 19706759e06SMatthew G. Knepley ierr = PetscInfoDeactivateClass(PETSCFE_CLASSID);CHKERRQ(ierr); 19806759e06SMatthew G. Knepley } 19906759e06SMatthew G. Knepley } 20006759e06SMatthew G. Knepley /* Process summary exclusions */ 20106759e06SMatthew G. Knepley ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr); 20206759e06SMatthew G. Knepley if (opt) { 20306759e06SMatthew G. Knepley ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr); 20406759e06SMatthew G. Knepley if (className) { 20506759e06SMatthew G. Knepley ierr = PetscLogEventDeactivateClass(DM_CLASSID);CHKERRQ(ierr); 20606759e06SMatthew G. Knepley } 20706759e06SMatthew G. Knepley } 20806759e06SMatthew G. Knepley ierr = PetscRegisterFinalize(PetscFEFinalizePackage);CHKERRQ(ierr); 20906759e06SMatthew G. Knepley PetscFunctionReturn(0); 21006759e06SMatthew G. Knepley } 211e8597998SBarry Smith 212e8597998SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 213e8597998SBarry Smith #undef __FUNCT__ 214e8597998SBarry Smith #define __FUNCT__ "PetscDLLibraryRegister_petscdm" 215e8597998SBarry Smith /* 216e8597998SBarry Smith PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. 217e8597998SBarry Smith 218e8597998SBarry Smith This one registers all the mesh generators and partitioners that are in 219e8597998SBarry Smith the basic DM library. 220e8597998SBarry Smith 221e8597998SBarry Smith */ 222607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void) 223e8597998SBarry Smith { 224e8597998SBarry Smith PetscErrorCode ierr; 225e8597998SBarry Smith 226e8597998SBarry Smith PetscFunctionBegin; 227607a6623SBarry Smith ierr = AOInitializePackage();CHKERRQ(ierr); 228607a6623SBarry Smith ierr = DMInitializePackage();CHKERRQ(ierr); 22906759e06SMatthew G. Knepley ierr = PetscFEInitializePackage();CHKERRQ(ierr); 230e8597998SBarry Smith PetscFunctionReturn(0); 231e8597998SBarry Smith } 232e8597998SBarry Smith 233e8597998SBarry Smith #endif /* PETSC_USE_DYNAMIC_LIBRARIES */ 234