Actual source code: ex27.c

  1: static char help[] = "Test section ordering for FEM discretizations\n\n";

  3: #include <petscdmplex.h>
  4: #include <petscds.h>

  6: static PetscErrorCode CreateMesh(MPI_Comm comm, DM *dm)
  7: {
  8:   DMCreate(comm, dm);
  9:   DMSetType(*dm, DMPLEX);
 10:   DMSetFromOptions(*dm);
 11:   DMViewFromOptions(*dm, NULL, "-dm_view");
 12:   return 0;
 13: }

 15: static PetscErrorCode TestLocalDofOrder(DM dm)
 16: {
 17:   PetscFE      fe[3];
 18:   PetscSection s;
 19:   PetscBool    simplex;
 20:   PetscInt     dim, Nf, f;

 22:   DMGetDimension(dm, &dim);
 23:   DMPlexIsSimplex(dm, &simplex);
 24:   PetscFECreateDefault(PETSC_COMM_SELF, dim, dim, simplex, "field0_", -1, &fe[0]);
 25:   PetscFECreateDefault(PETSC_COMM_SELF, dim, 1, simplex, "field1_", -1, &fe[1]);
 26:   PetscFECreateDefault(PETSC_COMM_SELF, dim, 1, simplex, "field2_", -1, &fe[2]);

 28:   DMSetField(dm, 0, NULL, (PetscObject)fe[0]);
 29:   DMSetField(dm, 1, NULL, (PetscObject)fe[1]);
 30:   DMSetField(dm, 2, NULL, (PetscObject)fe[2]);
 31:   DMCreateDS(dm);
 32:   DMGetLocalSection(dm, &s);
 33:   PetscObjectViewFromOptions((PetscObject)s, NULL, "-dof_view");

 35:   DMGetNumFields(dm, &Nf);
 36:   for (f = 0; f < Nf; ++f) PetscFEDestroy(&fe[f]);
 37:   return 0;
 38: }

 40: int main(int argc, char **argv)
 41: {
 42:   DM dm;

 45:   PetscInitialize(&argc, &argv, NULL, help);
 46:   CreateMesh(PETSC_COMM_WORLD, &dm);
 47:   TestLocalDofOrder(dm);
 48:   DMDestroy(&dm);
 49:   PetscFinalize();
 50:   return 0;
 51: }

 53: /*TEST

 55:   test:
 56:     suffix: tri_pm
 57:     requires: triangle
 58:     args: -dm_plex_box_faces 1,1 -field0_petscspace_degree 2 -field1_petscspace_degree 1 -field2_petscspace_degree 1 -dm_view -dof_view

 60:   test:
 61:     suffix: quad_pm
 62:     requires:
 63:     args: -dm_plex_simplex 0 -dm_plex_box_faces 1,1 -field0_petscspace_degree 2 -field1_petscspace_degree 1 -field2_petscspace_degree 1 -dm_view -dof_view

 65:   test:
 66:     suffix: tri_fm
 67:     requires: triangle
 68:     args: -dm_coord_space 0 -dm_plex_box_faces 1,1 -field0_petscspace_degree 2 -field1_petscspace_degree 1 -field2_petscspace_degree 1 -petscsection_point_major 0 -dm_view -dof_view

 70:   test:
 71:     suffix: quad_fm
 72:     requires:
 73:     args: -dm_coord_space 0 -dm_plex_simplex 0 -dm_plex_box_faces 1,1 -field0_petscspace_degree 2 -field1_petscspace_degree 1 -field2_petscspace_degree 1 -petscsection_point_major 0 -dm_view -dof_view

 75: TEST*/