[cig-commits] r14349 - in short/3D/PyLith/branches/pylith-swig: . libsrc/bc libsrc/feassemble libsrc/topology

brad at geodynamics.org brad at geodynamics.org
Mon Mar 16 15:20:28 PDT 2009


Author: brad
Date: 2009-03-16 15:20:28 -0700 (Mon, 16 Mar 2009)
New Revision: 14349

Modified:
   short/3D/PyLith/branches/pylith-swig/TODO
   short/3D/PyLith/branches/pylith-swig/libsrc/bc/AbsorbingDampers.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityExplicit.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityImplicit.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc
Log:
Updated to use CHECK_PETSC_ERROR macros.

Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO	2009-03-16 22:10:54 UTC (rev 14348)
+++ short/3D/PyLith/branches/pylith-swig/TODO	2009-03-16 22:20:28 UTC (rev 14349)
@@ -8,8 +8,9 @@
   level using the C++ EventLogger. Add finer grain logging at C++
   level as in ElasticityImplicit.
 
-  Cleanup error checking on PETSc calls. Use PetscError as in
-  Jacobian.
+  Cleanup error checking on PETSc calls.
+    FaultCohesiveKin
+    DataWriterVTK
 
   TestMesh.test_view()
   TestMesh.test_checkMaterialIds()

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/bc/AbsorbingDampers.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/bc/AbsorbingDampers.cc	2009-03-16 22:10:54 UTC (rev 14348)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/bc/AbsorbingDampers.cc	2009-03-16 22:20:28 UTC (rev 14349)
@@ -252,8 +252,6 @@
   assert(0 != _dampingConsts);
   assert(0 != fields);
 
-  PetscErrorCode err = 0;
-
   // Get cell geometry information that doesn't depend on cell
   const int numQuadPts = _quadrature->numQuadPts();
   const double_array& quadWts = _quadrature->quadWts();
@@ -364,8 +362,6 @@
 
   typedef ALE::ISieveVisitor::IndicesVisitor<RealSection,SieveMesh::order_type,PetscInt> visitor_type;
 
-  PetscErrorCode err = 0;
-
   // Get cell geometry information that doesn't depend on cell
   const int numQuadPts = _quadrature->numQuadPts();
   const double_array& quadWts = _quadrature->quadWts();
@@ -444,10 +440,10 @@
     PetscLogFlops(numQuadPts*(3+numBasis*(1+numBasis*(1+2*spaceDim))));
     
     // Assemble cell contribution into PETSc Matrix
-    err = updateOperator(*jacobianMat, *submesh->getSieve(), 
-			 iV, *c_iter, &_cellMatrix[0], ADD_VALUES);
-    if (err)
-      throw std::runtime_error("Update to PETSc Mat failed.");
+    PetscErrorCode err = updateOperator(*jacobianMat, *submesh->getSieve(), 
+					iV, *c_iter, &_cellMatrix[0], 
+					ADD_VALUES);
+    CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
     iV.clear();
   } // for
 

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc	2009-03-16 22:10:54 UTC (rev 14348)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/bc/Neumann.cc	2009-03-16 22:20:28 UTC (rev 14349)
@@ -252,8 +252,6 @@
   assert(0 != _boundaryMesh);
   assert(0 != _tractions);
 
-  PetscErrorCode err = 0;
-
   // Get cell geometry information that doesn't depend on cell
   const int numQuadPts = _quadrature->numQuadPts();
   const double_array& quadWts = _quadrature->quadWts();

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityExplicit.cc	2009-03-16 22:10:54 UTC (rev 14348)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityExplicit.cc	2009-03-16 22:20:28 UTC (rev 14349)
@@ -30,6 +30,7 @@
 #include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
 #include "spatialdata/units/Nondimensional.hh" // USES Nondimendional
 
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
 #include <cassert> // USES assert()
 #include <stdexcept> // USES std::runtime_error
 
@@ -381,8 +382,7 @@
     PetscErrorCode err = updateOperator(*jacobianMat, *sieveMesh->getSieve(),
 					jacobianVisitor, *c_iter,
 					&_cellMatrix[0], ADD_VALUES);
-    if (err)
-      throw std::runtime_error("Update to PETSc Mat failed.");
+    CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
     _logger->eventEnd(updateEvent);
   } // for
 

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityImplicit.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityImplicit.cc	2009-03-16 22:10:54 UTC (rev 14348)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityImplicit.cc	2009-03-16 22:20:28 UTC (rev 14349)
@@ -32,6 +32,7 @@
 #include "spatialdata/units/Nondimensional.hh" // USES Nondimendional
 #include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
 
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
 #include <cassert> // USES assert()
 #include <stdexcept> // USES std::runtime_error
 
@@ -450,8 +451,7 @@
     PetscErrorCode err = updateOperator(*jacobianMat, *sieveMesh->getSieve(),
 					jacobianVisitor, *c_iter,
 					&_cellMatrix[0], ADD_VALUES);
