Commits

Matt Knepley committed d3443b3

TS ex11: Replaced DMPlex label calls with DMLabel calls
- Avoids strcmp

Comments (0)

Files changed (1)

src/ts/examples/tutorials/ex11.c

 PetscErrorCode ConstructGeometry(DM dm, Vec *facegeom, Vec *cellgeom, User user)
 {
   DM             dmFace, dmCell;
+  DMLabel        ghostLabel;
   PetscSection   sectionFace, sectionCell;
   PetscSection   coordSection;
   Vec            coordinates;
   ierr = PetscSectionDestroy(&sectionFace);CHKERRQ(ierr);
   ierr = DMCreateLocalVector(dmFace, facegeom);CHKERRQ(ierr);
   ierr = VecGetArray(*facegeom, &fgeom);CHKERRQ(ierr);
+  ierr = DMPlexGetLabel(dm, "ghost", &ghostLabel);CHKERRQ(ierr);
   minradius = PETSC_MAX_REAL;
   for (f = fStart; f < fEnd; ++f) {
     FaceGeom *fg;
     PetscInt  ghost;
 
-    ierr = DMPlexGetLabelValue(dm, "ghost", f, &ghost);CHKERRQ(ierr);
+    ierr = DMLabelGetValue(ghostLabel, f, &ghost);CHKERRQ(ierr);
     if (ghost >= 0) continue;
     ierr = DMPlexPointLocalRef(dmFace, f, fgeom, &fg);CHKERRQ(ierr);
     ierr = DMPlexComputeCellGeometryFVM(dm, f, NULL, fg->centroid, fg->normal);CHKERRQ(ierr);
 static PetscErrorCode RHSFunctionLocal_Upwind(DM dm,DM dmFace,DM dmCell,PetscReal time,Vec locX,Vec F,User user)
 {
   Physics           phys = user->model->physics;
+  DMLabel           ghostLabel;
   PetscErrorCode    ierr;
   const PetscScalar *facegeom, *cellgeom, *x;
   PetscScalar       *f;
   ierr = VecGetArrayRead(user->cellgeom,&cellgeom);CHKERRQ(ierr);
   ierr = VecGetArrayRead(locX,&x);CHKERRQ(ierr);
   ierr = VecGetArray(F,&f);CHKERRQ(ierr);
+  ierr = DMPlexGetLabel(dm, "ghost", &ghostLabel);CHKERRQ(ierr);
   ierr = DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd);CHKERRQ(ierr);
   for (face = fStart; face < fEnd; ++face) {
     const PetscInt    *cells;
     const CellGeom    *cgL,*cgR;
     const PetscScalar *xL,*xR;
 
-    ierr = DMPlexGetLabelValue(dm, "ghost", face, &ghost);CHKERRQ(ierr);
+    ierr = DMLabelGetValue(ghostLabel, face, &ghost);CHKERRQ(ierr);
     if (ghost >= 0) continue;
     ierr = DMPlexGetSupport(dm, face, &cells);CHKERRQ(ierr);
     ierr = DMPlexPointLocalRead(dmFace,face,facegeom,&fg);CHKERRQ(ierr);
   ierr = DMRestoreGlobalVector(dmGrad,&Grad);CHKERRQ(ierr);
 
   {
+    DMLabel            ghostLabel, faceLabel;
     const PetscScalar *grad;
+    ierr = DMPlexGetLabel(dm, "ghost", &ghostLabel);CHKERRQ(ierr);
+    ierr = DMPlexGetLabel(dm, "Face Sets", &faceLabel);CHKERRQ(ierr);
     ierr = VecGetArrayRead(locGrad,&grad);CHKERRQ(ierr);
     ierr = VecGetArray(F,&f);CHKERRQ(ierr);
     for (face=fStart; face<fEnd; ++face) {
       const CellGeom    *cg[2];
       const PetscScalar *cx[2],*cgrad[2];
 
-      ierr = DMPlexGetLabelValue(dm, "ghost", face, &ghost);CHKERRQ(ierr);
+      ierr = DMLabelGetValue(ghostLabel, face, &ghost);CHKERRQ(ierr);
       if (ghost >= 0) continue;
       ierr = DMPlexGetSupport(dm, face, &cells);CHKERRQ(ierr);
       ierr = DMPlexPointLocalRead(dmFace,face,facegeom,&fg);CHKERRQ(ierr);
         Waxpy2(-1,cg[i]->centroid,fg->centroid,dx);
         for (j=0; j<dof; j++) fx[i][j] = cx[i][j] + Dot2(cgrad[i],dx);
       }
-      ierr = DMPlexGetLabelValue(dm, "Face Sets", face, &bset);CHKERRQ(ierr);
+      ierr = DMLabelGetValue(faceLabel, face, &bset);CHKERRQ(ierr);
       if (bset != -1) {
         BoundaryFunction bcFunc;
         void             *bcCtx;