Actual source code: taggerregi.c

      1: #include <petsc/private/vecimpl.h>

      3: PETSC_INTERN PetscErrorCode VecTaggerCreate_Absolute(VecTagger);
      4: PETSC_INTERN PetscErrorCode VecTaggerCreate_Relative(VecTagger);
      5: PETSC_INTERN PetscErrorCode VecTaggerCreate_CDF(VecTagger);
      6: PETSC_INTERN PetscErrorCode VecTaggerCreate_Or(VecTagger);
      7: PETSC_INTERN PetscErrorCode VecTaggerCreate_And(VecTagger);

      9: PetscFunctionList VecTaggerList;

     11: /*@C
     12:   VecTaggerRegisterAll - Registers all the `VecTagger` communication implementations

     14:   Not Collective

     16:   Level: advanced

     18: .seealso: `VecTaggerRegisterDestroy()`
     19: @*/
     20: PetscErrorCode VecTaggerRegisterAll(void)
     21: {
     22:   PetscFunctionBegin;
     23:   if (VecTaggerRegisterAllCalled) PetscFunctionReturn(PETSC_SUCCESS);
     24:   VecTaggerRegisterAllCalled = PETSC_TRUE;
     25:   PetscCall(VecTaggerRegister(VECTAGGERABSOLUTE, VecTaggerCreate_Absolute));
     26:   PetscCall(VecTaggerRegister(VECTAGGERRELATIVE, VecTaggerCreate_Relative));
     27:   PetscCall(VecTaggerRegister(VECTAGGERCDF, VecTaggerCreate_CDF));
     28:   PetscCall(VecTaggerRegister(VECTAGGEROR, VecTaggerCreate_Or));
     29:   PetscCall(VecTaggerRegister(VECTAGGERAND, VecTaggerCreate_And));
     30:   PetscFunctionReturn(PETSC_SUCCESS);
     31: }

     33: /*@C
     34:   VecTaggerRegister  - Adds an implementation of the `VecTagger` communication protocol.

     36:   Not Collective, No Fortran Support

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

     42:   Level: advanced

     44:   Notes:
     45:   `VecTaggerRegister()` may be called multiple times to add several user-defined implementations.

     47:   Example Usage:
     48: .vb
     49:    VecTaggerRegister("my_impl", MyImplCreate);
     50: .ve

     52:   Then, this implementation can be chosen with the procedural interface via
     53: .vb
     54:   VecTaggerSetType(tagger, "my_impl")
     55: .ve
     56:   or at runtime via the option
     57: .vb
     58:   -snes_type my_solver
     59: .ve

     61: .seealso: `VecTaggerType`, `VecTaggerCreate()`, `VecTagger`, `VecTaggerRegisterAll()`, `VecTaggerRegisterDestroy()`
     62: @*/
     63: PetscErrorCode VecTaggerRegister(const char sname[], PetscErrorCode (*function)(VecTagger))
     64: {
     65:   PetscFunctionBegin;
     66:   PetscCall(PetscFunctionListAdd(&VecTaggerList, sname, function));
     67:   PetscFunctionReturn(PETSC_SUCCESS);
     68: }