Actual source code: dmimpl.h

petsc-master 2019-11-20
Report Typos and Errors


  3: #if !defined(_DMIMPL_H)
  4: #define _DMIMPL_H

  6:  #include <petscdm.h>
  7:  #include <petsc/private/petscimpl.h>
  8:  #include <petsc/private/petscdsimpl.h>
  9:  #include <petsc/private/sectionimpl.h>

 11: PETSC_EXTERN PetscBool DMRegisterAllCalled;
 12: PETSC_EXTERN PetscErrorCode DMRegisterAll(void);
 13: typedef PetscErrorCode (*NullSpaceFunc)(DM dm, PetscInt field, MatNullSpace *nullSpace);

 15: typedef struct _DMOps *DMOps;
 16: struct _DMOps {
 17:   PetscErrorCode (*view)(DM,PetscViewer);
 18:   PetscErrorCode (*load)(DM,PetscViewer);
 19:   PetscErrorCode (*clone)(DM,DM*);
 20:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,DM);
 21:   PetscErrorCode (*setup)(DM);
 22:   PetscErrorCode (*createlocalsection)(DM);
 23:   PetscErrorCode (*createdefaultconstraints)(DM);
 24:   PetscErrorCode (*createglobalvector)(DM,Vec*);
 25:   PetscErrorCode (*createlocalvector)(DM,Vec*);
 26:   PetscErrorCode (*getlocaltoglobalmapping)(DM);
 27:   PetscErrorCode (*createfieldis)(DM,PetscInt*,char***,IS**);
 28:   PetscErrorCode (*createcoordinatedm)(DM,DM*);
 29:   PetscErrorCode (*createcoordinatefield)(DM,DMField*);

 31:   PetscErrorCode (*getcoloring)(DM,ISColoringType,ISColoring*);
 32:   PetscErrorCode (*creatematrix)(DM, Mat*);
 33:   PetscErrorCode (*createinterpolation)(DM,DM,Mat*,Vec*);
 34:   PetscErrorCode (*createrestriction)(DM,DM,Mat*);
 35:   PetscErrorCode (*createmassmatrix)(DM,DM,Mat*);
 36:   PetscErrorCode (*hascreateinjection)(DM,PetscBool*);
 37:   PetscErrorCode (*createinjection)(DM,DM,Mat*);

 39:   PetscErrorCode (*refine)(DM,MPI_Comm,DM*);
 40:   PetscErrorCode (*coarsen)(DM,MPI_Comm,DM*);
 41:   PetscErrorCode (*refinehierarchy)(DM,PetscInt,DM*);
 42:   PetscErrorCode (*coarsenhierarchy)(DM,PetscInt,DM*);
 43:   PetscErrorCode (*adaptlabel)(DM,DMLabel,DM*);
 44:   PetscErrorCode (*adaptmetric)(DM,Vec,DMLabel,DM*);

 46:   PetscErrorCode (*globaltolocalbegin)(DM,Vec,InsertMode,Vec);
 47:   PetscErrorCode (*globaltolocalend)(DM,Vec,InsertMode,Vec);
 48:   PetscErrorCode (*localtoglobalbegin)(DM,Vec,InsertMode,Vec);
 49:   PetscErrorCode (*localtoglobalend)(DM,Vec,InsertMode,Vec);
 50:   PetscErrorCode (*localtolocalbegin)(DM,Vec,InsertMode,Vec);
 51:   PetscErrorCode (*localtolocalend)(DM,Vec,InsertMode,Vec);

 53:   PetscErrorCode (*destroy)(DM);

 55:   PetscErrorCode (*computevariablebounds)(DM,Vec,Vec);

 57:   PetscErrorCode (*createsubdm)(DM,PetscInt,const PetscInt*,IS*,DM*);
 58:   PetscErrorCode (*createsuperdm)(DM*,PetscInt,IS**,DM*);
 59:   PetscErrorCode (*createfielddecomposition)(DM,PetscInt*,char***,IS**,DM**);
 60:   PetscErrorCode (*createdomaindecomposition)(DM,PetscInt*,char***,IS**,IS**,DM**);
 61:   PetscErrorCode (*createddscatters)(DM,PetscInt,DM*,VecScatter**,VecScatter**,VecScatter**);

 63:   PetscErrorCode (*getdimpoints)(DM,PetscInt,PetscInt*,PetscInt*);
 64:   PetscErrorCode (*locatepoints)(DM,Vec,DMPointLocationType,PetscSF);
 65:   PetscErrorCode (*getneighbors)(DM,PetscInt*,const PetscMPIInt**);
 66:   PetscErrorCode (*getboundingbox)(DM,PetscReal*,PetscReal*);
 67:   PetscErrorCode (*getlocalboundingbox)(DM,PetscReal*,PetscReal*);
 68:   PetscErrorCode (*locatepointssubdomain)(DM,Vec,PetscMPIInt**);

 70:   PetscErrorCode (*projectfunctionlocal)(DM,PetscReal,PetscErrorCode(**)(PetscInt,PetscReal,const PetscReal[],PetscInt,PetscScalar *,void *),void **,InsertMode,Vec);
 71:   PetscErrorCode (*projectfunctionlabellocal)(DM,PetscReal,DMLabel,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscErrorCode(**)(PetscInt,PetscReal,const PetscReal[],PetscInt,PetscScalar *,void *),void **,InsertMode,Vec);
 72:   PetscErrorCode (*projectfieldlocal)(DM,PetscReal,Vec,void(**)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),InsertMode,Vec);
 73:   PetscErrorCode (*projectfieldlabellocal)(DM,PetscReal,DMLabel,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Vec,void(**)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),InsertMode,Vec);
 74:   PetscErrorCode (*computel2diff)(DM,PetscReal,PetscErrorCode(**)(PetscInt, PetscReal,const PetscReal [], PetscInt, PetscScalar *, void *), void **, Vec, PetscReal *);
 75:   PetscErrorCode (*computel2gradientdiff)(DM,PetscReal,PetscErrorCode(**)(PetscInt,PetscReal,const PetscReal [],const PetscReal[],PetscInt, PetscScalar *,void *),void **,Vec,const PetscReal[],PetscReal *);
 76:   PetscErrorCode (*computel2fielddiff)(DM,PetscReal,PetscErrorCode(**)(PetscInt, PetscReal,const PetscReal [], PetscInt, PetscScalar *, void *), void **, Vec, PetscReal *);

 78:   PetscErrorCode (*getcompatibility)(DM,DM,PetscBool*,PetscBool*);
 79: };

 81: PETSC_EXTERN PetscErrorCode DMLocalizeCoordinate_Internal(DM, PetscInt, const PetscScalar[], const PetscScalar[], PetscScalar[]);
 82: PETSC_EXTERN PetscErrorCode DMLocalizeCoordinateReal_Internal(DM, PetscInt, const PetscReal[], const PetscReal[], PetscReal[]);
 83: PETSC_EXTERN PetscErrorCode DMLocalizeAddCoordinate_Internal(DM, PetscInt, const PetscScalar[], const PetscScalar[], PetscScalar[]);

 85: typedef struct _DMCoarsenHookLink *DMCoarsenHookLink;
 86: struct _DMCoarsenHookLink {
 87:   PetscErrorCode (*coarsenhook)(DM,DM,void*);              /* Run once, when coarse DM is created */
 88:   PetscErrorCode (*restricthook)(DM,Mat,Vec,Mat,DM,void*); /* Run each time a new problem is restricted to a coarse grid */
 89:   void *ctx;
 90:   DMCoarsenHookLink next;
 91: };

 93: typedef struct _DMRefineHookLink *DMRefineHookLink;
 94: struct _DMRefineHookLink {
 95:   PetscErrorCode (*refinehook)(DM,DM,void*);     /* Run once, when a fine DM is created */
 96:   PetscErrorCode (*interphook)(DM,Mat,DM,void*); /* Run each time a new problem is interpolated to a fine grid */
 97:   void *ctx;
 98:   DMRefineHookLink next;
 99: };

