Actual source code: dmimpl.h

petsc-master 2019-07-21
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/isimpl.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 (*createdefaultsection)(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: struct _n_DMLabelLinkList {
151:   PetscInt refct;
152:   DMLabelLink next;
153: };
154: typedef struct _n_DMLabelLinkList *DMLabelLinkList;

156: typedef struct _n_Boundary *DMBoundary;

158: struct _n_Boundary {
159:   DSBoundary  dsboundary;
160:   DMLabel     label;
161:   DMBoundary  next;
162: };

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

170: typedef struct _n_Space {
171:   PetscDS ds;     /* Approximation space in this domain */
172:   DMLabel label;  /* Label defining the domain of definition of the discretization */
173:   IS      fields; /* Map from DS field numbers to original field numbers in the DM */
174: } DMSpace;

176: PETSC_EXTERN PetscErrorCode DMDestroyLabelLinkList(DM);

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

257:   PetscObject             dmksp,dmsnes,dmts;
258: };

260: PETSC_EXTERN PetscLogEvent DM_Convert;
261: PETSC_EXTERN PetscLogEvent DM_GlobalToLocal;
262: PETSC_EXTERN PetscLogEvent DM_LocalToGlobal;
263: PETSC_EXTERN PetscLogEvent DM_LocatePoints;
264: PETSC_EXTERN PetscLogEvent DM_Coarsen;
265: PETSC_EXTERN PetscLogEvent DM_Refine;
266: PETSC_EXTERN PetscLogEvent DM_CreateInterpolation;
267: PETSC_EXTERN PetscLogEvent DM_CreateRestriction;
268: PETSC_EXTERN PetscLogEvent DM_CreateInjection;
269: PETSC_EXTERN PetscLogEvent DM_CreateMatrix;

271: PETSC_EXTERN PetscErrorCode DMCreateGlobalVector_Section_Private(DM,Vec*);
272: PETSC_EXTERN PetscErrorCode DMCreateLocalVector_Section_Private(DM,Vec*);

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

276: /*

278:           Composite Vectors

280:       Single global representation
281:       Individual global representations
282:       Single local representation
283:       Individual local representations

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

287:        DM da_u, da_v, da_p

289:        DM dm_velocities

291:        DM dm

293:        DMDACreate(,&da_u);
294:        DMDACreate(,&da_v);
295:        DMCompositeCreate(,&dm_velocities);
296:        DMCompositeAddDM(dm_velocities,(DM)du);
297:        DMCompositeAddDM(dm_velocities,(DM)dv);

299:        DMDACreate(,&da_p);
300:        DMCompositeCreate(,&dm_velocities);
301:        DMCompositeAddDM(dm,(DM)dm_velocities);
302:        DMCompositeAddDM(dm,(DM)dm_p);


305:     Access parts of composite vectors (Composite only)
306:     ---------------------------------
307:       DMCompositeGetAccess  - access the global vector as subvectors and array (for redundant arrays)
308:       ADD for local vector -

310:     Element access
311:     --------------
312:       From global vectors
313:          -DAVecGetArray   - for DMDA
314:          -VecGetArray - for DMSliced
315:          ADD for DMComposite???  maybe

317:       From individual vector
318:           -DAVecGetArray - for DMDA
319:           -VecGetArray -for sliced
320:          ADD for DMComposite??? maybe

322:       From single local vector
323:           ADD         * single local vector as arrays?

325:    Communication
326:    -------------
327:       DMGlobalToLocal - global vector to single local vector

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

331:    Obtaining vectors
332:    -----------------
333:       DMCreateGlobal/Local
334:       DMGetGlobal/Local
335:       DMCompositeGetLocalVectors   - gives individual local work vectors and arrays


338: ?????   individual global vectors   ????

340: */

342: #if defined(PETSC_HAVE_HDF5)
343: PETSC_EXTERN PetscErrorCode DMSequenceLoad_HDF5_Internal(DM, const char *, PetscInt, PetscScalar *, PetscViewer);
344: #endif

