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;
14: typedef struct _p_DMPlexTransformOps *DMPlexTransformOps;
15: struct _p_DMPlexTransformOps {
16: PetscErrorCode (*view)(DMPlexTransform, PetscViewer);
17: PetscErrorCode (*setfromoptions)(DMPlexTransform, PetscOptionItems);
18: PetscErrorCode (*setup)(DMPlexTransform);
19: PetscErrorCode (*destroy)(DMPlexTransform);
20: PetscErrorCode (*setdimensions)(DMPlexTransform, DM, DM);
21: PetscErrorCode (*celltransform)(DMPlexTransform, DMPolytopeType, PetscInt, PetscInt *, PetscInt *, DMPolytopeType *[], PetscInt *[], PetscInt *[], PetscInt *[]);
22: PetscErrorCode (*ordersupports)(DMPlexTransform, DM, DM);
23: PetscErrorCode (*getsubcellorientation)(DMPlexTransform, DMPolytopeType, PetscInt, PetscInt, DMPolytopeType, PetscInt, PetscInt, PetscInt *, PetscInt *);
24: PetscErrorCode (*mapcoordinates)(DMPlexTransform, DMPolytopeType, DMPolytopeType, PetscInt, PetscInt, PetscInt, PetscInt, const PetscScalar[], PetscScalar[]);
25: };
27: struct _p_DMPlexTransform {
28: PETSCHEADER(struct _p_DMPlexTransformOps);
29: void *data;
31: DM dm; /* This is the DM for which the transform has been computed */
32: DMLabel active; /* If not NULL, indicates points that are participating in the transform */
33: DMLabel trType; /* If not NULL, this holds the transformation type for each point */
34: PetscBool setupcalled; /* true if setup has been called */
35: PetscInt *ctOrderOld; /* [i] = ct: An array with original cell types in depth order */
36: PetscInt *ctOrderInvOld; /* [ct] = i: An array with the ordinal numbers for each original cell type */
37: PetscInt *ctStart; /* [ct]: The number for the first cell of each polytope type in the original mesh */
38: PetscInt *ctOrderNew; /* [i] = ct: An array with produced cell types in depth order */
39: PetscInt *ctOrderInvNew; /* [ct] = i: An array with the ordinal numbers for each produced cell type */
40: PetscInt *ctStartNew; /* [ctNew]: The number for the first cell of each polytope type in the new mesh */
41: 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 */
42: PetscInt depth; /* The depth of the transformed mesh */
43: PetscInt *depthStart; /* The starting point for each depth stratum */
44: PetscInt *depthEnd; /* The starting point for the next depth stratum */
45: PetscInt *trNv; /* The number of transformed vertices in the closure of a cell of each type */
46: PetscScalar **trVerts; /* The transformed vertex coordinates in the closure of a cell of each type */
47: PetscInt ****trSubVerts; /* The indices for vertices of subcell (rct, r) in a cell of each type */
48: PetscFE *coordFE; /* Finite element for each cell type, used for localized coordinate interpolation */
49: PetscFEGeom **refGeom; /* Geometry of the reference cell for each cell type */
50: /* Label construction */
51: PetscBool labelMatchStrata; /* Flag to restrict labeled points to the same cell type as parents */
52: PetscInt labelReplicaInc; /* Multiplier to create new label values for replicas v = oldv + r * repInc */
53: };
55: typedef struct {
56: PetscInt dummy;
57: } DMPlexTransform_Filter;
59: typedef enum {
60: NORMAL_DEFAULT,
61: NORMAL_INPUT,
62: NORMAL_COMPUTE,
63: NORMAL_COMPUTE_BD
64: } PlexNormalAlg;
65: PETSC_EXTERN const char *const PlexNormalAlgs[];
67: typedef struct {
68: /* Inputs */
69: PetscInt dimEx; /* The dimension of the extruded mesh */
70: PetscInt cdim; /* The coordinate dimension of the input mesh */
71: PetscInt cdimEx; /* The coordinate dimension of the extruded mesh */
72: PetscInt layers; /* The number of extruded layers */
73: PetscReal thickness; /* The total thickness of the extruded layers */
74: PetscInt Nth; /* The number of specified thicknesses */
75: PetscReal *thicknesses; /* The input layer thicknesses */
76: PetscBool useTensor; /* Flag to create tensor cells */
77: PlexNormalAlg normalAlg; /* Algorithm to use for computing normal */
78: PetscReal normal[3]; /* Surface normal from input */
79: DM dmNormal; // DM for normal field
80: Vec vecNormal; // Normal at each vertex
81: PetscSimplePointFn *normalFunc; /* A function returning the normal at a given point */
82: PetscBool symmetric; /* Extrude layers symmetrically about the surface */
83: PetscBool periodic; /* Connect the extruded layer periodically to the beginning */
84: /* Calculated quantities */
85: PetscReal *layerPos; /* The position of each layer relative to the original surface, along the local normal direction */
86: PetscInt *Nt; /* The array of the number of target types */
87: DMPolytopeType **target; /* The array of target types */
88: PetscInt **size; /* The array of the number of each target type */
89: PetscInt **cone; /* The array of cones for each target cell */
90: PetscInt **ornt; /* The array of orientation for each target cell */
91: // Borrowed storage
92: const PetscInt *degree; // The root degree of all points in the original mesh
93: } DMPlexTransform_Extrude;
95: typedef struct {
96: PetscInt debug; // Debugging level
97: PetscBool useTensor; // Flag to create tensor cells
98: PetscReal width; // The width of a cohesive cell
99: PetscInt *Nt; // The array of the number of target types
100: DMPolytopeType **target; // The array of target types
101: PetscInt **size; // The array of the number of each target type
102: PetscInt **cone; // The array of cones for each target cell
103: PetscInt **ornt; // The array of orientation for each target cell
104: } DMPlexTransform_Cohesive;
106: typedef struct {
107: PetscInt dummy;
108: } DMPlexRefine_Regular;
110: typedef struct {
111: PetscInt dummy;
112: } DMPlexRefine_ToBox;
114: typedef struct {
115: PetscInt dummy;
116: } DMPlexRefine_Alfeld;
118: typedef struct {
119: DMLabel splitPoints; /* List of edges to be bisected (1) and cells to be divided (2) */
120: PetscSection secEdgeLen; /* Section for edge length field */
121: PetscReal *edgeLen; /* Storage for edge length field */
122: } DMPlexRefine_SBR;
124: typedef struct {
125: PetscInt dummy;
126: } DMPlexRefine_1D;
128: typedef struct {
129: PetscInt n; /* The number of divisions to produce, so n = 1 gives 2 new cells */
130: PetscReal r; /* The factor increase for cell height */
131: PetscScalar *h; /* The computed cell heights, based on r */
132: PetscInt *Nt; /* The array of the number of target types */
133: DMPolytopeType **target; /* The array of target types */
134: PetscInt **size; /* The array of the number of each target type */
135: PetscInt **cone; /* The array of cones for each target cell */
136: PetscInt **ornt; /* The array of orientation for each target cell */
137: } DMPlexRefine_BL;
139: PetscErrorCode DMPlexTransformSetDimensions_Internal(DMPlexTransform, DM, DM);
140: PetscErrorCode DMPlexTransformMapCoordinatesBarycenter_Internal(DMPlexTransform, DMPolytopeType, DMPolytopeType, PetscInt, PetscInt, PetscInt, PetscInt, const PetscScalar[], PetscScalar[]);
141: PetscErrorCode DMPlexTransformGetSubcellOrientation_Regular(DMPlexTransform, DMPolytopeType, PetscInt, PetscInt, DMPolytopeType, PetscInt, PetscInt, PetscInt *, PetscInt *);
142: PetscErrorCode DMPlexTransformCellRefine_Regular(DMPlexTransform, DMPolytopeType, PetscInt, PetscInt *, PetscInt *, DMPolytopeType *[], PetscInt *[], PetscInt *[], PetscInt *[]);