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 @*/ 38*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOView(AO ao, PetscViewer viewer) 39*d71ae5a4SJacob Faibussowitsch { 401447629fSBarry Smith PetscFunctionBegin; 411447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 4248a46eb9SPierre Jolivet if (!viewer) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)ao), &viewer)); 431447629fSBarry Smith PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 2); 4498c3331eSBarry Smith 459566063dSJacob Faibussowitsch PetscCall(PetscObjectPrintClassNamePrefixType((PetscObject)ao, viewer)); 46dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, view, viewer); 471447629fSBarry Smith PetscFunctionReturn(0); 481447629fSBarry Smith } 491447629fSBarry Smith 50fe2efc57SMark /*@C 51fe2efc57SMark AOViewFromOptions - View from Options 52fe2efc57SMark 53fe2efc57SMark Collective on AO 54fe2efc57SMark 55fe2efc57SMark Input Parameters: 56fe2efc57SMark + ao - the application ordering context 57736c3998SJose E. Roman . obj - Optional object 58736c3998SJose E. Roman - name - command line option 59fe2efc57SMark 60fe2efc57SMark Level: intermediate 61db781477SPatrick Sanan .seealso: `AO`, `AOView`, `PetscObjectViewFromOptions()`, `AOCreate()` 62fe2efc57SMark @*/ 63*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOViewFromOptions(AO ao, PetscObject obj, const char name[]) 64*d71ae5a4SJacob Faibussowitsch { 65fe2efc57SMark PetscFunctionBegin; 66fe2efc57SMark PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 679566063dSJacob Faibussowitsch PetscCall(PetscObjectViewFromOptions((PetscObject)ao, obj, name)); 68fe2efc57SMark PetscFunctionReturn(0); 69fe2efc57SMark } 70fe2efc57SMark 7101e608bcSBarry Smith /*@ 721447629fSBarry Smith AODestroy - Destroys an application ordering. 731447629fSBarry Smith 741447629fSBarry Smith Collective on AO 751447629fSBarry Smith 761447629fSBarry Smith Input Parameters: 771447629fSBarry Smith . ao - the application ordering context 781447629fSBarry Smith 791447629fSBarry Smith Level: beginner 801447629fSBarry Smith 81db781477SPatrick Sanan .seealso: `AOCreate()` 821447629fSBarry Smith @*/ 83*d71ae5a4SJacob Faibussowitsch PetscErrorCode AODestroy(AO *ao) 84*d71ae5a4SJacob Faibussowitsch { 851447629fSBarry Smith PetscFunctionBegin; 861447629fSBarry Smith if (!*ao) PetscFunctionReturn(0); 871447629fSBarry Smith PetscValidHeaderSpecific((*ao), AO_CLASSID, 1); 889371c9d4SSatish Balay if (--((PetscObject)(*ao))->refct > 0) { 899371c9d4SSatish Balay *ao = NULL; 909371c9d4SSatish Balay PetscFunctionReturn(0); 919371c9d4SSatish Balay } 92e04113cfSBarry Smith /* if memory was published with SAWs then destroy it */ 939566063dSJacob Faibussowitsch PetscCall(PetscObjectSAWsViewOff((PetscObject)*ao)); 949566063dSJacob Faibussowitsch PetscCall(ISDestroy(&(*ao)->isapp)); 959566063dSJacob Faibussowitsch PetscCall(ISDestroy(&(*ao)->ispetsc)); 961447629fSBarry Smith /* destroy the internal part */ 9748a46eb9SPierre Jolivet if ((*ao)->ops->destroy) PetscCall((*(*ao)->ops->destroy)(*ao)); 989566063dSJacob Faibussowitsch PetscCall(PetscHeaderDestroy(ao)); 991447629fSBarry Smith PetscFunctionReturn(0); 1001447629fSBarry Smith } 1011447629fSBarry Smith 1021447629fSBarry Smith #include <../src/vec/is/is/impls/general/general.h> 1031447629fSBarry Smith /* ---------------------------------------------------------------------*/ 1041cc6b274SLisandro Dalcin 1051cc6b274SLisandro Dalcin PETSC_INTERN PetscErrorCode ISSetUp_General(IS); 1061cc6b274SLisandro Dalcin 1071447629fSBarry Smith /*@ 1081447629fSBarry Smith AOPetscToApplicationIS - Maps an index set in the PETSc ordering to 1091447629fSBarry Smith the application-defined ordering. 1101447629fSBarry Smith 111d083f849SBarry Smith Collective on AO 1121447629fSBarry Smith 1131447629fSBarry Smith Input Parameters: 1141447629fSBarry Smith + ao - the application ordering context 1151447629fSBarry Smith - is - the index set; this is replaced with its mapped values 1161447629fSBarry Smith 1171447629fSBarry Smith Output Parameter: 1181447629fSBarry Smith . is - the mapped index set 1191447629fSBarry Smith 1201447629fSBarry Smith Level: intermediate 1211447629fSBarry Smith 1221447629fSBarry Smith Notes: 1231447629fSBarry Smith The index set cannot be of type stride or block 1241447629fSBarry Smith 1251447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 1261447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 1271447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions 1281447629fSBarry Smith etc. 1291447629fSBarry Smith 130c2e3fba1SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, 131c2e3fba1SPatrick Sanan `AOApplicationToPetscIS()`, `AOPetscToApplication()` 1321447629fSBarry Smith @*/ 133*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOPetscToApplicationIS(AO ao, IS is) 134*d71ae5a4SJacob Faibussowitsch { 1351447629fSBarry Smith PetscInt n; 1361447629fSBarry Smith PetscInt *ia; 1371447629fSBarry Smith 1381447629fSBarry Smith PetscFunctionBegin; 1391447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 1401447629fSBarry Smith PetscValidHeaderSpecific(is, IS_CLASSID, 2); 1419566063dSJacob Faibussowitsch PetscCall(ISToGeneral(is)); 1421447629fSBarry Smith /* we cheat because we know the is is general and that we can change the indices */ 1439566063dSJacob Faibussowitsch PetscCall(ISGetIndices(is, (const PetscInt **)&ia)); 1449566063dSJacob Faibussowitsch PetscCall(ISGetLocalSize(is, &n)); 145dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, petsctoapplication, n, ia); 1469566063dSJacob Faibussowitsch PetscCall(ISRestoreIndices(is, (const PetscInt **)&ia)); 1471cc6b274SLisandro Dalcin /* updated cached values (sorted, min, max, etc.)*/ 1489566063dSJacob Faibussowitsch PetscCall(ISSetUp_General(is)); 1491447629fSBarry Smith PetscFunctionReturn(0); 1501447629fSBarry Smith } 1511447629fSBarry Smith 1521447629fSBarry Smith /*@ 1531447629fSBarry Smith AOApplicationToPetscIS - Maps an index set in the application-defined 1541447629fSBarry Smith ordering to the PETSc ordering. 1551447629fSBarry Smith 156d083f849SBarry Smith Collective on AO 1571447629fSBarry Smith 1581447629fSBarry Smith Input Parameters: 1591447629fSBarry Smith + ao - the application ordering context 1601447629fSBarry Smith - is - the index set; this is replaced with its mapped values 1611447629fSBarry Smith 1621447629fSBarry Smith Output Parameter: 1631447629fSBarry Smith . is - the mapped index set 1641447629fSBarry Smith 1651447629fSBarry Smith Level: beginner 1661447629fSBarry Smith 1671447629fSBarry Smith Note: 1681447629fSBarry Smith The index set cannot be of type stride or block 1691447629fSBarry Smith 1701447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 1711447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 1721447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 1731447629fSBarry Smith 174db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOPetscToApplication()`, 175db781477SPatrick Sanan `AOPetscToApplicationIS()`, `AOApplicationToPetsc()` 1761447629fSBarry Smith @*/ 177*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOApplicationToPetscIS(AO ao, IS is) 178*d71ae5a4SJacob Faibussowitsch { 1791447629fSBarry Smith PetscInt n, *ia; 1801447629fSBarry Smith 1811447629fSBarry Smith PetscFunctionBegin; 1821447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 1831447629fSBarry Smith PetscValidHeaderSpecific(is, IS_CLASSID, 2); 1849566063dSJacob Faibussowitsch PetscCall(ISToGeneral(is)); 1851447629fSBarry Smith /* we cheat because we know the is is general and that we can change the indices */ 1869566063dSJacob Faibussowitsch PetscCall(ISGetIndices(is, (const PetscInt **)&ia)); 1879566063dSJacob Faibussowitsch PetscCall(ISGetLocalSize(is, &n)); 188dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, applicationtopetsc, n, ia); 1899566063dSJacob Faibussowitsch PetscCall(ISRestoreIndices(is, (const PetscInt **)&ia)); 1901cc6b274SLisandro Dalcin /* updated cached values (sorted, min, max, etc.)*/ 1919566063dSJacob Faibussowitsch PetscCall(ISSetUp_General(is)); 1921447629fSBarry Smith PetscFunctionReturn(0); 1931447629fSBarry Smith } 1941447629fSBarry Smith 1951447629fSBarry Smith /*@ 1961447629fSBarry Smith AOPetscToApplication - Maps a set of integers in the PETSc ordering to 1971447629fSBarry Smith the application-defined ordering. 1981447629fSBarry Smith 1991447629fSBarry Smith Collective on AO 2001447629fSBarry Smith 2011447629fSBarry Smith Input Parameters: 2021447629fSBarry Smith + ao - the application ordering context 2031447629fSBarry Smith . n - the number of integers 2041447629fSBarry Smith - ia - the integers; these are replaced with their mapped value 2051447629fSBarry Smith 2061447629fSBarry Smith Output Parameter: 2071447629fSBarry Smith . ia - the mapped integers 2081447629fSBarry Smith 2091447629fSBarry Smith Level: beginner 2101447629fSBarry Smith 2111447629fSBarry Smith Note: 2121447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 2131447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 2141447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 2151447629fSBarry Smith 2161447629fSBarry Smith Integers that are out of range are mapped to -1 2171447629fSBarry Smith 218c2e3fba1SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, 219db781477SPatrick Sanan `AOPetscToApplicationIS()`, `AOApplicationToPetsc()` 2201447629fSBarry Smith @*/ 221*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOPetscToApplication(AO ao, PetscInt n, PetscInt ia[]) 222*d71ae5a4SJacob Faibussowitsch { 2231447629fSBarry Smith PetscFunctionBegin; 2241447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 2251447629fSBarry Smith if (n) PetscValidIntPointer(ia, 3); 226dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, petsctoapplication, n, ia); 2271447629fSBarry Smith PetscFunctionReturn(0); 2281447629fSBarry Smith } 2291447629fSBarry Smith 2301447629fSBarry Smith /*@ 2311447629fSBarry Smith AOApplicationToPetsc - Maps a set of integers in the application-defined 2321447629fSBarry Smith ordering to the PETSc ordering. 2331447629fSBarry Smith 2341447629fSBarry Smith Collective on AO 2351447629fSBarry Smith 2361447629fSBarry Smith Input Parameters: 2371447629fSBarry Smith + ao - the application ordering context 2381447629fSBarry Smith . n - the number of integers 2391447629fSBarry Smith - ia - the integers; these are replaced with their mapped value 2401447629fSBarry Smith 2411447629fSBarry Smith Output Parameter: 2421447629fSBarry Smith . ia - the mapped integers 2431447629fSBarry Smith 2441447629fSBarry Smith Level: beginner 2451447629fSBarry Smith 2461447629fSBarry Smith Note: 2471447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 2481447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 2491447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 2501447629fSBarry Smith 2511447629fSBarry Smith Integers that are out of range are mapped to -1 2521447629fSBarry Smith 253db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOPetscToApplication()`, 254db781477SPatrick Sanan `AOPetscToApplicationIS()`, `AOApplicationToPetsc()` 2551447629fSBarry Smith @*/ 256*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOApplicationToPetsc(AO ao, PetscInt n, PetscInt ia[]) 257*d71ae5a4SJacob Faibussowitsch { 2581447629fSBarry Smith PetscFunctionBegin; 2591447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 2601447629fSBarry Smith if (n) PetscValidIntPointer(ia, 3); 261dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, applicationtopetsc, n, ia); 2621447629fSBarry Smith PetscFunctionReturn(0); 2631447629fSBarry Smith } 2641447629fSBarry Smith 2651447629fSBarry Smith /*@ 2661447629fSBarry Smith AOPetscToApplicationPermuteInt - Permutes an array of blocks of integers 2671447629fSBarry Smith in the PETSc ordering to the application-defined ordering. 2681447629fSBarry Smith 2691447629fSBarry Smith Collective on AO 2701447629fSBarry Smith 2711447629fSBarry Smith Input Parameters: 2721447629fSBarry Smith + ao - The application ordering context 2731447629fSBarry Smith . block - The block size 2741447629fSBarry Smith - array - The integer array 2751447629fSBarry Smith 2761447629fSBarry Smith Output Parameter: 2771447629fSBarry Smith . array - The permuted array 2781447629fSBarry Smith 2791447629fSBarry Smith Note: The length of the array should be block*N, where N is length 2801447629fSBarry Smith provided to the AOCreate*() method that created the AO. 2811447629fSBarry Smith 2821447629fSBarry Smith The permutation takes array[i_pet] --> array[i_app], where i_app is 2831447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 2841447629fSBarry Smith of 'i' in the petsc ordering. 2851447629fSBarry Smith 2861447629fSBarry Smith Level: beginner 2871447629fSBarry Smith 288db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, `AOPetscToApplicationIS()` 2891447629fSBarry Smith @*/ 290*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOPetscToApplicationPermuteInt(AO ao, PetscInt block, PetscInt array[]) 291*d71ae5a4SJacob Faibussowitsch { 2921447629fSBarry Smith PetscFunctionBegin; 2931447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 2941447629fSBarry Smith PetscValidIntPointer(array, 3); 295dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, petsctoapplicationpermuteint, block, array); 2961447629fSBarry Smith PetscFunctionReturn(0); 2971447629fSBarry Smith } 2981447629fSBarry Smith 2991447629fSBarry Smith /*@ 3001447629fSBarry Smith AOApplicationToPetscPermuteInt - Permutes an array of blocks of integers 3011447629fSBarry Smith in the application-defined ordering to the PETSc ordering. 3021447629fSBarry Smith 3031447629fSBarry Smith Collective on AO 3041447629fSBarry Smith 3051447629fSBarry Smith Input Parameters: 3061447629fSBarry Smith + ao - The application ordering context 3071447629fSBarry Smith . block - The block size 3081447629fSBarry Smith - array - The integer array 3091447629fSBarry Smith 3101447629fSBarry Smith Output Parameter: 3111447629fSBarry Smith . array - The permuted array 3121447629fSBarry Smith 3131447629fSBarry Smith Note: The length of the array should be block*N, where N is length 3141447629fSBarry Smith provided to the AOCreate*() method that created the AO. 3151447629fSBarry Smith 3161447629fSBarry Smith The permutation takes array[i_app] --> array[i_pet], where i_app is 3171447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 3181447629fSBarry Smith of 'i' in the petsc ordering. 3191447629fSBarry Smith 3201447629fSBarry Smith Level: beginner 3211447629fSBarry Smith 322db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOPetscToApplicationIS()`, `AOApplicationToPetsc()` 3231447629fSBarry Smith @*/ 324*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOApplicationToPetscPermuteInt(AO ao, PetscInt block, PetscInt array[]) 325*d71ae5a4SJacob Faibussowitsch { 3261447629fSBarry Smith PetscFunctionBegin; 3271447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 3281447629fSBarry Smith PetscValidIntPointer(array, 3); 329dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, applicationtopetscpermuteint, block, array); 3301447629fSBarry Smith PetscFunctionReturn(0); 3311447629fSBarry Smith } 3321447629fSBarry Smith 3331447629fSBarry Smith /*@ 3341447629fSBarry Smith AOPetscToApplicationPermuteReal - Permutes an array of blocks of reals 3351447629fSBarry Smith in the PETSc ordering to the application-defined ordering. 3361447629fSBarry Smith 3371447629fSBarry Smith Collective on AO 3381447629fSBarry Smith 3391447629fSBarry Smith Input Parameters: 3401447629fSBarry Smith + ao - The application ordering context 3411447629fSBarry Smith . block - The block size 3421447629fSBarry Smith - array - The integer array 3431447629fSBarry Smith 3441447629fSBarry Smith Output Parameter: 3451447629fSBarry Smith . array - The permuted array 3461447629fSBarry Smith 3471447629fSBarry Smith Note: The length of the array should be block*N, where N is length 3481447629fSBarry Smith provided to the AOCreate*() method that created the AO. 3491447629fSBarry Smith 3501447629fSBarry Smith The permutation takes array[i_pet] --> array[i_app], where i_app is 3511447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 3521447629fSBarry Smith of 'i' in the petsc ordering. 3531447629fSBarry Smith 3541447629fSBarry Smith Level: beginner 3551447629fSBarry Smith 356db781477SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, `AOPetscToApplicationIS()` 3571447629fSBarry Smith @*/ 358*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOPetscToApplicationPermuteReal(AO ao, PetscInt block, PetscReal array[]) 359*d71ae5a4SJacob Faibussowitsch { 3601447629fSBarry Smith PetscFunctionBegin; 3611447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 362064a246eSJacob Faibussowitsch PetscValidRealPointer(array, 3); 363dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, petsctoapplicationpermutereal, block, array); 3641447629fSBarry Smith PetscFunctionReturn(0); 3651447629fSBarry Smith } 3661447629fSBarry Smith 3671447629fSBarry Smith /*@ 3681447629fSBarry Smith AOApplicationToPetscPermuteReal - Permutes an array of blocks of reals 3691447629fSBarry Smith in the application-defined ordering to the PETSc ordering. 3701447629fSBarry Smith 3711447629fSBarry Smith Collective on AO 3721447629fSBarry Smith 3731447629fSBarry Smith Input Parameters: 3741447629fSBarry Smith + ao - The application ordering context 3751447629fSBarry Smith . block - The block size 3761447629fSBarry Smith - array - The integer array 3771447629fSBarry Smith 3781447629fSBarry Smith Output Parameter: 3791447629fSBarry Smith . array - The permuted array 3801447629fSBarry Smith 3811447629fSBarry Smith Note: The length of the array should be block*N, where N is length 3821447629fSBarry Smith provided to the AOCreate*() method that created the AO. 3831447629fSBarry Smith 3841447629fSBarry Smith The permutation takes array[i_app] --> array[i_pet], where i_app is 3851447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 3861447629fSBarry Smith of 'i' in the petsc ordering. 3871447629fSBarry Smith 3881447629fSBarry Smith Level: beginner 3891447629fSBarry Smith 390c2e3fba1SPatrick Sanan .seealso: `AOCreateBasic()`, `AOView()`, `AOApplicationToPetsc()`, `AOPetscToApplicationIS()` 3911447629fSBarry Smith @*/ 392*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOApplicationToPetscPermuteReal(AO ao, PetscInt block, PetscReal array[]) 393*d71ae5a4SJacob Faibussowitsch { 3941447629fSBarry Smith PetscFunctionBegin; 3951447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 396064a246eSJacob Faibussowitsch PetscValidRealPointer(array, 3); 397dbbe0bcdSBarry Smith PetscUseTypeMethod(ao, applicationtopetscpermutereal, block, array); 3981447629fSBarry Smith PetscFunctionReturn(0); 3991447629fSBarry Smith } 4001447629fSBarry Smith 40101e608bcSBarry Smith /*@ 4021447629fSBarry Smith AOSetFromOptions - Sets AO options from the options database. 4031447629fSBarry Smith 4041447629fSBarry Smith Collective on AO 4051447629fSBarry Smith 4061447629fSBarry Smith Input Parameter: 4071447629fSBarry Smith . ao - the application ordering 4081447629fSBarry Smith 4091447629fSBarry Smith Level: beginner 4101447629fSBarry Smith 411db781477SPatrick Sanan .seealso: `AOCreate()`, `AOSetType()`, `AODestroy()`, `AOPetscToApplication()`, `AOApplicationToPetsc()` 4121447629fSBarry Smith @*/ 413*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOSetFromOptions(AO ao) 414*d71ae5a4SJacob Faibussowitsch { 4151447629fSBarry Smith char type[256]; 4161447629fSBarry Smith const char *def = AOBASIC; 4171447629fSBarry Smith PetscBool flg; 4181447629fSBarry Smith 4191447629fSBarry Smith PetscFunctionBegin; 4201447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID, 1); 4211447629fSBarry Smith 422d0609cedSBarry Smith PetscObjectOptionsBegin((PetscObject)ao); 4239566063dSJacob Faibussowitsch PetscCall(PetscOptionsFList("-ao_type", "AO type", "AOSetType", AOList, def, type, 256, &flg)); 4241447629fSBarry Smith if (flg) { 4259566063dSJacob Faibussowitsch PetscCall(AOSetType(ao, type)); 4261447629fSBarry Smith } else if (!((PetscObject)ao)->type_name) { 4279566063dSJacob Faibussowitsch PetscCall(AOSetType(ao, def)); 4281447629fSBarry Smith } 429d0609cedSBarry Smith PetscOptionsEnd(); 4301447629fSBarry Smith PetscFunctionReturn(0); 4311447629fSBarry Smith } 4321447629fSBarry Smith 43301e608bcSBarry Smith /*@ 4341447629fSBarry Smith AOSetIS - Sets the IS associated with the application ordering. 4351447629fSBarry Smith 436d083f849SBarry Smith Collective 4371447629fSBarry Smith 4381447629fSBarry Smith Input Parameters: 4391447629fSBarry Smith + ao - the application ordering 4401447629fSBarry Smith . isapp - index set that defines an ordering 4411447629fSBarry Smith - ispetsc - index set that defines another ordering (may be NULL to use the 4421447629fSBarry Smith natural ordering) 4431447629fSBarry Smith 4441447629fSBarry Smith Notes: 4451447629fSBarry Smith The index sets isapp and ispetsc are used only for creation of ao. 4461447629fSBarry Smith 44701e608bcSBarry 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 44801e608bcSBarry Smith 4491447629fSBarry Smith Level: beginner 4501447629fSBarry Smith 451db781477SPatrick Sanan .seealso: `AOCreate()`, `AODestroy()`, `AOPetscToApplication()`, `AOApplicationToPetsc()` 4521447629fSBarry Smith @*/ 453*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOSetIS(AO ao, IS isapp, IS ispetsc) 454*d71ae5a4SJacob Faibussowitsch { 4551447629fSBarry Smith PetscFunctionBegin; 4561447629fSBarry Smith if (ispetsc) { 4571447629fSBarry Smith PetscInt napp, npetsc; 4589566063dSJacob Faibussowitsch PetscCall(ISGetLocalSize(isapp, &napp)); 4599566063dSJacob Faibussowitsch PetscCall(ISGetLocalSize(ispetsc, &npetsc)); 46008401ef6SPierre Jolivet PetscCheck(napp == npetsc, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "napp %" PetscInt_FMT " != npetsc %" PetscInt_FMT ". Local IS lengths must match", napp, npetsc); 4611447629fSBarry Smith } 4629566063dSJacob Faibussowitsch if (isapp) PetscCall(PetscObjectReference((PetscObject)isapp)); 4639566063dSJacob Faibussowitsch if (ispetsc) PetscCall(PetscObjectReference((PetscObject)ispetsc)); 4649566063dSJacob Faibussowitsch PetscCall(ISDestroy(&ao->isapp)); 4659566063dSJacob Faibussowitsch PetscCall(ISDestroy(&ao->ispetsc)); 4661447629fSBarry Smith ao->isapp = isapp; 4671447629fSBarry Smith ao->ispetsc = ispetsc; 4681447629fSBarry Smith PetscFunctionReturn(0); 4691447629fSBarry Smith } 4701447629fSBarry Smith 47101e608bcSBarry Smith /*@ 4721447629fSBarry Smith AOCreate - Creates an application ordering. 4731447629fSBarry Smith 474d083f849SBarry Smith Collective 4751447629fSBarry Smith 4761447629fSBarry Smith Input Parameters: 4771447629fSBarry Smith . comm - MPI communicator that is to share AO 4781447629fSBarry Smith 4791447629fSBarry Smith Output Parameter: 4801447629fSBarry Smith . ao - the new application ordering 4811447629fSBarry Smith 4821447629fSBarry Smith Options Database Key: 4831447629fSBarry Smith + -ao_type <aotype> - create ao with particular format 4841447629fSBarry Smith - -ao_view - call AOView() at the conclusion of AOCreate() 4851447629fSBarry Smith 4861447629fSBarry Smith Level: beginner 4871447629fSBarry Smith 488db781477SPatrick Sanan .seealso: `AOSetIS()`, `AODestroy()`, `AOPetscToApplication()`, `AOApplicationToPetsc()` 4891447629fSBarry Smith @*/ 490*d71ae5a4SJacob Faibussowitsch PetscErrorCode AOCreate(MPI_Comm comm, AO *ao) 491*d71ae5a4SJacob Faibussowitsch { 4921447629fSBarry Smith AO aonew; 4931447629fSBarry Smith 4941447629fSBarry Smith PetscFunctionBegin; 4951447629fSBarry Smith PetscValidPointer(ao, 2); 4961447629fSBarry Smith *ao = NULL; 4979566063dSJacob Faibussowitsch PetscCall(AOInitializePackage()); 4981447629fSBarry Smith 4999566063dSJacob Faibussowitsch PetscCall(PetscHeaderCreate(aonew, AO_CLASSID, "AO", "Application Ordering", "AO", comm, AODestroy, AOView)); 5001447629fSBarry Smith *ao = aonew; 5011447629fSBarry Smith PetscFunctionReturn(0); 5021447629fSBarry Smith } 503