[cig-commits] r21568 - short/3D/PyLith/trunk/libsrc/pylith/topology

brad at geodynamics.org brad at geodynamics.org
Tue Mar 19 11:25:27 PDT 2013


Author: brad
Date: 2013-03-19 11:25:26 -0700 (Tue, 19 Mar 2013)
New Revision: 21568

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.icc
   short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.hh
   short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.icc
Log:
Code cleanup and small updates for removing Sieve stuff.

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc	2013-03-19 18:24:55 UTC (rev 21567)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc	2013-03-19 18:25:26 UTC (rev 21568)
@@ -34,7 +34,7 @@
 // ----------------------------------------------------------------------
 // Default constructor
 pylith::topology::Mesh::Mesh(void) :
-  _newMesh(PETSC_NULL),
+  _newMesh(NULL),
   _numNormalCells(0), _numCohesiveCells(0), _numNormalVertices(0), _numShadowVertices(0), _numLagrangeVertices(0),
   _coordsys(0),
   _comm(PETSC_COMM_WORLD),
@@ -47,7 +47,7 @@
 pylith::topology::Mesh::Mesh(const int dim,
 			     const MPI_Comm& comm) :
   _mesh(new SieveMesh(comm, dim)),
-  _newMesh(PETSC_NULL),
+  _newMesh(NULL),
   _numNormalCells(0), _numCohesiveCells(0), _numNormalVertices(0), _numShadowVertices(0), _numLagrangeVertices(0),
   _coordsys(0),
   _comm(comm),

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.icc	2013-03-19 18:24:55 UTC (rev 21567)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.icc	2013-03-19 18:25:26 UTC (rev 21568)
@@ -102,12 +102,11 @@
 inline
 int
 pylith::topology::Mesh::dimension(void) const {
+  PetscInt dim = 0;
   if (_newMesh) {
-    PetscInt dim;
     PetscErrorCode err = DMPlexGetDimension(_newMesh, &dim);CHECK_PETSC_ERROR(err);
-    return dim;
-  }
-  return 0;
+  } // if
+  return dim;
 }
 
 // Get representative cone size for mesh.
@@ -128,24 +127,26 @@
 inline
 int
 pylith::topology::Mesh::numVertices(void) const {
+  PetscInt nvertices = 0;
   if (_newMesh) {
-    PetscInt       vStart, vEnd;
-    PetscErrorCode err = DMPlexGetDepthStratum(_newMesh, 0, &vStart, &vEnd);CHECK_PETSC_ERROR(err);
-    return vEnd-vStart;
-  }
-  return 0;
+    PetscInt begin=0, end=0;
+    PetscErrorCode err = DMPlexGetDepthStratum(_newMesh, 0, &begin, &end);CHECK_PETSC_ERROR(err);
+    nvertices = end-begin;
+  } // if
+  return nvertices;
 }
 
 // Get number of cells in mesh.
 inline
 int
 pylith::topology::Mesh::numCells(void) const {
+  PetscInt ncells = 0;
   if (_newMesh) {
-    PetscInt       cStart, cEnd;
-    PetscErrorCode err = DMPlexGetHeightStratum(_newMesh, 0, &cStart, &cEnd);CHECK_PETSC_ERROR(err);
-    return cEnd-cStart;
-  }
-  return 0;
+    PetscInt begin=0, end=0;
+    PetscErrorCode err = DMPlexGetHeightStratum(_newMesh, 0, &begin, &end);CHECK_PETSC_ERROR(err);
+    ncells = end-begin;
+  } // if
+  return ncells;
 }
 
 // Set MPI communicator associated with mesh.

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.cc	2013-03-19 18:24:55 UTC (rev 21567)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.cc	2013-03-19 18:25:26 UTC (rev 21568)
@@ -31,10 +31,12 @@
 #include <sstream> // USES std::ostringstream
 #include <cassert> // USES assert()
 
+#define ALLOW_SIEVE_MESH
+
 // ----------------------------------------------------------------------
 // Default constructor
 pylith::topology::SubMesh::SubMesh(void) :
