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;
33: PetscFunctionBegin;
35: PetscCall(PetscObjectTypeCompare((PetscObject)ao, method, &match));
36: if (match) PetscFunctionReturn(PETSC_SUCCESS);
38: PetscCall(AORegisterAll());
39: PetscCall(PetscFunctionListFind(AOList, method, &r));
40: PetscCheck(r, PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method);
41: PetscTryTypeMethod(ao, destroy);
42: ao->ops->destroy = NULL;
44: PetscCall((*r)(ao));
45: PetscFunctionReturn(PETSC_SUCCESS);
46: }
48: /*@C
49: AOGetType - Gets the `AO` type name (as a string) from the AO.
51: Not Collective
53: Input Parameter:
54: . ao - The vector
56: Output Parameter:
57: . type - The `AO` type name
59: Level: intermediate
61: .seealso: `AO`, `AOType`, `AOSetType()`, `AOCreate()`
62: @*/
63: PetscErrorCode AOGetType(AO ao, AOType *type)
64: {
65: PetscFunctionBegin;
68: PetscCall(AORegisterAll());
69: *type = ((PetscObject)ao)->type_name;
70: PetscFunctionReturn(PETSC_SUCCESS);
71: }
73: /*--------------------------------------------------------------------------------------------------------------------*/
75: /*@C
76: AORegister - Register an application ordering method
78: Not Collective
80: Input Parameters:
81: + sname - the name (`AOType`) of the `AO` scheme
82: - function - the create routine for the application ordering method
84: Level: advanced
86: .seealso: `AO`, `AOType`, `AOCreate()`, `AORegisterAll()`, `AOBASIC`, `AOADVANCED`, `AOMAPPING`, `AOMEMORYSCALABLE`
87: @*/
88: PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO))
89: {
90: PetscFunctionBegin;
91: PetscCall(AOInitializePackage());
92: PetscCall(PetscFunctionListAdd(&AOList, sname, function));
93: PetscFunctionReturn(PETSC_SUCCESS);
94: }