[cig-commits] r16092 - in short/3D/PyLith/branches/pylith-friction/libsrc: bc meshio topology

brad at geodynamics.org brad at geodynamics.org
Tue Dec 8 22:01:14 PST 2009


Author: brad
Date: 2009-12-08 22:01:14 -0800 (Tue, 08 Dec 2009)
New Revision: 16092

Modified:
   short/3D/PyLith/branches/pylith-friction/libsrc/bc/BoundaryCondition.cc
   short/3D/PyLith/branches/pylith-friction/libsrc/bc/BoundaryConditionPoints.cc
   short/3D/PyLith/branches/pylith-friction/libsrc/meshio/MeshIO.cc
   short/3D/PyLith/branches/pylith-friction/libsrc/topology/Mesh.cc
   short/3D/PyLith/branches/pylith-friction/libsrc/topology/SubMesh.cc
Log:
Add trap for group not in mesh (use hasIntSection() test because getIntSection() will create a section if it does not exist).

Modified: short/3D/PyLith/branches/pylith-friction/libsrc/bc/BoundaryCondition.cc
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/bc/BoundaryCondition.cc	2009-12-09 02:25:05 UTC (rev 16091)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/bc/BoundaryCondition.cc	2009-12-09 06:01:14 UTC (rev 16092)
@@ -47,6 +47,8 @@
   const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
   assert(!sieveMesh.isNull());
 
+  std::cout << "HAS INT SECTION '" << _label << "': " << sieveMesh->hasIntSection(_label) << std::endl;
+
   if (!sieveMesh->hasIntSection(_label)) {
     std::ostringstream msg;
     msg << "Mesh missing group of vertices '" << _label

Modified: short/3D/PyLith/branches/pylith-friction/libsrc/bc/BoundaryConditionPoints.cc
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/bc/BoundaryConditionPoints.cc	2009-12-09 02:25:05 UTC (rev 16091)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/bc/BoundaryConditionPoints.cc	2009-12-09 06:01:14 UTC (rev 16092)
@@ -67,13 +67,14 @@
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   assert(!sieveMesh.isNull());
 
-  const ALE::Obj<SieveMesh::int_section_type>& groupField = 
-    sieveMesh->getIntSection(_label);
-  if (groupField.isNull()) {
+  if (!sieveMesh->hasIntSection(_label)) {
     std::ostringstream msg;
     msg << "Could not find group of points '" << _label << "' in mesh.";
     throw std::runtime_error(msg.str());
   } // if
+
+  const ALE::Obj<SieveMesh::int_section_type>& groupField = 
+    sieveMesh->getIntSection(_label);
   assert(!groupField.isNull());
   const chart_type& chart = groupField->getChart();
   const chart_type::const_iterator& chartEnd = chart.end();

Modified: short/3D/PyLith/branches/pylith-friction/libsrc/meshio/MeshIO.cc
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/meshio/MeshIO.cc	2009-12-09 02:25:05 UTC (rev 16091)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/meshio/MeshIO.cc	2009-12-09 06:01:14 UTC (rev 16092)
@@ -290,6 +290,13 @@
   const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
   assert(!sieveMesh.isNull());
 
+  if (sieveMesh->hasIntSection(name)) {
+    std::ostringstream msg;
+    msg << "Could not setup group '" << name
+	<< "'. Group already exists in mesh.";
+    throw std::runtime_error(msg.str());
+  } // if
+
   ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
   logger.stagePush("VertexGroups");
   const ALE::Obj<IntSection>& groupField = sieveMesh->getIntSection(name);
@@ -396,6 +403,13 @@
   const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
   assert(!sieveMesh.isNull());
 
+  if (!sieveMesh->hasIntSection(name)) {
+    std::ostringstream msg;
+    msg << "Could not get group '" << name
+	<< "'. Group missing from mesh.";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const ALE::Obj<IntSection>& groupField = sieveMesh->getIntSection(name);
   assert(!groupField.isNull());
   const IntSection::chart_type& chart = groupField->getChart();

Modified: short/3D/PyLith/branches/pylith-friction/libsrc/topology/Mesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/topology/Mesh.cc	2009-12-09 02:25:05 UTC (rev 16091)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/topology/Mesh.cc	2009-12-09 06:01:14 UTC (rev 16092)
@@ -153,16 +153,25 @@
 int
 pylith::topology::Mesh::groupSize(const char *name)
 { // groupSize
+  if (!_mesh->hasIntSection(name)) {
+    std::ostringstream msg;
+    msg << "Cannot get size of group '" << name
+	<< "'. Group missing from mesh.";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const ALE::Obj<IntSection>&            group    = _mesh->getIntSection(name);
   const IntSection::chart_type&          chart    = group->getChart();
   IntSection::chart_type::const_iterator chartEnd = chart.end();
   int                                    size     = 0;
 
-  for(IntSection::chart_type::const_iterator c_iter = chart.begin(); c_iter != chartEnd; ++c_iter) {
-    if (group->getFiberDimension(*c_iter)) {
+  for(IntSection::chart_type::const_iterator c_iter = chart.begin();
+      c_iter != chartEnd;
+      ++c_iter) {
+    if (group->getFiberDimension(*c_iter))
       size++;
-    }
-  }
+  } // for
+
   return size;
 } // groupSize
 

Modified: short/3D/PyLith/branches/pylith-friction/libsrc/topology/SubMesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-friction/libsrc/topology/SubMesh.cc	2009-12-09 02:25:05 UTC (rev 16091)
+++ short/3D/PyLith/branches/pylith-friction/libsrc/topology/SubMesh.cc	2009-12-09 06:01:14 UTC (rev 16092)
@@ -62,12 +62,14 @@
   const ALE::Obj<DomainSieveMesh>& meshSieveMesh = mesh.sieveMesh();
   assert(!meshSieveMesh.isNull());
 
-  const ALE::Obj<IntSection>& groupField = meshSieveMesh->getIntSection(label);
-  if (groupField.isNull()) {
+  if (!meshSieveMesh->hasIntSection(label)) {
     std::ostringstream msg;
     msg << "Could not find group of points '" << label << "' in mesh.";
     throw std::runtime_error(msg.str());
   } // if
+
+  const ALE::Obj<IntSection>& groupField = meshSieveMesh->getIntSection(label);
+  assert(!groupField.isNull());
   _mesh = 
     ALE::Selection<DomainSieveMesh>::submeshV<SieveMesh>(meshSieveMesh,
 							 groupField);



More information about the CIG-COMMITS mailing list