1 #include <petsc/private/sfimpl.h> /*I "petscsf.h" I*/ 2 3 PETSC_EXTERN PetscErrorCode PetscSFCreate_Basic(PetscSF); 4 #if defined(PETSC_HAVE_MPI_WIN_CREATE) && defined(PETSC_HAVE_MPI_TYPE_DUP) 5 PETSC_EXTERN PetscErrorCode PetscSFCreate_Window(PetscSF); 6 #endif 7 8 PetscFunctionList PetscSFList; 9 PetscBool PetscSFRegisterAllCalled; 10 11 /*@C 12 PetscSFRegisterAll - Registers all the PetscSF communication implementations 13 14 Not Collective 15 16 Level: advanced 17 18 .keywords: PetscSF, register, all 19 20 .seealso: PetscSFRegisterDestroy() 21 @*/ 22 PetscErrorCode PetscSFRegisterAll(void) 23 { 24 PetscErrorCode ierr; 25 26 PetscFunctionBegin; 27 if (PetscSFRegisterAllCalled) PetscFunctionReturn(0); 28 PetscSFRegisterAllCalled = PETSC_TRUE; 29 ierr = PetscSFRegister(PETSCSFBASIC, PetscSFCreate_Basic);CHKERRQ(ierr); 30 #if defined(PETSC_HAVE_MPI_WIN_CREATE) && defined(PETSC_HAVE_MPI_TYPE_DUP) 31 ierr = PetscSFRegister(PETSCSFWINDOW, PetscSFCreate_Window);CHKERRQ(ierr); 32 #endif 33 PetscFunctionReturn(0); 34 } 35 36 /*@C 37 PetscSFRegister - Adds an implementation of the PetscSF communication protocol. 38 39 Not collective 40 41 Input Parameters: 42 + name - name of a new user-defined implementation 43 - create - routine to create method context 44 45 Notes: 46 PetscSFRegister() may be called multiple times to add several user-defined implementations. 47 48 Sample usage: 49 .vb 50 PetscSFRegister("my_impl",MyImplCreate); 51 .ve 52 53 Then, this implementation can be chosen with the procedural interface via 54 $ PetscSFSetType(sf,"my_impl") 55 or at runtime via the option 56 $ -sf_type my_impl 57 58 Level: advanced 59 60 .keywords: PetscSF, register 61 62 .seealso: PetscSFRegisterAll(), PetscSFInitializePackage() 63 @*/ 64 PetscErrorCode PetscSFRegister(const char name[],PetscErrorCode (*create)(PetscSF)) 65 { 66 PetscErrorCode ierr; 67 68 PetscFunctionBegin; 69 ierr = PetscFunctionListAdd(&PetscSFList,name,create);CHKERRQ(ierr); 70 PetscFunctionReturn(0); 71 } 72