Actual source code: aoreg.c


  2: #include <../src/vec/is/ao/aoimpl.h>

  4: PetscFunctionList AOList              = NULL;
  5: PetscBool         AORegisterAllCalled = PETSC_FALSE;

  7: /*@C
  8:   AOSetType - Builds an application ordering for a particular implementation.

 10:   Collective on AO

 12:   Input Parameters:
 13: + ao    - The AO object
 14: - method - The name of the AO type

 16:   Options Database Key:
 17: . -ao_type <type> - Sets the AO type; use -help for a list of available types

 19:   Notes:
 20:   See "petsc/include/petscao.h" for available AO types (for instance, AOBASIC and AOMEMORYSCALABLE).

 22:   Level: intermediate

 24: .seealso: `AOGetType()`, `AOCreate()`
 25: @*/
 26: PetscErrorCode AOSetType(AO ao, AOType method)
 27: {
 28:   PetscErrorCode (*r)(AO);
 29:   PetscBool match;

 32:   PetscObjectTypeCompare((PetscObject)ao, method, &match);
 33:   if (match) return 0;

 35:   AORegisterAll();
 36:   PetscFunctionListFind(AOList, method, &r);
 38:   PetscTryTypeMethod(ao, destroy);
 39:   ao->ops->destroy = NULL;

 41:   (*r)(ao);
 42:   return 0;
 43: }

 45: /*@C
 46:   AOGetType - Gets the AO type name (as a string) from the AO.

 48:   Not Collective

 50:   Input Parameter:
 51: . ao  - The vector

 53:   Output Parameter:
 54: . type - The AO type name

 56:   Level: intermediate

 58: .seealso: `AOSetType()`, `AOCreate()`
 59: @*/
 60: PetscErrorCode AOGetType(AO ao, AOType *type)
 61: {
 64:   AORegisterAll();
 65:   *type = ((PetscObject)ao)->type_name;
 66:   return 0;
 67: }

 69: /*--------------------------------------------------------------------------------------------------------------------*/

 71: /*@C
 72:   AORegister - Register  an application ordering method

 74:     Not Collective

 76:    Input Parameters:
 77: +   sname - the name of the AO scheme
 78: -   function - the create routine for the application ordering method

 80:   Level: advanced

 82: .seealso: `AOCreate()`, `AORegisterAll()`, `AOBASIC`, `AOADVANCED`, `AOMAPPING`, `AOMEMORYSCALABLE`

 84: @*/
 85: PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO))
 86: {
 87:   AOInitializePackage();
 88:   PetscFunctionListAdd(&AOList, sname, function);
 89:   return 0;
 90: }