346: PETSC_STATIC_INLINE PetscErrorCode DMGetLocalOffset_Private(DM dm, PetscInt point, PetscInt *start, PetscInt *end)
347: {
349: #if defined(PETSC_USE_DEBUG)
350:   {
351:     PetscInt       dof;
353:     *start = *end = 0; /* Silence overzealous compiler warning */
354:     if (!dm->defaultSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a default Section, see DMSetDefaultSection()");
355:     PetscSectionGetOffset(dm->defaultSection, point, start);
356:     PetscSectionGetDof(dm->defaultSection, point, &dof);
357:     *end = *start + dof;
358:   }
359: #else
360:   {
361:     const PetscSection s = dm->defaultSection;
362:     *start = s->atlasOff[point - s->pStart];
363:     *end   = *start + s->atlasDof[point - s->pStart];
364:   }
365: #endif
366:   return(0);
367: }

369: PETSC_STATIC_INLINE PetscErrorCode DMGetLocalFieldOffset_Private(DM dm, PetscInt point, PetscInt field, PetscInt *start, PetscInt *end)
370: {
372: #if defined(PETSC_USE_DEBUG)
373:   {
374:     PetscInt       dof;
376:     *start = *end = 0; /* Silence overzealous compiler warning */
377:     if (!dm->defaultSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a default Section, see DMSetDefaultSection()");
378:     PetscSectionGetFieldOffset(dm->defaultSection, point, field, start);
379:     PetscSectionGetFieldDof(dm->defaultSection, point, field, &dof);
380:     *end = *start + dof;
381:   }
382: #else
383:   {
384:     const PetscSection s = dm->defaultSection->field[field];
385:     *start = s->atlasOff[point - s->pStart];
386:     *end   = *start + s->atlasDof[point - s->pStart];
387:   }
388: #endif
389:   return(0);
390: }

392: PETSC_STATIC_INLINE PetscErrorCode DMGetGlobalOffset_Private(DM dm, PetscInt point, PetscInt *start, PetscInt *end)
393: {
395: #if defined(PETSC_USE_DEBUG)
396:   {
398:     PetscInt       dof,cdof;
399:     *start = *end = 0; /* Silence overzealous compiler warning */
400:     if (!dm->defaultSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a default Section, see DMSetDefaultSection()");
401:     if (!dm->defaultGlobalSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a default global Section. It will be created automatically by DMGetDefaultGlobalSection()");
402:     PetscSectionGetOffset(dm->defaultGlobalSection, point, start);
403:     PetscSectionGetDof(dm->defaultGlobalSection, point, &dof);
404:     PetscSectionGetConstraintDof(dm->defaultGlobalSection, point, &cdof);
405:     *end = *start + dof - cdof + (dof < 0 ? 1 : 0);
406:   }
407: #else
408:   {
409:     const PetscSection s    = dm->defaultGlobalSection;
410:     const PetscInt     dof  = s->atlasDof[point - s->pStart];
411:     const PetscInt     cdof = s->bc ? s->bc->atlasDof[point - s->bc->pStart] : 0;
412:     *start = s->atlasOff[point - s->pStart];
413:     *end   = *start + dof - cdof + (dof < 0 ? 1 : 0);
414:   }
415: #endif
416:   return(0);
417: }

419: PETSC_STATIC_INLINE PetscErrorCode DMGetGlobalFieldOffset_Private(DM dm, PetscInt point, PetscInt field, PetscInt *start, PetscInt *end)
420: {
422: #if defined(PETSC_USE_DEBUG)
423:   {
424:     PetscInt       loff, lfoff, fdof, fcdof, ffcdof, f;
426:     *start = *end = 0; /* Silence overzealous compiler warning */
427:     if (!dm->defaultSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a default Section, see DMSetDefaultSection()");
428:     if (!dm->defaultGlobalSection) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "DM must have a default global Section. It will be crated automatically by DMGetDefaultGlobalSection()");
429:     PetscSectionGetOffset(dm->defaultGlobalSection, point, start);
430:     PetscSectionGetOffset(dm->defaultSection, point, &loff);
431:     PetscSectionGetFieldOffset(dm->defaultSection, point, field, &lfoff);
432:     PetscSectionGetFieldDof(dm->defaultSection, point, field, &fdof);
433:     PetscSectionGetFieldConstraintDof(dm->defaultSection, point, field, &fcdof);
434:     *start = *start < 0 ? *start - (lfoff-loff) : *start + lfoff-loff;
435:     for (f = 0; f < field; ++f) {
436:       PetscSectionGetFieldConstraintDof(dm->defaultSection, point, f, &ffcdof);
437:       *start = *start < 0 ? *start + ffcdof : *start - ffcdof;
438:     }
439:     *end   = *start < 0 ? *start - (fdof-fcdof) : *start + fdof-fcdof;
440:   }
441: #else
442:   {
443:     const PetscSection s     = dm->defaultSection;
444:     const PetscSection fs    = dm->defaultSection->field[field];
445:     const PetscSection gs    = dm->defaultGlobalSection;
446:     const PetscInt     loff  = s->atlasOff[point - s->pStart];
447:     const PetscInt     goff  = gs->atlasOff[point - s->pStart];
448:     const PetscInt     lfoff = fs->atlasOff[point - s->pStart];
449:     const PetscInt     fdof  = fs->atlasDof[point - s->pStart];
450:     const PetscInt     fcdof = fs->bc ? fs->bc->atlasDof[point - fs->bc->pStart] : 0;
451:     PetscInt           ffcdof = 0, f;

453:     for (f = 0; f < field; ++f) {
454:       const PetscSection ffs = dm->defaultSection->field[f];
455:       ffcdof += ffs->bc ? ffs->bc->atlasDof[point - ffs->bc->pStart] : 0;
456:     }
457:     *start = goff + (goff < 0 ? loff-lfoff + ffcdof : lfoff-loff - ffcdof);
458:     *end   = *start < 0 ? *start - (fdof-fcdof) : *start + fdof-fcdof;
459:   }
460: #endif
461:   return(0);
462: }

464: PETSC_EXTERN PetscErrorCode DMGetBasisTransformDM_Internal(DM, DM *);
465: PETSC_EXTERN PetscErrorCode DMGetBasisTransformVec_Internal(DM, Vec *);
466: PETSC_INTERN PetscErrorCode DMConstructBasisTransform_Internal(DM);

468: #endif