[petsc-users] dmplex extrude in parallel

Matthew Knepley knepley at gmail.com
Tue Nov 9 15:56:28 CST 2021


On Tue, Nov 9, 2021 at 9:54 AM Bhargav Subramanya <
bhargav.subramanya at kaust.edu.sa> wrote:

> Dear All,
>
> I want to generate a prismatic mesh from a base spherical surface mesh. I
> first refine the base icosahedron sequential mesh to some extent,
> distribute the mesh, continue the refinement in parallel, project the mesh
> to a unit sphere, and then finally extrude the mesh. The following is the
> code I am using. As the extrusion is performed in parallel, the extruded
> mesh seems to be broken as shown in the attached figure. May I know how to
> get an intact extruded mesh in parallel? Also, is it possible to make mesh
> refinement respect the spherical surface geometry, without having to
> project it using a function as shown below?
>

I think you can do most of what you want from the command line. Here is a
simple code:

#include <petsc.h>

int main(int argc, char **argv)
{
  DM             dm;
  PetscErrorCode ierr;

  ierr = PetscInitialize(&argc, &argv, NULL, NULL);if (ierr) return ierr;
  ierr = DMCreate(PETSC_COMM_WORLD, &dm);CHKERRQ(ierr);
  ierr = DMSetType(dm, DMPLEX);CHKERRQ(ierr);
  ierr = DMSetFromOptions(dm);CHKERRQ(ierr);
  ierr = DMViewFromOptions(dm, NULL, "-dm_view");CHKERRQ(ierr);
  ierr = DMDestroy(&dm);CHKERRQ(ierr);
  ierr = PetscFinalize();
  return ierr;
}

that I run using

  mpiexec -n 2 ./meshtest -dm_plex_shape sphere -dm_refine_pre 3
-dm_extrude 5 -dm_plex_transform_extrude_thickness 0.1 -dm_distribute
-dm_view hdf5:mesh.h5

and get the attached picture. I am refining before distribution only here,
since the after distribution refinement would refine the extrude thing,
which is not what you want.
If you want refinement after distribution, you could use this code to do

  mpiexec -n 2 ./meshtest -dm_plex_shape sphere -dm_refine_pre
3 -dm_distribute -dm_refine 2

and then call DMExtrude() by hand after that. Alternatively, I could make a
pre-extrusion refinement option.

  Thanks,

     Matt


> Thanks,
> Bhargav
>
> /* refine the sequential mesh first */
> for (int r = 0; r < numRefinePre; ++r) {
> DM rdm = NULL;
> DMRefine(dm, MPI_COMM_WORLD, &rdm);
> DMDestroy(&dm);
> dm = rdm;
>  }
>
> /* project to a unit sphere */
> ierr = ProjectToUnitSphere(dm); CHKERRQ(ierr);
>
> /* create and distribute DM */
> ierr = DMPlexDistribute(dm, 0, NULL, &dmDist);CHKERRQ(ierr);
> if (dmDist) {
> DMDestroy(&dm);
> dm   = dmDist;
> }
>
> /* refine the mesh in parallel */
> for (int r = 0; r < numRefine; ++r) {
> DM rdm = NULL;
> DMRefine(dm, MPI_COMM_WORLD, &rdm);
> DMDestroy(&dm);
> dm = rdm;
>  }
>
> /* project to a unit sphere */
> ierr = ProjectToUnitSphere(dm); CHKERRQ(ierr);
>
> ierr = DMPlexExtrude(dm, numLayers-1, radialThickness, PETSC_FALSE, NULL,
> PETSC_TRUE, &dm3D);CHKERRQ(ierr);
>
> if (dm3D) {
> DMDestroy(&dm);
> dm = dm3D;
> }
>
>
> ------------------------------
> This message and its contents, including attachments are intended solely
> for the original recipient. If you are not the intended recipient or have
> received this message in error, please notify me immediately and delete
> this message from your computer system. Any unauthorized use or
> distribution is prohibited. Please consider the environment before printing
> this email.



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20211109/454966e7/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shell.png
Type: image/png
Size: 377130 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20211109/454966e7/attachment-0001.png>


More information about the petsc-users mailing list