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 #undef __FUNCT__ 121447629fSBarry Smith #define __FUNCT__ "AOView" 131447629fSBarry Smith /*@C 141447629fSBarry Smith AOView - Displays an application ordering. 151447629fSBarry Smith 161447629fSBarry Smith Collective on AO and PetscViewer 171447629fSBarry Smith 181447629fSBarry Smith Input Parameters: 191447629fSBarry Smith + ao - the application ordering context 201447629fSBarry Smith - viewer - viewer used for display 211447629fSBarry Smith 221447629fSBarry Smith Level: intermediate 231447629fSBarry Smith 241447629fSBarry Smith Options Database Key: 251447629fSBarry Smith . -ao_view - calls AOView() at end of AOCreate() 261447629fSBarry Smith 271447629fSBarry Smith Note: 281447629fSBarry Smith The available visualization contexts include 291447629fSBarry Smith + PETSC_VIEWER_STDOUT_SELF - standard output (default) 301447629fSBarry Smith - PETSC_VIEWER_STDOUT_WORLD - synchronized standard 311447629fSBarry Smith output where only the first processor opens 321447629fSBarry Smith the file. All other processors send their 331447629fSBarry Smith data to the first processor to print. 341447629fSBarry Smith 351447629fSBarry Smith The user can open an alternative visualization context with 361447629fSBarry Smith PetscViewerASCIIOpen() - output to a specified file. 371447629fSBarry Smith 381447629fSBarry Smith .keywords: application ordering 391447629fSBarry Smith 401447629fSBarry Smith .seealso: PetscViewerASCIIOpen() 411447629fSBarry Smith @*/ 421447629fSBarry Smith PetscErrorCode AOView(AO ao,PetscViewer viewer) 431447629fSBarry Smith { 441447629fSBarry Smith PetscErrorCode ierr; 451447629fSBarry Smith 461447629fSBarry Smith PetscFunctionBegin; 471447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 481447629fSBarry Smith if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ao)); 491447629fSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); 501447629fSBarry Smith ierr = (*ao->ops->view)(ao,viewer);CHKERRQ(ierr); 511447629fSBarry Smith PetscFunctionReturn(0); 521447629fSBarry Smith } 531447629fSBarry Smith 541447629fSBarry Smith #undef __FUNCT__ 551447629fSBarry Smith #define __FUNCT__ "AODestroy" 561447629fSBarry Smith /*@C 571447629fSBarry Smith AODestroy - Destroys an application ordering. 581447629fSBarry Smith 591447629fSBarry Smith Collective on AO 601447629fSBarry Smith 611447629fSBarry Smith Input Parameters: 621447629fSBarry Smith . ao - the application ordering context 631447629fSBarry Smith 641447629fSBarry Smith Level: beginner 651447629fSBarry Smith 661447629fSBarry Smith .keywords: destroy, application ordering 671447629fSBarry Smith 681447629fSBarry Smith .seealso: AOCreate() 691447629fSBarry Smith @*/ 701447629fSBarry Smith PetscErrorCode AODestroy(AO *ao) 711447629fSBarry Smith { 721447629fSBarry Smith PetscErrorCode ierr; 731447629fSBarry Smith 741447629fSBarry Smith PetscFunctionBegin; 751447629fSBarry Smith if (!*ao) PetscFunctionReturn(0); 761447629fSBarry Smith PetscValidHeaderSpecific((*ao),AO_CLASSID,1); 771447629fSBarry Smith if (--((PetscObject)(*ao))->refct > 0) {*ao = 0; PetscFunctionReturn(0);} 78*e04113cfSBarry Smith /* if memory was published with SAWs then destroy it */ 79*e04113cfSBarry Smith ierr = PetscObjectSAWsViewOff((PetscObject)*ao);CHKERRQ(ierr); 801447629fSBarry Smith /* destroy the internal part */ 811447629fSBarry Smith if ((*ao)->ops->destroy) { 821447629fSBarry Smith ierr = (*(*ao)->ops->destroy)(*ao);CHKERRQ(ierr); 831447629fSBarry Smith } 841447629fSBarry Smith ierr = PetscHeaderDestroy(ao);CHKERRQ(ierr); 851447629fSBarry Smith PetscFunctionReturn(0); 861447629fSBarry Smith } 871447629fSBarry Smith 881447629fSBarry Smith 891447629fSBarry Smith #include <../src/vec/is/is/impls/general/general.h> 901447629fSBarry Smith /* ---------------------------------------------------------------------*/ 911447629fSBarry Smith #undef __FUNCT__ 921447629fSBarry Smith #define __FUNCT__ "AOPetscToApplicationIS" 931447629fSBarry Smith /*@ 941447629fSBarry Smith AOPetscToApplicationIS - Maps an index set in the PETSc ordering to 951447629fSBarry Smith the application-defined ordering. 961447629fSBarry Smith 971447629fSBarry Smith Collective on AO and IS 981447629fSBarry Smith 991447629fSBarry Smith Input Parameters: 1001447629fSBarry Smith + ao - the application ordering context 1011447629fSBarry Smith - is - the index set; this is replaced with its mapped values 1021447629fSBarry Smith 1031447629fSBarry Smith Output Parameter: 1041447629fSBarry Smith . is - the mapped index set 1051447629fSBarry Smith 1061447629fSBarry Smith Level: intermediate 1071447629fSBarry Smith 1081447629fSBarry Smith Notes: 1091447629fSBarry Smith The index set cannot be of type stride or block 1101447629fSBarry Smith 1111447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 1121447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 1131447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions 1141447629fSBarry Smith etc. 1151447629fSBarry Smith 1161447629fSBarry Smith .keywords: application ordering, mapping 1171447629fSBarry Smith 1181447629fSBarry Smith .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), 1191447629fSBarry Smith AOApplicationToPetscIS(),AOPetscToApplication() 1201447629fSBarry Smith @*/ 1211447629fSBarry Smith PetscErrorCode AOPetscToApplicationIS(AO ao,IS is) 1221447629fSBarry Smith { 1231447629fSBarry Smith PetscErrorCode ierr; 1241447629fSBarry Smith PetscInt n; 1251447629fSBarry Smith PetscInt *ia; 1261447629fSBarry Smith 1271447629fSBarry Smith PetscFunctionBegin; 1281447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 1291447629fSBarry Smith PetscValidHeaderSpecific(is,IS_CLASSID,2); 1301447629fSBarry Smith ierr = ISToGeneral(is);CHKERRQ(ierr); 1311447629fSBarry Smith /* we cheat because we know the is is general and that we can change the indices */ 1321447629fSBarry Smith ierr = ISGetIndices(is,(const PetscInt**)&ia);CHKERRQ(ierr); 1331447629fSBarry Smith ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr); 1341447629fSBarry Smith ierr = (*ao->ops->petsctoapplication)(ao,n,ia);CHKERRQ(ierr); 1351447629fSBarry Smith ierr = ISRestoreIndices(is,(const PetscInt**)&ia);CHKERRQ(ierr); 1361447629fSBarry Smith PetscFunctionReturn(0); 1371447629fSBarry Smith } 1381447629fSBarry Smith 1391447629fSBarry Smith #undef __FUNCT__ 1401447629fSBarry Smith #define __FUNCT__ "AOApplicationToPetscIS" 1411447629fSBarry Smith /*@ 1421447629fSBarry Smith AOApplicationToPetscIS - Maps an index set in the application-defined 1431447629fSBarry Smith ordering to the PETSc ordering. 1441447629fSBarry Smith 1451447629fSBarry Smith Collective on AO and IS 1461447629fSBarry Smith 1471447629fSBarry Smith Input Parameters: 1481447629fSBarry Smith + ao - the application ordering context 1491447629fSBarry Smith - is - the index set; this is replaced with its mapped values 1501447629fSBarry Smith 1511447629fSBarry Smith Output Parameter: 1521447629fSBarry Smith . is - the mapped index set 1531447629fSBarry Smith 1541447629fSBarry Smith Level: beginner 1551447629fSBarry Smith 1561447629fSBarry Smith Note: 1571447629fSBarry Smith The index set cannot be of type stride or block 1581447629fSBarry Smith 1591447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 1601447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 1611447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 1621447629fSBarry Smith 1631447629fSBarry Smith .keywords: application ordering, mapping 1641447629fSBarry Smith 1651447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(), 1661447629fSBarry Smith AOPetscToApplicationIS(), AOApplicationToPetsc() 1671447629fSBarry Smith @*/ 1681447629fSBarry Smith PetscErrorCode AOApplicationToPetscIS(AO ao,IS is) 1691447629fSBarry Smith { 1701447629fSBarry Smith PetscErrorCode ierr; 1711447629fSBarry Smith PetscInt n,*ia; 1721447629fSBarry Smith 1731447629fSBarry Smith PetscFunctionBegin; 1741447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 1751447629fSBarry Smith PetscValidHeaderSpecific(is,IS_CLASSID,2); 1761447629fSBarry Smith ierr = ISToGeneral(is);CHKERRQ(ierr); 1771447629fSBarry Smith /* we cheat because we know the is is general and that we can change the indices */ 1781447629fSBarry Smith ierr = ISGetIndices(is,(const PetscInt**)&ia);CHKERRQ(ierr); 1791447629fSBarry Smith ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr); 1801447629fSBarry Smith ierr = (*ao->ops->applicationtopetsc)(ao,n,ia);CHKERRQ(ierr); 1811447629fSBarry Smith ierr = ISRestoreIndices(is,(const PetscInt**)&ia);CHKERRQ(ierr); 1821447629fSBarry Smith PetscFunctionReturn(0); 1831447629fSBarry Smith } 1841447629fSBarry Smith 1851447629fSBarry Smith #undef __FUNCT__ 1861447629fSBarry Smith #define __FUNCT__ "AOPetscToApplication" 1871447629fSBarry Smith /*@ 1881447629fSBarry Smith AOPetscToApplication - Maps a set of integers in the PETSc ordering to 1891447629fSBarry Smith the application-defined ordering. 1901447629fSBarry Smith 1911447629fSBarry Smith Collective on AO 1921447629fSBarry Smith 1931447629fSBarry Smith Input Parameters: 1941447629fSBarry Smith + ao - the application ordering context 1951447629fSBarry Smith . n - the number of integers 1961447629fSBarry Smith - ia - the integers; these are replaced with their mapped value 1971447629fSBarry Smith 1981447629fSBarry Smith Output Parameter: 1991447629fSBarry Smith . ia - the mapped integers 2001447629fSBarry Smith 2011447629fSBarry Smith Level: beginner 2021447629fSBarry Smith 2031447629fSBarry Smith Note: 2041447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 2051447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 2061447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 2071447629fSBarry Smith 2081447629fSBarry Smith Integers that are out of range are mapped to -1 2091447629fSBarry Smith 2101447629fSBarry Smith .keywords: application ordering, mapping 2111447629fSBarry Smith 2121447629fSBarry Smith .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), 2131447629fSBarry Smith AOPetscToApplicationIS(), AOApplicationToPetsc() 2141447629fSBarry Smith @*/ 2151447629fSBarry Smith PetscErrorCode AOPetscToApplication(AO ao,PetscInt n,PetscInt ia[]) 2161447629fSBarry Smith { 2171447629fSBarry Smith PetscErrorCode ierr; 2181447629fSBarry Smith 2191447629fSBarry Smith PetscFunctionBegin; 2201447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 2211447629fSBarry Smith if (n) PetscValidIntPointer(ia,3); 2221447629fSBarry Smith ierr = (*ao->ops->petsctoapplication)(ao,n,ia);CHKERRQ(ierr); 2231447629fSBarry Smith PetscFunctionReturn(0); 2241447629fSBarry Smith } 2251447629fSBarry Smith 2261447629fSBarry Smith #undef __FUNCT__ 2271447629fSBarry Smith #define __FUNCT__ "AOApplicationToPetsc" 2281447629fSBarry Smith /*@ 2291447629fSBarry Smith AOApplicationToPetsc - Maps a set of integers in the application-defined 2301447629fSBarry Smith ordering to the PETSc ordering. 2311447629fSBarry Smith 2321447629fSBarry Smith Collective on AO 2331447629fSBarry Smith 2341447629fSBarry Smith Input Parameters: 2351447629fSBarry Smith + ao - the application ordering context 2361447629fSBarry Smith . n - the number of integers 2371447629fSBarry Smith - ia - the integers; these are replaced with their mapped value 2381447629fSBarry Smith 2391447629fSBarry Smith Output Parameter: 2401447629fSBarry Smith . ia - the mapped integers 2411447629fSBarry Smith 2421447629fSBarry Smith Level: beginner 2431447629fSBarry Smith 2441447629fSBarry Smith Note: 2451447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 2461447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 2471447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 2481447629fSBarry Smith 2491447629fSBarry Smith Integers that are out of range are mapped to -1 2501447629fSBarry Smith 2511447629fSBarry Smith .keywords: application ordering, mapping 2521447629fSBarry Smith 2531447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(), 2541447629fSBarry Smith AOPetscToApplicationIS(), AOApplicationToPetsc() 2551447629fSBarry Smith @*/ 2561447629fSBarry Smith PetscErrorCode AOApplicationToPetsc(AO ao,PetscInt n,PetscInt ia[]) 2571447629fSBarry Smith { 2581447629fSBarry Smith PetscErrorCode ierr; 2591447629fSBarry Smith 2601447629fSBarry Smith PetscFunctionBegin; 2611447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 2621447629fSBarry Smith if (n) PetscValidIntPointer(ia,3); 2631447629fSBarry Smith ierr = (*ao->ops->applicationtopetsc)(ao,n,ia);CHKERRQ(ierr); 2641447629fSBarry Smith PetscFunctionReturn(0); 2651447629fSBarry Smith } 2661447629fSBarry Smith 2671447629fSBarry Smith #undef __FUNCT__ 2681447629fSBarry Smith #define __FUNCT__ "AOPetscToApplicationPermuteInt" 2691447629fSBarry Smith /*@ 2701447629fSBarry Smith AOPetscToApplicationPermuteInt - Permutes an array of blocks of integers 2711447629fSBarry Smith in the PETSc ordering to the application-defined ordering. 2721447629fSBarry Smith 2731447629fSBarry Smith Collective on AO 2741447629fSBarry Smith 2751447629fSBarry Smith Input Parameters: 2761447629fSBarry Smith + ao - The application ordering context 2771447629fSBarry Smith . block - The block size 2781447629fSBarry Smith - array - The integer array 2791447629fSBarry Smith 2801447629fSBarry Smith Output Parameter: 2811447629fSBarry Smith . array - The permuted array 2821447629fSBarry Smith 2831447629fSBarry Smith Note: The length of the array should be block*N, where N is length 2841447629fSBarry Smith provided to the AOCreate*() method that created the AO. 2851447629fSBarry Smith 2861447629fSBarry Smith The permutation takes array[i_pet] --> array[i_app], where i_app is 2871447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 2881447629fSBarry Smith of 'i' in the petsc ordering. 2891447629fSBarry Smith 2901447629fSBarry Smith Level: beginner 2911447629fSBarry Smith 2921447629fSBarry Smith .keywords: application ordering, mapping 2931447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS() 2941447629fSBarry Smith @*/ 2951447629fSBarry Smith PetscErrorCode AOPetscToApplicationPermuteInt(AO ao, PetscInt block, PetscInt array[]) 2961447629fSBarry Smith { 2971447629fSBarry Smith PetscErrorCode ierr; 2981447629fSBarry Smith 2991447629fSBarry Smith PetscFunctionBegin; 3001447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 3011447629fSBarry Smith PetscValidIntPointer(array,3); 3021447629fSBarry Smith ierr = (*ao->ops->petsctoapplicationpermuteint)(ao, block, array);CHKERRQ(ierr); 3031447629fSBarry Smith PetscFunctionReturn(0); 3041447629fSBarry Smith } 3051447629fSBarry Smith 3061447629fSBarry Smith #undef __FUNCT__ 3071447629fSBarry Smith #define __FUNCT__ "AOApplicationToPetscPermuteInt" 3081447629fSBarry Smith /*@ 3091447629fSBarry Smith AOApplicationToPetscPermuteInt - Permutes an array of blocks of integers 3101447629fSBarry Smith in the application-defined ordering to the PETSc ordering. 3111447629fSBarry Smith 3121447629fSBarry Smith Collective on AO 3131447629fSBarry Smith 3141447629fSBarry Smith Input Parameters: 3151447629fSBarry Smith + ao - The application ordering context 3161447629fSBarry Smith . block - The block size 3171447629fSBarry Smith - array - The integer array 3181447629fSBarry Smith 3191447629fSBarry Smith Output Parameter: 3201447629fSBarry Smith . array - The permuted array 3211447629fSBarry Smith 3221447629fSBarry Smith Note: The length of the array should be block*N, where N is length 3231447629fSBarry Smith provided to the AOCreate*() method that created the AO. 3241447629fSBarry Smith 3251447629fSBarry Smith The permutation takes array[i_app] --> array[i_pet], where i_app is 3261447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 3271447629fSBarry Smith of 'i' in the petsc ordering. 3281447629fSBarry Smith 3291447629fSBarry Smith Level: beginner 3301447629fSBarry Smith 3311447629fSBarry Smith .keywords: application ordering, mapping 3321447629fSBarry Smith 3331447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOPetscToApplicationIS(), AOApplicationToPetsc() 3341447629fSBarry Smith @*/ 3351447629fSBarry Smith PetscErrorCode AOApplicationToPetscPermuteInt(AO ao, PetscInt block, PetscInt array[]) 3361447629fSBarry Smith { 3371447629fSBarry Smith PetscErrorCode ierr; 3381447629fSBarry Smith 3391447629fSBarry Smith PetscFunctionBegin; 3401447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 3411447629fSBarry Smith PetscValidIntPointer(array,3); 3421447629fSBarry Smith ierr = (*ao->ops->applicationtopetscpermuteint)(ao, block, array);CHKERRQ(ierr); 3431447629fSBarry Smith PetscFunctionReturn(0); 3441447629fSBarry Smith } 3451447629fSBarry Smith 3461447629fSBarry Smith #undef __FUNCT__ 3471447629fSBarry Smith #define __FUNCT__ "AOPetscToApplicationPermuteReal" 3481447629fSBarry Smith /*@ 3491447629fSBarry Smith AOPetscToApplicationPermuteReal - Permutes an array of blocks of reals 3501447629fSBarry Smith in the PETSc ordering to the application-defined ordering. 3511447629fSBarry Smith 3521447629fSBarry Smith Collective on AO 3531447629fSBarry Smith 3541447629fSBarry Smith Input Parameters: 3551447629fSBarry Smith + ao - The application ordering context 3561447629fSBarry Smith . block - The block size 3571447629fSBarry Smith - array - The integer array 3581447629fSBarry Smith 3591447629fSBarry Smith Output Parameter: 3601447629fSBarry Smith . array - The permuted array 3611447629fSBarry Smith 3621447629fSBarry Smith Note: The length of the array should be block*N, where N is length 3631447629fSBarry Smith provided to the AOCreate*() method that created the AO. 3641447629fSBarry Smith 3651447629fSBarry Smith The permutation takes array[i_pet] --> array[i_app], where i_app is 3661447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 3671447629fSBarry Smith of 'i' in the petsc ordering. 3681447629fSBarry Smith 3691447629fSBarry Smith Level: beginner 3701447629fSBarry Smith 3711447629fSBarry Smith .keywords: application ordering, mapping 3721447629fSBarry Smith 3731447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS() 3741447629fSBarry Smith @*/ 3751447629fSBarry Smith PetscErrorCode AOPetscToApplicationPermuteReal(AO ao, PetscInt block, PetscReal array[]) 3761447629fSBarry Smith { 3771447629fSBarry Smith PetscErrorCode ierr; 3781447629fSBarry Smith 3791447629fSBarry Smith PetscFunctionBegin; 3801447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 3811447629fSBarry Smith PetscValidIntPointer(array,3); 3821447629fSBarry Smith ierr = (*ao->ops->petsctoapplicationpermutereal)(ao, block, array);CHKERRQ(ierr); 3831447629fSBarry Smith PetscFunctionReturn(0); 3841447629fSBarry Smith } 3851447629fSBarry Smith 3861447629fSBarry Smith #undef __FUNCT__ 3871447629fSBarry Smith #define __FUNCT__ "AOApplicationToPetscPermuteReal" 3881447629fSBarry Smith /*@ 3891447629fSBarry Smith AOApplicationToPetscPermuteReal - Permutes an array of blocks of reals 3901447629fSBarry Smith in the application-defined ordering to the PETSc ordering. 3911447629fSBarry Smith 3921447629fSBarry Smith Collective on AO 3931447629fSBarry Smith 3941447629fSBarry Smith Input Parameters: 3951447629fSBarry Smith + ao - The application ordering context 3961447629fSBarry Smith . block - The block size 3971447629fSBarry Smith - array - The integer array 3981447629fSBarry Smith 3991447629fSBarry Smith Output Parameter: 4001447629fSBarry Smith . array - The permuted array 4011447629fSBarry Smith 4021447629fSBarry Smith Note: The length of the array should be block*N, where N is length 4031447629fSBarry Smith provided to the AOCreate*() method that created the AO. 4041447629fSBarry Smith 4051447629fSBarry Smith The permutation takes array[i_app] --> array[i_pet], where i_app is 4061447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 4071447629fSBarry Smith of 'i' in the petsc ordering. 4081447629fSBarry Smith 4091447629fSBarry Smith Level: beginner 4101447629fSBarry Smith 4111447629fSBarry Smith .keywords: application ordering, mapping 4121447629fSBarry Smith 4131447629fSBarry Smith .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), AOPetscToApplicationIS() 4141447629fSBarry Smith @*/ 4151447629fSBarry Smith PetscErrorCode AOApplicationToPetscPermuteReal(AO ao, PetscInt block, PetscReal array[]) 4161447629fSBarry Smith { 4171447629fSBarry Smith PetscErrorCode ierr; 4181447629fSBarry Smith 4191447629fSBarry Smith PetscFunctionBegin; 4201447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 4211447629fSBarry Smith PetscValidIntPointer(array,3); 4221447629fSBarry Smith ierr = (*ao->ops->applicationtopetscpermutereal)(ao, block, array);CHKERRQ(ierr); 4231447629fSBarry Smith PetscFunctionReturn(0); 4241447629fSBarry Smith } 4251447629fSBarry Smith 4261447629fSBarry Smith #undef __FUNCT__ 4271447629fSBarry Smith #define __FUNCT__ "AOSetFromOptions" 4281447629fSBarry Smith /*@C 4291447629fSBarry Smith AOSetFromOptions - Sets AO options from the options database. 4301447629fSBarry Smith 4311447629fSBarry Smith Collective on AO 4321447629fSBarry Smith 4331447629fSBarry Smith Input Parameter: 4341447629fSBarry Smith . ao - the application ordering 4351447629fSBarry Smith 4361447629fSBarry Smith Level: beginner 4371447629fSBarry Smith 4381447629fSBarry Smith .keywords: AO, options, database 4391447629fSBarry Smith 4401447629fSBarry Smith .seealso: AOCreate(), AOSetType(), AODestroy(), AOPetscToApplication(), AOApplicationToPetsc() 4411447629fSBarry Smith @*/ 4421447629fSBarry Smith PetscErrorCode AOSetFromOptions(AO ao) 4431447629fSBarry Smith { 4441447629fSBarry Smith PetscErrorCode ierr; 4451447629fSBarry Smith char type[256]; 4461447629fSBarry Smith const char *def=AOBASIC; 4471447629fSBarry Smith PetscBool flg; 4481447629fSBarry Smith 4491447629fSBarry Smith PetscFunctionBegin; 4501447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 4511447629fSBarry Smith 4521447629fSBarry Smith ierr = PetscObjectOptionsBegin((PetscObject)ao);CHKERRQ(ierr); 4531447629fSBarry Smith ierr = PetscOptionsList("-ao_type","AO type","AOSetType",AOList,def,type,256,&flg);CHKERRQ(ierr); 4541447629fSBarry Smith if (flg) { 4551447629fSBarry Smith ierr = AOSetType(ao,type);CHKERRQ(ierr); 4561447629fSBarry Smith } else if (!((PetscObject)ao)->type_name) { 4571447629fSBarry Smith ierr = AOSetType(ao,def);CHKERRQ(ierr); 4581447629fSBarry Smith } 4591447629fSBarry Smith 4601447629fSBarry Smith /* not used here, but called so will go into help messaage */ 4611447629fSBarry Smith ierr = PetscOptionsName("-ao_view","Print detailed information on AO used","AOView",0);CHKERRQ(ierr); 4621447629fSBarry Smith 4631447629fSBarry Smith ierr = PetscOptionsEnd();CHKERRQ(ierr); 4641447629fSBarry Smith PetscFunctionReturn(0); 4651447629fSBarry Smith } 4661447629fSBarry Smith 4671447629fSBarry Smith #undef __FUNCT__ 4681447629fSBarry Smith #define __FUNCT__ "AOSetIS" 4691447629fSBarry Smith /*@C 4701447629fSBarry Smith AOSetIS - Sets the IS associated with the application ordering. 4711447629fSBarry Smith 4721447629fSBarry Smith Collective on MPI_Comm 4731447629fSBarry Smith 4741447629fSBarry Smith Input Parameters: 4751447629fSBarry Smith + ao - the application ordering 4761447629fSBarry Smith . isapp - index set that defines an ordering 4771447629fSBarry Smith - ispetsc - index set that defines another ordering (may be NULL to use the 4781447629fSBarry Smith natural ordering) 4791447629fSBarry Smith 4801447629fSBarry Smith Notes: 4811447629fSBarry Smith The index sets isapp and ispetsc are used only for creation of ao. 4821447629fSBarry Smith 4831447629fSBarry Smith Level: beginner 4841447629fSBarry Smith 4851447629fSBarry Smith .keywords: AO, create 4861447629fSBarry Smith 4871447629fSBarry Smith .seealso: AOCreate(), AODestroy(), AOPetscToApplication(), AOApplicationToPetsc() 4881447629fSBarry Smith @*/ 4891447629fSBarry Smith PetscErrorCode AOSetIS(AO ao,IS isapp,IS ispetsc) 4901447629fSBarry Smith { 4911447629fSBarry Smith PetscErrorCode ierr; 4921447629fSBarry Smith 4931447629fSBarry Smith PetscFunctionBegin; 4941447629fSBarry Smith if (ispetsc) { 4951447629fSBarry Smith PetscInt napp,npetsc; 4961447629fSBarry Smith ierr = ISGetLocalSize(isapp,&napp);CHKERRQ(ierr); 4971447629fSBarry Smith ierr = ISGetLocalSize(ispetsc,&npetsc);CHKERRQ(ierr); 4981447629fSBarry Smith if (napp != npetsc) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"napp %D != npetsc %d. Local IS lengths must match",napp,npetsc); 4991447629fSBarry Smith } 5001447629fSBarry Smith ao->isapp = isapp; 5011447629fSBarry Smith ao->ispetsc = ispetsc; 5021447629fSBarry Smith PetscFunctionReturn(0); 5031447629fSBarry Smith } 5041447629fSBarry Smith 5051447629fSBarry Smith #undef __FUNCT__ 5061447629fSBarry Smith #define __FUNCT__ "AOCreate" 5071447629fSBarry Smith /*@C 5081447629fSBarry Smith AOCreate - Creates an application ordering. 5091447629fSBarry Smith 5101447629fSBarry Smith Collective on MPI_Comm 5111447629fSBarry Smith 5121447629fSBarry Smith Input Parameters: 5131447629fSBarry Smith . comm - MPI communicator that is to share AO 5141447629fSBarry Smith 5151447629fSBarry Smith Output Parameter: 5161447629fSBarry Smith . ao - the new application ordering 5171447629fSBarry Smith 5181447629fSBarry Smith Options Database Key: 5191447629fSBarry Smith + -ao_type <aotype> - create ao with particular format 5201447629fSBarry Smith - -ao_view - call AOView() at the conclusion of AOCreate() 5211447629fSBarry Smith 5221447629fSBarry Smith Level: beginner 5231447629fSBarry Smith 5241447629fSBarry Smith .keywords: AO, create 5251447629fSBarry Smith 5261447629fSBarry Smith .seealso: AOSetIS(), AODestroy(), AOPetscToApplication(), AOApplicationToPetsc() 5271447629fSBarry Smith @*/ 5281447629fSBarry Smith PetscErrorCode AOCreate(MPI_Comm comm,AO *ao) 5291447629fSBarry Smith { 5301447629fSBarry Smith PetscErrorCode ierr; 5311447629fSBarry Smith AO aonew; 5321447629fSBarry Smith PetscBool opt; 5331447629fSBarry Smith 5341447629fSBarry Smith PetscFunctionBegin; 5351447629fSBarry Smith PetscValidPointer(ao,2); 5361447629fSBarry Smith *ao = NULL; 5371447629fSBarry Smith #if !defined(PETSC_USE_DYNAMIC_LIBRARIES) 538607a6623SBarry Smith ierr = AOInitializePackage();CHKERRQ(ierr); 5391447629fSBarry Smith #endif 5401447629fSBarry Smith 5411447629fSBarry Smith ierr = PetscHeaderCreate(aonew,_p_AO,struct _AOOps,AO_CLASSID,"AO","Application Ordering","AO",comm,AODestroy,AOView);CHKERRQ(ierr); 5421447629fSBarry Smith ierr = PetscMemzero(aonew->ops, sizeof(struct _AOOps));CHKERRQ(ierr); 5431447629fSBarry Smith *ao = aonew; 5441447629fSBarry Smith 5451447629fSBarry Smith opt = PETSC_FALSE; 5461447629fSBarry Smith ierr = PetscOptionsGetBool(NULL, "-ao_view", &opt,NULL);CHKERRQ(ierr); 5471447629fSBarry Smith if (opt) { 5481447629fSBarry Smith ierr = AOView(aonew, PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); 5491447629fSBarry Smith } 5501447629fSBarry Smith PetscFunctionReturn(0); 5511447629fSBarry Smith } 552