Actual source code: aoreg.c

petsc-3.8.4 2018-03-24
Report Typos and Errors

  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: .keywords: ao, set, type
 25: .seealso: AOGetType(), AOCreate()
 26: @*/
 27: PetscErrorCode  AOSetType(AO ao, AOType method)
 28: {
 29:   PetscErrorCode (*r)(AO);
 30:   PetscBool      match;

 35:   PetscObjectTypeCompare((PetscObject)ao, method, &match);
 36:   if (match) return(0);

 38:   AORegisterAll();
 39:   PetscFunctionListFind(AOList,method,&r);
 40:   if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method);
 41:   if (ao->ops->destroy) {
 42:     (*ao->ops->destroy)(ao);
 43:     ao->ops->destroy = NULL;
 44:   }

 46:   (*r)(ao);
 47:   return(0);
 48: }

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

 53:   Not Collective

 55:   Input Parameter:
 56: . ao  - The vector

 58:   Output Parameter:
 59: . type - The AO type name

 61:   Level: intermediate

 63: .keywords: ao, get, type, name
 64: .seealso: AOSetType(), AOCreate()
 65: @*/
 66: PetscErrorCode  AOGetType(AO ao, AOType *type)
 67: {

 73:   AORegisterAll();
 74:   *type = ((PetscObject)ao)->type_name;
 75:   return(0);
 76: }


 79: /*--------------------------------------------------------------------------------------------------------------------*/

 81: /*@C
 82:   AORegister - 

 84:   Level: advanced
 85: @*/
 86: PetscErrorCode  AORegister(const char sname[], PetscErrorCode (*function)(AO))
 87: {

 91:   PetscFunctionListAdd(&AOList,sname,function);
 92:   return(0);
 93: }