-  _newMesh(PETSC_NULL),
+  _newMesh(NULL),
   _coordsys(0),
   _debug(false)
 { // constructor
@@ -44,7 +46,7 @@
 // Constructor with mesh and label for vertices marking boundary.
 pylith::topology::SubMesh::SubMesh(const Mesh& mesh,
 				   const char* label) :
-  _newMesh(PETSC_NULL),
+  _newMesh(NULL),
   _coordsys(0),
   _debug(false)
 { // constructor
@@ -73,6 +75,7 @@
 pylith::topology::SubMesh::createSubMesh(const Mesh& mesh,
 					 const char* label)
 { // createSieveMesh
+#if defined(ALLOW_SIEVE_MESH) // :TODO: REMOVE SIEVE STUFF
   _mesh.destroy();
 
   const ALE::Obj<DomainSieveMesh>& meshSieveMesh = mesh.sieveMesh();
@@ -137,12 +140,12 @@
                                             recvParallelMeshOverlap);
     _mesh->setCalculatedOverlap(true);
   }
+#endif
 
-  DM             dmMesh = mesh.dmMesh();
-  PetscBool      hasLabel;
+  PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
+  PetscBool hasLabel;
   PetscErrorCode err;
 
-  assert(dmMesh);
   err = DMPlexHasLabel(dmMesh, label, &hasLabel);CHECK_PETSC_ERROR(err);
   if (!hasLabel) {
     std::ostringstream msg;
@@ -181,9 +184,8 @@
 { // coordsys
   delete _coordsys; _coordsys = 0;
   const spatialdata::geocoords::CoordSys* cs = mesh.coordsys();
-  if (0 != cs) {
-    _coordsys = cs->clone();
-    assert(0 != _coordsys);
+  if (cs) {
+    _coordsys = cs->clone();assert(_coordsys);
     _coordsys->initialize();
   } // if
 } // coordsys
@@ -193,7 +195,7 @@
 void 
 pylith::topology::SubMesh::initialize(void)
 { // initialize
-  if (0 != _coordsys)
+  if (_coordsys)
     _coordsys->initialize();
 } // initialize
 

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.hh	2013-03-19 18:24:55 UTC (rev 21567)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.hh	2013-03-19 18:25:26 UTC (rev 21568)
@@ -106,7 +106,7 @@
    *
    * @param DMPlex mesh.
    */
-  void setDMMesh(DM dm);
+  void setDMMesh(PetscDM dm);
 
   /** Get sizes for all point types.
    *
@@ -116,7 +116,11 @@
    * @param numShadowVertices
    * @param numLagrangeVertices.
    */
-  void getPointTypeSizes(PetscInt *numNormalCells, PetscInt *numCohesiveCells, PetscInt *numNormalVertices, PetscInt *numShadowVertices, PetscInt *numLagrangeVertices) const;
+  void getPointTypeSizes(PetscInt *numNormalCells,
+			 PetscInt *numCohesiveCells,
+			 PetscInt *numNormalVertices,
+			 PetscInt *numShadowVertices,
+			 PetscInt *numLagrangeVertices) const;
 
   /** Set coordinate system using mesh.
    *
@@ -185,7 +189,7 @@
 private :
 
   ALE::Obj<SieveMesh> _mesh; ///< Sieve mesh.
-  DM _newMesh;
+  PetscDM _newMesh;
   spatialdata::geocoords::CoordSys* _coordsys; ///< Coordinate system.
   bool _debug; ///< Debugging flag for mesh.
   

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.icc	2013-03-19 18:24:55 UTC (rev 21567)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/SubMesh.icc	2013-03-19 18:25:26 UTC (rev 21568)
@@ -38,7 +38,7 @@
 
 // Get DMComplex mesh.
 inline
-DM
+PetscDM
 pylith::topology::SubMesh::dmMesh(void) const {
   return _newMesh;
 }
@@ -46,7 +46,7 @@
 // Set DMComplex mesh.
 inline
 void
-pylith::topology::SubMesh::setDMMesh(DM dm) {
+pylith::topology::SubMesh::setDMMesh(PetscDM dm) {
   PetscErrorCode err;
   err = DMDestroy(&_newMesh);CHECK_PETSC_ERROR(err);
   _newMesh = dm;
@@ -56,11 +56,15 @@
 // Get point type sizes.
 inline
 void
-pylith::topology::SubMesh::getPointTypeSizes(PetscInt *numNormalCells, PetscInt *numCohesiveCells, PetscInt *numNormalVertices, PetscInt *numShadowVertices, PetscInt *numLagrangeVertices) const {
-  *numNormalCells      = 0;
-  *numCohesiveCells    = 0;
-  *numNormalVertices   = 0;
-  *numShadowVertices   = 0;
+pylith::topology::SubMesh::getPointTypeSizes(PetscInt *numNormalCells,
+					     PetscInt *numCohesiveCells,
+					     PetscInt *numNormalVertices,
+					     PetscInt *numShadowVertices,
+					     PetscInt *numLagrangeVertices) const {
+  *numNormalCells = 0;
+  *numCohesiveCells = 0;
+  *numNormalVertices = 0;
+  *numShadowVertices = 0;
   *numLagrangeVertices = 0;
 }
 
@@ -91,38 +95,63 @@
 inline
 int
 pylith::topology::SubMesh::dimension(void) const {
-  return (!_mesh.isNull()) ? _mesh->getDimension() : 0;
+  PetscInt dim = 0;
+  if (_newMesh) {
+    PetscErrorCode err = DMPlexGetDimension(_newMesh, &dim);CHECK_PETSC_ERROR(err);
+  } // if
+  return dim;
 }
 
 // Get representative cone size for mesh.
 inline
 int
 pylith::topology::SubMesh::coneSize(void) const {
-  
-  return (!_mesh.isNull() && numCells() > 0) ? 
-    _mesh->getSieve()->getConeSize(*_mesh->heightStratum(1)->begin()) : 0;
+  PetscInt coneSize = 0;
+  if (_newMesh) {
+    PetscErrorCode err;
+    PetscInt cStart = 0;
+    err = DMPlexGetHeightStratum(_newMesh, 0, &cStart, NULL);CHECK_PETSC_ERROR(err);
+    err = DMPlexGetConeSize(_newMesh, cStart, &coneSize);CHECK_PETSC_ERROR(err);
+  } // if
+  return coneSize;
 }
 
 // Get number of vertices in mesh.
 inline
 int
 pylith::topology::SubMesh::numVertices(void) const {
-  return (!_mesh.isNull() && _mesh->depth() > 0) ? _mesh->depthStratum(0)->size() : 0;
+  PetscInt nvertices = 0;
+  if (_newMesh) {
+    PetscInt begin=0, end=0;
+    PetscErrorCode err = DMPlexGetDepthStratum(_newMesh, 0, &begin, &end);CHECK_PETSC_ERROR(err);
+    nvertices = end-begin;
+  } // if
+  return nvertices;
 }
 
 // Get number of cells in mesh.
 inline
 int
 pylith::topology::SubMesh::numCells(void) const {
-  return (!_mesh.isNull() && _mesh->height() > 0) ? _mesh->heightStratum(1)->size() : 0;
+  PetscInt ncells = 0;
+  if (_newMesh) {
+    PetscInt begin=0, end=0;
+    PetscErrorCode err = DMPlexGetHeightStratum(_newMesh, 0, &begin, &end);CHECK_PETSC_ERROR(err);
+    ncells = end-begin;
+  } // if
+  return ncells;
 }
 
 // Get MPI communicator associated with mesh.
 inline
 const MPI_Comm
 pylith::topology::SubMesh::comm(void) const {
-  return (!_mesh.isNull()) ? _mesh->comm() : 0;
-}
+  MPI_Comm comm = NULL;
+  if (_newMesh) {
+    PetscErrorCode err = PetscObjectGetComm((PetscObject)_newMesh, &comm);
+  } // if
+  return comm;
+} // if
     
 // Print mesh to stdout.
 inline



More information about the CIG-COMMITS mailing list