Actual source code: dmfieldregi.c

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

      3: PETSC_EXTERN PetscErrorCode DMFieldCreate_DA(DMField);
      4: PETSC_EXTERN PetscErrorCode DMFieldCreate_DS(DMField);
      5: PETSC_EXTERN PetscErrorCode DMFieldCreate_Shell(DMField);

      7: PetscFunctionList DMFieldList;

      9: /*@C
     10:    DMFieldRegisterAll - Registers all the DMField implementations

     12:    Not Collective

     14:    Level: advanced

     16: .seealso:  DMFieldRegisterDestroy()
     17: @*/
     18: PetscErrorCode  DMFieldRegisterAll(void)
     19: {
     20:   if (DMFieldRegisterAllCalled) return 0;
     21:   DMFieldRegisterAllCalled = PETSC_TRUE;
     22:   DMFieldRegister(DMFIELDDA,    DMFieldCreate_DA);
     23:   DMFieldRegister(DMFIELDDS,    DMFieldCreate_DS);
     24:   DMFieldRegister(DMFIELDSHELL, DMFieldCreate_Shell);
     25:   return 0;
     26: }

     28: /*@C
     29:   DMFieldRegister  - Adds an implementation of the DMField object.

     31:    Not collective

     33:    Input Parameters:
     34: +  name_impl - name of a new user-defined implementation
     35: -  routine_create - routine to create method context

     37:    Notes:
     38:    DMFieldRegister() may be called multiple times to add several user-defined implementations.

     40:    Sample usage:
     41: .vb
     42:    DMFieldRegister("my_impl",MyImplCreate);
     43: .ve

     45:    Then, this implementation can be chosen with the procedural interface via
     46: $     DMFieldSetType(tagger,"my_impl")

     48:    Level: advanced

     50: .seealso: DMFieldRegisterAll(), DMFieldRegisterDestroy()
     51: @*/
     52: PetscErrorCode  DMFieldRegister(const char sname[],PetscErrorCode (*function)(DMField))
     53: {
     54:   PetscFunctionListAdd(&DMFieldList,sname,function);
     55:   return 0;
     56: }