[cig-commits] r18828 - in short/3D/PyLith/branches/v1.6-stable: libsrc/pylith/faults libsrc/pylith/meshio libsrc/pylith/topology modulesrc/topology pylith/problems

brad at geodynamics.org brad at geodynamics.org
Mon Aug 15 12:02:08 PDT 2011


Author: brad
Date: 2011-08-15 12:02:08 -0700 (Mon, 15 Aug 2011)
New Revision: 18828

Modified:
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/faults/FaultCohesiveDyn.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/DataWriterHDF5.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/DataWriterHDF5Ext.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/Field.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/Field.hh
   short/3D/PyLith/branches/v1.6-stable/modulesrc/topology/Field.i
   short/3D/PyLith/branches/v1.6-stable/modulesrc/topology/topology.i
   short/3D/PyLith/branches/v1.6-stable/pylith/problems/Explicit.py
   short/3D/PyLith/branches/v1.6-stable/pylith/problems/ExplicitLumped.py
   short/3D/PyLith/branches/v1.6-stable/pylith/problems/Formulation.py
   short/3D/PyLith/branches/v1.6-stable/pylith/problems/Implicit.py
   short/3D/PyLith/branches/v1.6-stable/pylith/problems/ImplicitCUDA.py
Log:
Fixed bug in creatting scatter. Can't use mesh associated with field because mesh for scatter might be different (e.g., subset of the mesh). Fix is to require mesh for scatter as an argument to createScatter().

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/faults/FaultCohesiveDyn.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/faults/FaultCohesiveDyn.cc	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/faults/FaultCohesiveDyn.cc	2011-08-15 19:02:08 UTC (rev 18828)
@@ -1529,7 +1529,7 @@
     const topology::Field<topology::SubMesh>& slip =
         _fields->get("slip");
     solution.cloneSection(slip);
-    solution.createScatter();
+    solution.createScatter(solution.mesh());
   } // if
   const topology::Field<topology::SubMesh>& solution =
       _fields->get("sensitivity solution");
@@ -1539,7 +1539,7 @@
     topology::Field<topology::SubMesh>& residual =
         _fields->get("sensitivity residual");
     residual.cloneSection(solution);
