Actual source code: dmlabelimpl.h

  1: #ifndef _LABELIMPL_H
  2: #define _LABELIMPL_H

  4: #include <petscdmlabel.h>
  5: #include <petscbt.h>
  6: #include <petscistypes.h>
  7: #include <petsc/private/hashmapi.h>
  8: #include <petsc/private/hashseti.h>

 10: typedef struct _p_DMLabelOps *DMLabelOps;
 11: struct _p_DMLabelOps {
 12:   PetscErrorCode (*view)(DMLabel, PetscViewer);
 13:   PetscErrorCode (*setup)(DMLabel);
 14:   PetscErrorCode (*destroy)(DMLabel);
 15:   PetscErrorCode (*duplicate)(DMLabel, DMLabel *);
 16:   PetscErrorCode (*getstratumis)(DMLabel, PetscInt, IS *);
 17: };

 19: /* This is an integer map, in addition it is also a container class
 20:    Design points:
 21:      - Low storage is the most important design point
 22:      - We want flexible insertion and deletion
 23:      - We can live with O(log) query, but we need O(1) iteration over strata
 24: */
 25: struct _p_DMLabel {
 26:   PETSCHEADER(struct _p_DMLabelOps);
 27:   PetscBool readonly;      /* Flag for labels which cannot be modified after creation */
 28:   PetscInt  numStrata;     /* Number of integer values */
 29:   PetscInt  defaultValue;  /* Background value when no value explicitly given */
 30:   PetscInt *stratumValues; /* Value of each stratum */
 31:   /* Basic IS storage */
 32:   PetscBool *validIS;      /* The IS is valid (no additions need to be merged in) */
 33:   PetscInt  *stratumSizes; /* Size of each stratum */
 34:   IS        *points;       /* Points for each stratum, always sorted */
 35:   /* Hash tables for fast search and insertion */
 36:   PetscHMapI  hmap; /* Hash map for fast strata search */
 37:   PetscHSetI *ht;   /* Hash set for fast insertion */
 38:   /* Index for fast search */
 39:   PetscInt pStart, pEnd; /* Bounds for index lookup */
 40:   PetscBT  bt;           /* A bit-wise index */
 41:   /* Propagation */
 42:   PetscInt *propArray; /* Array of values for propagation */
 43: };

 45: PETSC_INTERN PetscErrorCode DMLabelLookupStratum(DMLabel, PetscInt, PetscInt *);
 46: PETSC_INTERN PetscErrorCode DMLabelGetStratumSize_Private(DMLabel, PetscInt, PetscInt *);
 47: PETSC_INTERN PetscErrorCode PetscSectionSymCreate_Label(PetscSectionSym);
 48: PETSC_INTERN PetscErrorCode DMLabelMakeAllInvalid_Internal(DMLabel);
 49: #endif