1*1447629fSBarry Smith 2*1447629fSBarry Smith /* 3*1447629fSBarry Smith Defines the abstract operations on AO (application orderings) 4*1447629fSBarry Smith */ 5*1447629fSBarry Smith #include <../src/vec/is/ao/aoimpl.h> /*I "petscao.h" I*/ 6*1447629fSBarry Smith 7*1447629fSBarry Smith /* Logging support */ 8*1447629fSBarry Smith PetscClassId AO_CLASSID; 9*1447629fSBarry Smith PetscLogEvent AO_PetscToApplication, AO_ApplicationToPetsc; 10*1447629fSBarry Smith 11*1447629fSBarry Smith #undef __FUNCT__ 12*1447629fSBarry Smith #define __FUNCT__ "AOView" 13*1447629fSBarry Smith /*@C 14*1447629fSBarry Smith AOView - Displays an application ordering. 15*1447629fSBarry Smith 16*1447629fSBarry Smith Collective on AO and PetscViewer 17*1447629fSBarry Smith 18*1447629fSBarry Smith Input Parameters: 19*1447629fSBarry Smith + ao - the application ordering context 20*1447629fSBarry Smith - viewer - viewer used for display 21*1447629fSBarry Smith 22*1447629fSBarry Smith Level: intermediate 23*1447629fSBarry Smith 24*1447629fSBarry Smith Options Database Key: 25*1447629fSBarry Smith . -ao_view - calls AOView() at end of AOCreate() 26*1447629fSBarry Smith 27*1447629fSBarry Smith Note: 28*1447629fSBarry Smith The available visualization contexts include 29*1447629fSBarry Smith + PETSC_VIEWER_STDOUT_SELF - standard output (default) 30*1447629fSBarry Smith - PETSC_VIEWER_STDOUT_WORLD - synchronized standard 31*1447629fSBarry Smith output where only the first processor opens 32*1447629fSBarry Smith the file. All other processors send their 33*1447629fSBarry Smith data to the first processor to print. 34*1447629fSBarry Smith 35*1447629fSBarry Smith The user can open an alternative visualization context with 36*1447629fSBarry Smith PetscViewerASCIIOpen() - output to a specified file. 37*1447629fSBarry Smith 38*1447629fSBarry Smith .keywords: application ordering 39*1447629fSBarry Smith 40*1447629fSBarry Smith .seealso: PetscViewerASCIIOpen() 41*1447629fSBarry Smith @*/ 42*1447629fSBarry Smith PetscErrorCode AOView(AO ao,PetscViewer viewer) 43*1447629fSBarry Smith { 44*1447629fSBarry Smith PetscErrorCode ierr; 45*1447629fSBarry Smith 46*1447629fSBarry Smith PetscFunctionBegin; 47*1447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 48*1447629fSBarry Smith if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ao)); 49*1447629fSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); 50*1447629fSBarry Smith ierr = (*ao->ops->view)(ao,viewer);CHKERRQ(ierr); 51*1447629fSBarry Smith PetscFunctionReturn(0); 52*1447629fSBarry Smith } 53*1447629fSBarry Smith 54*1447629fSBarry Smith #undef __FUNCT__ 55*1447629fSBarry Smith #define __FUNCT__ "AODestroy" 56*1447629fSBarry Smith /*@C 57*1447629fSBarry Smith AODestroy - Destroys an application ordering. 58*1447629fSBarry Smith 59*1447629fSBarry Smith Collective on AO 60*1447629fSBarry Smith 61*1447629fSBarry Smith Input Parameters: 62*1447629fSBarry Smith . ao - the application ordering context 63*1447629fSBarry Smith 64*1447629fSBarry Smith Level: beginner 65*1447629fSBarry Smith 66*1447629fSBarry Smith .keywords: destroy, application ordering 67*1447629fSBarry Smith 68*1447629fSBarry Smith .seealso: AOCreate() 69*1447629fSBarry Smith @*/ 70*1447629fSBarry Smith PetscErrorCode AODestroy(AO *ao) 71*1447629fSBarry Smith { 72*1447629fSBarry Smith PetscErrorCode ierr; 73*1447629fSBarry Smith 74*1447629fSBarry Smith PetscFunctionBegin; 75*1447629fSBarry Smith if (!*ao) PetscFunctionReturn(0); 76*1447629fSBarry Smith PetscValidHeaderSpecific((*ao),AO_CLASSID,1); 77*1447629fSBarry Smith if (--((PetscObject)(*ao))->refct > 0) {*ao = 0; PetscFunctionReturn(0);} 78*1447629fSBarry Smith /* if memory was published with AMS then destroy it */ 79*1447629fSBarry Smith ierr = PetscObjectDepublish((*ao));CHKERRQ(ierr); 80*1447629fSBarry Smith /* destroy the internal part */ 81*1447629fSBarry Smith if ((*ao)->ops->destroy) { 82*1447629fSBarry Smith ierr = (*(*ao)->ops->destroy)(*ao);CHKERRQ(ierr); 83*1447629fSBarry Smith } 84*1447629fSBarry Smith ierr = PetscHeaderDestroy(ao);CHKERRQ(ierr); 85*1447629fSBarry Smith PetscFunctionReturn(0); 86*1447629fSBarry Smith } 87*1447629fSBarry Smith 88*1447629fSBarry Smith 89*1447629fSBarry Smith #include <../src/vec/is/is/impls/general/general.h> 90*1447629fSBarry Smith /* ---------------------------------------------------------------------*/ 91*1447629fSBarry Smith #undef __FUNCT__ 92*1447629fSBarry Smith #define __FUNCT__ "AOPetscToApplicationIS" 93*1447629fSBarry Smith /*@ 94*1447629fSBarry Smith AOPetscToApplicationIS - Maps an index set in the PETSc ordering to 95*1447629fSBarry Smith the application-defined ordering. 96*1447629fSBarry Smith 97*1447629fSBarry Smith Collective on AO and IS 98*1447629fSBarry Smith 99*1447629fSBarry Smith Input Parameters: 100*1447629fSBarry Smith + ao - the application ordering context 101*1447629fSBarry Smith - is - the index set; this is replaced with its mapped values 102*1447629fSBarry Smith 103*1447629fSBarry Smith Output Parameter: 104*1447629fSBarry Smith . is - the mapped index set 105*1447629fSBarry Smith 106*1447629fSBarry Smith Level: intermediate 107*1447629fSBarry Smith 108*1447629fSBarry Smith Notes: 109*1447629fSBarry Smith The index set cannot be of type stride or block 110*1447629fSBarry Smith 111*1447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 112*1447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 113*1447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions 114*1447629fSBarry Smith etc. 115*1447629fSBarry Smith 116*1447629fSBarry Smith .keywords: application ordering, mapping 117*1447629fSBarry Smith 118*1447629fSBarry Smith .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), 119*1447629fSBarry Smith AOApplicationToPetscIS(),AOPetscToApplication() 120*1447629fSBarry Smith @*/ 121*1447629fSBarry Smith PetscErrorCode AOPetscToApplicationIS(AO ao,IS is) 122*1447629fSBarry Smith { 123*1447629fSBarry Smith PetscErrorCode ierr; 124*1447629fSBarry Smith PetscInt n; 125*1447629fSBarry Smith PetscInt *ia; 126*1447629fSBarry Smith 127*1447629fSBarry Smith PetscFunctionBegin; 128*1447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 129*1447629fSBarry Smith PetscValidHeaderSpecific(is,IS_CLASSID,2); 130*1447629fSBarry Smith ierr = ISToGeneral(is);CHKERRQ(ierr); 131*1447629fSBarry Smith /* we cheat because we know the is is general and that we can change the indices */ 132*1447629fSBarry Smith ierr = ISGetIndices(is,(const PetscInt**)&ia);CHKERRQ(ierr); 133*1447629fSBarry Smith ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr); 134*1447629fSBarry Smith ierr = (*ao->ops->petsctoapplication)(ao,n,ia);CHKERRQ(ierr); 135*1447629fSBarry Smith ierr = ISRestoreIndices(is,(const PetscInt**)&ia);CHKERRQ(ierr); 136*1447629fSBarry Smith PetscFunctionReturn(0); 137*1447629fSBarry Smith } 138*1447629fSBarry Smith 139*1447629fSBarry Smith #undef __FUNCT__ 140*1447629fSBarry Smith #define __FUNCT__ "AOApplicationToPetscIS" 141*1447629fSBarry Smith /*@ 142*1447629fSBarry Smith AOApplicationToPetscIS - Maps an index set in the application-defined 143*1447629fSBarry Smith ordering to the PETSc ordering. 144*1447629fSBarry Smith 145*1447629fSBarry Smith Collective on AO and IS 146*1447629fSBarry Smith 147*1447629fSBarry Smith Input Parameters: 148*1447629fSBarry Smith + ao - the application ordering context 149*1447629fSBarry Smith - is - the index set; this is replaced with its mapped values 150*1447629fSBarry Smith 151*1447629fSBarry Smith Output Parameter: 152*1447629fSBarry Smith . is - the mapped index set 153*1447629fSBarry Smith 154*1447629fSBarry Smith Level: beginner 155*1447629fSBarry Smith 156*1447629fSBarry Smith Note: 157*1447629fSBarry Smith The index set cannot be of type stride or block 158*1447629fSBarry Smith 159*1447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 160*1447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 161*1447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 162*1447629fSBarry Smith 163*1447629fSBarry Smith .keywords: application ordering, mapping 164*1447629fSBarry Smith 165*1447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(), 166*1447629fSBarry Smith AOPetscToApplicationIS(), AOApplicationToPetsc() 167*1447629fSBarry Smith @*/ 168*1447629fSBarry Smith PetscErrorCode AOApplicationToPetscIS(AO ao,IS is) 169*1447629fSBarry Smith { 170*1447629fSBarry Smith PetscErrorCode ierr; 171*1447629fSBarry Smith PetscInt n,*ia; 172*1447629fSBarry Smith 173*1447629fSBarry Smith PetscFunctionBegin; 174*1447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 175*1447629fSBarry Smith PetscValidHeaderSpecific(is,IS_CLASSID,2); 176*1447629fSBarry Smith ierr = ISToGeneral(is);CHKERRQ(ierr); 177*1447629fSBarry Smith /* we cheat because we know the is is general and that we can change the indices */ 178*1447629fSBarry Smith ierr = ISGetIndices(is,(const PetscInt**)&ia);CHKERRQ(ierr); 179*1447629fSBarry Smith ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr); 180*1447629fSBarry Smith ierr = (*ao->ops->applicationtopetsc)(ao,n,ia);CHKERRQ(ierr); 181*1447629fSBarry Smith ierr = ISRestoreIndices(is,(const PetscInt**)&ia);CHKERRQ(ierr); 182*1447629fSBarry Smith PetscFunctionReturn(0); 183*1447629fSBarry Smith } 184*1447629fSBarry Smith 185*1447629fSBarry Smith #undef __FUNCT__ 186*1447629fSBarry Smith #define __FUNCT__ "AOPetscToApplication" 187*1447629fSBarry Smith /*@ 188*1447629fSBarry Smith AOPetscToApplication - Maps a set of integers in the PETSc ordering to 189*1447629fSBarry Smith the application-defined ordering. 190*1447629fSBarry Smith 191*1447629fSBarry Smith Collective on AO 192*1447629fSBarry Smith 193*1447629fSBarry Smith Input Parameters: 194*1447629fSBarry Smith + ao - the application ordering context 195*1447629fSBarry Smith . n - the number of integers 196*1447629fSBarry Smith - ia - the integers; these are replaced with their mapped value 197*1447629fSBarry Smith 198*1447629fSBarry Smith Output Parameter: 199*1447629fSBarry Smith . ia - the mapped integers 200*1447629fSBarry Smith 201*1447629fSBarry Smith Level: beginner 202*1447629fSBarry Smith 203*1447629fSBarry Smith Note: 204*1447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 205*1447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 206*1447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 207*1447629fSBarry Smith 208*1447629fSBarry Smith Integers that are out of range are mapped to -1 209*1447629fSBarry Smith 210*1447629fSBarry Smith .keywords: application ordering, mapping 211*1447629fSBarry Smith 212*1447629fSBarry Smith .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), 213*1447629fSBarry Smith AOPetscToApplicationIS(), AOApplicationToPetsc() 214*1447629fSBarry Smith @*/ 215*1447629fSBarry Smith PetscErrorCode AOPetscToApplication(AO ao,PetscInt n,PetscInt ia[]) 216*1447629fSBarry Smith { 217*1447629fSBarry Smith PetscErrorCode ierr; 218*1447629fSBarry Smith 219*1447629fSBarry Smith PetscFunctionBegin; 220*1447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 221*1447629fSBarry Smith if (n) PetscValidIntPointer(ia,3); 222*1447629fSBarry Smith ierr = (*ao->ops->petsctoapplication)(ao,n,ia);CHKERRQ(ierr); 223*1447629fSBarry Smith PetscFunctionReturn(0); 224*1447629fSBarry Smith } 225*1447629fSBarry Smith 226*1447629fSBarry Smith #undef __FUNCT__ 227*1447629fSBarry Smith #define __FUNCT__ "AOApplicationToPetsc" 228*1447629fSBarry Smith /*@ 229*1447629fSBarry Smith AOApplicationToPetsc - Maps a set of integers in the application-defined 230*1447629fSBarry Smith ordering to the PETSc ordering. 231*1447629fSBarry Smith 232*1447629fSBarry Smith Collective on AO 233*1447629fSBarry Smith 234*1447629fSBarry Smith Input Parameters: 235*1447629fSBarry Smith + ao - the application ordering context 236*1447629fSBarry Smith . n - the number of integers 237*1447629fSBarry Smith - ia - the integers; these are replaced with their mapped value 238*1447629fSBarry Smith 239*1447629fSBarry Smith Output Parameter: 240*1447629fSBarry Smith . ia - the mapped integers 241*1447629fSBarry Smith 242*1447629fSBarry Smith Level: beginner 243*1447629fSBarry Smith 244*1447629fSBarry Smith Note: 245*1447629fSBarry Smith Any integers in ia[] that are negative are left unchanged. This 246*1447629fSBarry Smith allows one to convert, for example, neighbor lists that use negative 247*1447629fSBarry Smith entries to indicate nonexistent neighbors due to boundary conditions, etc. 248*1447629fSBarry Smith 249*1447629fSBarry Smith Integers that are out of range are mapped to -1 250*1447629fSBarry Smith 251*1447629fSBarry Smith .keywords: application ordering, mapping 252*1447629fSBarry Smith 253*1447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(), 254*1447629fSBarry Smith AOPetscToApplicationIS(), AOApplicationToPetsc() 255*1447629fSBarry Smith @*/ 256*1447629fSBarry Smith PetscErrorCode AOApplicationToPetsc(AO ao,PetscInt n,PetscInt ia[]) 257*1447629fSBarry Smith { 258*1447629fSBarry Smith PetscErrorCode ierr; 259*1447629fSBarry Smith 260*1447629fSBarry Smith PetscFunctionBegin; 261*1447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 262*1447629fSBarry Smith if (n) PetscValidIntPointer(ia,3); 263*1447629fSBarry Smith ierr = (*ao->ops->applicationtopetsc)(ao,n,ia);CHKERRQ(ierr); 264*1447629fSBarry Smith PetscFunctionReturn(0); 265*1447629fSBarry Smith } 266*1447629fSBarry Smith 267*1447629fSBarry Smith #undef __FUNCT__ 268*1447629fSBarry Smith #define __FUNCT__ "AOPetscToApplicationPermuteInt" 269*1447629fSBarry Smith /*@ 270*1447629fSBarry Smith AOPetscToApplicationPermuteInt - Permutes an array of blocks of integers 271*1447629fSBarry Smith in the PETSc ordering to the application-defined ordering. 272*1447629fSBarry Smith 273*1447629fSBarry Smith Collective on AO 274*1447629fSBarry Smith 275*1447629fSBarry Smith Input Parameters: 276*1447629fSBarry Smith + ao - The application ordering context 277*1447629fSBarry Smith . block - The block size 278*1447629fSBarry Smith - array - The integer array 279*1447629fSBarry Smith 280*1447629fSBarry Smith Output Parameter: 281*1447629fSBarry Smith . array - The permuted array 282*1447629fSBarry Smith 283*1447629fSBarry Smith Note: The length of the array should be block*N, where N is length 284*1447629fSBarry Smith provided to the AOCreate*() method that created the AO. 285*1447629fSBarry Smith 286*1447629fSBarry Smith The permutation takes array[i_pet] --> array[i_app], where i_app is 287*1447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 288*1447629fSBarry Smith of 'i' in the petsc ordering. 289*1447629fSBarry Smith 290*1447629fSBarry Smith Level: beginner 291*1447629fSBarry Smith 292*1447629fSBarry Smith .keywords: application ordering, mapping 293*1447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS() 294*1447629fSBarry Smith @*/ 295*1447629fSBarry Smith PetscErrorCode AOPetscToApplicationPermuteInt(AO ao, PetscInt block, PetscInt array[]) 296*1447629fSBarry Smith { 297*1447629fSBarry Smith PetscErrorCode ierr; 298*1447629fSBarry Smith 299*1447629fSBarry Smith PetscFunctionBegin; 300*1447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 301*1447629fSBarry Smith PetscValidIntPointer(array,3); 302*1447629fSBarry Smith ierr = (*ao->ops->petsctoapplicationpermuteint)(ao, block, array);CHKERRQ(ierr); 303*1447629fSBarry Smith PetscFunctionReturn(0); 304*1447629fSBarry Smith } 305*1447629fSBarry Smith 306*1447629fSBarry Smith #undef __FUNCT__ 307*1447629fSBarry Smith #define __FUNCT__ "AOApplicationToPetscPermuteInt" 308*1447629fSBarry Smith /*@ 309*1447629fSBarry Smith AOApplicationToPetscPermuteInt - Permutes an array of blocks of integers 310*1447629fSBarry Smith in the application-defined ordering to the PETSc ordering. 311*1447629fSBarry Smith 312*1447629fSBarry Smith Collective on AO 313*1447629fSBarry Smith 314*1447629fSBarry Smith Input Parameters: 315*1447629fSBarry Smith + ao - The application ordering context 316*1447629fSBarry Smith . block - The block size 317*1447629fSBarry Smith - array - The integer array 318*1447629fSBarry Smith 319*1447629fSBarry Smith Output Parameter: 320*1447629fSBarry Smith . array - The permuted array 321*1447629fSBarry Smith 322*1447629fSBarry Smith Note: The length of the array should be block*N, where N is length 323*1447629fSBarry Smith provided to the AOCreate*() method that created the AO. 324*1447629fSBarry Smith 325*1447629fSBarry Smith The permutation takes array[i_app] --> array[i_pet], where i_app is 326*1447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 327*1447629fSBarry Smith of 'i' in the petsc ordering. 328*1447629fSBarry Smith 329*1447629fSBarry Smith Level: beginner 330*1447629fSBarry Smith 331*1447629fSBarry Smith .keywords: application ordering, mapping 332*1447629fSBarry Smith 333*1447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOPetscToApplicationIS(), AOApplicationToPetsc() 334*1447629fSBarry Smith @*/ 335*1447629fSBarry Smith PetscErrorCode AOApplicationToPetscPermuteInt(AO ao, PetscInt block, PetscInt array[]) 336*1447629fSBarry Smith { 337*1447629fSBarry Smith PetscErrorCode ierr; 338*1447629fSBarry Smith 339*1447629fSBarry Smith PetscFunctionBegin; 340*1447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 341*1447629fSBarry Smith PetscValidIntPointer(array,3); 342*1447629fSBarry Smith ierr = (*ao->ops->applicationtopetscpermuteint)(ao, block, array);CHKERRQ(ierr); 343*1447629fSBarry Smith PetscFunctionReturn(0); 344*1447629fSBarry Smith } 345*1447629fSBarry Smith 346*1447629fSBarry Smith #undef __FUNCT__ 347*1447629fSBarry Smith #define __FUNCT__ "AOPetscToApplicationPermuteReal" 348*1447629fSBarry Smith /*@ 349*1447629fSBarry Smith AOPetscToApplicationPermuteReal - Permutes an array of blocks of reals 350*1447629fSBarry Smith in the PETSc ordering to the application-defined ordering. 351*1447629fSBarry Smith 352*1447629fSBarry Smith Collective on AO 353*1447629fSBarry Smith 354*1447629fSBarry Smith Input Parameters: 355*1447629fSBarry Smith + ao - The application ordering context 356*1447629fSBarry Smith . block - The block size 357*1447629fSBarry Smith - array - The integer array 358*1447629fSBarry Smith 359*1447629fSBarry Smith Output Parameter: 360*1447629fSBarry Smith . array - The permuted array 361*1447629fSBarry Smith 362*1447629fSBarry Smith Note: The length of the array should be block*N, where N is length 363*1447629fSBarry Smith provided to the AOCreate*() method that created the AO. 364*1447629fSBarry Smith 365*1447629fSBarry Smith The permutation takes array[i_pet] --> array[i_app], where i_app is 366*1447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 367*1447629fSBarry Smith of 'i' in the petsc ordering. 368*1447629fSBarry Smith 369*1447629fSBarry Smith Level: beginner 370*1447629fSBarry Smith 371*1447629fSBarry Smith .keywords: application ordering, mapping 372*1447629fSBarry Smith 373*1447629fSBarry Smith .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS() 374*1447629fSBarry Smith @*/ 375*1447629fSBarry Smith PetscErrorCode AOPetscToApplicationPermuteReal(AO ao, PetscInt block, PetscReal array[]) 376*1447629fSBarry Smith { 377*1447629fSBarry Smith PetscErrorCode ierr; 378*1447629fSBarry Smith 379*1447629fSBarry Smith PetscFunctionBegin; 380*1447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 381*1447629fSBarry Smith PetscValidIntPointer(array,3); 382*1447629fSBarry Smith ierr = (*ao->ops->petsctoapplicationpermutereal)(ao, block, array);CHKERRQ(ierr); 383*1447629fSBarry Smith PetscFunctionReturn(0); 384*1447629fSBarry Smith } 385*1447629fSBarry Smith 386*1447629fSBarry Smith #undef __FUNCT__ 387*1447629fSBarry Smith #define __FUNCT__ "AOApplicationToPetscPermuteReal" 388*1447629fSBarry Smith /*@ 389*1447629fSBarry Smith AOApplicationToPetscPermuteReal - Permutes an array of blocks of reals 390*1447629fSBarry Smith in the application-defined ordering to the PETSc ordering. 391*1447629fSBarry Smith 392*1447629fSBarry Smith Collective on AO 393*1447629fSBarry Smith 394*1447629fSBarry Smith Input Parameters: 395*1447629fSBarry Smith + ao - The application ordering context 396*1447629fSBarry Smith . block - The block size 397*1447629fSBarry Smith - array - The integer array 398*1447629fSBarry Smith 399*1447629fSBarry Smith Output Parameter: 400*1447629fSBarry Smith . array - The permuted array 401*1447629fSBarry Smith 402*1447629fSBarry Smith Note: The length of the array should be block*N, where N is length 403*1447629fSBarry Smith provided to the AOCreate*() method that created the AO. 404*1447629fSBarry Smith 405*1447629fSBarry Smith The permutation takes array[i_app] --> array[i_pet], where i_app is 406*1447629fSBarry Smith the index of 'i' in the application ordering and i_pet is the index 407*1447629fSBarry Smith of 'i' in the petsc ordering. 408*1447629fSBarry Smith 409*1447629fSBarry Smith Level: beginner 410*1447629fSBarry Smith 411*1447629fSBarry Smith .keywords: application ordering, mapping 412*1447629fSBarry Smith 413*1447629fSBarry Smith .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), AOPetscToApplicationIS() 414*1447629fSBarry Smith @*/ 415*1447629fSBarry Smith PetscErrorCode AOApplicationToPetscPermuteReal(AO ao, PetscInt block, PetscReal array[]) 416*1447629fSBarry Smith { 417*1447629fSBarry Smith PetscErrorCode ierr; 418*1447629fSBarry Smith 419*1447629fSBarry Smith PetscFunctionBegin; 420*1447629fSBarry Smith PetscValidHeaderSpecific(ao, AO_CLASSID,1); 421*1447629fSBarry Smith PetscValidIntPointer(array,3); 422*1447629fSBarry Smith ierr = (*ao->ops->applicationtopetscpermutereal)(ao, block, array);CHKERRQ(ierr); 423*1447629fSBarry Smith PetscFunctionReturn(0); 424*1447629fSBarry Smith } 425*1447629fSBarry Smith 426*1447629fSBarry Smith #undef __FUNCT__ 427*1447629fSBarry Smith #define __FUNCT__ "AOSetFromOptions" 428*1447629fSBarry Smith /*@C 429*1447629fSBarry Smith AOSetFromOptions - Sets AO options from the options database. 430*1447629fSBarry Smith 431*1447629fSBarry Smith Collective on AO 432*1447629fSBarry Smith 433*1447629fSBarry Smith Input Parameter: 434*1447629fSBarry Smith . ao - the application ordering 435*1447629fSBarry Smith 436*1447629fSBarry Smith Level: beginner 437*1447629fSBarry Smith 438*1447629fSBarry Smith .keywords: AO, options, database 439*1447629fSBarry Smith 440*1447629fSBarry Smith .seealso: AOCreate(), AOSetType(), AODestroy(), AOPetscToApplication(), AOApplicationToPetsc() 441*1447629fSBarry Smith @*/ 442*1447629fSBarry Smith PetscErrorCode AOSetFromOptions(AO ao) 443*1447629fSBarry Smith { 444*1447629fSBarry Smith PetscErrorCode ierr; 445*1447629fSBarry Smith char type[256]; 446*1447629fSBarry Smith const char *def=AOBASIC; 447*1447629fSBarry Smith PetscBool flg; 448*1447629fSBarry Smith 449*1447629fSBarry Smith PetscFunctionBegin; 450*1447629fSBarry Smith PetscValidHeaderSpecific(ao,AO_CLASSID,1); 451*1447629fSBarry Smith 452*1447629fSBarry Smith ierr = PetscObjectOptionsBegin((PetscObject)ao);CHKERRQ(ierr); 453*1447629fSBarry Smith ierr = PetscOptionsList("-ao_type","AO type","AOSetType",AOList,def,type,256,&flg);CHKERRQ(ierr); 454*1447629fSBarry Smith if (flg) { 455*1447629fSBarry Smith ierr = AOSetType(ao,type);CHKERRQ(ierr); 456*1447629fSBarry Smith } else if (!((PetscObject)ao)->type_name) { 457*1447629fSBarry Smith ierr = AOSetType(ao,def);CHKERRQ(ierr); 458*1447629fSBarry Smith } 459*1447629fSBarry Smith 460*1447629fSBarry Smith /* not used here, but called so will go into help messaage */ 461*1447629fSBarry Smith ierr = PetscOptionsName("-ao_view","Print detailed information on AO used","AOView",0);CHKERRQ(ierr); 462*1447629fSBarry Smith 463*1447629fSBarry Smith ierr = PetscOptionsEnd();CHKERRQ(ierr); 464*1447629fSBarry Smith PetscFunctionReturn(0); 465*1447629fSBarry Smith } 466*1447629fSBarry Smith 467*1447629fSBarry Smith #undef __FUNCT__ 468*1447629fSBarry Smith #define __FUNCT__ "AOSetIS" 469*1447629fSBarry Smith /*@C 470*1447629fSBarry Smith AOSetIS - Sets the IS associated with the application ordering. 471*1447629fSBarry Smith 472*1447629fSBarry Smith Collective on MPI_Comm 473*1447629fSBarry Smith 474*1447629fSBarry Smith Input Parameters: 475*1447629fSBarry Smith + ao - the application ordering 476*1447629fSBarry Smith . isapp - index set that defines an ordering 477*1447629fSBarry Smith - ispetsc - index set that defines another ordering (may be NULL to use the 478*1447629fSBarry Smith natural ordering) 479*1447629fSBarry Smith 480*1447629fSBarry Smith Notes: 481*1447629fSBarry Smith The index sets isapp and ispetsc are used only for creation of ao. 482*1447629fSBarry Smith 483*1447629fSBarry Smith Level: beginner 484*1447629fSBarry Smith 485*1447629fSBarry Smith .keywords: AO, create 486*1447629fSBarry Smith 487*1447629fSBarry Smith .seealso: AOCreate(), AODestroy(), AOPetscToApplication(), AOApplicationToPetsc() 488*1447629fSBarry Smith @*/ 489*1447629fSBarry Smith PetscErrorCode AOSetIS(AO ao,IS isapp,IS ispetsc) 490*1447629fSBarry Smith { 491*1447629fSBarry Smith PetscErrorCode ierr; 492*1447629fSBarry Smith 493*1447629fSBarry Smith PetscFunctionBegin; 494*1447629fSBarry Smith if (ispetsc) { 495*1447629fSBarry Smith PetscInt napp,npetsc; 496*1447629fSBarry Smith ierr = ISGetLocalSize(isapp,&napp);CHKERRQ(ierr); 497*1447629fSBarry Smith ierr = ISGetLocalSize(ispetsc,&npetsc);CHKERRQ(ierr); 498*1447629fSBarry Smith if (napp != npetsc) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"napp %D != npetsc %d. Local IS lengths must match",napp,npetsc); 499*1447629fSBarry Smith } 500*1447629fSBarry Smith ao->isapp = isapp; 501*1447629fSBarry Smith ao->ispetsc = ispetsc; 502*1447629fSBarry Smith PetscFunctionReturn(0); 503*1447629fSBarry Smith } 504*1447629fSBarry Smith 505*1447629fSBarry Smith #undef __FUNCT__ 506*1447629fSBarry Smith #define __FUNCT__ "AOCreate" 507*1447629fSBarry Smith /*@C 508*1447629fSBarry Smith AOCreate - Creates an application ordering. 509*1447629fSBarry Smith 510*1447629fSBarry Smith Collective on MPI_Comm 511*1447629fSBarry Smith 512*1447629fSBarry Smith Input Parameters: 513*1447629fSBarry Smith . comm - MPI communicator that is to share AO 514*1447629fSBarry Smith 515*1447629fSBarry Smith Output Parameter: 516*1447629fSBarry Smith . ao - the new application ordering 517*1447629fSBarry Smith 518*1447629fSBarry Smith Options Database Key: 519*1447629fSBarry Smith + -ao_type <aotype> - create ao with particular format 520*1447629fSBarry Smith - -ao_view - call AOView() at the conclusion of AOCreate() 521*1447629fSBarry Smith 522*1447629fSBarry Smith Level: beginner 523*1447629fSBarry Smith 524*1447629fSBarry Smith .keywords: AO, create 525*1447629fSBarry Smith 526*1447629fSBarry Smith .seealso: AOSetIS(), AODestroy(), AOPetscToApplication(), AOApplicationToPetsc() 527*1447629fSBarry Smith @*/ 528*1447629fSBarry Smith PetscErrorCode AOCreate(MPI_Comm comm,AO *ao) 529*1447629fSBarry Smith { 530*1447629fSBarry Smith PetscErrorCode ierr; 531*1447629fSBarry Smith AO aonew; 532*1447629fSBarry Smith PetscBool opt; 533*1447629fSBarry Smith 534*1447629fSBarry Smith PetscFunctionBegin; 535*1447629fSBarry Smith PetscValidPointer(ao,2); 536*1447629fSBarry Smith *ao = NULL; 537*1447629fSBarry Smith #if !defined(PETSC_USE_DYNAMIC_LIBRARIES) 538*1447629fSBarry Smith ierr = AOInitializePackage(NULL);CHKERRQ(ierr); 539*1447629fSBarry Smith #endif 540*1447629fSBarry Smith 541*1447629fSBarry Smith ierr = PetscHeaderCreate(aonew,_p_AO,struct _AOOps,AO_CLASSID,"AO","Application Ordering","AO",comm,AODestroy,AOView);CHKERRQ(ierr); 542*1447629fSBarry Smith ierr = PetscMemzero(aonew->ops, sizeof(struct _AOOps));CHKERRQ(ierr); 543*1447629fSBarry Smith *ao = aonew; 544*1447629fSBarry Smith 545*1447629fSBarry Smith opt = PETSC_FALSE; 546*1447629fSBarry Smith ierr = PetscOptionsGetBool(NULL, "-ao_view", &opt,NULL);CHKERRQ(ierr); 547*1447629fSBarry Smith if (opt) { 548*1447629fSBarry Smith ierr = AOView(aonew, PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); 549*1447629fSBarry Smith } 550*1447629fSBarry Smith PetscFunctionReturn(0); 551*1447629fSBarry Smith } 552