[cig-commits] r21660 - short/3D/PyLith/trunk/libsrc/pylith/problems

brad at geodynamics.org brad at geodynamics.org
Wed Mar 27 13:03:29 PDT 2013


Author: brad
Date: 2013-03-27 13:03:29 -0700 (Wed, 27 Mar 2013)
New Revision: 21660

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/problems/Explicit.cc
   short/3D/PyLith/trunk/libsrc/pylith/problems/Formulation.cc
   short/3D/PyLith/trunk/libsrc/pylith/problems/Implicit.cc
   short/3D/PyLith/trunk/libsrc/pylith/problems/Solver.cc
   short/3D/PyLith/trunk/libsrc/pylith/problems/SolverLinear.cc
   short/3D/PyLith/trunk/libsrc/pylith/problems/SolverLumped.cc
   short/3D/PyLith/trunk/libsrc/pylith/problems/SolverNonlinear.cc
Log:
Use begin/end macros for better error trapping.

Modified: short/3D/PyLith/trunk/libsrc/pylith/problems/Explicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/problems/Explicit.cc	2013-03-27 20:03:23 UTC (rev 21659)
+++ short/3D/PyLith/trunk/libsrc/pylith/problems/Explicit.cc	2013-03-27 20:03:29 UTC (rev 21660)
@@ -41,6 +41,8 @@
 void
 pylith::problems::Explicit::calcRateFields(void)
 { // calcRateFields
+  PYLITH_METHOD_BEGIN;
+
   assert(_fields);
 
   // vel(t) = (disp(t+dt) - disp(t-dt)) / (2*dt)
@@ -108,6 +110,8 @@
   } // for
 
   PetscLogFlops((vEnd - vStart) * 6*spaceDim);
+
+  PYLITH_METHOD_END;
 } // calcRateFields
 
 

Modified: short/3D/PyLith/trunk/libsrc/pylith/problems/Formulation.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/problems/Formulation.cc	2013-03-27 20:03:23 UTC (rev 21659)
+++ short/3D/PyLith/trunk/libsrc/pylith/problems/Formulation.cc	2013-03-27 20:03:29 UTC (rev 21660)
@@ -57,6 +57,8 @@
 void
 pylith::problems::Formulation::deallocate(void)
 { // deallocate
+  PYLITH_METHOD_BEGIN;
+
   _jacobian = 0; // :TODO: Use shared pointer.
   _jacobianLumped = 0; // :TODO: Use shared pointer.
   _fields = 0; // :TODO: Use shared pointer.
@@ -70,6 +72,8 @@
 #else
   _customConstraintPCMat = 0;
 #endif
+
+  PYLITH_METHOD_END;
 } // deallocate
   
 // ----------------------------------------------------------------------
@@ -219,6 +223,8 @@
 pylith::problems::Formulation::reformResidual(const PetscVec* tmpResidualVec,
 					      const PetscVec* tmpSolutionVec)
 { // reformResidual
+  PYLITH_METHOD_BEGIN;
+
   assert(_fields);
 
   // Update section view of field.
@@ -259,6 +265,8 @@
   // TODO: Move this to SolverLinear 
   if (tmpResidualVec)
     VecScale(*tmpResidualVec, -1.0);
+
+  PYLITH_METHOD_END;
 } // reformResidual
 
 // ----------------------------------------------------------------------
@@ -266,6 +274,8 @@
 void
 pylith::problems::Formulation::reformJacobian(const PetscVec* tmpSolutionVec)
 { // reformJacobian
+  PYLITH_METHOD_BEGIN;
+
   assert(0 != _jacobian);
   assert(0 != _fields);
 
@@ -308,6 +318,8 @@
     MatView(_customConstraintPCMat, PETSC_VIEWER_STDOUT_WORLD);
 #endif
   } // if
+
+  PYLITH_METHOD_END;
 } // reformJacobian
 
 // ----------------------------------------------------------------------
@@ -315,6 +327,8 @@
 void
 pylith::problems::Formulation::reformJacobianLumped(void)
 { // reformJacobianLumped
+  PYLITH_METHOD_BEGIN;
+
   assert(_jacobianLumped);
   assert(_fields);
 
@@ -332,6 +346,7 @@
   // Assemble jacbian.
   _jacobianLumped->complete();
 
+  PYLITH_METHOD_END;
 } // reformJacobianLumped
 
 // ----------------------------------------------------------------------
