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