101: typedef struct _DMSubDomainHookLink *DMSubDomainHookLink;
102: struct _DMSubDomainHookLink {
103:   PetscErrorCode (*ddhook)(DM,DM,void*);
104:   PetscErrorCode (*restricthook)(DM,VecScatter,VecScatter,DM,void*);
105:   void *ctx;
106:   DMSubDomainHookLink next;
107: };

109: typedef struct _DMGlobalToLocalHookLink *DMGlobalToLocalHookLink;
110: struct _DMGlobalToLocalHookLink {
111:   PetscErrorCode (*beginhook)(DM,Vec,InsertMode,Vec,void*);
112:   PetscErrorCode (*endhook)(DM,Vec,InsertMode,Vec,void*);
113:   void *ctx;
114:   DMGlobalToLocalHookLink next;
115: };

117: typedef struct _DMLocalToGlobalHookLink *DMLocalToGlobalHookLink;
118: struct _DMLocalToGlobalHookLink {
119:   PetscErrorCode (*beginhook)(DM,Vec,InsertMode,Vec,void*);
120:   PetscErrorCode (*endhook)(DM,Vec,InsertMode,Vec,void*);
121:   void *ctx;
122:   DMLocalToGlobalHookLink next;
123: };

125: typedef enum {DMVEC_STATUS_IN,DMVEC_STATUS_OUT} DMVecStatus;
126: typedef struct _DMNamedVecLink *DMNamedVecLink;
127: struct _DMNamedVecLink {
128:   Vec X;
129:   char *name;
130:   DMVecStatus status;
131:   DMNamedVecLink next;
132: };