@@ -339,6 +354,8 @@
 void
 pylith::problems::Formulation::constrainSolnSpace(const PetscVec* tmpSolutionVec)
 { // constrainSolnSpace
+  PYLITH_METHOD_BEGIN;
+
   assert(tmpSolutionVec);
   assert(_fields);
 
@@ -376,6 +393,8 @@
   if (tmpSolutionVec) {
     solution.scatterSectionToVector(*tmpSolutionVec);
   } // if
+
+  PYLITH_METHOD_END;
 } // constrainSolnSpace
 
 // ----------------------------------------------------------------------
@@ -384,6 +403,8 @@
 void
 pylith::problems::Formulation::adjustSolnLumped(void)
 { // adjustSolnLumped
+  PYLITH_METHOD_BEGIN;
+
   topology::Field<topology::Mesh>& solution = _fields->solution();
 
   if (!_fields->hasField("dispIncr adjust")) {
@@ -404,6 +425,8 @@
 
   adjust.complete();
   solution += adjust;
+
+  PYLITH_METHOD_END;
 } // adjustSolnLumped
 
 #include "pylith/meshio/DataWriterHDF5.hh"

Modified: short/3D/PyLith/trunk/libsrc/pylith/problems/Implicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/problems/Implicit.cc	2013-03-27 20:03:23 UTC (rev 21659)
+++ short/3D/PyLith/trunk/libsrc/pylith/problems/Implicit.cc	2013-03-27 20:03:29 UTC (rev 21660)
@@ -41,6 +41,8 @@
 void
 pylith::problems::Implicit::calcRateFields(void)
 { // calcRateFields
+  PYLITH_METHOD_BEGIN;
+
   assert(0 != _fields);
 
   // vel(t) = (disp(t+dt) - disp(t)) / dt
@@ -78,6 +80,8 @@
   } // for
 
   PetscLogFlops((vEnd - vStart) * spaceDim);
+
+  PYLITH_METHOD_END;
 } // calcRateFields
 
 

Modified: short/3D/PyLith/trunk/libsrc/pylith/problems/Solver.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/problems/Solver.cc	2013-03-27 20:03:23 UTC (rev 21659)
+++ short/3D/PyLith/trunk/libsrc/pylith/problems/Solver.cc	2013-03-27 20:03:29 UTC (rev 21660)
@@ -87,6 +87,8 @@
 void
 pylith::problems::Solver::deallocate(void)
 { // deallocate
+  PYLITH_METHOD_BEGIN;
+
   _formulation = 0; // Handle only, do not manage memory.
   delete _logger; _logger = 0;
 
@@ -97,6 +99,8 @@
   _ctx.pc = 0; // KSP PC (managed separately)
   _ctx.A = 0; // Jacobian (managed separately)
   _ctx.faultA  = 0; // Handle to _jacobianPCFault
+
+  PYLITH_METHOD_END;
 } // deallocate
   
 // ----------------------------------------------------------------------
@@ -106,6 +110,8 @@
 				     const topology::Jacobian& jacobian,
 				     Formulation* const formulation)
 { // initialize
+  PYLITH_METHOD_BEGIN;
+
   assert(formulation);
   _formulation = formulation;
 
@@ -134,6 +140,8 @@
     _jacobianPC = jacobianMat;
     err = PetscObjectReference((PetscObject) jacobianMat);CHECK_PETSC_ERROR(err);
   } // if/else
+
+  PYLITH_METHOD_END;
 } // initialize
 
 
@@ -145,6 +153,8 @@
 					   const topology::Jacobian& jacobian,
 					   const topology::SolutionFields& fields)
 { // _setupFieldSplit
+  PYLITH_METHOD_BEGIN;
+
   assert(pc);
   assert(formulation);
 
@@ -287,6 +297,8 @@
     err = MatNullSpaceDestroy(&nullsp);CHECK_PETSC_ERROR(err);
     err = PetscObjectCompose(field, "pmat", (PetscObject) _jacobianPCFault);CHECK_PETSC_ERROR(err);
   } // if/else
+
+  PYLITH_METHOD_END;
 } // _setupFieldSplit
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/libsrc/pylith/problems/SolverLinear.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/problems/SolverLinear.cc	2013-03-27 20:03:23 UTC (rev 21659)
+++ short/3D/PyLith/trunk/libsrc/pylith/problems/SolverLinear.cc	2013-03-27 20:03:29 UTC (rev 21660)
@@ -48,9 +48,13 @@
 void
 pylith::problems::SolverLinear::deallocate(void)
 { // deallocate
+  PYLITH_METHOD_BEGIN;
+
   Solver::deallocate();
 
   PetscErrorCode err = KSPDestroy(&_ksp);CHECK_PETSC_ERROR(err);
+
+  PYLITH_METHOD_END;
 } // deallocate
   
 // ----------------------------------------------------------------------
