Commits

Matt Knepley committed f247202 Merge

Merge branch 'knepley/fix-dm-label-fortran'

* knepley/fix-dm-label-fortran:
DMPlex ex1F90: Added test of DMLabel bindings
DMLabel: Moved custom bindings to zplexlabel.c - Added DMPlexGetLabel() binding - Added DMLabelGet/Set/ClearValue() bindings

Comments (0)

Files changed (5)

src/dm/impls/plex/examples/tutorials/ex1f90.F

       implicit none
 #include "finclude/petsc.h90"
       DM :: dm
+      DMLabel :: label
       Vec :: u
       PetscViewer :: viewer
       PetscSection :: section
-      PetscInt :: dim,numFields,numBC,i
+      PetscInt :: dim,numFields,numBC,i,val
       PetscInt, target, dimension(3) ::                                 &
      &     numComp
       PetscInt, pointer :: pNumComp(:)
       pNumDof => numDof
 !     Setup boundary conditions
       numBC = 1
+!     Test label retrieval
+      call DMPlexGetLabel(dm, "marker", label, ierr)
+      CHKERRQ(ierr)
+      call DMLabelGetValue(label, 0, val, ierr)
+      CHKERRQ(ierr)
+      if (val .ne. -1) then
+        CHKERRQ(1)
+      endif
+      call DMLabelGetValue(label, 8, val, ierr)
+      CHKERRQ(ierr)
+      if (val .ne. 1) then
+        CHKERRQ(1)
+      endif
 !     Prescribe a Dirichlet condition on u on the boundary
 !       Label "marker" is made by the mesh creation routine
       bcField(1) = 0

src/dm/impls/plex/ftn-custom/makefile

 ALL: lib
 CFLAGS   =
 FFLAGS   =
-SOURCEC  = zplex.c zplexsubmesh.c
+SOURCEC  = zplex.c zplexsubmesh.c zplexlabel.c
 SOURCEF  =
 SOURCEH  =
 DIRS     =

src/dm/impls/plex/ftn-custom/zplex.c

 
 #if defined(PETSC_HAVE_FORTRAN_CAPS)
 #define dmplexdistribute_          DMPLEXDISTRIBUTE
-#define dmplexhaslabel_            DMPLEXHASLABEL
-#define dmplexgetlabelvalue_       DMPLEXGETLABELVALUE
-#define dmplexsetlabelvalue_       DMPLEXSETLABELVALUE
-#define dmplexgetlabelsize_        DMPLEXGETLABELSIZE
-#define dmplexgetlabelidis_        DMPLEXGETLABELIDIS
-#define dmplexgetstratumsize_      DMPLEXGETSTRATUMSIZE
-#define dmplexgetstratumis_        DMPLEXGETSTRATUMIS
 #define dmplexcreatefromcelllist_  DMPLEXCREATEFROMCELLLIST
 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE)
 #define dmplexdistribute_          dmplexdistribute
-#define dmplexhaslabel_            dmplexhaslabel
-#define dmplexgetlabelvalue_       dmplexgetlabelvalue
-#define dmplexsetlabelvalue_       dmplexsetlabelvalue
-#define dmplexgetlabelsize_        dmplexlabelsize
-#define dmplexgetlabelidis_        dmplexlabelidis
-#define dmplexgetstratumsize_      dmplexgetstratumsize
-#define dmplexgetstratumis_        dmplexgetstratumis
 #define dmplexcreatefromcelllist_  dmplexcreatefromcelllist
 #endif
 
   FREECHAR(name, partitioner);
 }
 