-    if (err)
-      throw std::runtime_error("Update to PETSc Mat failed.");
+    CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
     _logger->eventEnd(updateEvent);
   } // for
   _needNewJacobian = false;

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc	2009-03-16 22:10:54 UTC (rev 14348)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc	2009-03-16 22:20:28 UTC (rev 14349)
@@ -18,6 +18,8 @@
 #include "SolutionFields.hh" // USES SolutionFields
 #include "Field.hh" // USES Field
 
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
 // ----------------------------------------------------------------------
 // Default constructor.
 pylith::topology::Jacobian::Jacobian(const SolutionFields& fields) :
@@ -31,13 +33,8 @@
   assert(0 != _matrix);
   PetscErrorCode err = MeshCreateMatrix(sieveMesh, solnSection, 
 					MATAIJ, _matrix);
-  if (err) {
-    PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-    throw std::runtime_error("Could not create PETSc sparse matrix "
-			     "associated with system Jacobian.");
-  } // if
-  
-
+  CHECK_PETSC_ERROR_MSG(err, "Could not create PETSc sparse matrix "
+			"associated with system Jacobian.");
 } // constructor
 
 // ----------------------------------------------------------------------
@@ -71,31 +68,15 @@
 { // assemble
   PetscErrorCode err = 0;
   if (0 == strcmp(mode, "final_assembly")) {
-    err = MatAssemblyBegin(*_matrix, MAT_FINAL_ASSEMBLY);
-    if (err) {
-      PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-      throw std::runtime_error("Error beginning final assembly of sparse "
-			       "matrix associated with system Jacobian.");
-    } // if
+    err = MatAssemblyBegin(*_matrix, MAT_FINAL_ASSEMBLY); 
+    CHECK_PETSC_ERROR(err);
     err = MatAssemblyEnd(*_matrix, MAT_FINAL_ASSEMBLY);
-    if (err) {
-      PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-      throw std::runtime_error("Error ending final assembly of sparse "
-			       "matrix associated with system Jacobian.");
-    } // if
+    CHECK_PETSC_ERROR(err);
   } else if (0 == strcmp(mode, "flush_assembly")) {
     err = MatAssemblyBegin(*_matrix, MAT_FLUSH_ASSEMBLY);
-    if (err) {
-      PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-      throw std::runtime_error("Error beginning flush assembly of sparse "
-			       "matrix associated with system Jacobian.");
-    } // if
+    CHECK_PETSC_ERROR(err);
     err = MatAssemblyEnd(*_matrix, MAT_FLUSH_ASSEMBLY);
-    if (err) {
-      PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-      throw std::runtime_error("Error ending flush assembly of sparse "
-			       "matrix associated with system Jacobian.");
-    } // if
+    CHECK_PETSC_ERROR(err);
   } else
     throw std::runtime_error("Unknown mode for assembly of sparse matrix "
 			     "associated with system Jacobian.");
@@ -107,11 +88,7 @@
 pylith::topology::Jacobian::zero(void)
 { // zero
   PetscErrorCode err = MatZeroEntries(*_matrix);
-  if (err) {
-    PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-    throw std::runtime_error("Error zeroing entries of sparse matrix "
-			     "associated with system Jacobian.");
-  } // if
+  CHECK_PETSC_ERROR(err);
 } // zero
 
 // ----------------------------------------------------------------------
@@ -120,11 +97,7 @@
 pylith::topology::Jacobian::view(void)
 { // view
   PetscErrorCode err = MatView(*_matrix, PETSC_VIEWER_STDOUT_WORLD);
-  if (err) {
-    PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-    throw std::runtime_error("Error viewing sparse matrix associatd "
-			     "with system Jacobian.");
-  } // if
+  CHECK_PETSC_ERROR(err);
 } // view
 
 // ----------------------------------------------------------------------
@@ -137,28 +110,11 @@
   const MPI_Comm comm = _fields.mesh().comm();
 
   PetscErrorCode err = 
-    PetscViewerBinaryOpen(comm, filename,
-			  FILE_MODE_WRITE, &viewer);
-  if (err) {
-    PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-    throw std::runtime_error("Could not create PETSc binary viewer for "
-			     "sparse matrix associated with system Jacobian.");
-  } // if
+    PetscViewerBinaryOpen(comm, filename, FILE_MODE_WRITE, &viewer);
+  CHECK_PETSC_ERROR(err);
 
-  err = MatView(*_matrix, viewer);
-  if (err) {
-    PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-    throw std::runtime_error("Could not view PETSc sparse matrix associated "
-			     "with system Jacobian.");
-  } // if
-
-  err = PetscViewerDestroy(viewer);
-  if (err) {
-    PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
-    throw std::runtime_error("Could not destroy PETSc binary viewer for "
-			     "sparse matrix associated with system Jacobian.");
-  } // if
-
+  err = MatView(*_matrix, viewer); CHECK_PETSC_ERROR(err);
+  err = PetscViewerDestroy(viewer); CHECK_PETSC_ERROR(err);
 } // write
 
 



More information about the CIG-COMMITS mailing list