1 2 #include <../src/vec/is/ao/aoimpl.h> /*I "petscao.h" I*/ 3 4 PetscFunctionList AOList = NULL; 5 PetscBool AORegisterAllCalled = PETSC_FALSE; 6 7 /*@C 8 AOSetType - Builds an application ordering for a particular implementation. 9 10 Collective on AO 11 12 Input Parameters: 13 + ao - The AO object 14 - method - The name of the AO type 15 16 Options Database Key: 17 . -ao_type <type> - Sets the AO type; use -help for a list of available types 18 19 Notes: 20 See "petsc/include/petscao.h" for available AO types (for instance, AOBASIC and AOMEMORYSCALABLE). 21 22 Level: intermediate 23 24 .seealso: `AOGetType()`, `AOCreate()` 25 @*/ 26 PetscErrorCode AOSetType(AO ao, AOType method) { 27 PetscErrorCode (*r)(AO); 28 PetscBool match; 29 30 PetscFunctionBegin; 31 PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 32 PetscCall(PetscObjectTypeCompare((PetscObject)ao, method, &match)); 33 if (match) PetscFunctionReturn(0); 34 35 PetscCall(AORegisterAll()); 36 PetscCall(PetscFunctionListFind(AOList, method, &r)); 37 PetscCheck(r, PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method); 38 PetscTryTypeMethod(ao, destroy); 39 ao->ops->destroy = NULL; 40 41 PetscCall((*r)(ao)); 42 PetscFunctionReturn(0); 43 } 44 45 /*@C 46 AOGetType - Gets the AO type name (as a string) from the AO. 47 48 Not Collective 49 50 Input Parameter: 51 . ao - The vector 52 53 Output Parameter: 54 . type - The AO type name 55 56 Level: intermediate 57 58 .seealso: `AOSetType()`, `AOCreate()` 59 @*/ 60 PetscErrorCode AOGetType(AO ao, AOType *type) { 61 PetscFunctionBegin; 62 PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 63 PetscValidPointer(type, 2); 64 PetscCall(AORegisterAll()); 65 *type = ((PetscObject)ao)->type_name; 66 PetscFunctionReturn(0); 67 } 68 69 /*--------------------------------------------------------------------------------------------------------------------*/ 70 71 /*@C 72 AORegister - Register an application ordering method 73 74 Not Collective 75 76 Input Parameters: 77 + sname - the name of the AO scheme 78 - function - the create routine for the application ordering method 79 80 Level: advanced 81 82 .seealso: `AOCreate()`, `AORegisterAll()`, `AOBASIC`, `AOADVANCED`, `AOMAPPING`, `AOMEMORYSCALABLE` 83 84 @*/ 85 PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO)) { 86 PetscFunctionBegin; 87 PetscCall(AOInitializePackage()); 88 PetscCall(PetscFunctionListAdd(&AOList, sname, function)); 89 PetscFunctionReturn(0); 90 } 91