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 #undef __FUNCT__ 81447629fSBarry Smith #define __FUNCT__ "AOSetType" 91447629fSBarry Smith /*@C 101447629fSBarry Smith AOSetType - Builds an application ordering for a particular implementation. 111447629fSBarry Smith 121447629fSBarry Smith Collective on AO 131447629fSBarry Smith 141447629fSBarry Smith Input Parameters: 151447629fSBarry Smith + ao - The AO object 161447629fSBarry Smith - method - The name of the AO type 171447629fSBarry Smith 181447629fSBarry Smith Options Database Key: 191447629fSBarry Smith . -ao_type <type> - Sets the AO type; use -help for a list of available types 201447629fSBarry Smith 211447629fSBarry Smith Notes: 221447629fSBarry Smith See "petsc/include/petscao.h" for available AO types (for instance, AOBASIC and AOMEMORYSCALABLE). 231447629fSBarry Smith 241447629fSBarry Smith Level: intermediate 251447629fSBarry Smith 261447629fSBarry Smith .keywords: ao, set, type 271447629fSBarry Smith .seealso: AOGetType(), AOCreate() 281447629fSBarry Smith @*/ 291447629fSBarry Smith PetscErrorCode AOSetType(AO ao, AOType method) 301447629fSBarry Smith { 311447629fSBarry Smith PetscErrorCode (*r)(AO); 321447629fSBarry Smith PetscBool match; 331447629fSBarry Smith PetscErrorCode ierr; 341447629fSBarry Smith 351447629fSBarry Smith PetscFunctionBegin; 361447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 371447629fSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)ao, method, &match);CHKERRQ(ierr); 381447629fSBarry Smith if (match) PetscFunctionReturn(0); 391447629fSBarry Smith 40607a6623SBarry Smith if (!AORegisterAllCalled) {ierr = AORegisterAll();CHKERRQ(ierr);} 41*1c9cd337SJed Brown ierr = PetscFunctionListFind(AOList,method,&r);CHKERRQ(ierr); 421447629fSBarry Smith if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method); 431447629fSBarry Smith if (ao->ops->destroy) { 441447629fSBarry Smith ierr = (*ao->ops->destroy)(ao);CHKERRQ(ierr); 451447629fSBarry Smith ao->ops->destroy = NULL; 461447629fSBarry Smith } 471447629fSBarry Smith 481447629fSBarry Smith ierr = (*r)(ao);CHKERRQ(ierr); 491447629fSBarry Smith PetscFunctionReturn(0); 501447629fSBarry Smith } 511447629fSBarry Smith 521447629fSBarry Smith #undef __FUNCT__ 531447629fSBarry Smith #define __FUNCT__ "AOGetType" 541447629fSBarry Smith /*@C 551447629fSBarry Smith AOGetType - Gets the AO type name (as a string) from the AO. 561447629fSBarry Smith 571447629fSBarry Smith Not Collective 581447629fSBarry Smith 591447629fSBarry Smith Input Parameter: 601447629fSBarry Smith . ao - The vector 611447629fSBarry Smith 621447629fSBarry Smith Output Parameter: 631447629fSBarry Smith . type - The AO type name 641447629fSBarry Smith 651447629fSBarry Smith Level: intermediate 661447629fSBarry Smith 671447629fSBarry Smith .keywords: ao, get, type, name 681447629fSBarry Smith .seealso: AOSetType(), AOCreate() 691447629fSBarry Smith @*/ 701447629fSBarry Smith PetscErrorCode AOGetType(AO ao, AOType *type) 711447629fSBarry Smith { 721447629fSBarry Smith PetscErrorCode ierr; 731447629fSBarry Smith 741447629fSBarry Smith PetscFunctionBegin; 751447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 761447629fSBarry Smith PetscValidCharPointer(type,2); 771447629fSBarry Smith if (!AORegisterAllCalled) { 78607a6623SBarry Smith ierr = AORegisterAll();CHKERRQ(ierr); 791447629fSBarry Smith } 801447629fSBarry Smith *type = ((PetscObject)ao)->type_name; 811447629fSBarry Smith PetscFunctionReturn(0); 821447629fSBarry Smith } 831447629fSBarry Smith 841447629fSBarry Smith 851447629fSBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/ 861447629fSBarry Smith 871447629fSBarry Smith #undef __FUNCT__ 881447629fSBarry Smith #define __FUNCT__ "AORegister" 891447629fSBarry Smith /*@C 90607a6623SBarry Smith AORegister - 911447629fSBarry Smith 921447629fSBarry Smith Level: advanced 931447629fSBarry Smith @*/ 94bdf89e91SBarry Smith PetscErrorCode AORegister(const char sname[], PetscErrorCode (*function)(AO)) 951447629fSBarry Smith { 961447629fSBarry Smith PetscErrorCode ierr; 971447629fSBarry Smith 981447629fSBarry Smith PetscFunctionBegin; 99bdf89e91SBarry Smith ierr = PetscFunctionListAdd(&AOList, sname, (void (*)(void)) function);CHKERRQ(ierr); 1001447629fSBarry Smith PetscFunctionReturn(0); 1011447629fSBarry Smith } 1021447629fSBarry Smith 1031447629fSBarry Smith 1041447629fSBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/ 1051447629fSBarry Smith #undef __FUNCT__ 1061447629fSBarry Smith #define __FUNCT__ "AORegisterDestroy" 1071447629fSBarry Smith /*@C 108607a6623SBarry Smith AORegisterDestroy - Frees the list of AO methods that were registered by AORegister() 1091447629fSBarry Smith 1101447629fSBarry Smith Not Collective 1111447629fSBarry Smith 1121447629fSBarry Smith Level: advanced 1131447629fSBarry Smith 1141447629fSBarry Smith .keywords: AO, register, destroy 115607a6623SBarry Smith .seealso: AORegister(), AORegisterAll() 1161447629fSBarry Smith @*/ 1171447629fSBarry Smith PetscErrorCode AORegisterDestroy(void) 1181447629fSBarry Smith { 1191447629fSBarry Smith PetscErrorCode ierr; 1201447629fSBarry Smith 1211447629fSBarry Smith PetscFunctionBegin; 1221447629fSBarry Smith ierr = PetscFunctionListDestroy(&AOList);CHKERRQ(ierr); 1231447629fSBarry Smith AORegisterAllCalled = PETSC_FALSE; 1241447629fSBarry Smith PetscFunctionReturn(0); 1251447629fSBarry Smith } 1261447629fSBarry Smith 127