1d410b0cfSMatthew G. Knepley #include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/ 2d410b0cfSMatthew G. Knepley #include <petscdmplextransform.h> 3d410b0cfSMatthew G. Knepley 4*9695643eSMatthew G. Knepley /*@C 5*9695643eSMatthew G. Knepley DMPlexExtrude - Extrude a volumetric mesh from the input surface mesh 6*9695643eSMatthew G. Knepley 7*9695643eSMatthew G. Knepley Input Parameters: 8*9695643eSMatthew G. Knepley + dm - The surface mesh 9*9695643eSMatthew G. Knepley . layers - The number of extruded layers 10*9695643eSMatthew G. Knepley . thickness - The total thickness of the extruded layers, or PETSC_DETERMINE 11*9695643eSMatthew G. Knepley . tensor - Flag to create tensor produt cells 12*9695643eSMatthew G. Knepley . symmetric - Flag to extrude symmetrically about the surface 13*9695643eSMatthew G. Knepley . normal - Surface normal vector, or NULL 14*9695643eSMatthew G. Knepley - thicknesses - Thickness of each layer, or NULL 15*9695643eSMatthew G. Knepley 16*9695643eSMatthew G. Knepley Output Parameter: 17*9695643eSMatthew G. Knepley . edm - The volumetric mesh 18*9695643eSMatthew G. Knepley 19*9695643eSMatthew G. Knepley Notes: 20*9695643eSMatthew G. Knepley Extrusion is implemented as a DMPlexTransform, so that new mesh points are produced from old mesh points. In the exmaple below, 21*9695643eSMatthew G. Knepley we begin with an edge (v0, v3). It is extruded for two layers. The original vertex v0 produces two edges, e1 and e2, and three vertices, 22*9695643eSMatthew G. Knepley v0, v2, and v2. Similarly, vertex v3 produces e3, e4, v3, v4, and v5. The original edge produces itself, e5 and e6, as well as face1 and 23*9695643eSMatthew G. Knepley face2. The new mesh points are given the same labels as the original points which produced them. Thus, if v0 had a label value 1, then so 24*9695643eSMatthew G. Knepley would v1, v2, e1 and e2. 25*9695643eSMatthew G. Knepley 26*9695643eSMatthew G. Knepley $ v2----- e6 -----v5 27*9695643eSMatthew G. Knepley $ | | 28*9695643eSMatthew G. Knepley $ e2 face2 e4 29*9695643eSMatthew G. Knepley $ | | 30*9695643eSMatthew G. Knepley $ v1----- e5 -----v4 31*9695643eSMatthew G. Knepley $ | | 32*9695643eSMatthew G. Knepley $ e1 face1 e3 33*9695643eSMatthew G. Knepley $ | | 34*9695643eSMatthew G. Knepley $ v0--- original ----v3 35*9695643eSMatthew G. Knepley 36*9695643eSMatthew G. Knepley Options Database: 37*9695643eSMatthew G. Knepley + -dm_plex_transform_extrude_thickness <t> - The total thickness of extruded layers 38*9695643eSMatthew G. Knepley . -dm_plex_transform_extrude_use_tensor <bool> - Use tensor cells when extruding 39*9695643eSMatthew G. Knepley . -dm_plex_transform_extrude_symmetric <bool> - Extrude layers symmetrically about the surface 40*9695643eSMatthew G. Knepley . -dm_plex_transform_extrude_normal <n0,...,nd> - Specify the extrusion direction 41*9695643eSMatthew G. Knepley - -dm_plex_transform_extrude_thicknesses <t0,...,tl> - Specify thickness of each layer 42*9695643eSMatthew G. Knepley 43*9695643eSMatthew G. Knepley Level: intermediate 44*9695643eSMatthew G. Knepley 45*9695643eSMatthew G. Knepley .seealso: DMExtrude(), DMPlexTransform, DMPlexTransformExtrudeSetThickness(), DMPlexTransformExtrudeSetTensor() 46*9695643eSMatthew G. Knepley @*/ 47d410b0cfSMatthew G. Knepley PetscErrorCode DMPlexExtrude(DM dm, PetscInt layers, PetscReal thickness, PetscBool tensor, PetscBool symmetric, const PetscReal normal[], const PetscReal thicknesses[], DM *edm) 48d410b0cfSMatthew G. Knepley { 49d410b0cfSMatthew G. Knepley DMPlexTransform tr; 50d410b0cfSMatthew G. Knepley DM cdm, ecdm; 51d410b0cfSMatthew G. Knepley const char *prefix; 52d410b0cfSMatthew G. Knepley PetscOptions options; 53d410b0cfSMatthew G. Knepley PetscErrorCode ierr; 54d410b0cfSMatthew G. Knepley 55d410b0cfSMatthew G. Knepley PetscFunctionBegin; 56d410b0cfSMatthew G. Knepley ierr = DMPlexTransformCreate(PetscObjectComm((PetscObject) dm), &tr);CHKERRQ(ierr); 57d410b0cfSMatthew G. Knepley ierr = DMPlexTransformSetDM(tr, dm);CHKERRQ(ierr); 58d410b0cfSMatthew G. Knepley ierr = DMPlexTransformSetType(tr, DMPLEXEXTRUDE);CHKERRQ(ierr); 59d410b0cfSMatthew G. Knepley ierr = PetscObjectGetOptionsPrefix((PetscObject) dm, &prefix);CHKERRQ(ierr); 60d410b0cfSMatthew G. Knepley ierr = PetscObjectSetOptionsPrefix((PetscObject) tr, prefix);CHKERRQ(ierr); 61d410b0cfSMatthew G. Knepley ierr = PetscObjectGetOptions((PetscObject) dm, &options);CHKERRQ(ierr); 62d410b0cfSMatthew G. Knepley ierr = PetscObjectSetOptions((PetscObject) tr, options);CHKERRQ(ierr); 63d410b0cfSMatthew G. Knepley ierr = DMPlexTransformExtrudeSetLayers(tr, layers);CHKERRQ(ierr); 64d410b0cfSMatthew G. Knepley if (thickness > 0.) {ierr = DMPlexTransformExtrudeSetThickness(tr, thickness);CHKERRQ(ierr);} 65d410b0cfSMatthew G. Knepley ierr = DMPlexTransformExtrudeSetTensor(tr, tensor);CHKERRQ(ierr); 66d410b0cfSMatthew G. Knepley ierr = DMPlexTransformExtrudeSetSymmetric(tr, symmetric);CHKERRQ(ierr); 67d410b0cfSMatthew G. Knepley if (normal) {ierr = DMPlexTransformExtrudeSetNormal(tr, normal);CHKERRQ(ierr);} 68d410b0cfSMatthew G. Knepley if (thicknesses) {ierr = DMPlexTransformExtrudeSetThicknesses(tr, layers, thicknesses);CHKERRQ(ierr);} 69d410b0cfSMatthew G. Knepley ierr = DMPlexTransformSetFromOptions(tr);CHKERRQ(ierr); 70d410b0cfSMatthew G. Knepley ierr = PetscObjectSetOptions((PetscObject) tr, NULL);CHKERRQ(ierr); 71d410b0cfSMatthew G. Knepley ierr = DMPlexTransformSetUp(tr);CHKERRQ(ierr); 72d410b0cfSMatthew G. Knepley ierr = PetscObjectViewFromOptions((PetscObject) tr, NULL, "-dm_plex_transform_view");CHKERRQ(ierr); 73d410b0cfSMatthew G. Knepley ierr = DMPlexTransformApply(tr, dm, edm);CHKERRQ(ierr); 74d410b0cfSMatthew G. Knepley ierr = DMCopyDisc(dm, *edm);CHKERRQ(ierr); 75d410b0cfSMatthew G. Knepley ierr = DMGetCoordinateDM(dm, &cdm);CHKERRQ(ierr); 76d410b0cfSMatthew G. Knepley ierr = DMGetCoordinateDM(*edm, &ecdm);CHKERRQ(ierr); 77d410b0cfSMatthew G. Knepley ierr = DMCopyDisc(cdm, ecdm);CHKERRQ(ierr); 78d410b0cfSMatthew G. Knepley ierr = DMPlexTransformCreateDiscLabels(tr, *edm);CHKERRQ(ierr); 79d410b0cfSMatthew G. Knepley ierr = DMPlexTransformDestroy(&tr);CHKERRQ(ierr); 80d410b0cfSMatthew G. Knepley if (*edm) { 81d410b0cfSMatthew G. Knepley ((DM_Plex *) (*edm)->data)->printFEM = ((DM_Plex *) dm->data)->printFEM; 82d410b0cfSMatthew G. Knepley ((DM_Plex *) (*edm)->data)->printL2 = ((DM_Plex *) dm->data)->printL2; 83d410b0cfSMatthew G. Knepley } 84d410b0cfSMatthew G. Knepley PetscFunctionReturn(0); 85d410b0cfSMatthew G. Knepley } 86d410b0cfSMatthew G. Knepley 87d410b0cfSMatthew G. Knepley PetscErrorCode DMExtrude_Plex(DM dm, PetscInt layers, DM *edm) 88d410b0cfSMatthew G. Knepley { 89d410b0cfSMatthew G. Knepley PetscErrorCode ierr; 90d410b0cfSMatthew G. Knepley 91d410b0cfSMatthew G. Knepley PetscFunctionBegin; 92d410b0cfSMatthew G. Knepley ierr = DMPlexExtrude(dm, layers, PETSC_DETERMINE, PETSC_TRUE, PETSC_FALSE, NULL, NULL, edm);CHKERRQ(ierr); 93d410b0cfSMatthew G. Knepley ierr = DMViewFromOptions(*edm, NULL, "-check_extrude");CHKERRQ(ierr); 94d410b0cfSMatthew G. Knepley PetscFunctionReturn(0); 95d410b0cfSMatthew G. Knepley } 96