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 `AOType`
10: Collective
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: Level: intermediate
21: Notes:
22: See "petsc/include/petscao.h" for available AO types (for instance, `AOBASIC` and `AOMEMORYSCALABLE`).
24: `AO` are usually created via the convenience routines such as `AOCreateBasic()` or `AOCreateMemoryScalable()`
26: .seealso: `AO`, `AOType`, `AOCreateBasic()`, `AOCreateMemoryScalable()`, `AOGetType()`, `AOCreate()`
27: @*/
28: PetscErrorCode AOSetType(AO ao, AOType method)
29: {
30: PetscErrorCode (*r)(AO);
31: PetscBool match;
34: PetscObjectTypeCompare((PetscObject)ao, method, &match);
35: if (match) return 0;
37: AORegisterAll();
38: PetscFunctionListFind(AOList, method, &r);
40: PetscTryTypeMethod(ao, destroy);
41: ao->ops->destroy = NULL;
43: (*r)(ao);
44: return 0;
45: }
47: /*@C
48: AOGetType - Gets the `AO` type name (as a string) from the AO.
50: Not Collective
52: Input Parameter:
53: . ao - The vector
55: Output Parameter:
56: . type - The `AO` type name
58: Level: intermediate
60: .seealso: `AO`, `AOType`, `AOSetType()`, `AOCreate()`
61: @*/
62: PetscErrorCode AOGetType(AO ao, AOType *type)
63: {
66: AORegisterAll();
67: *type = ((PetscObject)ao)->type_name;
68: return 0;
69: }
71: /*--------------------------------------------------------------------------------------------------------------------*/
73: /*@C
74: AORegister - Register an application ordering method
76: Not Collective
78: Input Parameters:
79: + sname - the name (`AOType`) of the `AO` scheme
80: - function - the create routine for the application ordering method
82: Level: advanced
84: .seealso: `AO`, `AOType`, `AOCreate()`, `AORegisterAll()`, `AOBASIC`, `AOADVANCED`, `AOMAPPING`, `AOMEMORYSCALABLE`
85: @*/
86: PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO))
87: {
88: AOInitializePackage();
89: PetscFunctionListAdd(&AOList, sname, function);
90: return 0;
91: }