134: typedef struct _DMWorkLink *DMWorkLink;
135: struct _DMWorkLink {
136:   size_t     bytes;
137:   void       *mem;
138:   DMWorkLink next;
139: };

141: #define DM_MAX_WORK_VECTORS 100 /* work vectors available to users  via DMGetGlobalVector(), DMGetLocalVector() */

143: struct _n_DMLabelLink {
144:   DMLabel              label;
145:   PetscBool            output;
146:   struct _n_DMLabelLink *next;
147: };
148: typedef struct _n_DMLabelLink *DMLabelLink;

150: typedef struct _n_Boundary *DMBoundary;

152: struct _n_Boundary {
153:   DSBoundary  dsboundary;
154:   DMLabel     label;
155:   DMBoundary  next;
156: };

158: typedef struct _n_Field {
159:   PetscObject disc;         /* Field discretization, or a PetscContainer with the field name */
160:   DMLabel     label;        /* Label defining the domain of definition of the field */
161:   PetscBool   adjacency[2]; /* Flags for defining variable influence (adjacency) for each field [use cone() or support() first, use the transitive closure] */
162: } RegionField;

164: typedef struct _n_Space {
165:   PetscDS ds;     /* Approximation space in this domain */
166:   DMLabel label;  /* Label defining the domain of definition of the discretization */
167:   IS      fields; /* Map from DS field numbers to original field numbers in the DM */
168: } DMSpace;

170: PETSC_INTERN PetscErrorCode DMDestroyLabelLinkList_Internal(DM);

