[cig-commits] r21086 - in short/3D/PyLith/trunk/libsrc/pylith: meshio topology

knepley at geodynamics.org knepley at geodynamics.org
Wed Nov 28 22:05:04 PST 2012


Author: knepley
Date: 2012-11-28 22:05:03 -0800 (Wed, 28 Nov 2012)
New Revision: 21086

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5.cc
   short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5Ext.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/Field.hh
Log:
Respect labels when making BC scatters

Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5.cc	2012-11-28 22:24:57 UTC (rev 21085)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5.cc	2012-11-29 06:05:03 UTC (rev 21086)
@@ -376,7 +376,7 @@
   try {
     const char* context = DataWriter<mesh_type, field_type>::_context.c_str();
 
-    field.createScatterWithBC(mesh, PETSC_NULL, context);
+    field.createScatterWithBC(mesh, "", 0, context);
     field.scatterSectionToVector(context);
     PetscVec vector = field.vector(context);
     assert(vector);
@@ -435,7 +435,7 @@
     const char* context = DataWriter<mesh_type, field_type>::_context.c_str();
     PetscErrorCode err = 0;
 
-    field.createScatterWithBC(field.mesh(), PETSC_NULL, context);
+    field.createScatterWithBC(field.mesh(), label ? label : "", labelId, context);
     field.scatterSectionToVector(context);
     PetscVec vector = field.vector(context);
     assert(vector);

Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5Ext.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5Ext.cc	2012-11-28 22:24:57 UTC (rev 21085)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterHDF5Ext.cc	2012-11-29 06:05:03 UTC (rev 21086)
@@ -379,7 +379,7 @@
 
     assert(dmMesh);
     err = MPI_Comm_rank(((PetscObject) dmMesh)->comm, &commRank);CHECK_PETSC_ERROR(err);
-    field.createScatterWithBC(mesh, PETSC_NULL, context);
+    field.createScatterWithBC(mesh, "", 0, context);
     field.scatterSectionToVector(context);
     PetscVec vector = field.vector(context);
     assert(vector);
@@ -513,7 +513,7 @@
 
     assert(dmMesh);
     err = MPI_Comm_rank(((PetscObject) dmMesh)->comm, &commRank);CHECK_PETSC_ERROR(err);
-    field.createScatterWithBC(field.mesh(), PETSC_NULL, context);
+    field.createScatterWithBC(field.mesh(), label ? label : "", labelId, context);
     field.scatterSectionToVector(context);
     PetscVec vector = field.vector(context);
     assert(vector);

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc	2012-11-28 22:24:57 UTC (rev 21085)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc	2012-11-29 06:05:03 UTC (rev 21086)
@@ -1535,7 +1535,8 @@
 void
 pylith::topology::Field<mesh_type, section_type>::createScatterWithBC(
        const scatter_mesh_type& mesh,
-       const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
+       const std::string& labelName,
+       PetscInt labelValue,
        const char* context)
 { // createScatterWithBC
   assert(context);
@@ -1554,49 +1555,6 @@
   ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
   logger.stagePush("GlobalOrder");
 
-  if (!_section.isNull() && !numbering.isNull()) {
-    // Get global order (create if necessary).
-    const std::string& orderLabel = 
-      (strlen(context) > 0) ?
-      _section->getName() + std::string("_") + std::string(context) :
-      _section->getName();
-    const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = mesh.sieveMesh();
-    assert(!sieveMesh.isNull());
-    const ALE::Obj<typename mesh_type::SieveMesh::order_type>& order = 
-      sieveMesh->getFactory()->getGlobalOrderWithBC(sieveMesh, orderLabel,
-                                                    numbering->getChart().begin(),
-                                                    numbering->getChart().end(),
-                                                    _section);
-    assert(!order.isNull());
-    //order->view("GLOBAL ORDER"); // DEBUG
-
-    // Create scatter
-    err = DMMeshCreateGlobalScatter(sieveMesh, _section, order, true, &sinfo.scatter); 
-    CHECK_PETSC_ERROR(err);
-
-    // Create scatterVec
-    const int blockSize = _getFiberDim();
-    if (_section->sizeWithBC() > 0) {
-      err = VecCreateSeqWithArray(PETSC_COMM_SELF,
-                                  blockSize, _section->getStorageSize(),
-                                  _section->restrictSpace(),
-                                  &sinfo.scatterVec);CHECK_PETSC_ERROR(err);
-    } else {
-      err = VecCreateSeqWithArray(PETSC_COMM_SELF, 
-                                  blockSize, 0, PETSC_NULL,
-                                  &sinfo.scatterVec);CHECK_PETSC_ERROR(err);
-    } // else
-
-#if 0
-    // Create vector
-    err = VecCreate(mesh.comm(), &sinfo.vector);CHECK_PETSC_ERROR(err);
-    err = PetscObjectSetName((PetscObject)sinfo.vector, _metadata["default"].label.c_str());CHECK_PETSC_ERROR(err);
-    err = VecSetSizes(sinfo.vector,order->getLocalSize(), order->getGlobalSize());CHECK_PETSC_ERROR(err);
-    err = VecSetBlockSize(sinfo.vector, blockSize);CHECK_PETSC_ERROR(err);
-    err = VecSetFromOptions(sinfo.vector); CHECK_PETSC_ERROR(err);  
-#endif
-  }
-
   PetscSection section, newSection, gsection;
   PetscSF      sf;
   PetscInt     cEnd, cMax, vEnd, vMax;
@@ -1611,7 +1569,14 @@
   err = PetscSectionClone(section, &newSection);CHECK_PETSC_ERROR(err);
   err = DMSetDefaultSection(sinfo.dm, newSection);CHECK_PETSC_ERROR(err);
   err = DMGetPointSF(sinfo.dm, &sf);CHECK_PETSC_ERROR(err);
-  err = PetscSectionCreateGlobalSectionCensored(section, sf, PETSC_TRUE, numExcludes, excludeRanges, &gsection);CHECK_PETSC_ERROR(err);
+  if (labelName.empty()) {
+    err = PetscSectionCreateGlobalSectionCensored(section, sf, PETSC_TRUE, numExcludes, excludeRanges, &gsection);CHECK_PETSC_ERROR(err);
+  } else {
+    DMLabel label;
+
+    err = DMComplexGetLabel(sinfo.dm, labelName.c_str(), &label);CHECK_PETSC_ERROR(err);
+    err = PetscSectionCreateGlobalSectionLabel(section, sf, PETSC_TRUE, label, labelValue, &gsection);CHECK_PETSC_ERROR(err);
+  }
   err = DMSetDefaultGlobalSection(sinfo.dm, gsection);CHECK_PETSC_ERROR(err);
   err = DMCreateGlobalVector(sinfo.dm, &sinfo.vector);CHECK_PETSC_ERROR(err);
   err = PetscObjectSetName((PetscObject) sinfo.vector, _metadata["default"].label.c_str());CHECK_PETSC_ERROR(err);

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Field.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Field.hh	2012-11-28 22:24:57 UTC (rev 21085)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Field.hh	2012-11-29 06:05:03 UTC (rev 21086)
@@ -392,13 +392,15 @@
    * from the PETSc vector.
    *
    * @param mesh Mesh associated with scatter.
-   * @param numbering Numbering used to select points in section.
+   * @param labelName The name of the label defining the point set, or PETSC_NULL
+   * @param labelValue The label stratum defining the point set
    * @param context Label for context associated with vector.
    */
   template<typename scatter_mesh_type>
   void createScatterWithBC(const scatter_mesh_type& mesh,
-			   const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
-		     const char* context ="");
+                           const std::string& labelName,
+                           PetscInt labelValue,
+                           const char* context ="");
 
   /** Get PETSc vector associated with field.
    *



More information about the CIG-COMMITS mailing list