@@ -60,6 +64,8 @@
 					   const topology::Jacobian& jacobian,
 					   Formulation* formulation)
 { // initialize
+  PYLITH_METHOD_BEGIN;
+
   assert(formulation);
 
   _initializeLogger();
@@ -76,6 +82,8 @@
     err = KSPGetPC(_ksp, &pc);CHECK_PETSC_ERROR(err);
     _setupFieldSplit(&pc, formulation, jacobian, fields);
   } // if
+
+  PYLITH_METHOD_END;
 } // initialize
 
 // ----------------------------------------------------------------------
@@ -85,6 +93,8 @@
 				      topology::Jacobian* jacobian,
 				      const topology::Field<topology::Mesh>& residual)
 { // solve
+  PYLITH_METHOD_BEGIN;
+
   assert(solution);
   assert(jacobian);
   assert(_formulation);
@@ -94,8 +104,6 @@
   const int scatterEvent = _logger->eventId("SoLi scatter");
   _logger->eventBegin(scatterEvent);
 
-  //PetscFunctionBegin; // DEBUGGING
-
   // Update PetscVector view of field.
   residual.scatterSectionToVector();
 
@@ -130,7 +138,7 @@
   // Update rate fields to be consistent with current solution.
   _formulation->calcRateFields();
 
-  //PetscFunctionReturnVoid(); // DEBUGGING
+  PYLITH_METHOD_END;
 } // solve
 
 // ----------------------------------------------------------------------
@@ -138,13 +146,16 @@
 void
 pylith::problems::SolverLinear::_initializeLogger(void)
 { // initializeLogger
-  delete _logger; _logger = new utils::EventLogger;
-  assert(0 != _logger);
+  PYLITH_METHOD_BEGIN;
+
+  delete _logger; _logger = new utils::EventLogger;assert(_logger);
   _logger->className("SolverLinear");
   _logger->initialize();
   _logger->registerEvent("SoLi setup");
   _logger->registerEvent("SoLi solve");
   _logger->registerEvent("SoLi scatter");
+
+  PYLITH_METHOD_END;
 } // initializeLogger
 
 

Modified: short/3D/PyLith/trunk/libsrc/pylith/problems/SolverLumped.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/problems/SolverLumped.cc	2013-03-27 20:03:23 UTC (rev 21659)
+++ short/3D/PyLith/trunk/libsrc/pylith/problems/SolverLumped.cc	2013-03-27 20:03:29 UTC (rev 21660)
@@ -46,7 +46,11 @@
 void
 pylith::problems::SolverLumped::deallocate(void)
 { // deallocate
+  PYLITH_METHOD_BEGIN;
+
   Solver::deallocate();
+
+  PYLITH_METHOD_END;
 } // deallocate
   
 // ----------------------------------------------------------------------
@@ -56,11 +60,15 @@
 					   const topology::Field<topology::Mesh>& jacobian,
 					   Formulation* formulation)
 { // initialize
+  PYLITH_METHOD_BEGIN;
+
   assert(formulation);
 
   _initializeLogger();
 
   _formulation = formulation;
+
+  PYLITH_METHOD_END;
 } // initialize
 
 // ----------------------------------------------------------------------
@@ -70,6 +78,8 @@
 				      const topology::Field<topology::Mesh>& jacobian,
 				      const topology::Field<topology::Mesh>& residual)
 { // solve
+  PYLITH_METHOD_BEGIN;
+
   assert(solution);
   assert(_formulation);
   
@@ -131,6 +141,8 @@
   _formulation->calcRateFields(); // :KLUDGE: Limit to only those changed?
 
   _logger->eventEnd(adjustEvent);
+
+  PYLITH_METHOD_END;
 } // solve
 
 // ----------------------------------------------------------------------
@@ -138,13 +150,17 @@
 void
 pylith::problems::SolverLumped::_initializeLogger(void)
 { // initializeLogger
-  delete _logger; _logger = new utils::EventLogger;
-  assert(_logger);
+  PYLITH_METHOD_BEGIN;
+
+  delete _logger; _logger = new utils::EventLogger;assert(_logger);
   _logger->className("SolverLumped");
   _logger->initialize();
   _logger->registerEvent("SoLu setup");
   _logger->registerEvent("SoLu solve");
   _logger->registerEvent("SoLu adjust");
+
+
+  PYLITH_METHOD_END;
 } // initializeLogger
 
 

