Actual source code: dmplextransformimpl.h

  1: #pragma once

  3: #include <petsc/private/dmpleximpl.h>
  4: #include <petscdmplextransform.h>

  6: PETSC_EXTERN PetscLogEvent DMPLEXTRANSFORM_SetUp;
  7: PETSC_EXTERN PetscLogEvent DMPLEXTRANSFORM_Apply;
  8: PETSC_EXTERN PetscLogEvent DMPLEXTRANSFORM_SetConeSizes;
  9: PETSC_EXTERN PetscLogEvent DMPLEXTRANSFORM_SetCones;
 10: PETSC_EXTERN PetscLogEvent DMPLEXTRANSFORM_CreateSF;
 11: PETSC_EXTERN PetscLogEvent DMPLEXTRANSFORM_CreateLabels;
 12: PETSC_EXTERN PetscLogEvent DMPLEXTRANSFORM_SetCoordinates;
 13: PETSC_EXTERN PetscLogEvent DMPLEXTRANSFORM_Check;

 15: typedef struct _p_DMPlexTransformOps *DMPlexTransformOps;
 16: struct _p_DMPlexTransformOps {
 17:   PetscErrorCode (*view)(DMPlexTransform, PetscViewer);
 18:   PetscErrorCode (*setfromoptions)(DMPlexTransform, PetscOptionItems);
 19:   PetscErrorCode (*setup)(DMPlexTransform);
 20:   PetscErrorCode (*destroy)(DMPlexTransform);
 21:   PetscErrorCode (*setdimensions)(DMPlexTransform, DM, DM);
 22:   PetscErrorCode (*celltransform)(DMPlexTransform, DMPolytopeType, PetscInt, PetscInt *, PetscInt *, DMPolytopeType *[], PetscInt *[], PetscInt *[], PetscInt *[]);
 23:   PetscErrorCode (*ordersupports)(DMPlexTransform, DM, DM);
 24:   PetscErrorCode (*getsubcellorientation)(DMPlexTransform, DMPolytopeType, PetscInt, PetscInt, DMPolytopeType, PetscInt, PetscInt, PetscInt *, PetscInt *);
 25:   PetscErrorCode (*mapcoordinates)(DMPlexTransform, DMPolytopeType, DMPolytopeType, PetscInt, PetscInt, PetscInt, PetscInt, const PetscScalar[], PetscScalar[]);
 26:   PetscErrorCode (*check)(DMPlexTransform, DM);
 27: };

 29: struct _p_DMPlexTransform {
 30:   PETSCHEADER(struct _p_DMPlexTransformOps);
 31:   void *data;

 33:   DM            dm;            /* This is the DM for which the transform has been computed */
 34:   DMLabel       active;        /* If not NULL, indicates points that are participating in the transform */
 35:   DMLabel       trType;        /* If not NULL, this holds the transformation type for each point */
 36:   PetscBool     setupcalled;   /* true if setup has been called */
 37:   PetscInt     *ctOrderOld;    /* [i] = ct: An array with original cell types in depth order */
 38:   PetscInt     *ctOrderInvOld; /* [ct] = i: An array with the ordinal numbers for each original cell type */
 39:   PetscInt     *ctStart;       /* [ct]: The number for the first cell of each polytope type in the original mesh */
 40:   PetscInt     *ctOrderNew;    /* [i] = ct: An array with produced cell types in depth order */
 41:   PetscInt     *ctOrderInvNew; /* [ct] = i: An array with the ordinal numbers for each produced cell type */
 42:   PetscInt     *ctStartNew;    /* [ctNew]: The number for the first cell of each polytope type in the new mesh */
 43:   PetscInt     *offset;        /* [ct/rt][ctNew]: The offset from ctStartNew[ctNew] in the new point numbering of a point of type ctNew produced from an old point of type ct or refine type rt */
 44:   PetscInt      depth;         /* The depth of the transformed mesh */
 45:   PetscInt     *depthStart;    /* The starting point for each depth stratum */
 46:   PetscInt     *depthEnd;      /* The starting point for the next depth stratum */
 47:   PetscInt     *trNv;          /* The number of transformed vertices in the closure of a cell of each type */
 48:   PetscScalar **trVerts;       /* The transformed vertex coordinates in the closure of a cell of each type */
 49:   PetscInt  ****trSubVerts;    /* The indices for vertices of subcell (rct, r) in a cell of each type */
 50:   PetscFE      *coordFE;       /* Finite element for each cell type, used for localized coordinate interpolation */
 51:   PetscFEGeom **refGeom;       /* Geometry of the reference cell for each cell type */
 52:   PetscReal     redFactor;     // Used to scale maxCell in each direction
 53:   /* Label construction */
 54:   PetscBool labelMatchStrata; /* Flag to restrict labeled points to the same cell type as parents */
 55:   PetscInt  labelReplicaInc;  /* Multiplier to create new label values for replicas v = oldv + r * repInc */
 56: };

 58: typedef struct {
 59:   PetscInt dummy;
 60: } DMPlexTransform_Filter;

 62: typedef enum {
 63:   NORMAL_DEFAULT,
 64:   NORMAL_INPUT,
 65:   NORMAL_COMPUTE,
 66:   NORMAL_COMPUTE_BD
 67: } PlexNormalAlg;
 68: PETSC_EXTERN const char *const PlexNormalAlgs[];

 70: typedef struct {
 71:   /* Inputs */
 72:   PetscInt            dimEx;       /* The dimension of the extruded mesh */
 73:   PetscInt            cdim;        /* The coordinate dimension of the input mesh */
 74:   PetscInt            cdimEx;      /* The coordinate dimension of the extruded mesh */
 75:   PetscInt            layers;      /* The number of extruded layers */
 76:   PetscReal           thickness;   /* The total thickness of the extruded layers */
 77:   PetscInt            Nth;         /* The number of specified thicknesses */
 78:   PetscReal          *thicknesses; /* The input layer thicknesses */
 79:   PetscBool           useTensor;   /* Flag to create tensor cells */
 80:   PlexNormalAlg       normalAlg;   /* Algorithm to use for computing normal */
 81:   PetscReal           normal[3];   /* Surface normal from input */
 82:   DM                  dmNormal;    // DM for normal field
 83:   Vec                 vecNormal;   // Normal at each vertex
 84:   PetscSimplePointFn *normalFunc;  /* A function returning the normal at a given point */
 85:   PetscBool           symmetric;   /* Extrude layers symmetrically about the surface */
 86:   PetscBool           periodic;    /* Connect the extruded layer periodically to the beginning */
 87:   /* Calculated quantities */
 88:   PetscReal       *layerPos; /* The position of each layer relative to the original surface, along the local normal direction */
 89:   PetscInt        *Nt;       /* The array of the number of target types */
 90:   DMPolytopeType **target;   /* The array of target types */
 91:   PetscInt       **size;     /* The array of the number of each target type */
 92:   PetscInt       **cone;     /* The array of cones for each target cell */
 93:   PetscInt       **ornt;     /* The array of orientation for each target cell */
 94:   // Borrowed storage
 95:   const PetscInt *degree; // The root degree of all points in the original mesh
 96: } DMPlexTransform_Extrude;

 98: typedef struct {
 99:   PetscInt         debug;     // Debugging level
100:   PetscBool        useTensor; // Flag to create tensor cells
101:   PetscReal        width;     // The width of a cohesive cell
102:   PetscInt        *Nt;        // The array of the number of target types
103:   DMPolytopeType **target;    // The array of target types
104:   PetscInt       **size;      // The array of the number of each target type
105:   PetscInt       **cone;      // The array of cones for each target cell
106:   PetscInt       **ornt;      // The array of orientation for each target cell
107: } DMPlexTransform_Cohesive;