-    residual.createScatter();
+    residual.createScatter(solution.mesh());
   } // if
 
   if (!_fields->hasField("sensitivity dispRel")) {

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/DataWriterHDF5.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/DataWriterHDF5.cc	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/DataWriterHDF5.cc	2011-08-15 19:02:08 UTC (rev 18828)
@@ -129,7 +129,7 @@
     assert(!vNumbering.isNull());
     //vNumbering->view("VERTEX NUMBERING");
 
-    coordinates.createScatterWithBC(vNumbering, context);
+    coordinates.createScatterWithBC(mesh, vNumbering, context);
     coordinates.scatterSectionToVector(context);
     PetscVec coordinatesVector = coordinates.vector(context);
     assert(coordinatesVector);
@@ -277,7 +277,7 @@
     std::cout << std::endl;
 #endif
 
-    field.createScatterWithBC(vNumbering, context);
+    field.createScatterWithBC(mesh, vNumbering, context);
     field.scatterSectionToVector(context);
     PetscVec vector = field.vector(context);
     assert(vector);
@@ -373,7 +373,7 @@
     const ALE::Obj<typename mesh_type::SieveMesh::numbering_type>& numbering = 
       sieveMesh->getFactory()->getNumbering(sieveMesh, labelName, depth);
     assert(!numbering.isNull());
-    field.createScatterWithBC(numbering, context);
+    field.createScatterWithBC(field.mesh(), numbering, context);
     field.scatterSectionToVector(context);
     PetscVec vector = field.vector(context);
     assert(vector);

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/DataWriterHDF5Ext.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/DataWriterHDF5Ext.cc	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/DataWriterHDF5Ext.cc	2011-08-15 19:02:08 UTC (rev 18828)
@@ -130,7 +130,7 @@
       sieveMesh->getFactory()->getNumbering(sieveMesh, "censored depth", 0) :
       sieveMesh->getFactory()->getNumbering(sieveMesh, 0);
     assert(!vNumbering.isNull());
-    coordinates.createScatterWithBC(vNumbering, context);
+    coordinates.createScatterWithBC(mesh, vNumbering, context);
     coordinates.scatterSectionToVector(context);
     PetscVec coordinatesVector = coordinates.vector(context);
     assert(coordinatesVector);
@@ -300,7 +300,7 @@
       sieveMesh->getFactory()->getNumbering(sieveMesh, "censored depth", 0) :
       sieveMesh->getFactory()->getNumbering(sieveMesh, 0);
     assert(!vNumbering.isNull());
-    field.createScatterWithBC(vNumbering, context);
+    field.createScatterWithBC(mesh, vNumbering, context);
     field.scatterSectionToVector(context);
     PetscVec vector = field.vector(context);
     assert(vector);
@@ -436,7 +436,7 @@
     const ALE::Obj<typename mesh_type::SieveMesh::numbering_type>& numbering = 
       sieveMesh->getFactory()->getNumbering(sieveMesh, labelName, depth);
     assert(!numbering.isNull());
-    field.createScatterWithBC(numbering, context);
+    field.createScatterWithBC(field.mesh(), numbering, context);
     field.scatterSectionToVector(context);
     PetscVec vector = field.vector(context);
     assert(vector);

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/Field.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/Field.cc	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/Field.cc	2011-08-15 19:02:08 UTC (rev 18828)
@@ -745,12 +745,14 @@
 // information from the "global" PETSc vector view to the "local"
 // Sieve section view.
 template<typename mesh_type, typename section_type>
+template<typename scatter_mesh_type>
 void
-pylith::topology::Field<mesh_type, section_type>::createScatter(const char* context)
+pylith::topology::Field<mesh_type, section_type>::createScatter(const scatter_mesh_type& mesh,
+								const char* context)
 { // createScatter
   assert(context);
   assert(!_section.isNull());
-  assert(!_mesh.sieveMesh().isNull());
+  assert(!mesh.sieveMesh().isNull());
 
   PetscErrorCode err = 0;
   const bool createScatterOk = true;
@@ -767,7 +769,7 @@
   // Get global order (create if necessary).
   const std::string& orderLabel = _section->getName();
   const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh =
-    _mesh.sieveMesh();
+    mesh.sieveMesh();
   assert(!sieveMesh.isNull());
   const ALE::Obj<typename mesh_type::SieveMesh::order_type>& order = 
     sieveMesh->getFactory()->getGlobalOrder(sieveMesh, orderLabel,
@@ -775,7 +777,8 @@
   assert(!order.isNull());
 
   // Create scatter
-  err = DMMeshCreateGlobalScatter(_mesh.sieveMesh(), _section, order, false, &sinfo.scatter);
+  err = DMMeshCreateGlobalScatter(sieveMesh, _section, order, false, 
+				  &sinfo.scatter);
   CHECK_PETSC_ERROR(err);
   
   // Create scatterVec
@@ -809,14 +812,17 @@
 // DOF. Use createScatterWithBC() to include the constrained DOF in
 // the PETSc vector.
 template<typename mesh_type, typename section_type>
+template<typename scatter_mesh_type>
 void
-pylith::topology::Field<mesh_type, section_type>::createScatter(const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
-								const char* context)
+pylith::topology::Field<mesh_type, section_type>::createScatter(
+      const scatter_mesh_type& mesh,
+      const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
+      const char* context)
 { // createScatter
   assert(!numbering.isNull());
   assert(context);
   assert(!_section.isNull());
-  assert(!_mesh.sieveMesh().isNull());
+  assert(!mesh.sieveMesh().isNull());
 
   PetscErrorCode err = 0;
   const bool createScatterOk = true;
@@ -838,7 +844,7 @@
     _section->getName() + std::string("_") + std::string(context) :
     _section->getName();
   const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh =
-    _mesh.sieveMesh();
+    mesh.sieveMesh();
   assert(!sieveMesh.isNull());
   const ALE::Obj<typename mesh_type::SieveMesh::order_type>& order = 
     sieveMesh->getFactory()->getGlobalOrder(sieveMesh, orderLabel,
@@ -848,7 +854,8 @@
   assert(!order.isNull());
 
   // Create scatter
-  err = DMMeshCreateGlobalScatter(_mesh.sieveMesh(), _section, order, false, &sinfo.scatter); 
+  err = DMMeshCreateGlobalScatter(sieveMesh, _section, order, false, 
+				  &sinfo.scatter); 
   CHECK_PETSC_ERROR(err);
 
   // Create scatterVec
@@ -862,7 +869,7 @@
   } // if/else
 
   // Create vector
-  err = VecCreate(_mesh.comm(), &sinfo.vector);
+  err = VecCreate(mesh.comm(), &sinfo.vector);
   CHECK_PETSC_ERROR(err);
   err = PetscObjectSetName((PetscObject)sinfo.vector,
 			   _metadata.label.c_str());
@@ -892,12 +899,15 @@
 // DOF. Use createScatterWithBC() to include the constrained DOF in
 // the PETSc vector.
 template<typename mesh_type, typename section_type>
+template<typename scatter_mesh_type>
 void
-pylith::topology::Field<mesh_type, section_type>::createScatterWithBC(const char* context)
+pylith::topology::Field<mesh_type, section_type>::createScatterWithBC(
+        const scatter_mesh_type& mesh,
+	const char* context)
 { // createScatterWithBC
   assert(context);
   assert(!_section.isNull());
-  assert(!_mesh.sieveMesh().isNull());
+  assert(!mesh.sieveMesh().isNull());
 
 
   PetscErrorCode err = 0;
@@ -915,7 +925,7 @@
   // Get global order (create if necessary).
   const std::string& orderLabel = _section->getName();
   const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh =
-    _mesh.sieveMesh();
+    mesh.sieveMesh();
   assert(!sieveMesh.isNull());
   const ALE::Obj<typename mesh_type::SieveMesh::order_type>& order = 
     sieveMesh->getFactory()->getGlobalOrderWithBC(sieveMesh, orderLabel,
@@ -923,7 +933,8 @@
   assert(!order.isNull());
 
   // Create scatter
-  err = DMMeshCreateGlobalScatter(_mesh.sieveMesh(), _section, order, true, &sinfo.scatter); 
+  err = DMMeshCreateGlobalScatter(sieveMesh, _section, order, true, 
+				  &sinfo.scatter); 
   CHECK_PETSC_ERROR(err);
   
   // Create scatterVec
@@ -937,7 +948,7 @@
   } // if/else
   
   // Create vector
-   err = VecCreate(_mesh.comm(), &sinfo.vector);
+   err = VecCreate(mesh.comm(), &sinfo.vector);
   CHECK_PETSC_ERROR(err);
   err = PetscObjectSetName((PetscObject)sinfo.vector,
 			   _metadata.label.c_str());
@@ -957,9 +968,12 @@
 // createScatter() if constrained DOF should be omitted from the PETSc
 // vector.
 template<typename mesh_type, typename section_type>
+template<typename scatter_mesh_type>
 void
-pylith::topology::Field<mesh_type, section_type>::createScatterWithBC(const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
-								const char* context)
+pylith::topology::Field<mesh_type, section_type>::createScatterWithBC(
+       const scatter_mesh_type& mesh,
+       const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
+       const char* context)
 { // createScatterWithBC
   assert(!numbering.isNull());
   assert(context);
@@ -985,7 +999,7 @@
     _section->getName() + std::string("_") + std::string(context) :
     _section->getName();
   const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh =
-    _mesh.sieveMesh();
+    mesh.sieveMesh();
   assert(!sieveMesh.isNull());
   const ALE::Obj<typename mesh_type::SieveMesh::order_type>& order = 
     sieveMesh->getFactory()->getGlobalOrderWithBC(sieveMesh, orderLabel,
@@ -996,7 +1010,8 @@
   //order->view("GLOBAL ORDER"); // DEBUG
 
   // Create scatter
-  err = DMMeshCreateGlobalScatter(_mesh.sieveMesh(), _section, order, true, &sinfo.scatter); 
+  err = DMMeshCreateGlobalScatter(sieveMesh, _section, order, true, 
+				  &sinfo.scatter); 
   CHECK_PETSC_ERROR(err);
 
   // Create scatterVec
@@ -1010,7 +1025,7 @@
   } // if/else
 
   // Create vector
-  err = VecCreate(_mesh.comm(), &sinfo.vector);
+  err = VecCreate(mesh.comm(), &sinfo.vector);
   CHECK_PETSC_ERROR(err);
   err = PetscObjectSetName((PetscObject)sinfo.vector,
 			   _metadata.label.c_str());

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/Field.hh
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/Field.hh	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/Field.hh	2011-08-15 19:02:08 UTC (rev 18828)
@@ -267,9 +267,12 @@
    * DOF. Use createScatterWithBC() to include the constrained DOF in
    * the PETSc vector.
    *
+   * @param mesh Mesh associated with scatter.
    * @param context Label for context associated with vector.
    */
-  void createScatter(const char* context ="");
+  template<typename scatter_mesh_type>
+  void createScatter(const scatter_mesh_type& mesh,
+		     const char* context ="");
 
 
   /** Create PETSc vector scatter for field. This is used to transfer
@@ -278,10 +281,13 @@
    * DOF. Use createScatterWithBC() to include the constrained DOF in
    * the PETSc vector.
    *
+   * @param mesh Mesh associated with scatter.
    * @param numbering Numbering used to select points in section.
    * @param context Label for context associated with vector.
    */
-  void createScatter(const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
+  template<typename scatter_mesh_type>
+  void createScatter(const scatter_mesh_type& mesh,
+		     const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
 		     const char* context ="");
 
   /** Create PETSc vector scatter for field. This is used to transfer
@@ -290,9 +296,12 @@
    * DOF. Use createScatter() if constrained DOF should be omitted
    * from the PETSc vector.
    *
+   * @param mesh Mesh associated with scatter.
    * @param context Label for context associated with vector.
    */
-  void createScatterWithBC(const char* context ="");
+  template<typename scatter_mesh_type>
+  void createScatterWithBC(const scatter_mesh_type& mesh,
+			   const char* context ="");
 
 
   /** Create PETSc vector scatter for field. This is used to transfer
@@ -301,10 +310,13 @@
    * DOF. Use createScatter() if constrained DOF should be omitted
    * from the PETSc vector.
    *
+   * @param mesh Mesh associated with scatter.
    * @param numbering Numbering used to select points in section.
    * @param context Label for context associated with vector.
    */
-  void createScatterWithBC(const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
+  template<typename scatter_mesh_type>
+  void createScatterWithBC(const scatter_mesh_type& mesh,
+			   const typename ALE::Obj<typename SieveMesh::numbering_type> numbering,
 		     const char* context ="");
 
   /** Get PETSc vector associated with field.

Modified: short/3D/PyLith/branches/v1.6-stable/modulesrc/topology/Field.i
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/modulesrc/topology/Field.i	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/modulesrc/topology/Field.i	2011-08-15 19:02:08 UTC (rev 18828)
@@ -203,9 +203,12 @@
        * information from the "global" PETSc vector view to the "local"
        * Sieve section view.
        *
+       * @param mesh Mesh associated with scatter.
        * @param context Label for context associated with vector.
        */
-      void createScatter(const char* context ="");
+      template<typename scatter_mesh_type>
+      void createScatter(const scatter_mesh_type& mesh,
+			 const char* context ="");
 
       /** Get PETSc vector associated with field.
        *

Modified: short/3D/PyLith/branches/v1.6-stable/modulesrc/topology/topology.i
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/modulesrc/topology/topology.i	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/modulesrc/topology/topology.i	2011-08-15 19:02:08 UTC (rev 18828)
@@ -74,6 +74,7 @@
 %include "ReverseCuthillMcKee.i"
 
 // Template instatiation
+
 %template(MeshField) pylith::topology::Field<pylith::topology::Mesh>;
 %template(SubMeshField) pylith::topology::Field<pylith::topology::SubMesh>;
 %template(MeshFields) pylith::topology::Fields<pylith::topology::Field<pylith::topology::Mesh> >;
@@ -82,5 +83,12 @@
 %template(MeshFieldsNew) pylith::topology::FieldsNew<pylith::topology::Mesh>;
 %template(SubMeshFieldsNew) pylith::topology::FieldsNew<pylith::topology::SubMesh>;
 
+%extend pylith::topology::Field<pylith::topology::Mesh> {
+  %template(createScatterMesh) createScatter<pylith::topology::Mesh>;
+ }
+%extend pylith::topology::Field<pylith::topology::Mesh> {
+  %template(createScatterSubMesh) createScatter<pylith::topology::SubMesh>;
+ }
+
 // End of file
 

Modified: short/3D/PyLith/branches/v1.6-stable/pylith/problems/Explicit.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/pylith/problems/Explicit.py	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/pylith/problems/Explicit.py	2011-08-15 19:02:08 UTC (rev 18828)
@@ -119,7 +119,7 @@
     dispT.zero()
     residual = self.fields.get("residual")
     residual.zero()
-    residual.createScatter()
+    residual.createScatterMesh(residual.mesh())
 
     lengthScale = normalizer.lengthScale()
     timeScale = normalizer.timeScale()

Modified: short/3D/PyLith/branches/v1.6-stable/pylith/problems/ExplicitLumped.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/pylith/problems/ExplicitLumped.py	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/pylith/problems/ExplicitLumped.py	2011-08-15 19:02:08 UTC (rev 18828)
@@ -112,7 +112,7 @@
     dispT.zero()
     residual = self.fields.get("residual")
     residual.zero()
-    residual.createScatter()
+    residual.createScatterMesh(residual.mesh())
 
     lengthScale = normalizer.lengthScale()
     timeScale = normalizer.timeScale()

Modified: short/3D/PyLith/branches/v1.6-stable/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/pylith/problems/Formulation.py	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/pylith/problems/Formulation.py	2011-08-15 19:02:08 UTC (rev 18828)
@@ -491,7 +491,7 @@
     memoryLogger.stagePop()
 
     # This also creates a global order.
-    solution.createScatter()
+    solution.createScatterMesh(solution.mesh())
 
     memoryLogger.stagePush("Problem")
     dispT = self.fields.get("disp(t)")

Modified: short/3D/PyLith/branches/v1.6-stable/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/pylith/problems/Implicit.py	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/pylith/problems/Implicit.py	2011-08-15 19:02:08 UTC (rev 18828)
@@ -133,7 +133,7 @@
     dispT.zero()
     residual = self.fields.get("residual")
     residual.zero()
-    residual.createScatter()
+    residual.createScatterMesh(residual.mesh())
 
     lengthScale = normalizer.lengthScale()
     timeScale = normalizer.timeScale()

Modified: short/3D/PyLith/branches/v1.6-stable/pylith/problems/ImplicitCUDA.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/pylith/problems/ImplicitCUDA.py	2011-08-12 23:45:19 UTC (rev 18827)
+++ short/3D/PyLith/branches/v1.6-stable/pylith/problems/ImplicitCUDA.py	2011-08-15 19:02:08 UTC (rev 18828)
@@ -133,7 +133,7 @@
     dispT.zero()
     residual = self.fields.get("residual")
     residual.zero()
-    residual.createScatter()
+    residual.createScatterMesh(residual.mesh())
 
     lengthScale = normalizer.lengthScale()
     timeScale = normalizer.timeScale()



More information about the CIG-COMMITS mailing list