Modified: short/3D/PyLith/trunk/libsrc/pylith/problems/SolverNonlinear.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/problems/SolverNonlinear.cc	2013-03-27 20:03:23 UTC (rev 21659)
+++ short/3D/PyLith/trunk/libsrc/pylith/problems/SolverNonlinear.cc	2013-03-27 20:03:29 UTC (rev 21660)
@@ -65,9 +65,13 @@
 void
 pylith::problems::SolverNonlinear::deallocate(void)
 { // deallocate
+  PYLITH_METHOD_BEGIN;
+
   Solver::deallocate();
 
   PetscErrorCode err = SNESDestroy(&_snes);CHECK_PETSC_ERROR(err);
+
+  PYLITH_METHOD_END;
 } // deallocate
   
 // ----------------------------------------------------------------------
@@ -77,6 +81,8 @@
 					      const topology::Jacobian& jacobian,
 					      Formulation* formulation)
 { // initialize
+  PYLITH_METHOD_BEGIN;
+
   assert(formulation);
 
   _initializeLogger();
@@ -114,6 +120,8 @@
     err = KSPGetPC(ksp, &pc); CHECK_PETSC_ERROR(err);
     _setupFieldSplit(&pc, formulation, jacobian, fields);
   } // if
+
+  PYLITH_METHOD_END;
 } // initialize
 
 // ----------------------------------------------------------------------
@@ -123,6 +131,8 @@
 					 topology::Jacobian* jacobian,
 					 const topology::Field<topology::Mesh>& residual)
 { // solve
+  PYLITH_METHOD_BEGIN;
+
   assert(solution);
 
   const int solveEvent = _logger->eventId("SoNl solve");
@@ -144,6 +154,8 @@
 
   // Update rate fields to be consistent with current solution.
   _formulation->calcRateFields();
+
+  PYLITH_METHOD_END;
 } // solve
 
 // ----------------------------------------------------------------------
@@ -155,6 +167,8 @@
 						  PetscVec tmpResidualVec,
 						  void* context)
 { // reformResidual
+  PYLITH_METHOD_BEGIN;
+
   assert(context);
   Formulation* formulation = (Formulation*) context;
   assert(formulation);
@@ -165,7 +179,7 @@
   // Reform residual
   formulation->reformResidual(&tmpResidualVec, &tmpSolutionVec);
 
-  return 0;
+  PYLITH_METHOD_RETURN(0);
 } // reformResidual
 
 // ----------------------------------------------------------------------
@@ -179,19 +193,19 @@
 						  MatStructure* preconditionerLayout,
 						  void* context)
 { // reformJacobian
+  PYLITH_METHOD_BEGIN;
+
   assert(context);
   Formulation* formulation = (Formulation*) context;
   assert(formulation);
 
   formulation->reformJacobian(&tmpSolutionVec);
 
-  return 0;
+  PYLITH_METHOD_RETURN(0);
 } // reformJacobian
 
 // ----------------------------------------------------------------------
 // Generic C interface for customized PETSc line search.
-#undef __FUNCT__
-#define __FUNCT__ "lineSearch"
 PetscErrorCode
 pylith::problems::SolverNonlinear::lineSearch(PetscSNESLineSearch linesearch,
 					      void* lsctx)
@@ -492,19 +506,22 @@
   ierr = VecNorm(X, NORM_2, &xnorm);CHKERRQ(ierr);
   ierr = SNESLineSearchSetLambda(linesearch, lambda);CHKERRQ(ierr);
   ierr = SNESLineSearchSetNorms(linesearch, xnorm, gnorm, ynorm);CHKERRQ(ierr);
+
   PetscFunctionReturn(0);
 } // lineSearch
 
 // ----------------------------------------------------------------------
 // Generic C interface for customized PETSc initial guess.
-#undef __FUNCT__
-#define __FUNCT__ "initialGuess"
 PetscErrorCode
 pylith::problems::SolverNonlinear::initialGuess(PetscSNES snes,
 						PetscVec initialGuessVec,
 						void *lsctx)
 { // initialGuess
+  PYLITH_METHOD_BEGIN;
+
   PetscErrorCode err = VecSet(initialGuessVec, 0.0);CHECK_PETSC_ERROR(err);
+
+  PYLITH_METHOD_RETURN(0);
 } // initialGuess
 
 // ----------------------------------------------------------------------
@@ -512,13 +529,16 @@
 void
 pylith::problems::SolverNonlinear::_initializeLogger(void)
 { // initializeLogger
-  delete _logger; _logger = new utils::EventLogger;
-  assert(_logger);
+  PYLITH_METHOD_BEGIN;
+
+  delete _logger; _logger = new utils::EventLogger;assert(_logger);
   _logger->className("SolverNonlinear");
   _logger->initialize();
   _logger->registerEvent("SoNl setup");
   _logger->registerEvent("SoNl solve");
   _logger->registerEvent("SoNl scatter");
+
+  PYLITH_METHOD_END;
 } // initializeLogger
 
 



More information about the CIG-COMMITS mailing list