Date: 2025-03-28T21:10:44+00:00

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: `DMField`, `DMFieldRegisterDestroy()`
     17: @*/
     18: PetscErrorCode DMFieldRegisterAll(void)
     19: {
     20:   PetscFunctionBegin;
     21:   if (DMFieldRegisterAllCalled) PetscFunctionReturn(PETSC_SUCCESS);
     22:   DMFieldRegisterAllCalled = PETSC_TRUE;
     23:   PetscCall(DMFieldRegister(DMFIELDDA, DMFieldCreate_DA));
     24:   PetscCall(DMFieldRegister(DMFIELDDS, DMFieldCreate_DS));
     25:   PetscCall(DMFieldRegister(DMFIELDSHELL, DMFieldCreate_Shell));
     26:   PetscFunctionReturn(PETSC_SUCCESS);
     27: }

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

     32:   Not collective, No Fortran Support

     34:   Input Parameters:
     35: + sname    - name of a new user-defined implementation
     36: - function - routine to create method context

     38:   Example Usage:
     39: .vb
     40:    DMFieldRegister("my_impl",MyImplCreate);
     41: .ve

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

     46:   Level: advanced

     48:   Note:
     49:   `DMFieldRegister()` may be called multiple times to add several user-defined implementations.

     51: .seealso: `DMField`, `DMFieldRegisterAll()`, `DMFieldRegisterDestroy()`
     52: @*/
     53: PetscErrorCode DMFieldRegister(const char sname[], PetscErrorCode (*function)(DMField))
     54: {
     55:   PetscFunctionBegin;
     56:   PetscCall(PetscFunctionListAdd(&DMFieldList, sname, function));
     57:   PetscFunctionReturn(PETSC_SUCCESS);
     58: }