11447629fSBarry Smith 21447629fSBarry Smith /* 31447629fSBarry Smith Defines the abstract operations on AO (application orderings) 41447629fSBarry Smith */ 51447629fSBarry Smith #include <../src/vec/is/ao/aoimpl.h> /*I "petscao.h" I*/ 61447629fSBarry Smith 71447629fSBarry Smith /* Logging support */ 81447629fSBarry Smith PetscClassId AO_CLASSID; 91447629fSBarry Smith PetscLogEvent AO_PetscToApplication, AO_ApplicationToPetsc; 101447629fSBarry Smith 111447629fSBarry Smith /*@C 121447629fSBarry Smith AOView - Displays an application ordering. 131447629fSBarry Smith 14d083f849SBarry Smith Collective on AO 151447629fSBarry Smith 161447629fSBarry Smith Input Parameters: 171447629fSBarry Smith + ao - the application ordering context 181447629fSBarry Smith - viewer - viewer used for display 191447629fSBarry Smith 201447629fSBarry Smith Level: intermediate 211447629fSBarry Smith 221447629fSBarry Smith Options Database Key: 231447629fSBarry Smith . -ao_view - calls AOView() at end of AOCreate() 241447629fSBarry Smith 251447629fSBarry Smith Note: 261447629fSBarry Smith The available visualization contexts include 271447629fSBarry Smith + PETSC_VIEWER_STDOUT_SELF - standard output (default) 281447629fSBarry Smith - PETSC_VIEWER_STDOUT_WORLD - synchronized standard 291447629fSBarry Smith output where only the first processor opens 301447629fSBarry Smith the file. All other processors send their 311447629fSBarry Smith data to the first processor to print. 321447629fSBarry Smith 331447629fSBarry Smith The user can open an alternative visualization context with 341447629fSBarry Smith PetscViewerASCIIOpen() - output to a specified file. 351447629fSBarry Smith 36db781477SPatrick Sanan .seealso: `PetscViewerASCIIOpen()` 371447629fSBarry Smith @*/ 389371c9d4SSatish Balay PetscErrorCode AOView(AO ao, PetscViewer viewer) { 391447629fSBarry Smith PetscFunctionBegin; 401447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 41*48a46eb9SPierre Jolivet if (!viewer) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)ao), &viewer)); 421447629fSBarry Smith PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 2); 4398c3331eSBarry Smith 449566063dSJacob Faibussowitsch PetscCall(PetscObjectPrintClassNamePrefixType((PetscObject)ao, viewer)); 45dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, view, viewer); 461447629fSBarry Smith PetscFunctionReturn(0); 471447629fSBarry Smith } 481447629fSBarry Smith 49fe2efc57SMark /*@C 50fe2efc57SMark AOViewFromOptions - View from Options 51fe2efc57SMark 52fe2efc57SMark Collective on AO 53fe2efc57SMark 54fe2efc57SMark Input Parameters: 55fe2efc57SMark + ao - the application ordering context 56736c3998SJose E. Roman . obj - Optional object 57736c3998SJose E. Roman - name - command line option 58fe2efc57SMark 59fe2efc57SMark Level: intermediate 60db781477SPatrick Sanan .seealso: `AO`, `AOView`, `PetscObjectViewFromOptions()`, `AOCreate()` 61fe2efc57SMark @*/ 629371c9d4SSatish Balay PetscErrorCode AOViewFromOptions(AO ao, PetscObject obj, const char name[]) { 63fe2efc57SMark PetscFunctionBegin; 64fe2efc57SMark PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 659566063dSJacob Faibussowitsch PetscCall(PetscObjectViewFromOptions((PetscObject)ao, obj, name)); 66fe2efc57SMark PetscFunctionReturn(0); 67fe2efc57SMark } 68fe2efc57SMark 6901e608bcSBarry Smith /*@ 701447629fSBarry Smith AODestroy - Destroys an application ordering. 711447629fSBarry Smith 721447629fSBarry Smith Collective on AO 731447629fSBarry Smith 741447629fSBarry Smith Input Parameters: 751447629fSBarry Smith . ao - the application ordering context 761447629fSBarry Smith 771447629fSBarry Smith Level: beginner 781447629fSBarry Smith 79db781477SPatrick Sanan .seealso: `AOCreate()` 801447629fSBarry Smith @*/ 819371c9d4SSatish Balay PetscErrorCode AODestroy(AO *ao) { 821447629fSBarry Smith PetscFunctionBegin; 831447629fSBarry Smith if (!*ao) PetscFunctionReturn(0); 841447629fSBarry Smith PetscValidHeaderSpecific((*ao), AO_CLASSID, 1); 859371c9d4SSatish Balay if (--((PetscObject)(*ao))->refct > 0) { 869371c9d4SSatish Balay *ao = NULL; 879371c9d4SSatish Balay PetscFunctionReturn(0); 889371c9d4SSatish Balay } 89e04113cfSBarry Smith /* if memory was published with SAWs then destroy it */ 909566063dSJacob Faibussowitsch PetscCall(PetscObjectSAWsViewOff((PetscObject)*ao)); 919566063dSJacob Faibussowitsch PetscCall(ISDestroy(&(*ao)->isapp)); 929566063dSJacob Faibussowitsch PetscCall(ISDestroy(&(*ao)->ispetsc)); 931447629fSBarry Smith /* destroy the internal part */ 94*48a46eb9SPierre Jolivet if ((*ao)->ops->destroy) PetscCall((*(*ao)->ops->destroy)(*ao)); 959566063dSJacob Faibussowitsch PetscCall(PetscHeaderDestroy(ao)); 961447629fSBarry Smith PetscFunctionReturn(0); 971447629fSBarry Smith } 981447629fSBarry Smith 991447629fSBarry Smith #include <../src/vec/is/is/impls/general/general.h> 1001447629fSBarry Smith /* ---------------------------------------------------------------------*/ 1011cc6b274SLisandro Dalcin 1021cc6b274SLisandro Dalcin PETSC_INTERN PetscErrorCode ISSetUp_General(IS); 1031cc6b274SLisandro Dalcin 1041447629fSBarry Smith /*@ 1051447629fSBarry Smith AOPetscToApplicationIS - Maps an index set in the PETSc ordering to 1061447629fSBarry Smith the application-defined ordering. 1071447629fSBarry Smith 108d083f849SBarry Smith Collective on AO 1091447629fSBarry Smith 1101447629fSBarry Smith Input Parameters: 1111447629fSBarry Smith + ao - the application ordering context 1121447629fSBarry Smith - is - the index set; this is replaced with its mapped values 1131447629fSBarry Smith 1141447629fSBarry Smith Output Parameter: 1151447629fSBarry Smith . is - the mapped index set 1161447629fSBarry Smith 1171447629fSBarry Smith Level: intermediate 1181447629fSBarry Smith 1191447629fSBarry Smith Notes: 1201447629fSBarry Smith The index set cannot be of type stride or block 1211447629fSBarry Smith 1221447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 1231447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 1241447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions 1251447629fSBarry Smith etc. 1261447629fSBarry Smith 127c2e3fba1SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, 128c2e3fba1SPatrick Sanan `AOApplicationToPetscIS()`, `AOPetscToApplication()` 1291447629fSBarry Smith @*/ 1309371c9d4SSatish Balay PetscErrorCode AOPetscToApplicationIS(AO ao, IS is) { 1311447629fSBarry Smith PetscInt n; 1321447629fSBarry Smith PetscInt *ia; 1331447629fSBarry Smith 1341447629fSBarry Smith PetscFunctionBegin; 1351447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 1361447629fSBarry Smith PetscValidHeaderSpecific(is, IS_CLASSID, 2); 1379566063dSJacob Faibussowitsch PetscCall(ISToGeneral(is)); 1381447629fSBarry Smith /* we cheat because we know the is is general and that we can change the indices */ 1399566063dSJacob Faibussowitsch PetscCall(ISGetIndices(is, (const PetscInt **)&ia)); 1409566063dSJacob Faibussowitsch PetscCall(ISGetLocalSize(is, &n)); 141dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, petsctoapplication, n, ia); 1429566063dSJacob Faibussowitsch PetscCall(ISRestoreIndices(is, (const PetscInt **)&ia)); 1431cc6b274SLisandro Dalcin /* updated cached values (sorted, min, max, etc.)*/ 1449566063dSJacob Faibussowitsch PetscCall(ISSetUp_General(is)); 1451447629fSBarry Smith PetscFunctionReturn(0); 1461447629fSBarry Smith } 1471447629fSBarry Smith 1481447629fSBarry Smith /*@ 1491447629fSBarry Smith AOApplicationToPetscIS - Maps an index set in the application-defined 1501447629fSBarry Smith ordering to the PETSc ordering. 1511447629fSBarry Smith 152d083f849SBarry Smith Collective on AO 1531447629fSBarry Smith 1541447629fSBarry Smith Input Parameters: 1551447629fSBarry Smith + ao - the application ordering context 1561447629fSBarry Smith - is - the index set; this is replaced with its mapped values 1571447629fSBarry Smith 1581447629fSBarry Smith Output Parameter: 1591447629fSBarry Smith . is - the mapped index set 1601447629fSBarry Smith 1611447629fSBarry Smith Level: beginner 1621447629fSBarry Smith 1631447629fSBarry Smith Note: 1641447629fSBarry Smith The index set cannot be of type stride or block 1651447629fSBarry Smith 1661447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 1671447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 1681447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 1691447629fSBarry Smith 170db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOPetscToApplication()`, 171db781477SPatrick Sanan `AOPetscToApplicationIS()`, `AOApplicationToPetsc()` 1721447629fSBarry Smith @*/ 1739371c9d4SSatish Balay PetscErrorCode AOApplicationToPetscIS(AO ao, IS is) { 1741447629fSBarry Smith PetscInt n, *ia; 1751447629fSBarry Smith 1761447629fSBarry Smith PetscFunctionBegin; 1771447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 1781447629fSBarry Smith PetscValidHeaderSpecific(is, IS_CLASSID, 2); 1799566063dSJacob Faibussowitsch PetscCall(ISToGeneral(is)); 1801447629fSBarry Smith /* we cheat because we know the is is general and that we can change the indices */ 1819566063dSJacob Faibussowitsch PetscCall(ISGetIndices(is, (const PetscInt **)&ia)); 1829566063dSJacob Faibussowitsch PetscCall(ISGetLocalSize(is, &n)); 183dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, applicationtopetsc, n, ia); 1849566063dSJacob Faibussowitsch PetscCall(ISRestoreIndices(is, (const PetscInt **)&ia)); 1851cc6b274SLisandro Dalcin /* updated cached values (sorted, min, max, etc.)*/ 1869566063dSJacob Faibussowitsch PetscCall(ISSetUp_General(is)); 1871447629fSBarry Smith PetscFunctionReturn(0); 1881447629fSBarry Smith } 1891447629fSBarry Smith 1901447629fSBarry Smith /*@ 1911447629fSBarry Smith AOPetscToApplication - Maps a set of integers in the PETSc ordering to 1921447629fSBarry Smith the application-defined ordering. 1931447629fSBarry Smith 1941447629fSBarry Smith Collective on AO 1951447629fSBarry Smith 1961447629fSBarry Smith Input Parameters: 1971447629fSBarry Smith + ao - the application ordering context 1981447629fSBarry Smith . n - the number of integers 1991447629fSBarry Smith - ia - the integers; these are replaced with their mapped value 2001447629fSBarry Smith 2011447629fSBarry Smith Output Parameter: 2021447629fSBarry Smith . ia - the mapped integers 2031447629fSBarry Smith 2041447629fSBarry Smith Level: beginner 2051447629fSBarry Smith 2061447629fSBarry Smith Note: 2071447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 2081447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 2091447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 2101447629fSBarry Smith 2111447629fSBarry Smith Integers that are out of range are mapped to -1 2121447629fSBarry Smith 213c2e3fba1SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, 214db781477SPatrick Sanan `AOPetscToApplicationIS()`, `AOApplicationToPetsc()` 2151447629fSBarry Smith @*/ 2169371c9d4SSatish Balay PetscErrorCode AOPetscToApplication(AO ao, PetscInt n, PetscInt ia[]) { 2171447629fSBarry Smith PetscFunctionBegin; 2181447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 2191447629fSBarry Smith if (n) PetscValidIntPointer(ia, 3); 220dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, petsctoapplication, n, ia); 2211447629fSBarry Smith PetscFunctionReturn(0); 2221447629fSBarry Smith } 2231447629fSBarry Smith 2241447629fSBarry Smith /*@ 2251447629fSBarry Smith AOApplicationToPetsc - Maps a set of integers in the application-defined 2261447629fSBarry Smith ordering to the PETSc ordering. 2271447629fSBarry Smith 2281447629fSBarry Smith Collective on AO 2291447629fSBarry Smith 2301447629fSBarry Smith Input Parameters: 2311447629fSBarry Smith + ao - the application ordering context 2321447629fSBarry Smith . n - the number of integers 2331447629fSBarry Smith - ia - the integers; these are replaced with their mapped value 2341447629fSBarry Smith 2351447629fSBarry Smith Output Parameter: 2361447629fSBarry Smith . ia - the mapped integers 2371447629fSBarry Smith 2381447629fSBarry Smith Level: beginner 2391447629fSBarry Smith 2401447629fSBarry Smith Note: 2411447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 2421447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 2431447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 2441447629fSBarry Smith 2451447629fSBarry Smith Integers that are out of range are mapped to -1 2461447629fSBarry Smith 247db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOPetscToApplication()`, 248db781477SPatrick Sanan `AOPetscToApplicationIS()`, `AOApplicationToPetsc()` 2491447629fSBarry Smith @*/ 2509371c9d4SSatish Balay PetscErrorCode AOApplicationToPetsc(AO ao, PetscInt n, PetscInt ia[]) { 2511447629fSBarry Smith PetscFunctionBegin; 2521447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 2531447629fSBarry Smith if (n) PetscValidIntPointer(ia, 3); 254dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, applicationtopetsc, n, ia); 2551447629fSBarry Smith PetscFunctionReturn(0); 2561447629fSBarry Smith } 2571447629fSBarry Smith 2581447629fSBarry Smith /*@ 2591447629fSBarry Smith AOPetscToApplicationPermuteInt - Permutes an array of blocks of integers 2601447629fSBarry Smith in the PETSc ordering to the application-defined ordering. 2611447629fSBarry Smith 2621447629fSBarry Smith Collective on AO 2631447629fSBarry Smith 2641447629fSBarry Smith Input Parameters: 2651447629fSBarry Smith + ao - The application ordering context 2661447629fSBarry Smith . block - The block size 2671447629fSBarry Smith - array - The integer array 2681447629fSBarry Smith 2691447629fSBarry Smith Output Parameter: 2701447629fSBarry Smith . array - The permuted array 2711447629fSBarry Smith 2721447629fSBarry Smith Note: The length of the array should be block*N, where N is length 2731447629fSBarry Smith provided to the AOCreate*() method that created the AO. 2741447629fSBarry Smith 2751447629fSBarry Smith The permutation takes array[i_pet] --> array[i_app], where i_app is 2761447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 2771447629fSBarry Smith of 'i' in the petsc ordering. 2781447629fSBarry Smith 2791447629fSBarry Smith Level: beginner 2801447629fSBarry Smith 281db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, `AOPetscToApplicationIS()` 2821447629fSBarry Smith @*/ 2839371c9d4SSatish Balay PetscErrorCode AOPetscToApplicationPermuteInt(AO ao, PetscInt block, PetscInt array[]) { 2841447629fSBarry Smith PetscFunctionBegin; 2851447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 2861447629fSBarry Smith PetscValidIntPointer(array, 3); 287dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, petsctoapplicationpermuteint, block, array); 2881447629fSBarry Smith PetscFunctionReturn(0); 2891447629fSBarry Smith } 2901447629fSBarry Smith 2911447629fSBarry Smith /*@ 2921447629fSBarry Smith AOApplicationToPetscPermuteInt - Permutes an array of blocks of integers 2931447629fSBarry Smith in the application-defined ordering to the PETSc ordering. 2941447629fSBarry Smith 2951447629fSBarry Smith Collective on AO 2961447629fSBarry Smith 2971447629fSBarry Smith Input Parameters: 2981447629fSBarry Smith + ao - The application ordering context 2991447629fSBarry Smith . block - The block size 3001447629fSBarry Smith - array - The integer array 3011447629fSBarry Smith 3021447629fSBarry Smith Output Parameter: 3031447629fSBarry Smith . array - The permuted array 3041447629fSBarry Smith 3051447629fSBarry Smith Note: The length of the array should be block*N, where N is length 3061447629fSBarry Smith provided to the AOCreate*() method that created the AO. 3071447629fSBarry Smith 3081447629fSBarry Smith The permutation takes array[i_app] --> array[i_pet], where i_app is 3091447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 3101447629fSBarry Smith of 'i' in the petsc ordering. 3111447629fSBarry Smith 3121447629fSBarry Smith Level: beginner 3131447629fSBarry Smith 314db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOPetscToApplicationIS()`, `AOApplicationToPetsc()` 3151447629fSBarry Smith @*/ 3169371c9d4SSatish Balay PetscErrorCode AOApplicationToPetscPermuteInt(AO ao, PetscInt block, PetscInt array[]) { 3171447629fSBarry Smith PetscFunctionBegin; 3181447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 3191447629fSBarry Smith PetscValidIntPointer(array, 3); 320dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, applicationtopetscpermuteint, block, array); 3211447629fSBarry Smith PetscFunctionReturn(0); 3221447629fSBarry Smith } 3231447629fSBarry Smith 3241447629fSBarry Smith /*@ 3251447629fSBarry Smith AOPetscToApplicationPermuteReal - Permutes an array of blocks of reals 3261447629fSBarry Smith in the PETSc ordering to the application-defined ordering. 3271447629fSBarry Smith 3281447629fSBarry Smith Collective on AO 3291447629fSBarry Smith 3301447629fSBarry Smith Input Parameters: 3311447629fSBarry Smith + ao - The application ordering context 3321447629fSBarry Smith . block - The block size 3331447629fSBarry Smith - array - The integer array 3341447629fSBarry Smith 3351447629fSBarry Smith Output Parameter: 3361447629fSBarry Smith . array - The permuted array 3371447629fSBarry Smith 3381447629fSBarry Smith Note: The length of the array should be block*N, where N is length 3391447629fSBarry Smith provided to the AOCreate*() method that created the AO. 3401447629fSBarry Smith 3411447629fSBarry Smith The permutation takes array[i_pet] --> array[i_app], where i_app is 3421447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 3431447629fSBarry Smith of 'i' in the petsc ordering. 3441447629fSBarry Smith 3451447629fSBarry Smith Level: beginner 3461447629fSBarry Smith 347db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, `AOPetscToApplicationIS()` 3481447629fSBarry Smith @*/ 3499371c9d4SSatish Balay PetscErrorCode AOPetscToApplicationPermuteReal(AO ao, PetscInt block, PetscReal array[]) { 3501447629fSBarry Smith PetscFunctionBegin; 3511447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 352064a246eSJacob Faibussowitsch PetscValidRealPointer(array, 3); 353dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, petsctoapplicationpermutereal, block, array); 3541447629fSBarry Smith PetscFunctionReturn(0); 3551447629fSBarry Smith } 3561447629fSBarry Smith 3571447629fSBarry Smith /*@ 3581447629fSBarry Smith AOApplicationToPetscPermuteReal - Permutes an array of blocks of reals 3591447629fSBarry Smith in the application-defined ordering to the PETSc ordering. 3601447629fSBarry Smith 3611447629fSBarry Smith Collective on AO 3621447629fSBarry Smith 3631447629fSBarry Smith Input Parameters: 3641447629fSBarry Smith + ao - The application ordering context 3651447629fSBarry Smith . block - The block size 3661447629fSBarry Smith - array - The integer array 3671447629fSBarry Smith 3681447629fSBarry Smith Output Parameter: 3691447629fSBarry Smith . array - The permuted array 3701447629fSBarry Smith 3711447629fSBarry Smith Note: The length of the array should be block*N, where N is length 3721447629fSBarry Smith provided to the AOCreate*() method that created the AO. 3731447629fSBarry Smith 3741447629fSBarry Smith The permutation takes array[i_app] --> array[i_pet], where i_app is 3751447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 3761447629fSBarry Smith of 'i' in the petsc ordering. 3771447629fSBarry Smith 3781447629fSBarry Smith Level: beginner 3791447629fSBarry Smith 380c2e3fba1SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, `AOPetscToApplicationIS()` 3811447629fSBarry Smith @*/ 3829371c9d4SSatish Balay PetscErrorCode AOApplicationToPetscPermuteReal(AO ao, PetscInt block, PetscReal array[]) { 3831447629fSBarry Smith PetscFunctionBegin; 3841447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 385064a246eSJacob Faibussowitsch PetscValidRealPointer(array, 3); 386dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, applicationtopetscpermutereal, block, array); 3871447629fSBarry Smith PetscFunctionReturn(0); 3881447629fSBarry Smith } 3891447629fSBarry Smith 39001e608bcSBarry Smith /*@ 3911447629fSBarry Smith AOSetFromOptions - Sets AO options from the options database. 3921447629fSBarry Smith 3931447629fSBarry Smith Collective on AO 3941447629fSBarry Smith 3951447629fSBarry Smith Input Parameter: 3961447629fSBarry Smith . ao - the application ordering 3971447629fSBarry Smith 3981447629fSBarry Smith Level: beginner 3991447629fSBarry Smith 400db781477SPatrick Sanan .seealso: `AOCreate()`, `AOSetType()`, `AODestroy()`, `AOPetscToApplication()`, `AOApplicationToPetsc()` 4011447629fSBarry Smith @*/ 4029371c9d4SSatish Balay PetscErrorCode AOSetFromOptions(AO ao) { 4031447629fSBarry Smith char type[256]; 4041447629fSBarry Smith const char *def = AOBASIC; 4051447629fSBarry Smith PetscBool flg; 4061447629fSBarry Smith 4071447629fSBarry Smith PetscFunctionBegin; 4081447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 4091447629fSBarry Smith 410d0609cedSBarry Smith PetscObjectOptionsBegin((PetscObject)ao); 4119566063dSJacob Faibussowitsch PetscCall(PetscOptionsFList("-ao_type", "AO type", "AOSetType", AOList, def, type, 256, &flg)); 4121447629fSBarry Smith if (flg) { 4139566063dSJacob Faibussowitsch PetscCall(AOSetType(ao, type)); 4141447629fSBarry Smith } else if (!((PetscObject)ao)->type_name) { 4159566063dSJacob Faibussowitsch PetscCall(AOSetType(ao, def)); 4161447629fSBarry Smith } 417d0609cedSBarry Smith PetscOptionsEnd(); 4181447629fSBarry Smith PetscFunctionReturn(0); 4191447629fSBarry Smith } 4201447629fSBarry Smith 42101e608bcSBarry Smith /*@ 4221447629fSBarry Smith AOSetIS - Sets the IS associated with the application ordering. 4231447629fSBarry Smith 424d083f849SBarry Smith Collective 4251447629fSBarry Smith 4261447629fSBarry Smith Input Parameters: 4271447629fSBarry Smith + ao - the application ordering 4281447629fSBarry Smith . isapp - index set that defines an ordering 4291447629fSBarry Smith - ispetsc - index set that defines another ordering (may be NULL to use the 4301447629fSBarry Smith natural ordering) 4311447629fSBarry Smith 4321447629fSBarry Smith Notes: 4331447629fSBarry Smith The index sets isapp and ispetsc are used only for creation of ao. 4341447629fSBarry Smith 43501e608bcSBarry Smith This routine increases the reference count of isapp and ispetsc so you may/should destroy these arguments after this call if you no longer need them 43601e608bcSBarry Smith 4371447629fSBarry Smith Level: beginner 4381447629fSBarry Smith 439db781477SPatrick Sanan .seealso: `AOCreate()`, `AODestroy()`, `AOPetscToApplication()`, `AOApplicationToPetsc()` 4401447629fSBarry Smith @*/ 4419371c9d4SSatish Balay PetscErrorCode AOSetIS(AO ao, IS isapp, IS ispetsc) { 4421447629fSBarry Smith PetscFunctionBegin; 4431447629fSBarry Smith if (ispetsc) { 4441447629fSBarry Smith PetscInt napp, npetsc; 4459566063dSJacob Faibussowitsch PetscCall(ISGetLocalSize(isapp, &napp)); 4469566063dSJacob Faibussowitsch PetscCall(ISGetLocalSize(ispetsc, &npetsc)); 44708401ef6SPierre Jolivet PetscCheck(napp == npetsc, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "napp %" PetscInt_FMT " != npetsc %" PetscInt_FMT ". Local IS lengths must match", napp, npetsc); 4481447629fSBarry Smith } 4499566063dSJacob Faibussowitsch if (isapp) PetscCall(PetscObjectReference((PetscObject)isapp)); 4509566063dSJacob Faibussowitsch if (ispetsc) PetscCall(PetscObjectReference((PetscObject)ispetsc)); 4519566063dSJacob Faibussowitsch PetscCall(ISDestroy(&ao->isapp)); 4529566063dSJacob Faibussowitsch PetscCall(ISDestroy(&ao->ispetsc)); 4531447629fSBarry Smith ao->isapp = isapp; 4541447629fSBarry Smith ao->ispetsc = ispetsc; 4551447629fSBarry Smith PetscFunctionReturn(0); 4561447629fSBarry Smith } 4571447629fSBarry Smith 45801e608bcSBarry Smith /*@ 4591447629fSBarry Smith AOCreate - Creates an application ordering. 4601447629fSBarry Smith 461d083f849SBarry Smith Collective 4621447629fSBarry Smith 4631447629fSBarry Smith Input Parameters: 4641447629fSBarry Smith . comm - MPI communicator that is to share AO 4651447629fSBarry Smith 4661447629fSBarry Smith Output Parameter: 4671447629fSBarry Smith . ao - the new application ordering 4681447629fSBarry Smith 4691447629fSBarry Smith Options Database Key: 4701447629fSBarry Smith + -ao_type <aotype> - create ao with particular format 4711447629fSBarry Smith - -ao_view - call AOView() at the conclusion of AOCreate() 4721447629fSBarry Smith 4731447629fSBarry Smith Level: beginner 4741447629fSBarry Smith 475db781477SPatrick Sanan .seealso: `AOSetIS()`, `AODestroy()`, `AOPetscToApplication()`, `AOApplicationToPetsc()` 4761447629fSBarry Smith @*/ 4779371c9d4SSatish Balay PetscErrorCode AOCreate(MPI_Comm comm, AO *ao) { 4781447629fSBarry Smith AO aonew; 4791447629fSBarry Smith 4801447629fSBarry Smith PetscFunctionBegin; 4811447629fSBarry Smith PetscValidPointer(ao, 2); 4821447629fSBarry Smith *ao = NULL; 4839566063dSJacob Faibussowitsch PetscCall(AOInitializePackage()); 4841447629fSBarry Smith 4859566063dSJacob Faibussowitsch PetscCall(PetscHeaderCreate(aonew, AO_CLASSID, "AO", "Application Ordering", "AO", comm, AODestroy, AOView)); 4861447629fSBarry Smith *ao = aonew; 4871447629fSBarry Smith PetscFunctionReturn(0); 4881447629fSBarry Smith } 489