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