Actual source code: aoreg.c

  2: #include <../src/dm/ao/aoimpl.h>    /*I "petscao.h"  I*/

  4: PetscFList AOList                       = PETSC_NULL;
  5: PetscBool  AORegisterAllCalled          = PETSC_FALSE;

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

 12:   Collective on AO

 14:   Input Parameters:
 15: + ao    - The AO object
 16: - method - The name of the AO type

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

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

 24:   Level: intermediate

 26: .keywords: ao, set, type
 27: .seealso: AOGetType(), AOCreate()
 28: @*/
 29: PetscErrorCode  AOSetType(AO ao, const AOType method)
 30: {
 31:   PetscErrorCode (*r)(AO);
 32:   PetscBool      match;

 37:   PetscTypeCompare((PetscObject)ao, method, &match);
 38:   if (match) return(0);

 40:   if (!AORegisterAllCalled) {AORegisterAll(PETSC_NULL);}
 41:   PetscFListFind(AOList, ((PetscObject)ao)->comm, method,PETSC_TRUE,(void (**)(void)) &r);
 42:   if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method);
 43:   if (ao->ops->destroy) {
 44:     (*ao->ops->destroy)(ao);
 45:   }
 46: 
 47:   (*r)(ao);
 48:   return(0);
 49: }

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

 56:   Not Collective

 58:   Input Parameter:
 59: . ao  - The vector

 61:   Output Parameter:
 62: . type - The AO type name

 64:   Level: intermediate

 66: .keywords: ao, get, type, name
 67: .seealso: AOSetType(), AOCreate()
 68: @*/
 69: PetscErrorCode  AOGetType(AO ao, const AOType *type)
 70: {

 76:   if (!AORegisterAllCalled) {
 77:     AORegisterAll(PETSC_NULL);
 78:   }
 79:   *type = ((PetscObject)ao)->type_name;
 80:   return(0);
 81: }


 84: /*--------------------------------------------------------------------------------------------------------------------*/

 88: /*@C
 89:   AORegister - See AORegisterDynamic()

 91:   Level: advanced
 92: @*/
 93: PetscErrorCode  AORegister(const char sname[], const char path[], const char name[], PetscErrorCode (*function)(AO))
 94: {
 95:   char fullname[PETSC_MAX_PATH_LEN];

 99:   PetscStrcpy(fullname, path);
100:   PetscStrcat(fullname, ":");
101:   PetscStrcat(fullname, name);
102:   PetscFListAdd(&AOList, sname, fullname, (void (*)(void)) function);
103:   return(0);
104: }


107: /*--------------------------------------------------------------------------------------------------------------------*/
110: /*@C
111:    AORegisterDestroy - Frees the list of AO methods that were registered by AORegister()/AORegisterDynamic().

113:    Not Collective

115:    Level: advanced

117: .keywords: AO, register, destroy
118: .seealso: AORegister(), AORegisterAll(), AORegisterDynamic()
119: @*/
120: PetscErrorCode  AORegisterDestroy(void)
121: {

125:   PetscFListDestroy(&AOList);
126:   AORegisterAllCalled = PETSC_FALSE;
127:   return(0);
128: }