Matt Knepley avatar Matt Knepley committed a5e93ea

DMPlex: Added support for INSERT_BC_VALUES in VecSetClosure()

Comments (0)

Files changed (1)

src/dm/impls/plex/plex.c

 }
 
 #undef __FUNCT__
+#define __FUNCT__ "updatePointBC_private"
+PetscErrorCode updatePointBC_private(PetscSection section, PetscInt point, PetscInt dof, void (*fuse)(PetscScalar*, PetscScalar), PetscInt orientation, const PetscScalar values[], PetscScalar array[])
+{
+  PetscInt        cdof;   /* The number of constraints on this point */
+  const PetscInt *cdofs; /* The indices of the constrained dofs on this point */
+  PetscScalar    *a;
+  PetscInt        off, cind = 0, k;
+  PetscErrorCode  ierr;
+
+  PetscFunctionBegin;
+  ierr = PetscSectionGetConstraintDof(section, point, &cdof);CHKERRQ(ierr);
+  ierr = PetscSectionGetOffset(section, point, &off);CHKERRQ(ierr);
+  a    = &array[off];
+  if (cdof) {
+    ierr = PetscSectionGetConstraintIndices(section, point, &cdofs);CHKERRQ(ierr);
+    if (orientation >= 0) {
+      for (k = 0; k < dof; ++k) {
+        if ((cind < cdof) && (k == cdofs[cind])) {
+          fuse(&a[k], values[k]);
+          ++cind;
+        }
+      }
+    } else {
+      for (k = 0; k < dof; ++k) {
+        if ((cind < cdof) && (k == cdofs[cind])) {
+          fuse(&a[k], values[dof-k-1]);
+          ++cind;
+        }
+      }
+    }
+  }
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
 #define __FUNCT__ "updatePointFields_private"
 PetscErrorCode updatePointFields_private(PetscSection section, PetscInt point, PetscInt foffs[], void (*fuse)(PetscScalar*, PetscScalar), PetscBool setBC, PetscInt orientation, const PetscScalar values[], PetscScalar array[])
 {
 }
 
 #undef __FUNCT__
+#define __FUNCT__ "updatePointFieldsBC_private"
+PetscErrorCode updatePointFieldsBC_private(PetscSection section, PetscInt point, PetscInt foffs[], void (*fuse)(PetscScalar*, PetscScalar), PetscInt orientation, const PetscScalar values[], PetscScalar array[])
+{
+  PetscScalar   *a;
+  PetscInt       numFields, off, foff, f;
+  PetscErrorCode ierr;
+
+  PetscFunctionBegin;
+  ierr = PetscSectionGetNumFields(section, &numFields);CHKERRQ(ierr);
+  ierr = PetscSectionGetOffset(section, point, &off);CHKERRQ(ierr);
+  a    = &array[off];
+  for (f = 0, foff = 0; f < numFields; ++f) {
+    PetscInt        fdof, fcomp, fcdof;
+    const PetscInt *fcdofs; /* The indices of the constrained dofs for field f on this point */
+    PetscInt        cind = 0, k, c;
+
+    ierr = PetscSectionGetFieldComponents(section, f, &fcomp);CHKERRQ(ierr);
+    ierr = PetscSectionGetFieldDof(section, point, f, &fdof);CHKERRQ(ierr);
+    ierr = PetscSectionGetFieldConstraintDof(section, point, f, &fcdof);CHKERRQ(ierr);
+    if (fcdof) {
+      ierr = PetscSectionGetFieldConstraintIndices(section, point, f, &fcdofs);CHKERRQ(ierr);
+      if (orientation >= 0) {
+        for (k = 0; k < fdof; ++k) {
+          if ((cind < fcdof) && (k == fcdofs[cind])) {
+            fuse(&a[foff+k], values[foffs[f]+k]);
+            ++cind;
+          }
+        }
+      } else {
+        for (k = fdof/fcomp-1; k >= 0; --k) {
+          for (c = 0; c < fcomp; ++c) {
+            if ((cind < fcdof) && (k*fcomp+c == fcdofs[cind])) {
+              fuse(&a[foff+(fdof/fcomp-1-k)*fcomp+c], values[foffs[f]+k*fcomp+c]);
+              ++cind;
+            }
+          }
+        }
+      }
+    }
+    foff     += fdof;
+    foffs[f] += fdof;
+  }
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
 #define __FUNCT__ "DMPlexVecSetClosure"
 /*@C
   DMPlexVecSetClosure - Set an array of the values on the closure of 'point'
         PetscInt o = points[p+1];
         updatePointFields_private(section, points[p], offsets, insert, PETSC_TRUE,  o, values, array);
       } break;
+    case INSERT_BC_VALUES:
+      for (p = 0; p < numPoints*2; p += 2) {
+        PetscInt o = points[p+1];
+        updatePointFieldsBC_private(section, points[p], offsets, insert,  o, values, array);
+      } break;
     case ADD_VALUES:
       for (p = 0; p < numPoints*2; p += 2) {
         PetscInt o = points[p+1];
         ierr = PetscSectionGetDof(section, points[p], &dof);CHKERRQ(ierr);
         updatePoint_private(section, points[p], dof, insert, PETSC_TRUE,  o, &values[off], array);
       } break;
+    case INSERT_BC_VALUES:
+      for (p = 0, off = 0; p < numPoints*2; p += 2, off += dof) {
+        PetscInt o = points[p+1];
+        ierr = PetscSectionGetDof(section, points[p], &dof);CHKERRQ(ierr);
+        updatePointBC_private(section, points[p], dof, insert,  o, &values[off], array);
+      } break;
     case ADD_VALUES:
       for (p = 0, off = 0; p < numPoints*2; p += 2, off += dof) {
         PetscInt o = points[p+1];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.