Actual source code: aoreg.c

petsc-3.7.7 2017-09-25
Report Typos and Errors
  2: #include <../src/vec/is/ao/aoimpl.h>    /*I "petscao.h"  I*/

  4: PetscFunctionList AOList              = 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, AOType method)
 30: {
 31:   PetscErrorCode (*r)(AO);
 32:   PetscBool      match;

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

 40:   AORegisterAll();
 41:   PetscFunctionListFind(AOList,method,&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:     ao->ops->destroy = NULL;
 46:   }

 48:   (*r)(ao);
 49:   return(0);
 50: }

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

 57:   Not Collective

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

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

 65:   Level: intermediate

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

 77:   AORegisterAll();
 78:   *type = ((PetscObject)ao)->type_name;
 79:   return(0);
 80: }


 83: /*--------------------------------------------------------------------------------------------------------------------*/

 87: /*@C
 88:   AORegister - 

 90:   Level: advanced
 91: @*/
 92: PetscErrorCode  AORegister(const char sname[], PetscErrorCode (*function)(AO))
 93: {

 97:   PetscFunctionListAdd(&AOList,sname,function);
 98:   return(0);
 99: }