[cig-commits] [commit] knepley/upgrade-petsc-interface: Implemented StratumIS filtering to cells only. (1955c80)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Tue Nov 12 09:03:15 PST 2013


Repository : ssh://geoshell/pylith

On branch  : knepley/upgrade-petsc-interface
Link       : https://github.com/geodynamics/pylith/compare/70e98ee8a2f7a96f12d544487cc44287b37d1496...1955c80cd1c5ef0e23fe374bbad2ea204453c7a8

>---------------------------------------------------------------

commit 1955c80cd1c5ef0e23fe374bbad2ea204453c7a8
Author: Brad Aagaard <baagaard at usgs.gov>
Date:   Tue Nov 12 09:05:48 2013 -0800

    Implemented StratumIS filtering to cells only.


>---------------------------------------------------------------

1955c80cd1c5ef0e23fe374bbad2ea204453c7a8
 libsrc/pylith/faults/FaultCohesiveLagrange.cc    |  6 +++--
 libsrc/pylith/faults/FaultCohesiveTract.cc       |  3 ++-
 libsrc/pylith/feassemble/IntegratorElasticity.cc |  6 +++--
 libsrc/pylith/materials/Material.cc              |  3 ++-
 libsrc/pylith/meshio/CellFilterAvg.cc            |  3 ++-
 libsrc/pylith/meshio/DataWriterVTK.cc            |  3 ++-
 libsrc/pylith/topology/Stratum.icc               | 28 ++++++++++++++++++++----
 7 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/libsrc/pylith/faults/FaultCohesiveLagrange.cc b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
index 6043de8..06f584a 100644
--- a/libsrc/pylith/faults/FaultCohesiveLagrange.cc
+++ b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
@@ -966,7 +966,8 @@ pylith::faults::FaultCohesiveLagrange::verifyConfiguration(const topology::Mesh&
   } // if
 
   // Check quadrature against mesh
