Actual source code: sectionimpl.h
1: #if !defined(PETSCSECTIONIMPL_H)
2: #define PETSCSECTIONIMPL_H
4: #include <petscsection.h>
5: #include <petsc/private/petscimpl.h>
6: #include <petsc/private/hashmap.h>
8: typedef struct PetscSectionClosurePermKey {
9: PetscInt depth, size;
10: } PetscSectionClosurePermKey;
12: typedef struct {
13: PetscInt *perm, *invPerm;
14: } PetscSectionClosurePermVal;
16: PETSC_STATIC_INLINE PetscHash_t PetscSectionClosurePermHash(PetscSectionClosurePermKey k)
17: {
18: return PetscHashCombine(PetscHashInt(k.depth), PetscHashInt(k.size));
19: }
21: PETSC_STATIC_INLINE int PetscSectionClosurePermEqual(PetscSectionClosurePermKey k1, PetscSectionClosurePermKey k2)
22: {
23: return k1.depth == k2.depth && k1.size == k2.size;
24: }
26: static PetscSectionClosurePermVal PetscSectionClosurePermVal_Empty = {NULL, NULL};
27: PETSC_HASH_MAP(ClPerm, PetscSectionClosurePermKey, PetscSectionClosurePermVal, PetscSectionClosurePermHash, PetscSectionClosurePermEqual, PetscSectionClosurePermVal_Empty)
29: struct _p_PetscSection {
30: PETSCHEADER(int);
31: PetscInt pStart, pEnd; /* The chart: all points are contained in [pStart, pEnd) */
32: IS perm; /* A permutation of [0, pEnd-pStart) */
33: PetscBool pointMajor; /* True if the offsets are point major, otherwise they are fieldMajor */
34: PetscBool includesConstraints; /* True if constrained dofs are included when computing offsets */
35: PetscInt *atlasDof; /* Describes layout of storage, point --> # of values */
36: PetscInt *atlasOff; /* Describes layout of storage, point --> offset into storage */
37: PetscInt maxDof; /* Maximum dof on any point */
38: PetscSection bc; /* Describes constraints, point --> # local dofs which are constrained */
39: PetscInt *bcIndices; /* Local indices for constrained dofs */
40: PetscBool setup;
42: PetscInt numFields; /* The number of fields making up the degrees of freedom */
43: char **fieldNames; /* The field names */
44: PetscInt *numFieldComponents; /* The number of components in each field */
45: PetscSection *field; /* A section describing the layout and constraints for each field */
46: PetscBool useFieldOff; /* Use the field offsets directly for the global section, rather than the point offset */
47: char ***compNames; /* The component names */
49: PetscObject clObj; /* Key for the closure (right now we only have one) */
50: PetscClPerm clHash; /* Hash of (depth, size) to perm and invPerm */
51: PetscSection clSection; /* Section giving the number of points in each closure */
52: IS clPoints; /* Points in each closure */
53: PetscSectionSym sym; /* Symmetries of the data */
54: };
56: struct _PetscSectionSymOps {
57: PetscErrorCode (*getpoints)(PetscSectionSym,PetscSection,PetscInt,const PetscInt *,const PetscInt **,const PetscScalar **);
58: PetscErrorCode (*destroy)(PetscSectionSym);
59: PetscErrorCode (*view)(PetscSectionSym,PetscViewer);
60: };
62: typedef struct _n_SymWorkLink *SymWorkLink;
64: struct _n_SymWorkLink
65: {
66: SymWorkLink next;
67: const PetscInt **perms;
68: const PetscScalar **rots;
69: PetscInt numPoints;
70: };
72: struct _p_PetscSectionSym {
73: PETSCHEADER(struct _PetscSectionSymOps);
74: void *data;
75: SymWorkLink workin;
76: SymWorkLink workout;
77: };
79: PETSC_EXTERN PetscErrorCode PetscSectionSetClosurePermutation_Internal(PetscSection, PetscObject, PetscInt, PetscInt, PetscCopyMode, PetscInt *);
80: PETSC_EXTERN PetscErrorCode PetscSectionGetClosurePermutation_Internal(PetscSection, PetscObject, PetscInt, PetscInt, const PetscInt *[]);
81: PETSC_EXTERN PetscErrorCode PetscSectionGetClosureInversePermutation_Internal(PetscSection, PetscObject, PetscInt, PetscInt, const PetscInt *[]);
82: PETSC_EXTERN PetscErrorCode ISIntersect_Caching_Internal(IS, IS, IS *);
83: #if defined(PETSC_HAVE_HDF5)
84: PETSC_INTERN PetscErrorCode PetscSectionView_HDF5_Internal(PetscSection, PetscViewer);
85: PETSC_INTERN PetscErrorCode PetscSectionLoad_HDF5_Internal(PetscSection, PetscViewer);
86: #endif
87: #endif