172: struct _p_DM {
173:   PETSCHEADER(struct _DMOps);
174:   Vec                     localin[DM_MAX_WORK_VECTORS],localout[DM_MAX_WORK_VECTORS];
175:   Vec                     globalin[DM_MAX_WORK_VECTORS],globalout[DM_MAX_WORK_VECTORS];
176:   DMNamedVecLink          namedglobal;
177:   DMNamedVecLink          namedlocal;
178:   DMWorkLink              workin,workout;
179:   DMLabelLink             labels;            /* Linked list of labels */
180:   DMLabel                 depthLabel;        /* Optimized access to depth label */
181:   void                    *ctx;    /* a user context */
182:   PetscErrorCode          (*ctxdestroy)(void**);
183:   Vec                     x;       /* location at which the functions/Jacobian are computed */
184:   ISColoringType          coloringtype;
185:   MatFDColoring           fd;
186:   VecType                 vectype;  /* type of vector created with DMCreateLocalVector() and DMCreateGlobalVector() */
187:   MatType                 mattype;  /* type of matrix created with DMCreateMatrix() */
188:   PetscInt                bs;
189:   ISLocalToGlobalMapping  ltogmap;
190:   PetscBool               prealloc_only; /* Flag indicating the DMCreateMatrix() should only preallocate, not fill the matrix */
191:   PetscBool               structure_only; /* Flag indicating the DMCreateMatrix() create matrix structure without values */
192:   PetscInt                levelup,leveldown;  /* if the DM has been obtained by refining (or coarsening) this indicates how many times that process has been used to generate this DM */
193:   PetscBool               setupcalled;        /* Indicates that the DM has been set up, methods that modify a DM such that a fresh setup is required should reset this flag */
194:   PetscBool               setfromoptionscalled;
195:   void                    *data;
196:   /* Hierarchy / Submeshes */
197:   DM                      coarseMesh;
198:   DM                      fineMesh;
199:   DMCoarsenHookLink       coarsenhook; /* For transfering auxiliary problem data to coarser grids */
200:   DMRefineHookLink        refinehook;
201:   DMSubDomainHookLink     subdomainhook;
202:   DMGlobalToLocalHookLink gtolhook;
203:   DMLocalToGlobalHookLink ltoghook;
204:   /* Topology */
205:   PetscInt                dim;                  /* The topological dimension */
206:   /* Flexible communication */
207:   PetscSF                 sfMigration;          /* SF for point distribution created during distribution */
208:   PetscSF                 sf;                   /* SF for parallel point overlap */
209:   PetscSF                 sectionSF;            /* SF for parallel dof overlap using section */
210:   PetscSF                 sfNatural;            /* SF mapping to the "natural" ordering */
211:   PetscBool               useNatural;           /* Create the natural SF */
212:   /* Allows a non-standard data layout */
213:   PetscBool               adjacency[2];         /* [use cone() or support() first, use the transitive closure] */
214:   PetscSection            localSection;         /* Layout for local vectors */
215:   PetscSection            globalSection;        /* Layout for global vectors */
216:   PetscLayout             map;
217:   /* Constraints */
218:   PetscSection            defaultConstraintSection;
219:   Mat                     defaultConstraintMat;
220:   /* Basis transformation */
221:   DM                      transformDM;          /* Layout for basis transformation */
222:   Vec                     transform;            /* Basis transformation matrices */
223:   void                   *transformCtx;         /* Basis transformation context */
224:   PetscErrorCode        (*transformSetUp)(DM, void *);
225:   PetscErrorCode        (*transformDestroy)(DM, void *);
226:   PetscErrorCode        (*transformGetMatrix)(DM, const PetscReal[], PetscBool, const PetscScalar **, void *);
227:   /* Coordinates */
228:   PetscInt                dimEmbed;             /* The dimension of the embedding space */
229:   DM                      coordinateDM;         /* Layout for coordinates */
230:   Vec                     coordinates;          /* Coordinate values in global vector */
231:   Vec                     coordinatesLocal;     /* Coordinate values in local  vector */
232:   PetscBool               periodic;             /* Is the DM periodic? */
233:   DMField                 coordinateField;      /* Coordinates as an abstract field */
234:   PetscReal              *L, *maxCell;          /* Size of periodic box and max cell size for determining periodicity */
235:   DMBoundaryType         *bdtype;               /* Indicates type of topological boundary */
236:   /* Null spaces -- of course I should make this have a variable number of fields */
237:   /*   I now believe this might not be the right way: see below */
238:   NullSpaceFunc           nullspaceConstructors[10];
239:   NullSpaceFunc           nearnullspaceConstructors[10];
240:   /* Fields are represented by objects */
241:   PetscInt                Nf;                   /* Number of fields defined on the total domain */
242:   RegionField            *fields;               /* Array of discretization fields with regions of validity */
243:   DMBoundary              boundary;             /* List of boundary conditions */
244:   PetscInt                Nds;                  /* Number of discrete systems defined on the total domain */
245:   DMSpace                *probs;                /* Array of discrete systems */
246:   /* Output structures */
247:   DM                      dmBC;                 /* The DM with boundary conditions in the global DM */
248:   PetscInt                outputSequenceNum;    /* The current sequence number for output */
249:   PetscReal               outputSequenceVal;    /* The current sequence value for output */

251:   PetscObject             dmksp,dmsnes,dmts;
252: };

254: PETSC_EXTERN PetscLogEvent DM_Convert;
255: PETSC_EXTERN PetscLogEvent DM_GlobalToLocal;
256: PETSC_EXTERN PetscLogEvent DM_LocalToGlobal;
257: PETSC_EXTERN PetscLogEvent DM_LocatePoints;
258: PETSC_EXTERN PetscLogEvent DM_Coarsen;
259: PETSC_EXTERN PetscLogEvent DM_Refine;
260: PETSC_EXTERN PetscLogEvent DM_CreateInterpolation;
261: PETSC_EXTERN PetscLogEvent DM_CreateRestriction;
262: PETSC_EXTERN PetscLogEvent DM_CreateInjection;
263: PETSC_EXTERN PetscLogEvent DM_CreateMatrix;

265: PETSC_EXTERN PetscErrorCode DMCreateGlobalVector_Section_Private(DM,Vec*);
266: PETSC_EXTERN PetscErrorCode DMCreateLocalVector_Section_Private(DM,Vec*);