-  topology::StratumIS cohesiveIS(dmMesh, "material-id", id());
+  const bool includeOnlyCells = true;
+  topology::StratumIS cohesiveIS(dmMesh, "material-id", id(), includeOnlyCells);
   const PetscInt* cells = cohesiveIS.points();
   const PetscInt ncells = cohesiveIS.size();
   for(PetscInt i = 0; i < ncells; ++i) {
@@ -1050,7 +1051,8 @@ void pylith::faults::FaultCohesiveLagrange::_initializeCohesiveInfo(const topolo
 
   // Get cohesive cells
   PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
-  delete _cohesiveIS; _cohesiveIS = new topology::StratumIS(dmMesh, "material-id", id());assert(_cohesiveIS);
+  const bool includeOnlyCells = true;
+  delete _cohesiveIS; _cohesiveIS = new topology::StratumIS(dmMesh, "material-id", id(), includeOnlyCells);assert(_cohesiveIS);
   const PetscInt* cohesiveCells = _cohesiveIS->points();
   const int numCohesiveCells = _cohesiveIS->size();
 
diff --git a/libsrc/pylith/faults/FaultCohesiveTract.cc b/libsrc/pylith/faults/FaultCohesiveTract.cc
index d277080..aa0e2f2 100644
--- a/libsrc/pylith/faults/FaultCohesiveTract.cc
+++ b/libsrc/pylith/faults/FaultCohesiveTract.cc
@@ -134,7 +134,8 @@ pylith::faults::FaultCohesiveTract::verifyConfiguration(const topology::Mesh& me
   } // if
 
   const int numCorners = _quadrature->refGeometry().numCorners();
-  topology::StratumIS cohesiveIS(dmMesh, "material-id", id());
+  const bool includeOnlyCells = true;
+  topology::StratumIS cohesiveIS(dmMesh, "material-id", id(), includeOnlyCells);
   const PetscInt* cells = cohesiveIS.points();
   const PetscInt ncells = cohesiveIS.size();
 
diff --git a/libsrc/pylith/feassemble/IntegratorElasticity.cc b/libsrc/pylith/feassemble/IntegratorElasticity.cc
index 78c9a62..4b9a431 100644
--- a/libsrc/pylith/feassemble/IntegratorElasticity.cc
+++ b/libsrc/pylith/feassemble/IntegratorElasticity.cc
@@ -114,7 +114,8 @@ pylith::feassemble::IntegratorElasticity::initialize(const topology::Mesh& mesh)
   // Setup index set for material.
   PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
   if (!_materialIS) {
-    delete _materialIS; _materialIS = new topology::StratumIS(dmMesh, "material-id", _material->id());assert(_materialIS); // :TODO: FIX THIS
+    const bool includeOnlyCells = true;
+    delete _materialIS; _materialIS = new topology::StratumIS(dmMesh, "material-id", _material->id(), includeOnlyCells);assert(_materialIS);
   } // if
 
   // Compute geometry for quadrature operations.
@@ -261,7 +262,8 @@ pylith::feassemble::IntegratorElasticity::verifyConfiguration(const topology::Me
   } // if
 
   PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
-  topology::StratumIS materialIS(dmMesh, "material-id", _material->id()); // :TODO: FIX THIS
+  const bool includeOnlyCells = true;
+  topology::StratumIS materialIS(dmMesh, "material-id", _material->id(), includeOnlyCells);
   const PetscInt* cells = materialIS.points();
   const PetscInt numCells = materialIS.size();
 
diff --git a/libsrc/pylith/materials/Material.cc b/libsrc/pylith/materials/Material.cc
index e5aee74..0b2e543 100644
--- a/libsrc/pylith/materials/Material.cc
+++ b/libsrc/pylith/materials/Material.cc
@@ -128,7 +128,8 @@ pylith::materials::Material::initialize(const topology::Mesh& mesh,
 
   // Get cells associated with material
   PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
-  delete _materialIS; _materialIS = new topology::StratumIS(dmMesh, "material-id", _id);assert(_materialIS); // :TODO: FIX THIS
+  const bool includeOnlyCells = true;
+  delete _materialIS; _materialIS = new topology::StratumIS(dmMesh, "material-id", _id, includeOnlyCells);assert(_materialIS);
   const PetscInt numCells = _materialIS->size();
   const PetscInt* cells = _materialIS->points();
 
diff --git a/libsrc/pylith/meshio/CellFilterAvg.cc b/libsrc/pylith/meshio/CellFilterAvg.cc
index 0aff006..f2d2d64 100644
--- a/libsrc/pylith/meshio/CellFilterAvg.cc
+++ b/libsrc/pylith/meshio/CellFilterAvg.cc
@@ -107,7 +107,8 @@ pylith::meshio::CellFilterAvg::filter(const topology::Field& fieldIn,
     numCells = cEnd - cStart;
   } else {
     if (!_cellsIS) {
-      _cellsIS = new topology::StratumIS(dmMesh, label, labelId);assert(_cellsIS);
+      const bool includeOnlyCells = true;
+      _cellsIS = new topology::StratumIS(dmMesh, label, labelId, includeOnlyCells);assert(_cellsIS);
     } // if
     numCells = _cellsIS->size();
     if (numCells > 0) {
diff --git a/libsrc/pylith/meshio/DataWriterVTK.cc b/libsrc/pylith/meshio/DataWriterVTK.cc
index b828bd7..450a975 100644
--- a/libsrc/pylith/meshio/DataWriterVTK.cc
+++ b/libsrc/pylith/meshio/DataWriterVTK.cc
@@ -201,7 +201,8 @@ pylith::meshio::DataWriterVTK::openTimeStep(const PylithScalar t,
 
   // Create VTK label in DM: Cleared in closeTimeStep().
   if (label) {
-    topology::StratumIS cellsIS(_dm, label, labelId);
+    const bool includeOnlyCells = true;
+    topology::StratumIS cellsIS(_dm, label, labelId, includeOnlyCells);
     const PetscInt ncells = cellsIS.size();
     const PetscInt* cells = cellsIS.points();
     DMLabel label;
diff --git a/libsrc/pylith/topology/Stratum.icc b/libsrc/pylith/topology/Stratum.icc
index f8df592..58fe33b 100644
--- a/libsrc/pylith/topology/Stratum.icc
+++ b/libsrc/pylith/topology/Stratum.icc
@@ -92,13 +92,33 @@ pylith::topology::StratumIS::StratumIS(const PetscDM dmMesh,
 { // constructor
   assert(dmMesh);
   PetscErrorCode err;
-  err = DMPlexGetStratumIS(dmMesh, label, id, &_indexSet);PYLITH_CHECK_ERROR(err);assert(_indexSet);
   if (!includeOnlyCells) {
-    err = ISGetSize(_indexSet, &_size);PYLITH_CHECK_ERROR(err);assert(_size >= 0);
-    err = ISGetIndices(_indexSet, &_points);PYLITH_CHECK_ERROR(err);assert(!_size || _points);
+    err = DMPlexGetStratumIS(dmMesh, label, id, &_indexSet);PYLITH_CHECK_ERROR(err);assert(_indexSet);
   } else {
-    // :TODO: Matt add stuff here
+    PetscIS pointsIS = NULL;
+    PetscInt numPoints = 0;
+    const PetscInt* points = NULL;
+    err = DMPlexGetStratumIS(dmMesh, label, id, &pointsIS);PYLITH_CHECK_ERROR(err);assert(pointsIS);
+    err = ISGetSize(pointsIS, &numPoints);PYLITH_CHECK_ERROR(err);assert(numPoints >= 0);
+    err = ISGetIndices(pointsIS, &points);PYLITH_CHECK_ERROR(err);assert(!numPoints || points);
+    PetscInt cStart, cEnd;
+    err = DMPlexGetHeightStratum(dmMesh, 0, &cStart, &cEnd);PYLITH_CHECK_ERROR(err);
+    PetscInt* cells = (numPoints > 0) ? new PetscInt[numPoints] : 0;
+    PetscInt count = 0;
+    for (PetscInt i=0; i < numPoints; ++i) {
+      if (points[i] >= cStart && points[i] < cEnd) {
+	cells[count++] = points[i];
+      } // if
+    } // for
+    MPI_Comm comm;
+    err = PetscObjectGetComm((PetscObject) dmMesh, &comm);PYLITH_CHECK_ERROR(err);
+    err = ISCreateGeneral(comm, count, cells, PETSC_COPY_VALUES, &_indexSet);PYLITH_CHECK_ERROR(err);
+    delete[] cells; cells = 0;
+    err = ISDestroy(&pointsIS);PYLITH_CHECK_ERROR(err);assert(!pointsIS);
   } // if/else
+
+  err = ISGetSize(_indexSet, &_size);PYLITH_CHECK_ERROR(err);assert(_size >= 0);
+  err = ISGetIndices(_indexSet, &_points);PYLITH_CHECK_ERROR(err);assert(!_size || _points);
 } // constructor
 
 // ----------------------------------------------------------------------



More information about the CIG-COMMITS mailing list