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 81447629fSBarry Smith AOSetType - Builds an application ordering for a particular implementation. 91447629fSBarry Smith 101447629fSBarry Smith Collective on AO 111447629fSBarry Smith 121447629fSBarry Smith Input Parameters: 131447629fSBarry Smith + ao - The AO object 141447629fSBarry Smith - method - The name of the AO type 151447629fSBarry Smith 161447629fSBarry Smith Options Database Key: 171447629fSBarry Smith . -ao_type <type> - Sets the AO type; use -help for a list of available types 181447629fSBarry Smith 191447629fSBarry Smith Notes: 201447629fSBarry Smith See "petsc/include/petscao.h" for available AO types (for instance, AOBASIC and AOMEMORYSCALABLE). 211447629fSBarry Smith 221447629fSBarry Smith Level: intermediate 231447629fSBarry Smith 24db781477SPatrick Sanan .seealso: `AOGetType()`, `AOCreate()` 251447629fSBarry Smith @*/ 261447629fSBarry Smith PetscErrorCode AOSetType(AO ao, AOType method) 271447629fSBarry Smith { 281447629fSBarry Smith PetscErrorCode (*r)(AO); 291447629fSBarry Smith PetscBool match; 301447629fSBarry Smith 311447629fSBarry Smith PetscFunctionBegin; 321447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 339566063dSJacob Faibussowitsch PetscCall(PetscObjectTypeCompare((PetscObject)ao, method, &match)); 341447629fSBarry Smith if (match) PetscFunctionReturn(0); 351447629fSBarry Smith 369566063dSJacob Faibussowitsch PetscCall(AORegisterAll()); 379566063dSJacob Faibussowitsch PetscCall(PetscFunctionListFind(AOList,method,&r)); 3828b400f6SJacob Faibussowitsch PetscCheck(r,PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method); 39*dbbe0bcdSBarry Smith PetscTryTypeMethod(ao,destroy); 401447629fSBarry Smith ao->ops->destroy = NULL; 411447629fSBarry Smith 429566063dSJacob Faibussowitsch PetscCall((*r)(ao)); 431447629fSBarry Smith PetscFunctionReturn(0); 441447629fSBarry Smith } 451447629fSBarry Smith 461447629fSBarry Smith /*@C 471447629fSBarry Smith AOGetType - Gets the AO type name (as a string) from the AO. 481447629fSBarry Smith 491447629fSBarry Smith Not Collective 501447629fSBarry Smith 511447629fSBarry Smith Input Parameter: 521447629fSBarry Smith . ao - The vector 531447629fSBarry Smith 541447629fSBarry Smith Output Parameter: 551447629fSBarry Smith . type - The AO type name 561447629fSBarry Smith 571447629fSBarry Smith Level: intermediate 581447629fSBarry Smith 59db781477SPatrick Sanan .seealso: `AOSetType()`, `AOCreate()` 601447629fSBarry Smith @*/ 611447629fSBarry Smith PetscErrorCode AOGetType(AO ao, AOType *type) 621447629fSBarry Smith { 631447629fSBarry Smith PetscFunctionBegin; 641447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 65c959eef4SJed Brown PetscValidPointer(type,2); 669566063dSJacob Faibussowitsch PetscCall(AORegisterAll()); 671447629fSBarry Smith *type = ((PetscObject)ao)->type_name; 681447629fSBarry Smith PetscFunctionReturn(0); 691447629fSBarry Smith } 701447629fSBarry Smith 711447629fSBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/ 721447629fSBarry Smith 731447629fSBarry Smith /*@C 741d36bdfdSBarry Smith AORegister - Register an application ordering method 751d36bdfdSBarry Smith 761d36bdfdSBarry Smith Not Collective 771d36bdfdSBarry Smith 781d36bdfdSBarry Smith Input Parameters: 791d36bdfdSBarry Smith + sname - the name of the AO scheme 801d36bdfdSBarry Smith - function - the create routine for the application ordering method 811447629fSBarry Smith 821447629fSBarry Smith Level: advanced 831d36bdfdSBarry Smith 84db781477SPatrick Sanan .seealso: `AOCreate()`, `AORegisterAll()`, `AOBASIC`, `AOADVANCED`, `AOMAPPING`, `AOMEMORYSCALABLE` 851d36bdfdSBarry Smith 861447629fSBarry Smith @*/ 87bdf89e91SBarry Smith PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO)) 881447629fSBarry Smith { 891447629fSBarry Smith PetscFunctionBegin; 909566063dSJacob Faibussowitsch PetscCall(AOInitializePackage()); 919566063dSJacob Faibussowitsch PetscCall(PetscFunctionListAdd(&AOList,sname,function)); 921447629fSBarry Smith PetscFunctionReturn(0); 931447629fSBarry Smith } 94