Actual source code: dmlabelimpl.h
1: #pragma once
3: #include <petscdmlabel.h>
4: #include <petscistypes.h>
5: #include <petsc/private/hashmapi.h>
6: #include <petsc/private/hashseti.h>
8: typedef struct _n_DMLabelOps *DMLabelOps;
9: struct _n_DMLabelOps {
10: PetscErrorCode (*view)(DMLabel, PetscViewer);
11: PetscErrorCode (*setup)(DMLabel);
12: PetscErrorCode (*destroy)(DMLabel);
13: PetscErrorCode (*duplicate)(DMLabel, DMLabel *);
14: PetscErrorCode (*getstratumis)(DMLabel, PetscInt, IS *);
15: };
17: /* This is an integer map, in addition it is also a container class
18: Design points:
19: - Low storage is the most important design point
20: - We want flexible insertion and deletion
21: - We can live with O(log) query, but we need O(1) iteration over strata
22: */
23: struct _p_DMLabel {
24: PETSCHEADER(struct _n_DMLabelOps);
25: PetscBool readonly; /* Flag for labels which cannot be modified after creation */
26: PetscInt numStrata; /* Number of integer values */
27: PetscInt defaultValue; /* Background value when no value explicitly given */
28: PetscInt *stratumValues; /* Value of each stratum */
29: /* Basic IS storage */
30: PetscBool *validIS; /* The IS is valid (no additions need to be merged in) */
31: PetscInt *stratumSizes; /* Size of each stratum */
32: IS *points; /* Points for each stratum, always sorted */
33: /* Hash tables for fast search and insertion */
34: PetscHMapI hmap; /* Hash map for fast strata search */
35: PetscHSetI *ht; /* Hash set for fast insertion */
36: /* Index for fast search */
37: PetscInt pStart, pEnd; /* Bounds for index lookup */
38: PetscBT bt; /* A bit-wise index */
39: /* Propagation */
40: PetscInt *propArray; /* Array of values for propagation */
41: };
43: PETSC_INTERN PetscErrorCode DMLabelLookupStratum(DMLabel, PetscInt, PetscInt *);
44: PETSC_INTERN PetscErrorCode DMLabelGetStratumSize_Private(DMLabel, PetscInt, PetscInt *);
45: PETSC_INTERN PetscErrorCode PetscSectionSymCreate_Label(PetscSectionSym);
46: PETSC_INTERN PetscErrorCode DMLabelMakeAllInvalid_Internal(DMLabel);