109: typedef struct {
110:   PetscInt dummy;
111: } DMPlexRefine_Regular;

113: typedef struct {
114:   PetscInt dummy;
115: } DMPlexRefine_ToBox;

117: typedef struct {
118:   PetscBool reflect; /* Flag to reflect the transformation */
119: } DMPlexRefine_ToSimplex;

121: typedef struct {
122:   PetscInt dummy;
123: } DMPlexRefine_Alfeld;

125: typedef struct {
126:   DMLabel      splitPoints; /* List of edges to be bisected (1), triangles to be divided (2), and tetrahedra to be divided (3) */
127:   PetscSection secEdgeLen;  /* Section for edge length field */
128:   PetscReal   *edgeLen;     /* Storage for edge length field */
129:   /* Cache of generated tetrahedron subdivisions, keyed by the encoded bisection order */
130:   PetscInt         Ncache;      /* Number of cached tetrahedron subdivisions */
131:   PetscInt         maxCache;    /* Capacity of the cache */
132:   PetscInt        *cacheCode;   /* [Ncache] Encoded bisection order */
133:   PetscInt        *cacheNt;     /* [Ncache] Number of target types */
134:   DMPolytopeType **cacheTarget; /* [Ncache] Target types */
135:   PetscInt       **cacheSize;   /* [Ncache] Number of targets of each type */
136:   PetscInt       **cacheCone;   /* [Ncache] Cone specifications */
137:   PetscInt       **cacheOrnt;   /* [Ncache] Cone orientations */
138: } DMPlexRefine_SBR;

140: typedef struct {
141:   PetscInt dummy;
142: } DMPlexRefine_1D;

144: typedef struct {
145:   PetscInt         n;      /* The number of divisions to produce, so n = 1 gives 2 new cells */
146:   PetscReal        r;      /* The factor increase for cell height */
147:   PetscScalar     *h;      /* The computed cell heights, based on r */
148:   PetscInt        *Nt;     /* The array of the number of target types */
149:   DMPolytopeType **target; /* The array of target types */
150:   PetscInt       **size;   /* The array of the number of each target type */
151:   PetscInt       **cone;   /* The array of cones for each target cell */
152:   PetscInt       **ornt;   /* The array of orientation for each target cell */
153: } DMPlexRefine_BL;

155: PetscErrorCode DMPlexTransformSetDimensions_Internal(DMPlexTransform, DM, DM);
156: PetscErrorCode DMPlexTransformMapCoordinatesBarycenter_Internal(DMPlexTransform, DMPolytopeType, DMPolytopeType, PetscInt, PetscInt, PetscInt, PetscInt, const PetscScalar[], PetscScalar[]);
157: PetscErrorCode DMPlexTransformGetSubcellOrientation_Regular(DMPlexTransform, DMPolytopeType, PetscInt, PetscInt, DMPolytopeType, PetscInt, PetscInt, PetscInt *, PetscInt *);
158: PetscErrorCode DMPlexTransformCellRefine_Regular(DMPlexTransform, DMPolytopeType, PetscInt, PetscInt *, PetscInt *, DMPolytopeType *[], PetscInt *[], PetscInt *[], PetscInt *[]);