268: PETSC_EXTERN PetscErrorCode DMView_GLVis(DM,PetscViewer,PetscErrorCode(*)(DM,PetscViewer));

270: /*

272:           Composite Vectors

274:       Single global representation
275:       Individual global representations
276:       Single local representation
277:       Individual local representations

279:       Subsets of individual as a single????? Do we handle this by having DMComposite inside composite??????

281:        DM da_u, da_v, da_p

283:        DM dm_velocities

285:        DM dm

287:        DMDACreate(,&da_u);
288:        DMDACreate(,&da_v);
289:        DMCompositeCreate(,&dm_velocities);
290:        DMCompositeAddDM(dm_velocities,(DM)du);
291:        DMCompositeAddDM(dm_velocities,(DM)dv);

293:        DMDACreate(,&da_p);
294:        DMCompositeCreate(,&dm_velocities);
295:        DMCompositeAddDM(dm,(DM)dm_velocities);
296:        DMCompositeAddDM(dm,(DM)dm_p);


299:     Access parts of composite vectors (Composite only)
300:     ---------------------------------
301:       DMCompositeGetAccess  - access the global vector as subvectors and array (for redundant arrays)
302:       ADD for local vector -

304:     Element access
305:     --------------
306:       From global vectors
307:          -DAVecGetArray   - for DMDA
308:          -VecGetArray - for DMSliced
309:          ADD for DMComposite???  maybe

311:       From individual vector
312:           -DAVecGetArray - for DMDA
313:           -VecGetArray -for sliced
314:          ADD for DMComposite??? maybe

316:       From single local vector
317:           ADD         * single local vector as arrays?

319:    Communication
320:    -------------
321:       DMGlobalToLocal - global vector to single local vector

323:       DMCompositeScatter/Gather - direct to individual local vectors and arrays   CHANGE name closer to GlobalToLocal?

325:    Obtaining vectors
326:    -----------------
327:       DMCreateGlobal/Local
328:       DMGetGlobal/Local
329:       DMCompositeGetLocalVectors   - gives individual local work vectors and arrays


332: ?????   individual global vectors   ????

334: */

336: #if defined(PETSC_HAVE_HDF5)
337: PETSC_EXTERN PetscErrorCode DMSequenceLoad_HDF5_Internal(DM, const char *, PetscInt, PetscScalar *, PetscViewer);
338: #endif

