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 PetscErrorCode ierr; 311447629fSBarry Smith 321447629fSBarry Smith PetscFunctionBegin; 331447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 341447629fSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)ao, method, &match);CHKERRQ(ierr); 351447629fSBarry Smith if (match) PetscFunctionReturn(0); 361447629fSBarry Smith 370f51fdf8SToby Isaac ierr = AORegisterAll();CHKERRQ(ierr); 381c9cd337SJed Brown ierr = PetscFunctionListFind(AOList,method,&r);CHKERRQ(ierr); 39*2c71b3e2SJacob Faibussowitsch PetscCheckFalse(!r,PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method); 401447629fSBarry Smith if (ao->ops->destroy) { 411447629fSBarry Smith ierr = (*ao->ops->destroy)(ao);CHKERRQ(ierr); 421447629fSBarry Smith ao->ops->destroy = NULL; 431447629fSBarry Smith } 441447629fSBarry Smith 451447629fSBarry Smith ierr = (*r)(ao);CHKERRQ(ierr); 461447629fSBarry Smith PetscFunctionReturn(0); 471447629fSBarry Smith } 481447629fSBarry Smith 491447629fSBarry Smith /*@C 501447629fSBarry Smith AOGetType - Gets the AO type name (as a string) from the AO. 511447629fSBarry Smith 521447629fSBarry Smith Not Collective 531447629fSBarry Smith 541447629fSBarry Smith Input Parameter: 551447629fSBarry Smith . ao - The vector 561447629fSBarry Smith 571447629fSBarry Smith Output Parameter: 581447629fSBarry Smith . type - The AO type name 591447629fSBarry Smith 601447629fSBarry Smith Level: intermediate 611447629fSBarry Smith 621447629fSBarry Smith .seealso: AOSetType(), AOCreate() 631447629fSBarry Smith @*/ 641447629fSBarry Smith PetscErrorCode AOGetType(AO ao, AOType *type) 651447629fSBarry Smith { 661447629fSBarry Smith PetscErrorCode ierr; 671447629fSBarry Smith 681447629fSBarry Smith PetscFunctionBegin; 691447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 70c959eef4SJed Brown PetscValidPointer(type,2); 71607a6623SBarry Smith ierr = AORegisterAll();CHKERRQ(ierr); 721447629fSBarry Smith *type = ((PetscObject)ao)->type_name; 731447629fSBarry Smith PetscFunctionReturn(0); 741447629fSBarry Smith } 751447629fSBarry Smith 761447629fSBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/ 771447629fSBarry Smith 781447629fSBarry Smith /*@C 791d36bdfdSBarry Smith AORegister - Register an application ordering method 801d36bdfdSBarry Smith 811d36bdfdSBarry Smith Not Collective 821d36bdfdSBarry Smith 831d36bdfdSBarry Smith Input Parameters: 841d36bdfdSBarry Smith + sname - the name of the AO scheme 851d36bdfdSBarry Smith - function - the create routine for the application ordering method 861447629fSBarry Smith 871447629fSBarry Smith Level: advanced 881d36bdfdSBarry Smith 891d36bdfdSBarry Smith .seealso: AOCreate(), AORegisterAll(), AOBASIC, AOADVANCED, AOMAPPING, AOMEMORYSCALABLE 901d36bdfdSBarry Smith 911447629fSBarry Smith @*/ 92bdf89e91SBarry Smith PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO)) 931447629fSBarry Smith { 941447629fSBarry Smith PetscErrorCode ierr; 951447629fSBarry Smith 961447629fSBarry Smith PetscFunctionBegin; 971d36bdfdSBarry Smith ierr = AOInitializePackage();CHKERRQ(ierr); 98a240a19fSJed Brown ierr = PetscFunctionListAdd(&AOList,sname,function);CHKERRQ(ierr); 991447629fSBarry Smith PetscFunctionReturn(0); 1001447629fSBarry Smith } 1011447629fSBarry Smith 102