1*47c6ae99SBarry Smith #define PETSCDM_DLL 2*47c6ae99SBarry Smith 3*47c6ae99SBarry Smith /* 4*47c6ae99SBarry Smith Code for manipulating distributed regular arrays in parallel. 5*47c6ae99SBarry Smith */ 6*47c6ae99SBarry Smith 7*47c6ae99SBarry Smith #include "private/daimpl.h" /*I "petscda.h" I*/ 8*47c6ae99SBarry Smith 9*47c6ae99SBarry Smith #if defined(PETSC_HAVE_MATLAB_ENGINE) 10*47c6ae99SBarry Smith #include "mat.h" /* Matlab include file */ 11*47c6ae99SBarry Smith 12*47c6ae99SBarry Smith #undef __FUNCT__ 13*47c6ae99SBarry Smith #define __FUNCT__ "DAView_Matlab" 14*47c6ae99SBarry Smith PetscErrorCode DAView_Matlab(DA da,PetscViewer viewer) 15*47c6ae99SBarry Smith { 16*47c6ae99SBarry Smith PetscErrorCode ierr; 17*47c6ae99SBarry Smith PetscMPIInt rank; 18*47c6ae99SBarry Smith PetscInt dim,m,n,p,dof,swidth; 19*47c6ae99SBarry Smith DAStencilType stencil; 20*47c6ae99SBarry Smith DAPeriodicType periodic; 21*47c6ae99SBarry Smith mxArray *mx; 22*47c6ae99SBarry Smith const char *fnames[] = {"dimension","m","n","p","dof","stencil_width","periodicity","stencil_type"}; 23*47c6ae99SBarry Smith 24*47c6ae99SBarry Smith PetscFunctionBegin; 25*47c6ae99SBarry Smith ierr = MPI_Comm_rank(((PetscObject)da)->comm,&rank);CHKERRQ(ierr); 26*47c6ae99SBarry Smith if (!rank) { 27*47c6ae99SBarry Smith ierr = DAGetInfo(da,&dim,&m,&n,&p,0,0,0,&dof,&swidth,&periodic,&stencil);CHKERRQ(ierr); 28*47c6ae99SBarry Smith mx = mxCreateStructMatrix(1,1,8,(const char **)fnames); 29*47c6ae99SBarry Smith if (!mx) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Unable to generate Matlab struct array to hold DA informations"); 30*47c6ae99SBarry Smith mxSetFieldByNumber(mx,0,0,mxCreateDoubleScalar((double)dim)); 31*47c6ae99SBarry Smith mxSetFieldByNumber(mx,0,1,mxCreateDoubleScalar((double)m)); 32*47c6ae99SBarry Smith mxSetFieldByNumber(mx,0,2,mxCreateDoubleScalar((double)n)); 33*47c6ae99SBarry Smith mxSetFieldByNumber(mx,0,3,mxCreateDoubleScalar((double)p)); 34*47c6ae99SBarry Smith mxSetFieldByNumber(mx,0,4,mxCreateDoubleScalar((double)dof)); 35*47c6ae99SBarry Smith mxSetFieldByNumber(mx,0,5,mxCreateDoubleScalar((double)swidth)); 36*47c6ae99SBarry Smith mxSetFieldByNumber(mx,0,6,mxCreateDoubleScalar((double)periodic)); 37*47c6ae99SBarry Smith mxSetFieldByNumber(mx,0,7,mxCreateDoubleScalar((double)stencil)); 38*47c6ae99SBarry Smith ierr = PetscObjectName((PetscObject)da);CHKERRQ(ierr); 39*47c6ae99SBarry Smith ierr = PetscViewerMatlabPutVariable(viewer,((PetscObject)da)->name,mx);CHKERRQ(ierr); 40*47c6ae99SBarry Smith } 41*47c6ae99SBarry Smith PetscFunctionReturn(0); 42*47c6ae99SBarry Smith } 43*47c6ae99SBarry Smith #endif 44*47c6ae99SBarry Smith 45*47c6ae99SBarry Smith #undef __FUNCT__ 46*47c6ae99SBarry Smith #define __FUNCT__ "DAView_Binary" 47*47c6ae99SBarry Smith PetscErrorCode DAView_Binary(DA da,PetscViewer viewer) 48*47c6ae99SBarry Smith { 49*47c6ae99SBarry Smith PetscErrorCode ierr; 50*47c6ae99SBarry Smith PetscMPIInt rank; 51*47c6ae99SBarry Smith PetscInt i,dim,m,n,p,dof,swidth,M,N,P; 52*47c6ae99SBarry Smith size_t j,len; 53*47c6ae99SBarry Smith DAStencilType stencil; 54*47c6ae99SBarry Smith DAPeriodicType periodic; 55*47c6ae99SBarry Smith MPI_Comm comm; 56*47c6ae99SBarry Smith DM_DA *dd = (DM_DA*)da->data; 57*47c6ae99SBarry Smith 58*47c6ae99SBarry Smith PetscFunctionBegin; 59*47c6ae99SBarry Smith ierr = PetscObjectGetComm((PetscObject)da,&comm);CHKERRQ(ierr); 60*47c6ae99SBarry Smith 61*47c6ae99SBarry Smith ierr = DAGetInfo(da,&dim,&m,&n,&p,&M,&N,&P,&dof,&swidth,&periodic,&stencil);CHKERRQ(ierr); 62*47c6ae99SBarry Smith ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); 63*47c6ae99SBarry Smith if (!rank) { 64*47c6ae99SBarry Smith FILE *file; 65*47c6ae99SBarry Smith 66*47c6ae99SBarry Smith ierr = PetscViewerBinaryGetInfoPointer(viewer,&file);CHKERRQ(ierr); 67*47c6ae99SBarry Smith if (file) { 68*47c6ae99SBarry Smith char fieldname[PETSC_MAX_PATH_LEN]; 69*47c6ae99SBarry Smith 70*47c6ae99SBarry Smith ierr = PetscFPrintf(PETSC_COMM_SELF,file,"-daload_info %D,%D,%D,%D,%D,%D,%D,%D\n",dim,m,n,p,dof,swidth,stencil,periodic);CHKERRQ(ierr); 71*47c6ae99SBarry Smith for (i=0; i<dof; i++) { 72*47c6ae99SBarry Smith if (dd->fieldname[i]) { 73*47c6ae99SBarry Smith ierr = PetscStrncpy(fieldname,dd->fieldname[i],PETSC_MAX_PATH_LEN);CHKERRQ(ierr); 74*47c6ae99SBarry Smith ierr = PetscStrlen(fieldname,&len);CHKERRQ(ierr); 75*47c6ae99SBarry Smith len = PetscMin(PETSC_MAX_PATH_LEN,len);CHKERRQ(ierr); 76*47c6ae99SBarry Smith for (j=0; j<len; j++) { 77*47c6ae99SBarry Smith if (fieldname[j] == ' ') fieldname[j] = '_'; 78*47c6ae99SBarry Smith } 79*47c6ae99SBarry Smith ierr = PetscFPrintf(PETSC_COMM_SELF,file,"-daload_fieldname_%D %s\n",i,fieldname);CHKERRQ(ierr); 80*47c6ae99SBarry Smith } 81*47c6ae99SBarry Smith } 82*47c6ae99SBarry Smith if (dd->coordinates) { /* save the DA's coordinates */ 83*47c6ae99SBarry Smith ierr = PetscFPrintf(PETSC_COMM_SELF,file,"-daload_coordinates\n");CHKERRQ(ierr); 84*47c6ae99SBarry Smith } 85*47c6ae99SBarry Smith } 86*47c6ae99SBarry Smith } 87*47c6ae99SBarry Smith 88*47c6ae99SBarry Smith /* save the coordinates if they exist to disk (in the natural ordering) */ 89*47c6ae99SBarry Smith if (dd->coordinates) { 90*47c6ae99SBarry Smith DA dac; 91*47c6ae99SBarry Smith const PetscInt *lx,*ly,*lz; 92*47c6ae99SBarry Smith Vec natural; 93*47c6ae99SBarry Smith 94*47c6ae99SBarry Smith /* create the appropriate DA to map to natural ordering */ 95*47c6ae99SBarry Smith ierr = DAGetOwnershipRanges(da,&lx,&ly,&lz);CHKERRQ(ierr); 96*47c6ae99SBarry Smith if (dim == 1) { 97*47c6ae99SBarry Smith ierr = DACreate1d(comm,DA_NONPERIODIC,m,dim,0,lx,&dac);CHKERRQ(ierr); 98*47c6ae99SBarry Smith } else if (dim == 2) { 99*47c6ae99SBarry Smith ierr = DACreate2d(comm,DA_NONPERIODIC,DA_STENCIL_BOX,m,n,M,N,dim,0,lx,ly,&dac);CHKERRQ(ierr); 100*47c6ae99SBarry Smith } else if (dim == 3) { 101*47c6ae99SBarry Smith ierr = DACreate3d(comm,DA_NONPERIODIC,DA_STENCIL_BOX,m,n,p,M,N,P,dim,0,lx,ly,lz,&dac);CHKERRQ(ierr); 102*47c6ae99SBarry Smith } else { 103*47c6ae99SBarry Smith SETERRQ1(comm,PETSC_ERR_ARG_CORRUPT,"Dimension is not 1 2 or 3: %D\n",dim); 104*47c6ae99SBarry Smith } 105*47c6ae99SBarry Smith ierr = DACreateNaturalVector(dac,&natural);CHKERRQ(ierr); 106*47c6ae99SBarry Smith ierr = PetscObjectSetOptionsPrefix((PetscObject)natural,"coor_");CHKERRQ(ierr); 107*47c6ae99SBarry Smith ierr = DAGlobalToNaturalBegin(dac,dd->coordinates,INSERT_VALUES,natural);CHKERRQ(ierr); 108*47c6ae99SBarry Smith ierr = DAGlobalToNaturalEnd(dac,dd->coordinates,INSERT_VALUES,natural);CHKERRQ(ierr); 109*47c6ae99SBarry Smith ierr = VecView(natural,viewer);CHKERRQ(ierr); 110*47c6ae99SBarry Smith ierr = VecDestroy(natural);CHKERRQ(ierr); 111*47c6ae99SBarry Smith ierr = DADestroy(dac);CHKERRQ(ierr); 112*47c6ae99SBarry Smith } 113*47c6ae99SBarry Smith 114*47c6ae99SBarry Smith PetscFunctionReturn(0); 115*47c6ae99SBarry Smith } 116*47c6ae99SBarry Smith 117*47c6ae99SBarry Smith #undef __FUNCT__ 118*47c6ae99SBarry Smith #define __FUNCT__ "DAView_VTK" 119*47c6ae99SBarry Smith PetscErrorCode DAView_VTK(DA da, PetscViewer viewer) 120*47c6ae99SBarry Smith { 121*47c6ae99SBarry Smith PetscInt dim, dof, M = 0, N = 0, P = 0; 122*47c6ae99SBarry Smith PetscErrorCode ierr; 123*47c6ae99SBarry Smith DM_DA *dd = (DM_DA*)da->data; 124*47c6ae99SBarry Smith 125*47c6ae99SBarry Smith PetscFunctionBegin; 126*47c6ae99SBarry Smith ierr = DAGetInfo(da, &dim, &M, &N, &P, PETSC_NULL, PETSC_NULL, PETSC_NULL, &dof, PETSC_NULL, PETSC_NULL, PETSC_NULL);CHKERRQ(ierr); 127*47c6ae99SBarry Smith /* if (dim != 3) {SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP, "VTK output only works for three dimensional DAs.");} */ 128*47c6ae99SBarry Smith if (!dd->coordinates) SETERRQ(((PetscObject)da)->comm,PETSC_ERR_SUP, "VTK output requires DA coordinates."); 129*47c6ae99SBarry Smith /* Write Header */ 130*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"# vtk DataFile Version 2.0\n");CHKERRQ(ierr); 131*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"Structured Mesh Example\n");CHKERRQ(ierr); 132*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"ASCII\n");CHKERRQ(ierr); 133*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"DATASET STRUCTURED_GRID\n");CHKERRQ(ierr); 134*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"DIMENSIONS %d %d %d\n", M, N, P);CHKERRQ(ierr); 135*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"POINTS %d double\n", M*N*P);CHKERRQ(ierr); 136*47c6ae99SBarry Smith if (dd->coordinates) { 137*47c6ae99SBarry Smith DA dac; 138*47c6ae99SBarry Smith Vec natural; 139*47c6ae99SBarry Smith 140*47c6ae99SBarry Smith ierr = DAGetCoordinateDA(da, &dac);CHKERRQ(ierr); 141*47c6ae99SBarry Smith ierr = DACreateNaturalVector(dac, &natural);CHKERRQ(ierr); 142*47c6ae99SBarry Smith ierr = PetscObjectSetOptionsPrefix((PetscObject) natural, "coor_");CHKERRQ(ierr); 143*47c6ae99SBarry Smith ierr = DAGlobalToNaturalBegin(dac, dd->coordinates, INSERT_VALUES, natural);CHKERRQ(ierr); 144*47c6ae99SBarry Smith ierr = DAGlobalToNaturalEnd(dac, dd->coordinates, INSERT_VALUES, natural);CHKERRQ(ierr); 145*47c6ae99SBarry Smith ierr = PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_VTK_COORDS);CHKERRQ(ierr); 146*47c6ae99SBarry Smith ierr = VecView(natural, viewer);CHKERRQ(ierr); 147*47c6ae99SBarry Smith ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); 148*47c6ae99SBarry Smith ierr = VecDestroy(natural);CHKERRQ(ierr); 149*47c6ae99SBarry Smith } 150*47c6ae99SBarry Smith PetscFunctionReturn(0); 151*47c6ae99SBarry Smith } 152*47c6ae99SBarry Smith 153*47c6ae99SBarry Smith #undef __FUNCT__ 154*47c6ae99SBarry Smith #define __FUNCT__ "DAView" 155*47c6ae99SBarry Smith /*@C 156*47c6ae99SBarry Smith DAView - Visualizes a distributed array object. 157*47c6ae99SBarry Smith 158*47c6ae99SBarry Smith Collective on DA 159*47c6ae99SBarry Smith 160*47c6ae99SBarry Smith Input Parameters: 161*47c6ae99SBarry Smith + da - the distributed array 162*47c6ae99SBarry Smith - ptr - an optional visualization context 163*47c6ae99SBarry Smith 164*47c6ae99SBarry Smith Notes: 165*47c6ae99SBarry Smith The available visualization contexts include 166*47c6ae99SBarry Smith + PETSC_VIEWER_STDOUT_SELF - standard output (default) 167*47c6ae99SBarry Smith . PETSC_VIEWER_STDOUT_WORLD - synchronized standard 168*47c6ae99SBarry Smith output where only the first processor opens 169*47c6ae99SBarry Smith the file. All other processors send their 170*47c6ae99SBarry Smith data to the first processor to print. 171*47c6ae99SBarry Smith - PETSC_VIEWER_DRAW_WORLD - to default window 172*47c6ae99SBarry Smith 173*47c6ae99SBarry Smith The user can open alternative visualization contexts with 174*47c6ae99SBarry Smith + PetscViewerASCIIOpen() - Outputs vector to a specified file 175*47c6ae99SBarry Smith - PetscViewerDrawOpen() - Outputs vector to an X window display 176*47c6ae99SBarry Smith 177*47c6ae99SBarry Smith Default Output Format: 178*47c6ae99SBarry Smith (for 3d arrays) 179*47c6ae99SBarry Smith .vb 180*47c6ae99SBarry Smith Processor [proc] M N P m n p w s 181*47c6ae99SBarry Smith X range: xs xe, Y range: ys, ye, Z range: zs, ze 182*47c6ae99SBarry Smith 183*47c6ae99SBarry Smith where 184*47c6ae99SBarry Smith M,N,P - global dimension in each direction of the array 185*47c6ae99SBarry Smith m,n,p - corresponding number of procs in each dimension 186*47c6ae99SBarry Smith w - number of degrees of freedom per node 187*47c6ae99SBarry Smith s - stencil width 188*47c6ae99SBarry Smith xs, xe - internal local starting/ending grid points 189*47c6ae99SBarry Smith in x-direction, (augmented to handle multiple 190*47c6ae99SBarry Smith degrees of freedom per node) 191*47c6ae99SBarry Smith ys, ye - local starting/ending grid points in y-direction 192*47c6ae99SBarry Smith zs, ze - local starting/ending grid points in z-direction 193*47c6ae99SBarry Smith .ve 194*47c6ae99SBarry Smith 195*47c6ae99SBarry Smith Options Database Key: 196*47c6ae99SBarry Smith . -da_view - Calls DAView() at the conclusion of DACreate1d(), 197*47c6ae99SBarry Smith DACreate2d(), and DACreate3d() 198*47c6ae99SBarry Smith 199*47c6ae99SBarry Smith Level: beginner 200*47c6ae99SBarry Smith 201*47c6ae99SBarry Smith Notes: 202*47c6ae99SBarry Smith Use DAGetCorners() and DAGetGhostCorners() to get the starting 203*47c6ae99SBarry Smith and ending grid points (ghost points) in each direction. 204*47c6ae99SBarry Smith 205*47c6ae99SBarry Smith When drawing the DA grid it only draws the logical grid and does not 206*47c6ae99SBarry Smith respect the grid coordinates set with DASetCoordinates() 207*47c6ae99SBarry Smith 208*47c6ae99SBarry Smith .keywords: distributed array, view, visualize 209*47c6ae99SBarry Smith 210*47c6ae99SBarry Smith .seealso: PetscViewerASCIIOpen(), PetscViewerDrawOpen(), DAGetInfo(), DAGetCorners(), 211*47c6ae99SBarry Smith DAGetGhostCorners(), DAGetOwnershipRanges(), DACreate(), DACreate1d(), DACreate2d(), DACreate3d() 212*47c6ae99SBarry Smith @*/ 213*47c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DAView(DA da,PetscViewer viewer) 214*47c6ae99SBarry Smith { 215*47c6ae99SBarry Smith PetscErrorCode ierr; 216*47c6ae99SBarry Smith DM_DA *dd = (DM_DA*)da->data; 217*47c6ae99SBarry Smith PetscInt i,dof = dd->w; 218*47c6ae99SBarry Smith PetscBool iascii,fieldsnamed = PETSC_FALSE,isbinary; 219*47c6ae99SBarry Smith #if defined(PETSC_HAVE_MATLAB_ENGINE) 220*47c6ae99SBarry Smith PetscBool ismatlab; 221*47c6ae99SBarry Smith #endif 222*47c6ae99SBarry Smith 223*47c6ae99SBarry Smith PetscFunctionBegin; 224*47c6ae99SBarry Smith PetscValidHeaderSpecific(da,DM_CLASSID,1); 225*47c6ae99SBarry Smith if (!viewer) { 226*47c6ae99SBarry Smith ierr = PetscViewerASCIIGetStdout(((PetscObject)da)->comm,&viewer);CHKERRQ(ierr); 227*47c6ae99SBarry Smith } 228*47c6ae99SBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); 229*47c6ae99SBarry Smith 230*47c6ae99SBarry Smith ierr = PetscTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr); 231*47c6ae99SBarry Smith ierr = PetscTypeCompare((PetscObject)viewer,PETSCVIEWERBINARY,&isbinary);CHKERRQ(ierr); 232*47c6ae99SBarry Smith #if defined(PETSC_HAVE_MATLAB_ENGINE) 233*47c6ae99SBarry Smith ierr = PetscTypeCompare((PetscObject)viewer,PETSCVIEWERMATLAB,&ismatlab);CHKERRQ(ierr); 234*47c6ae99SBarry Smith #endif 235*47c6ae99SBarry Smith if (iascii) { 236*47c6ae99SBarry Smith PetscViewerFormat format; 237*47c6ae99SBarry Smith 238*47c6ae99SBarry Smith ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr); 239*47c6ae99SBarry Smith if (format == PETSC_VIEWER_ASCII_VTK || format == PETSC_VIEWER_ASCII_VTK_CELL) { 240*47c6ae99SBarry Smith ierr = DAView_VTK(da, viewer);CHKERRQ(ierr); 241*47c6ae99SBarry Smith } else { 242*47c6ae99SBarry Smith ierr = PetscObjectPrintClassNamePrefixType((PetscObject)da,viewer,"DA Object");CHKERRQ(ierr); 243*47c6ae99SBarry Smith for (i=0; i<dof; i++) { 244*47c6ae99SBarry Smith if (dd->fieldname[i]) { 245*47c6ae99SBarry Smith fieldsnamed = PETSC_TRUE; 246*47c6ae99SBarry Smith break; 247*47c6ae99SBarry Smith } 248*47c6ae99SBarry Smith } 249*47c6ae99SBarry Smith if (fieldsnamed) { 250*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"FieldNames: ");CHKERRQ(ierr); 251*47c6ae99SBarry Smith for (i=0; i<dof; i++) { 252*47c6ae99SBarry Smith if (dd->fieldname[i]) { 253*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"%s ",dd->fieldname[i]);CHKERRQ(ierr); 254*47c6ae99SBarry Smith } else { 255*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"(not named) ");CHKERRQ(ierr); 256*47c6ae99SBarry Smith } 257*47c6ae99SBarry Smith } 258*47c6ae99SBarry Smith ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); 259*47c6ae99SBarry Smith } 260*47c6ae99SBarry Smith } 261*47c6ae99SBarry Smith } 262*47c6ae99SBarry Smith if (isbinary){ 263*47c6ae99SBarry Smith ierr = DAView_Binary(da,viewer);CHKERRQ(ierr); 264*47c6ae99SBarry Smith #if defined(PETSC_HAVE_MATLAB_ENGINE) 265*47c6ae99SBarry Smith } else if (ismatlab) { 266*47c6ae99SBarry Smith ierr = DAView_Matlab(da,viewer);CHKERRQ(ierr); 267*47c6ae99SBarry Smith #endif 268*47c6ae99SBarry Smith } else { 269*47c6ae99SBarry Smith ierr = (*da->ops->view)(da,viewer);CHKERRQ(ierr); 270*47c6ae99SBarry Smith } 271*47c6ae99SBarry Smith PetscFunctionReturn(0); 272*47c6ae99SBarry Smith } 273*47c6ae99SBarry Smith 274*47c6ae99SBarry Smith #undef __FUNCT__ 275*47c6ae99SBarry Smith #define __FUNCT__ "DAGetInfo" 276*47c6ae99SBarry Smith /*@C 277*47c6ae99SBarry Smith DAGetInfo - Gets information about a given distributed array. 278*47c6ae99SBarry Smith 279*47c6ae99SBarry Smith Not Collective 280*47c6ae99SBarry Smith 281*47c6ae99SBarry Smith Input Parameter: 282*47c6ae99SBarry Smith . da - the distributed array 283*47c6ae99SBarry Smith 284*47c6ae99SBarry Smith Output Parameters: 285*47c6ae99SBarry Smith + dim - dimension of the distributed array (1, 2, or 3) 286*47c6ae99SBarry Smith . M, N, P - global dimension in each direction of the array 287*47c6ae99SBarry Smith . m, n, p - corresponding number of procs in each dimension 288*47c6ae99SBarry Smith . dof - number of degrees of freedom per node 289*47c6ae99SBarry Smith . s - stencil width 290*47c6ae99SBarry Smith . wrap - type of periodicity, one of DA_NONPERIODIC, DA_XPERIODIC, DA_YPERIODIC, 291*47c6ae99SBarry Smith DA_XYPERIODIC, DA_XYZPERIODIC, DA_XZPERIODIC, DA_YZPERIODIC,DA_ZPERIODIC 292*47c6ae99SBarry Smith - st - stencil type, either DA_STENCIL_STAR or DA_STENCIL_BOX 293*47c6ae99SBarry Smith 294*47c6ae99SBarry Smith Level: beginner 295*47c6ae99SBarry Smith 296*47c6ae99SBarry Smith Note: 297*47c6ae99SBarry Smith Use PETSC_NULL (PETSC_NULL_INTEGER in Fortran) in place of any output parameter that is not of interest. 298*47c6ae99SBarry Smith 299*47c6ae99SBarry Smith .keywords: distributed array, get, information 300*47c6ae99SBarry Smith 301*47c6ae99SBarry Smith .seealso: DAView(), DAGetCorners(), DAGetLocalInfo() 302*47c6ae99SBarry Smith @*/ 303*47c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DAGetInfo(DA da,PetscInt *dim,PetscInt *M,PetscInt *N,PetscInt *P,PetscInt *m,PetscInt *n,PetscInt *p,PetscInt *dof,PetscInt *s,DAPeriodicType *wrap,DAStencilType *st) 304*47c6ae99SBarry Smith { 305*47c6ae99SBarry Smith DM_DA *dd = (DM_DA*)da->data; 306*47c6ae99SBarry Smith 307*47c6ae99SBarry Smith PetscFunctionBegin; 308*47c6ae99SBarry Smith PetscValidHeaderSpecific(da,DM_CLASSID,1); 309*47c6ae99SBarry Smith if (dim) *dim = dd->dim; 310*47c6ae99SBarry Smith if (M) *M = dd->M; 311*47c6ae99SBarry Smith if (N) *N = dd->N; 312*47c6ae99SBarry Smith if (P) *P = dd->P; 313*47c6ae99SBarry Smith if (m) *m = dd->m; 314*47c6ae99SBarry Smith if (n) *n = dd->n; 315*47c6ae99SBarry Smith if (p) *p = dd->p; 316*47c6ae99SBarry Smith if (dof) *dof = dd->w; 317*47c6ae99SBarry Smith if (s) *s = dd->s; 318*47c6ae99SBarry Smith if (wrap) *wrap = dd->wrap; 319*47c6ae99SBarry Smith if (st) *st = dd->stencil_type; 320*47c6ae99SBarry Smith PetscFunctionReturn(0); 321*47c6ae99SBarry Smith } 322*47c6ae99SBarry Smith 323*47c6ae99SBarry Smith #undef __FUNCT__ 324*47c6ae99SBarry Smith #define __FUNCT__ "DAGetLocalInfo" 325*47c6ae99SBarry Smith /*@C 326*47c6ae99SBarry Smith DAGetLocalInfo - Gets information about a given distributed array and this processors location in it 327*47c6ae99SBarry Smith 328*47c6ae99SBarry Smith Not Collective 329*47c6ae99SBarry Smith 330*47c6ae99SBarry Smith Input Parameter: 331*47c6ae99SBarry Smith . da - the distributed array 332*47c6ae99SBarry Smith 333*47c6ae99SBarry Smith Output Parameters: 334*47c6ae99SBarry Smith . dainfo - structure containing the information 335*47c6ae99SBarry Smith 336*47c6ae99SBarry Smith Level: beginner 337*47c6ae99SBarry Smith 338*47c6ae99SBarry Smith .keywords: distributed array, get, information 339*47c6ae99SBarry Smith 340*47c6ae99SBarry Smith .seealso: DAGetInfo(), DAGetCorners() 341*47c6ae99SBarry Smith @*/ 342*47c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DAGetLocalInfo(DA da,DALocalInfo *info) 343*47c6ae99SBarry Smith { 344*47c6ae99SBarry Smith PetscInt w; 345*47c6ae99SBarry Smith DM_DA *dd = (DM_DA*)da->data; 346*47c6ae99SBarry Smith 347*47c6ae99SBarry Smith PetscFunctionBegin; 348*47c6ae99SBarry Smith PetscValidHeaderSpecific(da,DM_CLASSID,1); 349*47c6ae99SBarry Smith PetscValidPointer(info,2); 350*47c6ae99SBarry Smith info->da = da; 351*47c6ae99SBarry Smith info->dim = dd->dim; 352*47c6ae99SBarry Smith info->mx = dd->M; 353*47c6ae99SBarry Smith info->my = dd->N; 354*47c6ae99SBarry Smith info->mz = dd->P; 355*47c6ae99SBarry Smith info->dof = dd->w; 356*47c6ae99SBarry Smith info->sw = dd->s; 357*47c6ae99SBarry Smith info->pt = dd->wrap; 358*47c6ae99SBarry Smith info->st = dd->stencil_type; 359*47c6ae99SBarry Smith 360*47c6ae99SBarry Smith /* since the xs, xe ... have all been multiplied by the number of degrees 361*47c6ae99SBarry Smith of freedom per cell, w = dd->w, we divide that out before returning.*/ 362*47c6ae99SBarry Smith w = dd->w; 363*47c6ae99SBarry Smith info->xs = dd->xs/w; 364*47c6ae99SBarry Smith info->xm = (dd->xe - dd->xs)/w; 365*47c6ae99SBarry Smith /* the y and z have NOT been multiplied by w */ 366*47c6ae99SBarry Smith info->ys = dd->ys; 367*47c6ae99SBarry Smith info->ym = (dd->ye - dd->ys); 368*47c6ae99SBarry Smith info->zs = dd->zs; 369*47c6ae99SBarry Smith info->zm = (dd->ze - dd->zs); 370*47c6ae99SBarry Smith 371*47c6ae99SBarry Smith info->gxs = dd->Xs/w; 372*47c6ae99SBarry Smith info->gxm = (dd->Xe - dd->Xs)/w; 373*47c6ae99SBarry Smith /* the y and z have NOT been multiplied by w */ 374*47c6ae99SBarry Smith info->gys = dd->Ys; 375*47c6ae99SBarry Smith info->gym = (dd->Ye - dd->Ys); 376*47c6ae99SBarry Smith info->gzs = dd->Zs; 377*47c6ae99SBarry Smith info->gzm = (dd->Ze - dd->Zs); 378*47c6ae99SBarry Smith PetscFunctionReturn(0); 379*47c6ae99SBarry Smith } 380*47c6ae99SBarry Smith 381