[cig-commits] r19120 - short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio

brad at geodynamics.org brad at geodynamics.org
Thu Oct 27 13:20:31 PDT 2011


Author: brad
Date: 2011-10-27 13:20:30 -0700 (Thu, 27 Oct 2011)
New Revision: 19120

Modified:
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/OutputManager.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/OutputSolnSubset.cc
Log:
Added exception to catch writer not being set. Trivial code cleanup.

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/OutputManager.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/OutputManager.cc	2011-10-27 16:25:40 UTC (rev 19119)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/OutputManager.cc	2011-10-27 20:20:30 UTC (rev 19120)
@@ -118,8 +118,17 @@
 						   const char* label,
 						   const int labelId)
 { // open
-  assert(0 != _writer);
+  if (!_writer) {
+    std::ostringstream msg;
+    if (label) {
+      msg << "Writer for output manager for " << label << " not set.";
+      throw std::runtime_error(msg.str());
+    } else {
+      throw std::runtime_error("Writer for output manager not set.");
+    } // if/else
+  } // if
 
+  assert(_writer);
   _writer->open(mesh, numTimeSteps, label, labelId);
 } // open
 
@@ -129,7 +138,7 @@
 void
 pylith::meshio::OutputManager<mesh_type, field_type>::close(void)
 { // close
-  assert(0 != _writer);
+  assert(_writer);
   _writer->close();
 } // close
 
@@ -143,7 +152,7 @@
 						       const char* label,
 						       const int labelId)
 { // openTimeStep
-  assert(0 != _writer);
+  assert(_writer);
   _writer->openTimeStep(t, mesh, label, labelId);
 } // openTimeStep
 
@@ -153,7 +162,7 @@
 void
 pylith::meshio::OutputManager<mesh_type, field_type>::closeTimeStep(void)
 { // closeTimeStep
-  assert(0 != _writer);
+  assert(_writer);
   _writer->closeTimeStep();
 } // closeTimeStep
 

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/OutputSolnSubset.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/OutputSolnSubset.cc	2011-10-27 16:25:40 UTC (rev 19119)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/meshio/OutputSolnSubset.cc	2011-10-27 20:20:30 UTC (rev 19120)
@@ -77,7 +77,7 @@
 pylith::meshio::OutputSolnSubset::subdomainMesh(const topology::Mesh& mesh)
 { // subdomainMesh
   delete _submesh; _submesh = new topology::SubMesh(mesh, _label.c_str());
-  assert(0 != _submesh);
+  assert(_submesh);
   return *_submesh;
 } // subdomainMesh
 



More information about the CIG-COMMITS mailing list