Actual source code: sfregi.c

petsc-master 2019-07-16
Report Typos and Errors
  1:  #include <petsc/private/sfimpl.h>

  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

  8: PetscFunctionList PetscSFList;
  9: PetscBool         PetscSFRegisterAllCalled;

 11: /*@C
 12:    PetscSFRegisterAll - Registers all the PetscSF communication implementations

 14:    Not Collective

 16:    Level: advanced

 18: .seealso:  PetscSFRegisterDestroy()
 19: @*/
 20: PetscErrorCode  PetscSFRegisterAll(void)
 21: {

 25:   if (PetscSFRegisterAllCalled) return(0);
 26:   PetscSFRegisterAllCalled = PETSC_TRUE;
 27:   PetscSFRegister(PETSCSFBASIC,  PetscSFCreate_Basic);
 28: #if defined(PETSC_HAVE_MPI_WIN_CREATE) && defined(PETSC_HAVE_MPI_TYPE_DUP)
 29:   PetscSFRegister(PETSCSFWINDOW, PetscSFCreate_Window);
 30: #endif
 31:   return(0);
 32: }

 34: /*@C
 35:   PetscSFRegister  - Adds an implementation of the PetscSF communication protocol.

 37:    Not collective

 39:    Input Parameters:
 40: +  name - name of a new user-defined implementation
 41: -  create - routine to create method context

 43:    Notes:
 44:    PetscSFRegister() may be called multiple times to add several user-defined implementations.

 46:    Sample usage:
 47: .vb
 48:    PetscSFRegister("my_impl",MyImplCreate);
 49: .ve

 51:    Then, this implementation can be chosen with the procedural interface via
 52: $     PetscSFSetType(sf,"my_impl")
 53:    or at runtime via the option
 54: $     -sf_type my_impl

 56:    Level: advanced

 58: .seealso: PetscSFRegisterAll(), PetscSFInitializePackage()
 59: @*/
 60: PetscErrorCode  PetscSFRegister(const char name[],PetscErrorCode (*create)(PetscSF))
 61: {

 65:   PetscSFInitializePackage();
 66:   PetscFunctionListAdd(&PetscSFList,name,create);
 67:   return(0);
 68: }