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