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 241447629fSBarry Smith .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); 33*5f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectTypeCompare((PetscObject)ao, method, &match)); 341447629fSBarry Smith if (match) PetscFunctionReturn(0); 351447629fSBarry Smith 36*5f80ce2aSJacob Faibussowitsch CHKERRQ(AORegisterAll()); 37*5f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFunctionListFind(AOList,method,&r)); 382c71b3e2SJacob Faibussowitsch PetscCheckFalse(!r,PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method); 391447629fSBarry Smith if (ao->ops->destroy) { 40*5f80ce2aSJacob Faibussowitsch CHKERRQ((*ao->ops->destroy)(ao)); 411447629fSBarry Smith ao->ops->destroy = NULL; 421447629fSBarry Smith } 431447629fSBarry Smith 44*5f80ce2aSJacob Faibussowitsch CHKERRQ((*r)(ao)); 451447629fSBarry Smith PetscFunctionReturn(0); 461447629fSBarry Smith } 471447629fSBarry Smith 481447629fSBarry Smith /*@C 491447629fSBarry 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: 571447629fSBarry Smith . type - The AO type name 581447629fSBarry Smith 591447629fSBarry Smith Level: intermediate 601447629fSBarry Smith 611447629fSBarry Smith .seealso: AOSetType(), AOCreate() 621447629fSBarry Smith @*/ 631447629fSBarry Smith PetscErrorCode AOGetType(AO ao, AOType *type) 641447629fSBarry Smith { 651447629fSBarry Smith PetscFunctionBegin; 661447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 67c959eef4SJed Brown PetscValidPointer(type,2); 68*5f80ce2aSJacob Faibussowitsch CHKERRQ(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: 811d36bdfdSBarry Smith + sname - the name of the AO scheme 821d36bdfdSBarry Smith - function - the create routine for the application ordering method 831447629fSBarry Smith 841447629fSBarry Smith Level: advanced 851d36bdfdSBarry Smith 861d36bdfdSBarry Smith .seealso: AOCreate(), AORegisterAll(), AOBASIC, AOADVANCED, AOMAPPING, AOMEMORYSCALABLE 871d36bdfdSBarry Smith 881447629fSBarry Smith @*/ 89bdf89e91SBarry Smith PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO)) 901447629fSBarry Smith { 911447629fSBarry Smith PetscFunctionBegin; 92*5f80ce2aSJacob Faibussowitsch CHKERRQ(AOInitializePackage()); 93*5f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFunctionListAdd(&AOList,sname,function)); 941447629fSBarry Smith PetscFunctionReturn(0); 951447629fSBarry Smith } 96