1*1447629fSBarry Smith 2*1447629fSBarry Smith #include <../src/vec/is/ao/aoimpl.h> /*I "petscao.h" I*/ 3*1447629fSBarry Smith 4*1447629fSBarry Smith PetscFunctionList AOList = NULL; 5*1447629fSBarry Smith PetscBool AORegisterAllCalled = PETSC_FALSE; 6*1447629fSBarry Smith 7*1447629fSBarry Smith #undef __FUNCT__ 8*1447629fSBarry Smith #define __FUNCT__ "AOSetType" 9*1447629fSBarry Smith /*@C 10*1447629fSBarry Smith AOSetType - Builds an application ordering for a particular implementation. 11*1447629fSBarry Smith 12*1447629fSBarry Smith Collective on AO 13*1447629fSBarry Smith 14*1447629fSBarry Smith Input Parameters: 15*1447629fSBarry Smith + ao - The AO object 16*1447629fSBarry Smith - method - The name of the AO type 17*1447629fSBarry Smith 18*1447629fSBarry Smith Options Database Key: 19*1447629fSBarry Smith . -ao_type <type> - Sets the AO type; use -help for a list of available types 20*1447629fSBarry Smith 21*1447629fSBarry Smith Notes: 22*1447629fSBarry Smith See "petsc/include/petscao.h" for available AO types (for instance, AOBASIC and AOMEMORYSCALABLE). 23*1447629fSBarry Smith 24*1447629fSBarry Smith Level: intermediate 25*1447629fSBarry Smith 26*1447629fSBarry Smith .keywords: ao, set, type 27*1447629fSBarry Smith .seealso: AOGetType(), AOCreate() 28*1447629fSBarry Smith @*/ 29*1447629fSBarry Smith PetscErrorCode AOSetType(AO ao, AOType method) 30*1447629fSBarry Smith { 31*1447629fSBarry Smith PetscErrorCode (*r)(AO); 32*1447629fSBarry Smith PetscBool match; 33*1447629fSBarry Smith PetscErrorCode ierr; 34*1447629fSBarry Smith 35*1447629fSBarry Smith PetscFunctionBegin; 36*1447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 37*1447629fSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)ao, method, &match);CHKERRQ(ierr); 38*1447629fSBarry Smith if (match) PetscFunctionReturn(0); 39*1447629fSBarry Smith 40*1447629fSBarry Smith if (!AORegisterAllCalled) {ierr = AORegisterAll(NULL);CHKERRQ(ierr);} 41*1447629fSBarry Smith ierr = PetscFunctionListFind(PetscObjectComm((PetscObject)ao), AOList, method,PETSC_TRUE,(void (**)(void)) &r);CHKERRQ(ierr); 42*1447629fSBarry Smith if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method); 43*1447629fSBarry Smith if (ao->ops->destroy) { 44*1447629fSBarry Smith ierr = (*ao->ops->destroy)(ao);CHKERRQ(ierr); 45*1447629fSBarry Smith ao->ops->destroy = NULL; 46*1447629fSBarry Smith } 47*1447629fSBarry Smith 48*1447629fSBarry Smith ierr = (*r)(ao);CHKERRQ(ierr); 49*1447629fSBarry Smith PetscFunctionReturn(0); 50*1447629fSBarry Smith } 51*1447629fSBarry Smith 52*1447629fSBarry Smith #undef __FUNCT__ 53*1447629fSBarry Smith #define __FUNCT__ "AOGetType" 54*1447629fSBarry Smith /*@C 55*1447629fSBarry Smith AOGetType - Gets the AO type name (as a string) from the AO. 56*1447629fSBarry Smith 57*1447629fSBarry Smith Not Collective 58*1447629fSBarry Smith 59*1447629fSBarry Smith Input Parameter: 60*1447629fSBarry Smith . ao - The vector 61*1447629fSBarry Smith 62*1447629fSBarry Smith Output Parameter: 63*1447629fSBarry Smith . type - The AO type name 64*1447629fSBarry Smith 65*1447629fSBarry Smith Level: intermediate 66*1447629fSBarry Smith 67*1447629fSBarry Smith .keywords: ao, get, type, name 68*1447629fSBarry Smith .seealso: AOSetType(), AOCreate() 69*1447629fSBarry Smith @*/ 70*1447629fSBarry Smith PetscErrorCode AOGetType(AO ao, AOType *type) 71*1447629fSBarry Smith { 72*1447629fSBarry Smith PetscErrorCode ierr; 73*1447629fSBarry Smith 74*1447629fSBarry Smith PetscFunctionBegin; 75*1447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 76*1447629fSBarry Smith PetscValidCharPointer(type,2); 77*1447629fSBarry Smith if (!AORegisterAllCalled) { 78*1447629fSBarry Smith ierr = AORegisterAll(NULL);CHKERRQ(ierr); 79*1447629fSBarry Smith } 80*1447629fSBarry Smith *type = ((PetscObject)ao)->type_name; 81*1447629fSBarry Smith PetscFunctionReturn(0); 82*1447629fSBarry Smith } 83*1447629fSBarry Smith 84*1447629fSBarry Smith 85*1447629fSBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/ 86*1447629fSBarry Smith 87*1447629fSBarry Smith #undef __FUNCT__ 88*1447629fSBarry Smith #define __FUNCT__ "AORegister" 89*1447629fSBarry Smith /*@C 90*1447629fSBarry Smith AORegister - See AORegisterDynamic() 91*1447629fSBarry Smith 92*1447629fSBarry Smith Level: advanced 93*1447629fSBarry Smith @*/ 94*1447629fSBarry Smith PetscErrorCode AORegister(const char sname[], const char path[], const char name[], PetscErrorCode (*function)(AO)) 95*1447629fSBarry Smith { 96*1447629fSBarry Smith char fullname[PETSC_MAX_PATH_LEN]; 97*1447629fSBarry Smith PetscErrorCode ierr; 98*1447629fSBarry Smith 99*1447629fSBarry Smith PetscFunctionBegin; 100*1447629fSBarry Smith ierr = PetscStrcpy(fullname, path);CHKERRQ(ierr); 101*1447629fSBarry Smith ierr = PetscStrcat(fullname, ":");CHKERRQ(ierr); 102*1447629fSBarry Smith ierr = PetscStrcat(fullname, name);CHKERRQ(ierr); 103*1447629fSBarry Smith ierr = PetscFunctionListAdd(PETSC_COMM_WORLD,&AOList, sname, fullname, (void (*)(void)) function);CHKERRQ(ierr); 104*1447629fSBarry Smith PetscFunctionReturn(0); 105*1447629fSBarry Smith } 106*1447629fSBarry Smith 107*1447629fSBarry Smith 108*1447629fSBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/ 109*1447629fSBarry Smith #undef __FUNCT__ 110*1447629fSBarry Smith #define __FUNCT__ "AORegisterDestroy" 111*1447629fSBarry Smith /*@C 112*1447629fSBarry Smith AORegisterDestroy - Frees the list of AO methods that were registered by AORegister()/AORegisterDynamic(). 113*1447629fSBarry Smith 114*1447629fSBarry Smith Not Collective 115*1447629fSBarry Smith 116*1447629fSBarry Smith Level: advanced 117*1447629fSBarry Smith 118*1447629fSBarry Smith .keywords: AO, register, destroy 119*1447629fSBarry Smith .seealso: AORegister(), AORegisterAll(), AORegisterDynamic() 120*1447629fSBarry Smith @*/ 121*1447629fSBarry Smith PetscErrorCode AORegisterDestroy(void) 122*1447629fSBarry Smith { 123*1447629fSBarry Smith PetscErrorCode ierr; 124*1447629fSBarry Smith 125*1447629fSBarry Smith PetscFunctionBegin; 126*1447629fSBarry Smith ierr = PetscFunctionListDestroy(&AOList);CHKERRQ(ierr); 127*1447629fSBarry Smith AORegisterAllCalled = PETSC_FALSE; 128*1447629fSBarry Smith PetscFunctionReturn(0); 129*1447629fSBarry Smith } 130*1447629fSBarry Smith 131