-PETSC_EXTERN void PETSC_STDCALL dmplexhaslabel_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscBool *hasLabel, int *ierr PETSC_END_LEN(lenN))
-{
-  char *lname;
-
-  FIXCHAR(name, lenN, lname);
-  *ierr = DMPlexHasLabel(*dm, lname, hasLabel);
-  FREECHAR(name, lname);
-}
-
-PETSC_EXTERN void PETSC_STDCALL dmplexgetlabelvalue_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *point, PetscInt *value, int *ierr PETSC_END_LEN(lenN))
-{
-  char *lname;
-
-  FIXCHAR(name, lenN, lname);
-  *ierr = DMPlexGetLabelValue(*dm, lname, *point, value);
-  FREECHAR(name, lname);
-}
-
-PETSC_EXTERN void PETSC_STDCALL dmplexsetlabelvalue_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *point, PetscInt *value, int *ierr PETSC_END_LEN(lenN))
-{
-  char *lname;
-
-  FIXCHAR(name, lenN, lname);
-  *ierr = DMPlexSetLabelValue(*dm, lname, *point, *value);
-  FREECHAR(name, lname);
-}
-
-PETSC_EXTERN void PETSC_STDCALL dmplexgetlabelsize_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *size, int *ierr PETSC_END_LEN(lenN))
-{
-  char *lname;
-
-  FIXCHAR(name, lenN, lname);
-  *ierr = DMPlexGetLabelSize(*dm, lname, size);
-  FREECHAR(name, lname);
-}
-
-PETSC_EXTERN void PETSC_STDCALL dmplexgetlabelidis_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), IS *ids, int *ierr PETSC_END_LEN(lenN))
-{
-  char *lname;
-
-  FIXCHAR(name, lenN, lname);
-  *ierr = DMPlexGetLabelIdIS(*dm, lname, ids);
-  FREECHAR(name, lname);
-}
-
-PETSC_EXTERN void PETSC_STDCALL dmplexgetstratumsize_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *value, PetscInt *size, int *ierr PETSC_END_LEN(lenN))
-{
-  char *lname;
-
-  FIXCHAR(name, lenN, lname);
-  *ierr = DMPlexGetStratumSize(*dm, lname, *value, size);
-  FREECHAR(name, lname);
-}
-
-PETSC_EXTERN void PETSC_STDCALL dmplexgetstratumis_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *value, IS *is, int *ierr PETSC_END_LEN(lenN))
-{
-  char *lname;
-
-  FIXCHAR(name, lenN, lname);
-  *ierr = DMPlexGetStratumIS(*dm, lname, *value, is);
-  FREECHAR(name, lname);
-}
-
 PETSC_EXTERN void PETSC_STDCALL dmplexcreatefromcelllist_(MPI_Comm *comm, PetscInt *dim, PetscInt *numCells, PetscInt *numVertices, PetscInt *numCorners, PetscBool *interpolate, const int cells[], PetscInt *spaceDim, const double vertexCoords[], DM *dm, int *ierr)
 {
   *ierr = DMPlexCreateFromCellList(*comm, *dim, *numCells, *numVertices, *numCorners, *interpolate, cells, *spaceDim, vertexCoords, dm);

src/dm/impls/plex/ftn-custom/zplexlabel.c

+#include <petsc-private/fortranimpl.h>
+#include <petscdmplex.h>
+
+#if defined(PETSC_HAVE_FORTRAN_CAPS)
+#define dmplexhaslabel_            DMPLEXHASLABEL
+#define dmplexgetlabelvalue_       DMPLEXGETLABELVALUE
+#define dmplexsetlabelvalue_       DMPLEXSETLABELVALUE
+#define dmplexgetlabelsize_        DMPLEXGETLABELSIZE
+#define dmplexgetlabelidis_        DMPLEXGETLABELIDIS
+#define dmplexgetstratumsize_      DMPLEXGETSTRATUMSIZE
+#define dmplexgetstratumis_        DMPLEXGETSTRATUMIS
+#define dmplexgetlabel_            DMPLEXGETLABEL
+#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE)
+#define dmplexhaslabel_            dmplexhaslabel
+#define dmplexgetlabelvalue_       dmplexgetlabelvalue
+#define dmplexsetlabelvalue_       dmplexsetlabelvalue
+#define dmplexgetlabelsize_        dmplexlabelsize
+#define dmplexgetlabelidis_        dmplexlabelidis
+#define dmplexgetstratumsize_      dmplexgetstratumsize
+#define dmplexgetstratumis_        dmplexgetstratumis
+#define dmplexgetlabel_            dmplexgetlabel
+#endif
+
+/* Definitions of Fortran Wrapper routines */
+
+PETSC_EXTERN void PETSC_STDCALL dmplexhaslabel_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscBool *hasLabel, int *ierr PETSC_END_LEN(lenN))
+{
+  char *lname;
+
+  FIXCHAR(name, lenN, lname);
+  *ierr = DMPlexHasLabel(*dm, lname, hasLabel);
+  FREECHAR(name, lname);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmplexgetlabelvalue_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *point, PetscInt *value, int *ierr PETSC_END_LEN(lenN))
+{
+  char *lname;
+
+  FIXCHAR(name, lenN, lname);
+  *ierr = DMPlexGetLabelValue(*dm, lname, *point, value);
+  FREECHAR(name, lname);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmplexsetlabelvalue_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *point, PetscInt *value, int *ierr PETSC_END_LEN(lenN))
+{
+  char *lname;
+
+  FIXCHAR(name, lenN, lname);
+  *ierr = DMPlexSetLabelValue(*dm, lname, *point, *value);
+  FREECHAR(name, lname);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmplexgetlabelsize_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *size, int *ierr PETSC_END_LEN(lenN))
+{
+  char *lname;
+
+  FIXCHAR(name, lenN, lname);
+  *ierr = DMPlexGetLabelSize(*dm, lname, size);
+  FREECHAR(name, lname);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmplexgetlabelidis_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), IS *ids, int *ierr PETSC_END_LEN(lenN))
+{
+  char *lname;
+
+  FIXCHAR(name, lenN, lname);
+  *ierr = DMPlexGetLabelIdIS(*dm, lname, ids);
+  FREECHAR(name, lname);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmplexgetstratumsize_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *value, PetscInt *size, int *ierr PETSC_END_LEN(lenN))
+{
+  char *lname;
+
+  FIXCHAR(name, lenN, lname);
+  *ierr = DMPlexGetStratumSize(*dm, lname, *value, size);
+  FREECHAR(name, lname);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmplexgetstratumis_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), PetscInt *value, IS *is, int *ierr PETSC_END_LEN(lenN))
+{
+  char *lname;
+
+  FIXCHAR(name, lenN, lname);
+  *ierr = DMPlexGetStratumIS(*dm, lname, *value, is);
+  FREECHAR(name, lname);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmplexgetlabel_(DM *dm, CHAR name PETSC_MIXED_LEN(lenN), DMLabel *label, int *ierr PETSC_END_LEN(lenN))
+{
+  char *lname;
+
+  FIXCHAR(name, lenN, lname);
+  *ierr = DMPlexGetLabel(*dm, lname, label);
+  FREECHAR(name, lname);
+}

src/dm/impls/plex/plexlabel.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMLabelGetValue"
+/*@
+  DMLabelGetValue - Return the value a label assigns to a point, or -1
+
+  Input Parameters:
++ label - the DMLabel
+- point - the point
+
+  Output Parameter:
+. value - The point value, or -1
+
+  Level: intermediate
+
+.seealso: DMLabelCreate(), DMLabelSetValue(), DMLabelClearValue()
+@*/
 PetscErrorCode DMLabelGetValue(DMLabel label, PetscInt point, PetscInt *value)
 {
   PetscInt       v;
 
 #undef __FUNCT__
 #define __FUNCT__ "DMLabelSetValue"
+/*@
+  DMLabelSetValue - Set the value a label assigns to a point
+
+  Input Parameters:
++ label - the DMLabel
+. point - the point
+- value - The point value
+
+  Level: intermediate
+
+.seealso: DMLabelCreate(), DMLabelGetValue(), DMLabelClearValue()
+@*/
 PetscErrorCode DMLabelSetValue(DMLabel label, PetscInt point, PetscInt value)
 {
   PetscInt       v, loc;
 
 #undef __FUNCT__
 #define __FUNCT__ "DMLabelClearValue"
+/*@
+  DMLabelClearValue - Clear the value a label assigns to a point
+
+  Input Parameters:
++ label - the DMLabel
+. point - the point
+- value - The point value
+
+  Level: intermediate
+
+.seealso: DMLabelCreate(), DMLabelGetValue(), DMLabelSetValue()
+@*/
 PetscErrorCode DMLabelClearValue(DMLabel label, PetscInt point, PetscInt value)
 {
   PetscInt       v, p;