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