File: | dm/impls/da/dalocal.c |
Warning: | line 335, column 9 Dereference of null pointer (loaded from variable 'cone') |
[?] Use j/k keys for keyboard navigation
1 | ||||
2 | /* | |||
3 | Code for manipulating distributed regular arrays in parallel. | |||
4 | */ | |||
5 | ||||
6 | #include <petsc/private/dmdaimpl.h> /*I "petscdmda.h" I*/ | |||
7 | #include <petscbt.h> | |||
8 | #include <petscsf.h> | |||
9 | #include <petscds.h> | |||
10 | #include <petscfe.h> | |||
11 | ||||
12 | /* | |||
13 | This allows the DMDA vectors to properly tell MATLAB their dimensions | |||
14 | */ | |||
15 | #if defined(PETSC_HAVE_MATLAB_ENGINE) | |||
16 | #include <engine.h> /* MATLAB include file */ | |||
17 | #include <mex.h> /* MATLAB include file */ | |||
18 | static PetscErrorCode VecMatlabEnginePut_DA2d(PetscObject obj,void *mengine) | |||
19 | { | |||
20 | PetscErrorCode ierr; | |||
21 | PetscInt n,m; | |||
22 | Vec vec = (Vec)obj; | |||
23 | PetscScalar *array; | |||
24 | mxArray *mat; | |||
25 | DM da; | |||
26 | ||||
27 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 27; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
28 | ierr = VecGetDM(vec, &da);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),28,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
29 | if (!da) SETERRQ(PetscObjectComm((PetscObject)vec),PETSC_ERR_ARG_WRONGSTATE,"Vector not associated with a DMDA")return PetscError(PetscObjectComm((PetscObject)vec),29,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",73 ,PETSC_ERROR_INITIAL,"Vector not associated with a DMDA"); | |||
30 | ierr = DMDAGetGhostCorners(da,0,0,0,&m,&n,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),30,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
31 | ||||
32 | ierr = VecGetArray(vec,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),32,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
33 | #if !defined(PETSC_USE_COMPLEX) | |||
34 | mat = mxCreateDoubleMatrix(m,n,mxREAL); | |||
35 | #else | |||
36 | mat = mxCreateDoubleMatrix(m,n,mxCOMPLEX); | |||
37 | #endif | |||
38 | ierr = PetscArraycpy(mxGetPr(mat),array,n*m)((sizeof(*(mxGetPr(mat))) != sizeof(*(array))) || PetscMemcpy (mxGetPr(mat),array,(n*m)*sizeof(*(mxGetPr(mat)))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),38,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
39 | ierr = PetscObjectName(obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),39,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
40 | engPutVariable((Engine*)mengine,obj->name,mat); | |||
41 | ||||
42 | ierr = VecRestoreArray(vec,&array);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),42,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
43 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
44 | } | |||
45 | #endif | |||
46 | ||||
47 | PetscErrorCode DMCreateLocalVector_DA(DM da,Vec *g) | |||
48 | { | |||
49 | PetscErrorCode ierr; | |||
50 | DM_DA *dd = (DM_DA*)da->data; | |||
51 | ||||
52 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 52; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
53 | PetscValidHeaderSpecific(da,DM_CLASSID,1)do { if (!da) return PetscError(((MPI_Comm)0x44000001),53,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",85 ,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (!PetscCheckPointer (da,PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),53 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(da))->classid != DM_CLASSID) { if ( ((PetscObject)(da))->classid == -1) return PetscError(((MPI_Comm )0x44000001),53,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),53,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); | |||
54 | PetscValidPointer(g,2)do { if (!g) return PetscError(((MPI_Comm)0x44000001),54,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",85 ,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (! PetscCheckPointer(g,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),54,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
55 | ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001),g);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),55,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
56 | ierr = VecSetSizes(*g,dd->nlocal,PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),56,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
57 | ierr = VecSetBlockSize(*g,dd->w);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),57,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
58 | ierr = VecSetType(*g,da->vectype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),58,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
59 | ierr = VecSetDM(*g, da);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),59,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
60 | #if defined(PETSC_HAVE_MATLAB_ENGINE) | |||
61 | if (dd->w == 1 && da->dim == 2) { | |||
62 | ierr = PetscObjectComposeFunction((PetscObject)*g,"PetscMatlabEnginePut_C",VecMatlabEnginePut_DA2d)PetscObjectComposeFunction_Private((PetscObject)*g,"PetscMatlabEnginePut_C" ,(PetscVoidFunction)(VecMatlabEnginePut_DA2d));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),62,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
63 | } | |||
64 | #endif | |||
65 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
66 | } | |||
67 | ||||
68 | /*@ | |||
69 | DMDAGetNumCells - Get the number of cells in the local piece of the DMDA. This includes ghost cells. | |||
70 | ||||
71 | Input Parameter: | |||
72 | . dm - The DM object | |||
73 | ||||
74 | Output Parameters: | |||
75 | + numCellsX - The number of local cells in the x-direction | |||
76 | . numCellsY - The number of local cells in the y-direction | |||
77 | . numCellsZ - The number of local cells in the z-direction | |||
78 | - numCells - The number of local cells | |||
79 | ||||
80 | Level: developer | |||
81 | ||||
82 | .seealso: DMDAGetCellPoint() | |||
83 | @*/ | |||
84 | PetscErrorCode DMDAGetNumCells(DM dm, PetscInt *numCellsX, PetscInt *numCellsY, PetscInt *numCellsZ, PetscInt *numCells) | |||
85 | { | |||
86 | DM_DA *da = (DM_DA*) dm->data; | |||
87 | const PetscInt dim = dm->dim; | |||
88 | const PetscInt mx = (da->Xe - da->Xs)/da->w, my = da->Ye - da->Ys, mz = da->Ze - da->Zs; | |||
89 | const PetscInt nC = (mx)*(dim > 1 ? (my)*(dim > 2 ? (mz) : 1) : 1); | |||
90 | ||||
91 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 91; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
92 | PetscValidHeaderSpecificType(dm, DM_CLASSID, 1,DMDA)do { PetscErrorCode __ierr; PetscBool same; do { if (!dm) return PetscError(((MPI_Comm)0x44000001),92,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),92,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(dm))->classid != DM_CLASSID) { if ( ((PetscObject)(dm))->classid == -1) return PetscError(((MPI_Comm )0x44000001),92,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),92,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); __ierr = PetscObjectTypeCompare((PetscObject )dm,"da",&same);do {if (__builtin_expect(!!(__ierr),0)) return PetscError(((MPI_Comm)0x44000001),92,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!same) return PetscError(((MPI_Comm)0x44000001),92,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"da",((PetscObject)dm)->type_name); } while (0); | |||
93 | if (numCellsX) { | |||
94 | PetscValidIntPointer(numCellsX,2)do { if (!numCellsX) return PetscError(((MPI_Comm)0x44000001) ,94,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(numCellsX,PETSC_INT)) return PetscError( ((MPI_Comm)0x44000001),94,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); | |||
95 | *numCellsX = mx; | |||
96 | } | |||
97 | if (numCellsY) { | |||
98 | PetscValidIntPointer(numCellsY,3)do { if (!numCellsY) return PetscError(((MPI_Comm)0x44000001) ,98,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(numCellsY,PETSC_INT)) return PetscError( ((MPI_Comm)0x44000001),98,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,3); } while (0); | |||
99 | *numCellsY = my; | |||
100 | } | |||
101 | if (numCellsZ) { | |||
102 | PetscValidIntPointer(numCellsZ,4)do { if (!numCellsZ) return PetscError(((MPI_Comm)0x44000001) ,102,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(numCellsZ,PETSC_INT)) return PetscError( ((MPI_Comm)0x44000001),102,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,4); } while (0); | |||
103 | *numCellsZ = mz; | |||
104 | } | |||
105 | if (numCells) { | |||
106 | PetscValidIntPointer(numCells,5)do { if (!numCells) return PetscError(((MPI_Comm)0x44000001), 106,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",5); if (!PetscCheckPointer(numCells,PETSC_INT)) return PetscError(( (MPI_Comm)0x44000001),106,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,5); } while (0); | |||
107 | *numCells = nC; | |||
108 | } | |||
109 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
110 | } | |||
111 | ||||
112 | /*@ | |||
113 | DMDAGetCellPoint - Get the DM point corresponding to the tuple (i, j, k) in the DMDA | |||
114 | ||||
115 | Input Parameters: | |||
116 | + dm - The DM object | |||
117 | - i,j,k - The global indices for the cell | |||
118 | ||||
119 | Output Parameters: | |||
120 | . point - The local DM point | |||
121 | ||||
122 | Level: developer | |||
123 | ||||
124 | .seealso: DMDAGetNumCells() | |||
125 | @*/ | |||
126 | PetscErrorCode DMDAGetCellPoint(DM dm, PetscInt i, PetscInt j, PetscInt k, PetscInt *point) | |||
127 | { | |||
128 | const PetscInt dim = dm->dim; | |||
129 | DMDALocalInfo info; | |||
130 | PetscErrorCode ierr; | |||
131 | ||||
132 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 132; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
133 | PetscValidHeaderSpecificType(dm, DM_CLASSID, 1,DMDA)do { PetscErrorCode __ierr; PetscBool same; do { if (!dm) return PetscError(((MPI_Comm)0x44000001),133,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),133,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(dm))->classid != DM_CLASSID) { if ( ((PetscObject)(dm))->classid == -1) return PetscError(((MPI_Comm )0x44000001),133,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),133,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); __ierr = PetscObjectTypeCompare((PetscObject )dm,"da",&same);do {if (__builtin_expect(!!(__ierr),0)) return PetscError(((MPI_Comm)0x44000001),133,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!same) return PetscError(((MPI_Comm)0x44000001),133,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"da",((PetscObject)dm)->type_name); } while (0); | |||
134 | PetscValidIntPointer(point,5)do { if (!point) return PetscError(((MPI_Comm)0x44000001),134 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",5); if (!PetscCheckPointer(point,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),134,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,5); } while (0); | |||
135 | ierr = DMDAGetLocalInfo(dm, &info);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),135,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
136 | if (dim > 0) {if ((i < info.gxs) || (i >= info.gxs+info.gxm)) SETERRQ3(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "X index %d not in [%d, %d)", i, info.gxs, info.gxs+info.gxm)return PetscError(((MPI_Comm)0x44000001),136,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,63,PETSC_ERROR_INITIAL,"X index %d not in [%d, %d)",i,info.gxs ,info.gxs+info.gxm);} | |||
137 | if (dim > 1) {if ((j < info.gys) || (j >= info.gys+info.gym)) SETERRQ3(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Y index %d not in [%d, %d)", j, info.gys, info.gys+info.gym)return PetscError(((MPI_Comm)0x44000001),137,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,63,PETSC_ERROR_INITIAL,"Y index %d not in [%d, %d)",j,info.gys ,info.gys+info.gym);} | |||
138 | if (dim > 2) {if ((k < info.gzs) || (k >= info.gzs+info.gzm)) SETERRQ3(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Z index %d not in [%d, %d)", k, info.gzs, info.gzs+info.gzm)return PetscError(((MPI_Comm)0x44000001),138,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,63,PETSC_ERROR_INITIAL,"Z index %d not in [%d, %d)",k,info.gzs ,info.gzs+info.gzm);} | |||
139 | *point = i + (dim > 1 ? (j + (dim > 2 ? k*info.gym : 0))*info.gxm : 0); | |||
140 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
141 | } | |||
142 | ||||
143 | PetscErrorCode DMDAGetNumVertices(DM dm, PetscInt *numVerticesX, PetscInt *numVerticesY, PetscInt *numVerticesZ, PetscInt *numVertices) | |||
144 | { | |||
145 | DM_DA *da = (DM_DA*) dm->data; | |||
146 | const PetscInt dim = dm->dim; | |||
147 | const PetscInt mx = (da->Xe - da->Xs)/da->w, my = da->Ye - da->Ys, mz = da->Ze - da->Zs; | |||
148 | const PetscInt nVx = mx+1; | |||
149 | const PetscInt nVy = dim > 1 ? (my+1) : 1; | |||
150 | const PetscInt nVz = dim > 2 ? (mz+1) : 1; | |||
151 | const PetscInt nV = nVx*nVy*nVz; | |||
152 | ||||
153 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 153; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
154 | if (numVerticesX) { | |||
155 | PetscValidIntPointer(numVerticesX,2)do { if (!numVerticesX) return PetscError(((MPI_Comm)0x44000001 ),155,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(numVerticesX,PETSC_INT)) return PetscError (((MPI_Comm)0x44000001),155,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); | |||
156 | *numVerticesX = nVx; | |||
157 | } | |||
158 | if (numVerticesY) { | |||
159 | PetscValidIntPointer(numVerticesY,3)do { if (!numVerticesY) return PetscError(((MPI_Comm)0x44000001 ),159,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(numVerticesY,PETSC_INT)) return PetscError (((MPI_Comm)0x44000001),159,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,3); } while (0); | |||
160 | *numVerticesY = nVy; | |||
161 | } | |||
162 | if (numVerticesZ) { | |||
163 | PetscValidIntPointer(numVerticesZ,4)do { if (!numVerticesZ) return PetscError(((MPI_Comm)0x44000001 ),163,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(numVerticesZ,PETSC_INT)) return PetscError (((MPI_Comm)0x44000001),163,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,4); } while (0); | |||
164 | *numVerticesZ = nVz; | |||
165 | } | |||
166 | if (numVertices) { | |||
167 | PetscValidIntPointer(numVertices,5)do { if (!numVertices) return PetscError(((MPI_Comm)0x44000001 ),167,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",5); if (!PetscCheckPointer(numVertices,PETSC_INT)) return PetscError (((MPI_Comm)0x44000001),167,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,5); } while (0); | |||
168 | *numVertices = nV; | |||
169 | } | |||
170 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
171 | } | |||
172 | ||||
173 | PetscErrorCode DMDAGetNumFaces(DM dm, PetscInt *numXFacesX, PetscInt *numXFaces, PetscInt *numYFacesY, PetscInt *numYFaces, PetscInt *numZFacesZ, PetscInt *numZFaces) | |||
174 | { | |||
175 | DM_DA *da = (DM_DA*) dm->data; | |||
176 | const PetscInt dim = dm->dim; | |||
177 | const PetscInt mx = (da->Xe - da->Xs)/da->w, my = da->Ye - da->Ys, mz = da->Ze - da->Zs; | |||
178 | const PetscInt nxF = (dim > 1 ? (my)*(dim > 2 ? (mz) : 1) : 1); | |||
179 | const PetscInt nXF = (mx+1)*nxF; | |||
180 | const PetscInt nyF = mx*(dim > 2 ? mz : 1); | |||
181 | const PetscInt nYF = dim > 1 ? (my+1)*nyF : 0; | |||
182 | const PetscInt nzF = mx*(dim > 1 ? my : 0); | |||
183 | const PetscInt nZF = dim > 2 ? (mz+1)*nzF : 0; | |||
184 | ||||
185 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 185; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
186 | if (numXFacesX) { | |||
187 | PetscValidIntPointer(numXFacesX,2)do { if (!numXFacesX) return PetscError(((MPI_Comm)0x44000001 ),187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(numXFacesX,PETSC_INT)) return PetscError (((MPI_Comm)0x44000001),187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); | |||
188 | *numXFacesX = nxF; | |||
189 | } | |||
190 | if (numXFaces) { | |||
191 | PetscValidIntPointer(numXFaces,3)do { if (!numXFaces) return PetscError(((MPI_Comm)0x44000001) ,191,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(numXFaces,PETSC_INT)) return PetscError( ((MPI_Comm)0x44000001),191,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,3); } while (0); | |||
192 | *numXFaces = nXF; | |||
193 | } | |||
194 | if (numYFacesY) { | |||
195 | PetscValidIntPointer(numYFacesY,4)do { if (!numYFacesY) return PetscError(((MPI_Comm)0x44000001 ),195,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(numYFacesY,PETSC_INT)) return PetscError (((MPI_Comm)0x44000001),195,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,4); } while (0); | |||
196 | *numYFacesY = nyF; | |||
197 | } | |||
198 | if (numYFaces) { | |||
199 | PetscValidIntPointer(numYFaces,5)do { if (!numYFaces) return PetscError(((MPI_Comm)0x44000001) ,199,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",5); if (!PetscCheckPointer(numYFaces,PETSC_INT)) return PetscError( ((MPI_Comm)0x44000001),199,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,5); } while (0); | |||
200 | *numYFaces = nYF; | |||
201 | } | |||
202 | if (numZFacesZ) { | |||
203 | PetscValidIntPointer(numZFacesZ,6)do { if (!numZFacesZ) return PetscError(((MPI_Comm)0x44000001 ),203,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",6); if (!PetscCheckPointer(numZFacesZ,PETSC_INT)) return PetscError (((MPI_Comm)0x44000001),203,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,6); } while (0); | |||
204 | *numZFacesZ = nzF; | |||
205 | } | |||
206 | if (numZFaces) { | |||
207 | PetscValidIntPointer(numZFaces,7)do { if (!numZFaces) return PetscError(((MPI_Comm)0x44000001) ,207,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",7); if (!PetscCheckPointer(numZFaces,PETSC_INT)) return PetscError( ((MPI_Comm)0x44000001),207,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,7); } while (0); | |||
208 | *numZFaces = nZF; | |||
209 | } | |||
210 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
211 | } | |||
212 | ||||
213 | PetscErrorCode DMDAGetHeightStratum(DM dm, PetscInt height, PetscInt *pStart, PetscInt *pEnd) | |||
214 | { | |||
215 | const PetscInt dim = dm->dim; | |||
216 | PetscInt nC, nV, nXF, nYF, nZF; | |||
217 | PetscErrorCode ierr; | |||
218 | ||||
219 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 219; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
220 | if (pStart) PetscValidIntPointer(pStart,3)do { if (!pStart) return PetscError(((MPI_Comm)0x44000001),220 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(pStart,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),220,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,3); } while (0); | |||
221 | if (pEnd) PetscValidIntPointer(pEnd,4)do { if (!pEnd) return PetscError(((MPI_Comm)0x44000001),221, __func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(pEnd,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),221,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,4); } while (0); | |||
222 | ierr = DMDAGetNumCells(dm, NULL((void*)0), NULL((void*)0), NULL((void*)0), &nC);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),222,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
223 | ierr = DMDAGetNumVertices(dm, NULL((void*)0), NULL((void*)0), NULL((void*)0), &nV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),223,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
224 | ierr = DMDAGetNumFaces(dm, NULL((void*)0), &nXF, NULL((void*)0), &nYF, NULL((void*)0), &nZF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),224,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
225 | if (height == 0) { | |||
226 | /* Cells */ | |||
227 | if (pStart) *pStart = 0; | |||
228 | if (pEnd) *pEnd = nC; | |||
229 | } else if (height == 1) { | |||
230 | /* Faces */ | |||
231 | if (pStart) *pStart = nC+nV; | |||
232 | if (pEnd) *pEnd = nC+nV+nXF+nYF+nZF; | |||
233 | } else if (height == dim) { | |||
234 | /* Vertices */ | |||
235 | if (pStart) *pStart = nC; | |||
236 | if (pEnd) *pEnd = nC+nV; | |||
237 | } else if (height < 0) { | |||
238 | /* All points */ | |||
239 | if (pStart) *pStart = 0; | |||
240 | if (pEnd) *pEnd = nC+nV+nXF+nYF+nZF; | |||
241 | } else SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "No points of height %d in the DA", height)return PetscError(PetscObjectComm((PetscObject)dm),241,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",63 ,PETSC_ERROR_INITIAL,"No points of height %d in the DA",height ); | |||
242 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
243 | } | |||
244 | ||||
245 | PetscErrorCode DMDAGetDepthStratum(DM dm, PetscInt depth, PetscInt *pStart, PetscInt *pEnd) | |||
246 | { | |||
247 | const PetscInt dim = dm->dim; | |||
248 | PetscInt nC, nV, nXF, nYF, nZF; | |||
249 | PetscErrorCode ierr; | |||
250 | ||||
251 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 251; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
252 | if (pStart) PetscValidIntPointer(pStart,3)do { if (!pStart) return PetscError(((MPI_Comm)0x44000001),252 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(pStart,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),252,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,3); } while (0); | |||
253 | if (pEnd) PetscValidIntPointer(pEnd,4)do { if (!pEnd) return PetscError(((MPI_Comm)0x44000001),253, __func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if (!PetscCheckPointer(pEnd,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),253,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,4); } while (0); | |||
254 | ierr = DMDAGetNumCells(dm, NULL((void*)0), NULL((void*)0), NULL((void*)0), &nC);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),254,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
255 | ierr = DMDAGetNumVertices(dm, NULL((void*)0), NULL((void*)0), NULL((void*)0), &nV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),255,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
256 | ierr = DMDAGetNumFaces(dm, NULL((void*)0), &nXF, NULL((void*)0), &nYF, NULL((void*)0), &nZF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),256,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
257 | if (depth == dim) { | |||
258 | /* Cells */ | |||
259 | if (pStart) *pStart = 0; | |||
260 | if (pEnd) *pEnd = nC; | |||
261 | } else if (depth == dim-1) { | |||
262 | /* Faces */ | |||
263 | if (pStart) *pStart = nC+nV; | |||
264 | if (pEnd) *pEnd = nC+nV+nXF+nYF+nZF; | |||
265 | } else if (depth == 0) { | |||
266 | /* Vertices */ | |||
267 | if (pStart) *pStart = nC; | |||
268 | if (pEnd) *pEnd = nC+nV; | |||
269 | } else if (depth < 0) { | |||
270 | /* All points */ | |||
271 | if (pStart) *pStart = 0; | |||
272 | if (pEnd) *pEnd = nC+nV+nXF+nYF+nZF; | |||
273 | } else SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "No points of depth %d in the DA", depth)return PetscError(PetscObjectComm((PetscObject)dm),273,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",63 ,PETSC_ERROR_INITIAL,"No points of depth %d in the DA",depth); | |||
274 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
275 | } | |||
276 | ||||
277 | PetscErrorCode DMDAGetConeSize(DM dm, PetscInt p, PetscInt *coneSize) | |||
278 | { | |||
279 | const PetscInt dim = dm->dim; | |||
280 | PetscInt nC, nV, nXF, nYF, nZF; | |||
281 | PetscErrorCode ierr; | |||
282 | ||||
283 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 283; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
284 | *coneSize = 0; | |||
285 | ierr = DMDAGetNumCells(dm, NULL((void*)0), NULL((void*)0), NULL((void*)0), &nC);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),285,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
286 | ierr = DMDAGetNumVertices(dm, NULL((void*)0), NULL((void*)0), NULL((void*)0), &nV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),286,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
287 | ierr = DMDAGetNumFaces(dm, NULL((void*)0), &nXF, NULL((void*)0), &nYF, NULL((void*)0), &nZF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),287,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
288 | switch (dim) { | |||
289 | case 2: | |||
290 | if (p >= 0) { | |||
291 | if (p < nC) { | |||
292 | *coneSize = 4; | |||
293 | } else if (p < nC+nV) { | |||
294 | *coneSize = 0; | |||
295 | } else if (p < nC+nV+nXF+nYF+nZF) { | |||
296 | *coneSize = 2; | |||
297 | } else SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Point %d should be in [0, %d)", p, nC+nV+nXF+nYF+nZF)return PetscError(((MPI_Comm)0x44000001),297,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,63,PETSC_ERROR_INITIAL,"Point %d should be in [0, %d)",p,nC+ nV+nXF+nYF+nZF); | |||
298 | } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Negative point %d is invalid", p)return PetscError(((MPI_Comm)0x44000001),298,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,63,PETSC_ERROR_INITIAL,"Negative point %d is invalid",p); | |||
299 | break; | |||
300 | case 3: | |||
301 | SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP, "Too lazy to do 3D")return PetscError(((MPI_Comm)0x44000001),301,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,56,PETSC_ERROR_INITIAL,"Too lazy to do 3D"); | |||
302 | break; | |||
303 | } | |||
304 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
305 | } | |||
306 | ||||
307 | PetscErrorCode DMDAGetCone(DM dm, PetscInt p, PetscInt *cone[]) | |||
308 | { | |||
309 | const PetscInt dim = dm->dim; | |||
310 | PetscInt nCx, nCy, nCz, nC, nVx, nVy, nVz, nV, nxF, nyF, nzF, nXF, nYF, nZF; | |||
311 | PetscErrorCode ierr; | |||
312 | ||||
313 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 313; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
314 | if (!cone) {ierr = DMGetWorkArray(dm, 6, MPIU_INT((MPI_Datatype)0x4c000405), cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),314,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
| ||||
315 | ierr = DMDAGetNumCells(dm, &nCx, &nCy, &nCz, &nC);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),315,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
316 | ierr = DMDAGetNumVertices(dm, &nVx, &nVy, &nVz, &nV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),316,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
317 | ierr = DMDAGetNumFaces(dm, &nxF, &nXF, &nyF, &nYF, &nzF, &nZF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),317,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
318 | switch (dim) { | |||
319 | case 2: | |||
320 | if (p >= 0) { | |||
321 | if (p < nC) { | |||
322 | const PetscInt cy = p / nCx; | |||
323 | const PetscInt cx = p % nCx; | |||
324 | ||||
325 | (*cone)[0] = cy*nxF + cx + nC+nV; | |||
326 | (*cone)[1] = cx*nyF + cy + nyF + nC+nV+nXF; | |||
327 | (*cone)[2] = cy*nxF + cx + nxF + nC+nV; | |||
328 | (*cone)[3] = cx*nyF + cy + nC+nV+nXF; | |||
329 | SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP, "Too lazy to do cell cones")return PetscError(((MPI_Comm)0x44000001),329,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,56,PETSC_ERROR_INITIAL,"Too lazy to do cell cones"); | |||
330 | } else if (p < nC+nV) { | |||
331 | } else if (p < nC+nV+nXF) { | |||
332 | const PetscInt fy = (p - nC+nV) / nxF; | |||
333 | const PetscInt fx = (p - nC+nV) % nxF; | |||
334 | ||||
335 | (*cone)[0] = fy*nVx + fx + nC; | |||
| ||||
336 | (*cone)[1] = fy*nVx + fx + 1 + nC; | |||
337 | } else if (p < nC+nV+nXF+nYF) { | |||
338 | const PetscInt fx = (p - nC+nV+nXF) / nyF; | |||
339 | const PetscInt fy = (p - nC+nV+nXF) % nyF; | |||
340 | ||||
341 | (*cone)[0] = fy*nVx + fx + nC; | |||
342 | (*cone)[1] = fy*nVx + fx + nVx + nC; | |||
343 | } else SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Point %d should be in [0, %d)", p, nC+nV+nXF+nYF+nZF)return PetscError(((MPI_Comm)0x44000001),343,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,63,PETSC_ERROR_INITIAL,"Point %d should be in [0, %d)",p,nC+ nV+nXF+nYF+nZF); | |||
344 | } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Negative point %d is invalid", p)return PetscError(((MPI_Comm)0x44000001),344,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,63,PETSC_ERROR_INITIAL,"Negative point %d is invalid",p); | |||
345 | break; | |||
346 | case 3: | |||
347 | SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP, "Too lazy to do 3D")return PetscError(((MPI_Comm)0x44000001),347,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,56,PETSC_ERROR_INITIAL,"Too lazy to do 3D"); | |||
348 | break; | |||
349 | } | |||
350 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
351 | } | |||
352 | ||||
353 | PetscErrorCode DMDARestoreCone(DM dm, PetscInt p, PetscInt *cone[]) | |||
354 | { | |||
355 | PetscErrorCode ierr; | |||
356 | ||||
357 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 357; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
358 | ierr = DMGetWorkArray(dm, 6, MPIU_INT((MPI_Datatype)0x4c000405), cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),358,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
359 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
360 | } | |||
361 | ||||
362 | PetscErrorCode DMDASetVertexCoordinates(DM dm, PetscReal xl, PetscReal xu, PetscReal yl, PetscReal yu, PetscReal zl, PetscReal zu) | |||
363 | { | |||
364 | DM_DA *da = (DM_DA *) dm->data; | |||
365 | Vec coordinates; | |||
366 | PetscSection section; | |||
367 | PetscScalar *coords; | |||
368 | PetscReal h[3]; | |||
369 | PetscInt dim, size, M, N, P, nVx, nVy, nVz, nV, vStart, vEnd, v, i, j, k; | |||
370 | PetscErrorCode ierr; | |||
371 | ||||
372 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 372; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
373 | PetscValidHeaderSpecificType(dm, DM_CLASSID, 1,DMDA)do { PetscErrorCode __ierr; PetscBool same; do { if (!dm) return PetscError(((MPI_Comm)0x44000001),373,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),373,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(dm))->classid != DM_CLASSID) { if ( ((PetscObject)(dm))->classid == -1) return PetscError(((MPI_Comm )0x44000001),373,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),373,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); __ierr = PetscObjectTypeCompare((PetscObject )dm,"da",&same);do {if (__builtin_expect(!!(__ierr),0)) return PetscError(((MPI_Comm)0x44000001),373,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!same) return PetscError(((MPI_Comm)0x44000001),373,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"da",((PetscObject)dm)->type_name); } while (0); | |||
374 | ierr = DMDAGetInfo(dm, &dim, &M, &N, &P, 0,0,0,0,0,0,0,0,0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),374,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
375 | if (dim > 3) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_PLIB,"The following code only works for dim <= 3")return PetscError(PetscObjectComm((PetscObject)dm),375,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",77 ,PETSC_ERROR_INITIAL,"The following code only works for dim <= 3" ); | |||
376 | h[0] = (xu - xl)/M; | |||
377 | h[1] = (yu - yl)/N; | |||
378 | h[2] = (zu - zl)/P; | |||
379 | ierr = DMDAGetDepthStratum(dm, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),379,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
380 | ierr = DMDAGetNumVertices(dm, &nVx, &nVy, &nVz, &nV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),380,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
381 | ierr = PetscSectionCreate(PetscObjectComm((PetscObject) dm), §ion);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),381,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
382 | ierr = PetscSectionSetNumFields(section, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),382,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
383 | ierr = PetscSectionSetFieldComponents(section, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),383,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
384 | ierr = PetscSectionSetChart(section, vStart, vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),384,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
385 | for (v = vStart; v < vEnd; ++v) { | |||
386 | ierr = PetscSectionSetDof(section, v, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),386,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
387 | } | |||
388 | ierr = PetscSectionSetUp(section);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),388,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
389 | ierr = PetscSectionGetStorageSize(section, &size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),389,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
390 | ierr = VecCreateSeq(PETSC_COMM_SELF((MPI_Comm)0x44000001), size, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),390,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
391 | ierr = PetscObjectSetName((PetscObject)coordinates,"coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),391,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
392 | ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),392,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
393 | for (k = 0; k < nVz; ++k) { | |||
394 | PetscInt ind[3], d, off; | |||
395 | ||||
396 | ind[0] = 0; | |||
397 | ind[1] = 0; | |||
398 | ind[2] = k + da->zs; | |||
399 | for (j = 0; j < nVy; ++j) { | |||
400 | ind[1] = j + da->ys; | |||
401 | for (i = 0; i < nVx; ++i) { | |||
402 | const PetscInt vertex = (k*nVy + j)*nVx + i + vStart; | |||
403 | ||||
404 | ierr = PetscSectionGetOffset(section, vertex, &off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),404,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
405 | ind[0] = i + da->xs; | |||
406 | for (d = 0; d < dim; ++d) { | |||
407 | coords[off+d] = h[d]*ind[d]; | |||
408 | } | |||
409 | } | |||
410 | } | |||
411 | } | |||
412 | ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),412,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
413 | ierr = DMSetCoordinateSection(dm, PETSC_DETERMINE-1, section);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),413,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
414 | ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),414,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
415 | ierr = PetscSectionDestroy(§ion);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),415,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
416 | ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),416,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
417 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
418 | } | |||
419 | ||||
420 | /* ------------------------------------------------------------------- */ | |||
421 | ||||
422 | /*@C | |||
423 | DMDAGetArray - Gets a work array for a DMDA | |||
424 | ||||
425 | Input Parameter: | |||
426 | + da - information about my local patch | |||
427 | - ghosted - do you want arrays for the ghosted or nonghosted patch | |||
428 | ||||
429 | Output Parameters: | |||
430 | . vptr - array data structured | |||
431 | ||||
432 | Note: The vector values are NOT initialized and may have garbage in them, so you may need | |||
433 | to zero them. | |||
434 | ||||
435 | Level: advanced | |||
436 | ||||
437 | .seealso: DMDARestoreArray() | |||
438 | ||||
439 | @*/ | |||
440 | PetscErrorCode DMDAGetArray(DM da,PetscBool ghosted,void *vptr) | |||
441 | { | |||
442 | PetscErrorCode ierr; | |||
443 | PetscInt j,i,xs,ys,xm,ym,zs,zm; | |||
444 | char *iarray_start; | |||
445 | void **iptr = (void**)vptr; | |||
446 | DM_DA *dd = (DM_DA*)da->data; | |||
447 | ||||
448 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 448; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
449 | PetscValidHeaderSpecificType(da,DM_CLASSID,1,DMDA)do { PetscErrorCode __ierr; PetscBool same; do { if (!da) return PetscError(((MPI_Comm)0x44000001),449,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(da,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),449,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(da))->classid != DM_CLASSID) { if ( ((PetscObject)(da))->classid == -1) return PetscError(((MPI_Comm )0x44000001),449,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),449,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); __ierr = PetscObjectTypeCompare((PetscObject )da,"da",&same);do {if (__builtin_expect(!!(__ierr),0)) return PetscError(((MPI_Comm)0x44000001),449,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!same) return PetscError(((MPI_Comm)0x44000001),449,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"da",((PetscObject)da)->type_name); } while (0); | |||
450 | if (ghosted) { | |||
451 | for (i=0; i<DMDA_MAX_WORK_ARRAYS2; i++) { | |||
452 | if (dd->arrayghostedin[i]) { | |||
453 | *iptr = dd->arrayghostedin[i]; | |||
454 | iarray_start = (char*)dd->startghostedin[i]; | |||
455 | dd->arrayghostedin[i] = NULL((void*)0); | |||
456 | dd->startghostedin[i] = NULL((void*)0); | |||
457 | ||||
458 | goto done; | |||
459 | } | |||
460 | } | |||
461 | xs = dd->Xs; | |||
462 | ys = dd->Ys; | |||
463 | zs = dd->Zs; | |||
464 | xm = dd->Xe-dd->Xs; | |||
465 | ym = dd->Ye-dd->Ys; | |||
466 | zm = dd->Ze-dd->Zs; | |||
467 | } else { | |||
468 | for (i=0; i<DMDA_MAX_WORK_ARRAYS2; i++) { | |||
469 | if (dd->arrayin[i]) { | |||
470 | *iptr = dd->arrayin[i]; | |||
471 | iarray_start = (char*)dd->startin[i]; | |||
472 | dd->arrayin[i] = NULL((void*)0); | |||
473 | dd->startin[i] = NULL((void*)0); | |||
474 | ||||
475 | goto done; | |||
476 | } | |||
477 | } | |||
478 | xs = dd->xs; | |||
479 | ys = dd->ys; | |||
480 | zs = dd->zs; | |||
481 | xm = dd->xe-dd->xs; | |||
482 | ym = dd->ye-dd->ys; | |||
483 | zm = dd->ze-dd->zs; | |||
484 | } | |||
485 | ||||
486 | switch (da->dim) { | |||
487 | case 1: { | |||
488 | void *ptr; | |||
489 | ||||
490 | ierr = PetscMalloc(xm*sizeof(PetscScalar),&iarray_start)((*PetscTrMalloc)((xm*sizeof(PetscScalar)),PETSC_FALSE,490,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",(void **)(&iarray_start)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),490,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
491 | ||||
492 | ptr = (void*)(iarray_start - xs*sizeof(PetscScalar)); | |||
493 | *iptr = (void*)ptr; | |||
494 | break; | |||
495 | } | |||
496 | case 2: { | |||
497 | void **ptr; | |||
498 | ||||
499 | ierr = PetscMalloc((ym+1)*sizeof(void*)+xm*ym*sizeof(PetscScalar),&iarray_start)((*PetscTrMalloc)(((ym+1)*sizeof(void*)+xm*ym*sizeof(PetscScalar )),PETSC_FALSE,499,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,(void**)(&iarray_start)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),499,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
500 | ||||
501 | ptr = (void**)(iarray_start + xm*ym*sizeof(PetscScalar) - ys*sizeof(void*)); | |||
502 | for (j=ys; j<ys+ym; j++) ptr[j] = iarray_start + sizeof(PetscScalar)*(xm*(j-ys) - xs); | |||
503 | *iptr = (void*)ptr; | |||
504 | break; | |||
505 | } | |||
506 | case 3: { | |||
507 | void ***ptr,**bptr; | |||
508 | ||||
509 | ierr = PetscMalloc((zm+1)*sizeof(void**)+(ym*zm+1)*sizeof(void*)+xm*ym*zm*sizeof(PetscScalar),&iarray_start)((*PetscTrMalloc)(((zm+1)*sizeof(void**)+(ym*zm+1)*sizeof(void *)+xm*ym*zm*sizeof(PetscScalar)),PETSC_FALSE,509,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,(void**)(&iarray_start)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),509,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
510 | ||||
511 | ptr = (void***)(iarray_start + xm*ym*zm*sizeof(PetscScalar) - zs*sizeof(void*)); | |||
512 | bptr = (void**)(iarray_start + xm*ym*zm*sizeof(PetscScalar) + zm*sizeof(void**)); | |||
513 | for (i=zs; i<zs+zm; i++) ptr[i] = bptr + ((i-zs)*ym - ys); | |||
514 | for (i=zs; i<zs+zm; i++) { | |||
515 | for (j=ys; j<ys+ym; j++) { | |||
516 | ptr[i][j] = iarray_start + sizeof(PetscScalar)*(xm*ym*(i-zs) + xm*(j-ys) - xs); | |||
517 | } | |||
518 | } | |||
519 | *iptr = (void*)ptr; | |||
520 | break; | |||
521 | } | |||
522 | default: | |||
523 | SETERRQ1(PetscObjectComm((PetscObject)da),PETSC_ERR_SUP,"Dimension %D not supported",da->dim)return PetscError(PetscObjectComm((PetscObject)da),523,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",56 ,PETSC_ERROR_INITIAL,"Dimension %D not supported",da->dim); | |||
524 | } | |||
525 | ||||
526 | done: | |||
527 | /* add arrays to the checked out list */ | |||
528 | if (ghosted) { | |||
529 | for (i=0; i<DMDA_MAX_WORK_ARRAYS2; i++) { | |||
530 | if (!dd->arrayghostedout[i]) { | |||
531 | dd->arrayghostedout[i] = *iptr; | |||
532 | dd->startghostedout[i] = iarray_start; | |||
533 | break; | |||
534 | } | |||
535 | } | |||
536 | } else { | |||
537 | for (i=0; i<DMDA_MAX_WORK_ARRAYS2; i++) { | |||
538 | if (!dd->arrayout[i]) { | |||
539 | dd->arrayout[i] = *iptr; | |||
540 | dd->startout[i] = iarray_start; | |||
541 | break; | |||
542 | } | |||
543 | } | |||
544 | } | |||
545 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
546 | } | |||
547 | ||||
548 | /*@C | |||
549 | DMDARestoreArray - Restores an array of derivative types for a DMDA | |||
550 | ||||
551 | Input Parameter: | |||
552 | + da - information about my local patch | |||
553 | . ghosted - do you want arrays for the ghosted or nonghosted patch | |||
554 | - vptr - array data structured | |||
555 | ||||
556 | Level: advanced | |||
557 | ||||
558 | .seealso: DMDAGetArray() | |||
559 | ||||
560 | @*/ | |||
561 | PetscErrorCode DMDARestoreArray(DM da,PetscBool ghosted,void *vptr) | |||
562 | { | |||
563 | PetscInt i; | |||
564 | void **iptr = (void**)vptr,*iarray_start = 0; | |||
565 | DM_DA *dd = (DM_DA*)da->data; | |||
566 | ||||
567 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c"; petscstack->line[petscstack->currentsize] = 567; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
568 | PetscValidHeaderSpecificType(da,DM_CLASSID,1,DMDA)do { PetscErrorCode __ierr; PetscBool same; do { if (!da) return PetscError(((MPI_Comm)0x44000001),568,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(da,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),568,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(da))->classid != DM_CLASSID) { if ( ((PetscObject)(da))->classid == -1) return PetscError(((MPI_Comm )0x44000001),568,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),568,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); __ierr = PetscObjectTypeCompare((PetscObject )da,"da",&same);do {if (__builtin_expect(!!(__ierr),0)) return PetscError(((MPI_Comm)0x44000001),568,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!same) return PetscError(((MPI_Comm)0x44000001),568,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/da/dalocal.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"da",((PetscObject)da)->type_name); } while (0); | |||
569 | if (ghosted) { | |||
570 | for (i=0; i<DMDA_MAX_WORK_ARRAYS2; i++) { | |||
571 | if (dd->arrayghostedout[i] == *iptr) { | |||
572 | iarray_start = dd->startghostedout[i]; | |||
573 | dd->arrayghostedout[i] = NULL((void*)0); | |||
574 | dd->startghostedout[i] = NULL((void*)0); | |||
575 | break; | |||
576 | } | |||
577 | } | |||
578 | for (i=0; i<DMDA_MAX_WORK_ARRAYS2; i++) { | |||
579 | if (!dd->arrayghostedin[i]) { | |||
580 | dd->arrayghostedin[i] = *iptr; | |||
581 | dd->startghostedin[i] = iarray_start; | |||
582 | break; | |||
583 | } | |||
584 | } | |||
585 | } else { | |||
586 | for (i=0; i<DMDA_MAX_WORK_ARRAYS2; i++) { | |||
587 | if (dd->arrayout[i] == *iptr) { | |||
588 | iarray_start = dd->startout[i]; | |||
589 | dd->arrayout[i] = NULL((void*)0); | |||
590 | dd->startout[i] = NULL((void*)0); | |||
591 | break; | |||
592 | } | |||
593 | } | |||
594 | for (i=0; i<DMDA_MAX_WORK_ARRAYS2; i++) { | |||
595 | if (!dd->arrayin[i]) { | |||
596 | dd->arrayin[i] = *iptr; | |||
597 | dd->startin[i] = iarray_start; | |||
598 | break; | |||
599 | } | |||
600 | } | |||
601 | } | |||
602 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
603 | } | |||
604 |