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); 83a0845e3aSMatthew G. Knepley ierr = PetscLogEventRegister("DMPlexResidualFEM", DM_CLASSID,&DMPLEX_ResidualFEM);CHKERRQ(ierr); 84*a319912fSMatthew G. Knepley ierr = PetscLogEventRegister("DMPlexJacobianFEM", DM_CLASSID,&DMPLEX_JacobianFEM);CHKERRQ(ierr); 85e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 86e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshView", DM_CLASSID,&DMMesh_View);CHKERRQ(ierr); 87e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshGetGlobalScatter", DM_CLASSID,&DMMesh_GetGlobalScatter);CHKERRQ(ierr); 88e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshRestrictVector", DM_CLASSID,&DMMesh_restrictVector);CHKERRQ(ierr); 89e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshAssembleVector", DM_CLASSID,&DMMesh_assembleVector);CHKERRQ(ierr); 90e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshAssemVecComplete", DM_CLASSID,&DMMesh_assembleVectorComplete);CHKERRQ(ierr); 91e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshAssembleMatrix", DM_CLASSID,&DMMesh_assembleMatrix);CHKERRQ(ierr); 92e8597998SBarry Smith ierr = PetscLogEventRegister("DMMeshUpdateOperator", DM_CLASSID,&DMMesh_updateOperator);CHKERRQ(ierr); 93e8597998SBarry Smith ierr = PetscLogEventRegister("SectionRealView", SECTIONREAL_CLASSID,&SectionReal_View);CHKERRQ(ierr); 94e8597998SBarry Smith ierr = PetscLogEventRegister("SectionIntView", SECTIONINT_CLASSID,&SectionInt_View);CHKERRQ(ierr); 95e8597998SBarry Smith #endif 96e8597998SBarry Smith /* Process info exclusions */ 97e8597998SBarry Smith ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 98e8597998SBarry Smith if (opt) { 99e8597998SBarry Smith ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr); 100e8597998SBarry Smith if (className) { 101e8597998SBarry Smith ierr = PetscInfoDeactivateClass(DM_CLASSID);CHKERRQ(ierr); 102e8597998SBarry Smith } 103e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 104e8597998SBarry Smith ierr = PetscStrstr(logList, "sectionreal", &className);CHKERRQ(ierr); 105e8597998SBarry Smith if (className) { 106e8597998SBarry Smith ierr = PetscInfoDeactivateClass(SECTIONREAL_CLASSID);CHKERRQ(ierr); 107e8597998SBarry Smith } 108e8597998SBarry Smith ierr = PetscStrstr(logList, "sectionint", &className);CHKERRQ(ierr); 109e8597998SBarry Smith if (className) { 110e8597998SBarry Smith ierr = PetscInfoDeactivateClass(SECTIONINT_CLASSID);CHKERRQ(ierr); 111e8597998SBarry Smith } 112e8597998SBarry Smith #endif 113e8597998SBarry Smith } 114e8597998SBarry Smith /* Process summary exclusions */ 115e8597998SBarry Smith ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr); 116e8597998SBarry Smith if (opt) { 117e8597998SBarry Smith ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr); 118e8597998SBarry Smith if (className) { 119e8597998SBarry Smith ierr = PetscLogEventDeactivateClass(DM_CLASSID);CHKERRQ(ierr); 120e8597998SBarry Smith } 121e8597998SBarry Smith #if defined(PETSC_HAVE_SIEVE) 122e8597998SBarry Smith ierr = PetscStrstr(logList, "sectionreal", &className);CHKERRQ(ierr); 123e8597998SBarry Smith if (className) { 124e8597998SBarry Smith ierr = PetscLogEventDeactivateClass(SECTIONREAL_CLASSID);CHKERRQ(ierr); 125e8597998SBarry Smith } 126e8597998SBarry Smith ierr = PetscStrstr(logList, "sectionint", &className);CHKERRQ(ierr); 127e8597998SBarry Smith if (className) { 128e8597998SBarry Smith ierr = PetscLogEventDeactivateClass(SECTIONINT_CLASSID);CHKERRQ(ierr); 129e8597998SBarry Smith } 130e8597998SBarry Smith #endif 131e8597998SBarry Smith } 132e8597998SBarry Smith ierr = PetscRegisterFinalize(DMFinalizePackage);CHKERRQ(ierr); 133e8597998SBarry Smith PetscFunctionReturn(0); 134e8597998SBarry Smith } 13506759e06SMatthew G. Knepley #include <petscfe.h> 136e8597998SBarry Smith 13706759e06SMatthew G. Knepley static PetscBool PetscFEPackageInitialized = PETSC_FALSE; 13806759e06SMatthew G. Knepley #undef __FUNCT__ 13906759e06SMatthew G. Knepley #define __FUNCT__ "PetscFEFinalizePackage" 14006759e06SMatthew G. Knepley /*@C 14106759e06SMatthew G. Knepley PetscFEFinalizePackage - This function finalizes everything in the PetscFE package. It is called 14206759e06SMatthew G. Knepley from PetscFinalize(). 143e8597998SBarry Smith 14406759e06SMatthew G. Knepley Level: developer 14506759e06SMatthew G. Knepley 14606759e06SMatthew G. Knepley .keywords: PetscFE, initialize, package 14706759e06SMatthew G. Knepley .seealso: PetscInitialize() 14806759e06SMatthew G. Knepley @*/ 14906759e06SMatthew G. Knepley PetscErrorCode PetscFEFinalizePackage(void) 15006759e06SMatthew G. Knepley { 15106759e06SMatthew G. Knepley PetscErrorCode ierr; 15206759e06SMatthew G. Knepley 15306759e06SMatthew G. Knepley PetscFunctionBegin; 15406759e06SMatthew G. Knepley ierr = PetscFunctionListDestroy(&PetscSpaceList);CHKERRQ(ierr); 15506759e06SMatthew G. Knepley ierr = PetscFunctionListDestroy(&PetscDualSpaceList);CHKERRQ(ierr); 15606759e06SMatthew G. Knepley PetscFEPackageInitialized = PETSC_FALSE; 15706759e06SMatthew G. Knepley PetscSpaceRegisterAllCalled = PETSC_FALSE; 15806759e06SMatthew G. Knepley PetscDualSpaceRegisterAllCalled = PETSC_FALSE; 15906759e06SMatthew G. Knepley PetscFunctionReturn(0); 16006759e06SMatthew G. Knepley } 16106759e06SMatthew G. Knepley 16206759e06SMatthew G. Knepley #undef __FUNCT__ 16306759e06SMatthew G. Knepley #define __FUNCT__ "PetscFEInitializePackage" 16406759e06SMatthew G. Knepley /*@C 16506759e06SMatthew G. Knepley PetscFEInitializePackage - This function initializes everything in the FE package. It is called 16606759e06SMatthew G. Knepley from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscSpaceCreate() 16706759e06SMatthew G. Knepley when using static libraries. 16806759e06SMatthew G. Knepley 16906759e06SMatthew G. Knepley Level: developer 17006759e06SMatthew G. Knepley 17106759e06SMatthew G. Knepley .keywords: PetscFE, initialize, package 17206759e06SMatthew G. Knepley .seealso: PetscInitialize() 17306759e06SMatthew G. Knepley @*/ 17406759e06SMatthew G. Knepley PetscErrorCode PetscFEInitializePackage(void) 17506759e06SMatthew G. Knepley { 17606759e06SMatthew G. Knepley char logList[256]; 17706759e06SMatthew G. Knepley char *className; 17806759e06SMatthew G. Knepley PetscBool opt; 17906759e06SMatthew G. Knepley PetscErrorCode ierr; 18006759e06SMatthew G. Knepley 18106759e06SMatthew G. Knepley PetscFunctionBegin; 18206759e06SMatthew G. Knepley if (PetscFEPackageInitialized) PetscFunctionReturn(0); 18306759e06SMatthew G. Knepley PetscFEPackageInitialized = PETSC_TRUE; 18406759e06SMatthew G. Knepley 18506759e06SMatthew G. Knepley /* Register Classes */ 18606759e06SMatthew G. Knepley ierr = PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID);CHKERRQ(ierr); 18706759e06SMatthew G. Knepley ierr = PetscClassIdRegister("Dual Space", &PETSCDUALSPACE_CLASSID);CHKERRQ(ierr); 18806759e06SMatthew G. Knepley ierr = PetscClassIdRegister("FE Space", &PETSCFE_CLASSID);CHKERRQ(ierr); 18906759e06SMatthew G. Knepley 19006759e06SMatthew G. Knepley /* Register Constructors */ 19106759e06SMatthew G. Knepley ierr = PetscSpaceRegisterAll();CHKERRQ(ierr); 19206759e06SMatthew G. Knepley /* Register Events */ 19306759e06SMatthew G. Knepley /* Process info exclusions */ 19406759e06SMatthew G. Knepley ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 19506759e06SMatthew G. Knepley if (opt) { 19606759e06SMatthew G. Knepley ierr = PetscStrstr(logList, "fe", &className);CHKERRQ(ierr); 19706759e06SMatthew G. Knepley if (className) { 19806759e06SMatthew G. Knepley ierr = PetscInfoDeactivateClass(PETSCFE_CLASSID);CHKERRQ(ierr); 19906759e06SMatthew G. Knepley } 20006759e06SMatthew G. Knepley } 20106759e06SMatthew G. Knepley /* Process summary exclusions */ 20206759e06SMatthew G. Knepley ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr); 20306759e06SMatthew G. Knepley if (opt) { 20406759e06SMatthew G. Knepley ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr); 20506759e06SMatthew G. Knepley if (className) { 20606759e06SMatthew G. Knepley ierr = PetscLogEventDeactivateClass(DM_CLASSID);CHKERRQ(ierr); 20706759e06SMatthew G. Knepley } 20806759e06SMatthew G. Knepley } 20906759e06SMatthew G. Knepley ierr = PetscRegisterFinalize(PetscFEFinalizePackage);CHKERRQ(ierr); 21006759e06SMatthew G. Knepley PetscFunctionReturn(0); 21106759e06SMatthew G. Knepley } 212e8597998SBarry Smith 213e8597998SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 214e8597998SBarry Smith #undef __FUNCT__ 215e8597998SBarry Smith #define __FUNCT__ "PetscDLLibraryRegister_petscdm" 216e8597998SBarry Smith /* 217e8597998SBarry Smith PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. 218e8597998SBarry Smith 219e8597998SBarry Smith This one registers all the mesh generators and partitioners that are in 220e8597998SBarry Smith the basic DM library. 221e8597998SBarry Smith 222e8597998SBarry Smith */ 223607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void) 224e8597998SBarry Smith { 225e8597998SBarry Smith PetscErrorCode ierr; 226e8597998SBarry Smith 227e8597998SBarry Smith PetscFunctionBegin; 228607a6623SBarry Smith ierr = AOInitializePackage();CHKERRQ(ierr); 229607a6623SBarry Smith ierr = DMInitializePackage();CHKERRQ(ierr); 23006759e06SMatthew G. Knepley ierr = PetscFEInitializePackage();CHKERRQ(ierr); 231e8597998SBarry Smith PetscFunctionReturn(0); 232e8597998SBarry Smith } 233e8597998SBarry Smith 234e8597998SBarry Smith #endif /* PETSC_USE_DYNAMIC_LIBRARIES */ 235