11447629fSBarry Smith 21447629fSBarry Smith #include <../src/vec/is/ao/aoimpl.h> /*I "petscao.h" I*/ 31447629fSBarry Smith 41447629fSBarry Smith PetscFunctionList AOList = NULL; 51447629fSBarry Smith PetscBool AORegisterAllCalled = PETSC_FALSE; 61447629fSBarry Smith 71447629fSBarry Smith /*@C 8*cab54364SBarry Smith AOSetType - Builds an application ordering for a particular `AOType` 91447629fSBarry Smith 10*cab54364SBarry Smith Collective on ao 111447629fSBarry Smith 121447629fSBarry Smith Input Parameters: 13*cab54364SBarry Smith + ao - The `AO` object 141447629fSBarry Smith - method - The name of the AO type 151447629fSBarry Smith 161447629fSBarry Smith Options Database Key: 17*cab54364SBarry Smith . -ao_type <type> - Sets the `AO` type; use -help for a list of available types 181447629fSBarry Smith 191447629fSBarry Smith Level: intermediate 201447629fSBarry Smith 21*cab54364SBarry Smith Notes: 22*cab54364SBarry Smith See "petsc/include/petscao.h" for available AO types (for instance, `AOBASIC` and `AOMEMORYSCALABLE`). 23*cab54364SBarry Smith 24*cab54364SBarry Smith `AO` are usually created via the convenience routines such as `AOCreateBasic()` or `AOCreateMemoryScalable()` 25*cab54364SBarry Smith 26*cab54364SBarry Smith .seealso: `AO`, `AOType`, `AOCreateBasic()`, `AOCreateMemoryScalable()`, `AOGetType()`, `AOCreate()` 271447629fSBarry Smith @*/ 28d71ae5a4SJacob Faibussowitsch PetscErrorCode AOSetType(AO ao, AOType method) 29d71ae5a4SJacob Faibussowitsch { 301447629fSBarry Smith PetscErrorCode (*r)(AO); 311447629fSBarry Smith PetscBool match; 321447629fSBarry Smith 331447629fSBarry Smith PetscFunctionBegin; 341447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 359566063dSJacob Faibussowitsch PetscCall(PetscObjectTypeCompare((PetscObject)ao, method, &match)); 361447629fSBarry Smith if (match) PetscFunctionReturn(0); 371447629fSBarry Smith 389566063dSJacob Faibussowitsch PetscCall(AORegisterAll()); 399566063dSJacob Faibussowitsch PetscCall(PetscFunctionListFind(AOList, method, &r)); 4028b400f6SJacob Faibussowitsch PetscCheck(r, PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method); 41dbbe0bcdSBarry Smith PetscTryTypeMethod(ao, destroy); 421447629fSBarry Smith ao->ops->destroy = NULL; 431447629fSBarry Smith 449566063dSJacob Faibussowitsch PetscCall((*r)(ao)); 451447629fSBarry Smith PetscFunctionReturn(0); 461447629fSBarry Smith } 471447629fSBarry Smith 481447629fSBarry Smith /*@C 49*cab54364SBarry Smith AOGetType - Gets the `AO` type name (as a string) from the AO. 501447629fSBarry Smith 511447629fSBarry Smith Not Collective 521447629fSBarry Smith 531447629fSBarry Smith Input Parameter: 541447629fSBarry Smith . ao - The vector 551447629fSBarry Smith 561447629fSBarry Smith Output Parameter: 57*cab54364SBarry Smith . type - The `AO` type name 581447629fSBarry Smith 591447629fSBarry Smith Level: intermediate 601447629fSBarry Smith 61*cab54364SBarry Smith .seealso: `AO`, `AOType`, `AOSetType()`, `AOCreate()` 621447629fSBarry Smith @*/ 63d71ae5a4SJacob Faibussowitsch PetscErrorCode AOGetType(AO ao, AOType *type) 64d71ae5a4SJacob Faibussowitsch { 651447629fSBarry Smith PetscFunctionBegin; 661447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 67c959eef4SJed Brown PetscValidPointer(type, 2); 689566063dSJacob Faibussowitsch PetscCall(AORegisterAll()); 691447629fSBarry Smith *type = ((PetscObject)ao)->type_name; 701447629fSBarry Smith PetscFunctionReturn(0); 711447629fSBarry Smith } 721447629fSBarry Smith 731447629fSBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/ 741447629fSBarry Smith 751447629fSBarry Smith /*@C 761d36bdfdSBarry Smith AORegister - Register an application ordering method 771d36bdfdSBarry Smith 781d36bdfdSBarry Smith Not Collective 791d36bdfdSBarry Smith 801d36bdfdSBarry Smith Input Parameters: 81*cab54364SBarry Smith + sname - the name (`AOType`) of the `AO` scheme 821d36bdfdSBarry Smith - function - the create routine for the application ordering method 831447629fSBarry Smith 841447629fSBarry Smith Level: advanced 851d36bdfdSBarry Smith 86*cab54364SBarry Smith .seealso: `AO`, `AOType`, `AOCreate()`, `AORegisterAll()`, `AOBASIC`, `AOADVANCED`, `AOMAPPING`, `AOMEMORYSCALABLE` 871447629fSBarry Smith @*/ 88d71ae5a4SJacob Faibussowitsch PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO)) 89d71ae5a4SJacob Faibussowitsch { 901447629fSBarry Smith PetscFunctionBegin; 919566063dSJacob Faibussowitsch PetscCall(AOInitializePackage()); 929566063dSJacob Faibussowitsch PetscCall(PetscFunctionListAdd(&AOList, sname, function)); 931447629fSBarry Smith PetscFunctionReturn(0); 941447629fSBarry Smith } 95