340: PETSC_STATIC_INLINE PetscErrorCode DMGetLocalOffset_Private(DM dm, PetscInt point, PetscInt *start, PetscInt *end)
341: {
343: #if defined(PETSC_USE_DEBUG)
344:   {
345:     PetscInt       dof;
347:     *start = *end = 0; /* Silence overzealous compiler warning */
348:     if (!dm->localSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a local section, see DMSetLocalSection()");
349:     PetscSectionGetOffset(dm->localSection, point, start);
350:     PetscSectionGetDof(dm->localSection, point, &dof);
351:     *end = *start + dof;
352:   }
353: #else
354:   {
355:     const PetscSection s = dm->localSection;
356:     *start = s->atlasOff[point - s->pStart];
357:     *end   = *start + s->atlasDof[point - s->pStart];
358:   }
359: #endif
360:   return(0);
361: }

363: PETSC_STATIC_INLINE PetscErrorCode DMGetLocalFieldOffset_Private(DM dm, PetscInt point, PetscInt field, PetscInt *start, PetscInt *end)
364: {
366: #if defined(PETSC_USE_DEBUG)
367:   {
368:     PetscInt       dof;
370:     *start = *end = 0; /* Silence overzealous compiler warning */
371:     if (!dm->localSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a local section, see DMSetLocalSection()");
372:     PetscSectionGetFieldOffset(dm->localSection, point, field, start);
373:     PetscSectionGetFieldDof(dm->localSection, point, field, &dof);
374:     *end = *start + dof;
375:   }
376: #else
377:   {
378:     const PetscSection s = dm->localSection->field[field];
379:     *start = s->atlasOff[point - s->pStart];
380:     *end   = *start + s->atlasDof[point - s->pStart];
381:   }
382: #endif
383:   return(0);
384: }

386: PETSC_STATIC_INLINE PetscErrorCode DMGetGlobalOffset_Private(DM dm, PetscInt point, PetscInt *start, PetscInt *end)
387: {
389: #if defined(PETSC_USE_DEBUG)
390:   {
392:     PetscInt       dof,cdof;
393:     *start = *end = 0; /* Silence overzealous compiler warning */
394:     if (!dm->localSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a local section, see DMSetLocalSection()");
395:     if (!dm->globalSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a global section. It will be created automatically by DMGetGlobalSection()");
396:     PetscSectionGetOffset(dm->globalSection, point, start);
397:     PetscSectionGetDof(dm->globalSection, point, &dof);
398:     PetscSectionGetConstraintDof(dm->globalSection, point, &cdof);
399:     *end = *start + dof - cdof + (dof < 0 ? 1 : 0);
400:   }
401: #else
402:   {
403:     const PetscSection s    = dm->globalSection;
404:     const PetscInt     dof  = s->atlasDof[point - s->pStart];
405:     const PetscInt     cdof = s->bc ? s->bc->atlasDof[point - s->bc->pStart] : 0;
406:     *start = s->atlasOff[point - s->pStart];
407:     *end   = *start + dof - cdof + (dof < 0 ? 1 : 0);
408:   }
409: #endif
410:   return(0);
411: }

413: PETSC_STATIC_INLINE PetscErrorCode DMGetGlobalFieldOffset_Private(DM dm, PetscInt point, PetscInt field, PetscInt *start, PetscInt *end)
414: {
416: #if defined(PETSC_USE_DEBUG)
417:   {
418:     PetscInt       loff, lfoff, fdof, fcdof, ffcdof, f;
420:     *start = *end = 0; /* Silence overzealous compiler warning */
421:     if (!dm->localSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a local section, see DMSetLocalSection()");
422:     if (!dm->globalSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a global section. It will be crated automatically by DMGetGlobalSection()");
423:     PetscSectionGetOffset(dm->globalSection, point, start);
424:     PetscSectionGetOffset(dm->localSection, point, &loff);
425:     PetscSectionGetFieldOffset(dm->localSection, point, field, &lfoff);
426:     PetscSectionGetFieldDof(dm->localSection, point, field, &fdof);
427:     PetscSectionGetFieldConstraintDof(dm->localSection, point, field, &fcdof);
428:     *start = *start < 0 ? *start - (lfoff-loff) : *start + lfoff-loff;
429:     for (f = 0; f < field; ++f) {
430:       PetscSectionGetFieldConstraintDof(dm->localSection, point, f, &ffcdof);
431:       *start = *start < 0 ? *start + ffcdof : *start - ffcdof;
432:     }
433:     *end   = *start < 0 ? *start - (fdof-fcdof) : *start + fdof-fcdof;
434:   }
435: #else
436:   {
437:     const PetscSection s     = dm->localSection;
438:     const PetscSection fs    = dm->localSection->field[field];
439:     const PetscSection gs    = dm->globalSection;
440:     const PetscInt     loff  = s->atlasOff[point - s->pStart];
441:     const PetscInt     goff  = gs->atlasOff[point - s->pStart];
442:     const PetscInt     lfoff = fs->atlasOff[point - s->pStart];
443:     const PetscInt     fdof  = fs->atlasDof[point - s->pStart];
444:     const PetscInt     fcdof = fs->bc ? fs->bc->atlasDof[point - fs->bc->pStart] : 0;
445:     PetscInt           ffcdof = 0, f;

447:     for (f = 0; f < field; ++f) {
448:       const PetscSection ffs = dm->localSection->field[f];
449:       ffcdof += ffs->bc ? ffs->bc->atlasDof[point - ffs->bc->pStart] : 0;
450:     }
451:     *start = goff + (goff < 0 ? loff-lfoff + ffcdof : lfoff-loff - ffcdof);
452:     *end   = *start < 0 ? *start - (fdof-fcdof) : *start + fdof-fcdof;
453:   }
454: #endif
455:   return(0);
456: }

458: PETSC_EXTERN PetscErrorCode DMGetBasisTransformDM_Internal(DM, DM *);
459: PETSC_EXTERN PetscErrorCode DMGetBasisTransformVec_Internal(DM, Vec *);
460: PETSC_INTERN PetscErrorCode DMConstructBasisTransform_Internal(DM);

462: PETSC_INTERN PetscErrorCode DMGetLocalBoundingIndices_DMDA(DM, PetscReal[], PetscReal[]);

464: #endif