xref: /petsc/src/dm/impls/plex/plexextrude.c (revision d410b0cf18e1798d3d4c14858e0c2ffdbe2fea69)
1*d410b0cfSMatthew G. Knepley #include <petsc/private/dmpleximpl.h>   /*I      "petscdmplex.h"   I*/
2*d410b0cfSMatthew G. Knepley #include <petscdmplextransform.h>
3*d410b0cfSMatthew G. Knepley 
4*d410b0cfSMatthew G. Knepley PetscErrorCode DMPlexExtrude(DM dm, PetscInt layers, PetscReal thickness, PetscBool tensor, PetscBool symmetric, const PetscReal normal[], const PetscReal thicknesses[], DM *edm)
5*d410b0cfSMatthew G. Knepley {
6*d410b0cfSMatthew G. Knepley   DMPlexTransform tr;
7*d410b0cfSMatthew G. Knepley   DM              cdm, ecdm;
8*d410b0cfSMatthew G. Knepley   const char     *prefix;
9*d410b0cfSMatthew G. Knepley   PetscOptions    options;
10*d410b0cfSMatthew G. Knepley   PetscErrorCode  ierr;
11*d410b0cfSMatthew G. Knepley 
12*d410b0cfSMatthew G. Knepley   PetscFunctionBegin;
13*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformCreate(PetscObjectComm((PetscObject) dm), &tr);CHKERRQ(ierr);
14*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformSetDM(tr, dm);CHKERRQ(ierr);
15*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformSetType(tr, DMPLEXEXTRUDE);CHKERRQ(ierr);
16*d410b0cfSMatthew G. Knepley   ierr = PetscObjectGetOptionsPrefix((PetscObject) dm, &prefix);CHKERRQ(ierr);
17*d410b0cfSMatthew G. Knepley   ierr = PetscObjectSetOptionsPrefix((PetscObject) tr,  prefix);CHKERRQ(ierr);
18*d410b0cfSMatthew G. Knepley   ierr = PetscObjectGetOptions((PetscObject) dm, &options);CHKERRQ(ierr);
19*d410b0cfSMatthew G. Knepley   ierr = PetscObjectSetOptions((PetscObject) tr, options);CHKERRQ(ierr);
20*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformExtrudeSetLayers(tr, layers);CHKERRQ(ierr);
21*d410b0cfSMatthew G. Knepley   if (thickness > 0.) {ierr = DMPlexTransformExtrudeSetThickness(tr, thickness);CHKERRQ(ierr);}
22*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformExtrudeSetTensor(tr, tensor);CHKERRQ(ierr);
23*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformExtrudeSetSymmetric(tr, symmetric);CHKERRQ(ierr);
24*d410b0cfSMatthew G. Knepley   if (normal) {ierr = DMPlexTransformExtrudeSetNormal(tr, normal);CHKERRQ(ierr);}
25*d410b0cfSMatthew G. Knepley   if (thicknesses) {ierr = DMPlexTransformExtrudeSetThicknesses(tr, layers, thicknesses);CHKERRQ(ierr);}
26*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformSetFromOptions(tr);CHKERRQ(ierr);
27*d410b0cfSMatthew G. Knepley   ierr = PetscObjectSetOptions((PetscObject) tr, NULL);CHKERRQ(ierr);
28*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformSetUp(tr);CHKERRQ(ierr);
29*d410b0cfSMatthew G. Knepley   ierr = PetscObjectViewFromOptions((PetscObject) tr, NULL, "-dm_plex_transform_view");CHKERRQ(ierr);
30*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformApply(tr, dm, edm);CHKERRQ(ierr);
31*d410b0cfSMatthew G. Knepley   ierr = DMCopyDisc(dm, *edm);CHKERRQ(ierr);
32*d410b0cfSMatthew G. Knepley   ierr = DMGetCoordinateDM(dm, &cdm);CHKERRQ(ierr);
33*d410b0cfSMatthew G. Knepley   ierr = DMGetCoordinateDM(*edm, &ecdm);CHKERRQ(ierr);
34*d410b0cfSMatthew G. Knepley   ierr = DMCopyDisc(cdm, ecdm);CHKERRQ(ierr);
35*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformCreateDiscLabels(tr, *edm);CHKERRQ(ierr);
36*d410b0cfSMatthew G. Knepley   ierr = DMPlexTransformDestroy(&tr);CHKERRQ(ierr);
37*d410b0cfSMatthew G. Knepley   if (*edm) {
38*d410b0cfSMatthew G. Knepley     ((DM_Plex *) (*edm)->data)->printFEM = ((DM_Plex *) dm->data)->printFEM;
39*d410b0cfSMatthew G. Knepley     ((DM_Plex *) (*edm)->data)->printL2  = ((DM_Plex *) dm->data)->printL2;
40*d410b0cfSMatthew G. Knepley   }
41*d410b0cfSMatthew G. Knepley   PetscFunctionReturn(0);
42*d410b0cfSMatthew G. Knepley }
43*d410b0cfSMatthew G. Knepley 
44*d410b0cfSMatthew G. Knepley PetscErrorCode DMExtrude_Plex(DM dm, PetscInt layers, DM *edm)
45*d410b0cfSMatthew G. Knepley {
46*d410b0cfSMatthew G. Knepley   PetscErrorCode ierr;
47*d410b0cfSMatthew G. Knepley 
48*d410b0cfSMatthew G. Knepley   PetscFunctionBegin;
49*d410b0cfSMatthew G. Knepley   ierr = DMPlexExtrude(dm, layers, PETSC_DETERMINE, PETSC_TRUE, PETSC_FALSE, NULL, NULL, edm);CHKERRQ(ierr);
50*d410b0cfSMatthew G. Knepley   ierr = DMViewFromOptions(*edm, NULL, "-check_extrude");CHKERRQ(ierr);
51*d410b0cfSMatthew G. Knepley   PetscFunctionReturn(0);
52*d410b0cfSMatthew G. Knepley }
53