[cig-commits] r14967 - in short/3D/PyLith/trunk: . libsrc/utils pylith/apps pylith/problems unittests/libtests/utils

brad at geodynamics.org brad at geodynamics.org
Sun May 10 14:54:42 PDT 2009


Author: brad
Date: 2009-05-10 14:54:41 -0700 (Sun, 10 May 2009)
New Revision: 14967

Modified:
   short/3D/PyLith/trunk/TODO
   short/3D/PyLith/trunk/libsrc/utils/EventLogger.cc
   short/3D/PyLith/trunk/pylith/apps/PyLithApp.py
   short/3D/PyLith/trunk/pylith/problems/Implicit.py
   short/3D/PyLith/trunk/pylith/problems/Problem.py
   short/3D/PyLith/trunk/pylith/problems/TimeDependent.py
   short/3D/PyLith/trunk/unittests/libtests/utils/TestEventLogger.cc
Log:
Cleaned up top-level logging.

Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO	2009-05-10 20:44:14 UTC (rev 14966)
+++ short/3D/PyLith/trunk/TODO	2009-05-10 21:54:41 UTC (rev 14967)
@@ -128,6 +128,12 @@
       throw std::logic_error(message);
     after assert(0) to insure error is trapped.
 
+    Use Fields object to hold Field
+
+    Add Quadrature::computeGeometry(cell, coordinatesCell)
+      do computation on 1 cell
+      much less memory than holding all info in Fields
+
     Eliminate use of Inventory class.
 
     Switch Components to PetscComponents.

Modified: short/3D/PyLith/trunk/libsrc/utils/EventLogger.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/EventLogger.cc	2009-05-10 20:44:14 UTC (rev 14966)
+++ short/3D/PyLith/trunk/libsrc/utils/EventLogger.cc	2009-05-10 21:54:41 UTC (rev 14967)
@@ -109,9 +109,9 @@
 { // stageId
   map_event_type::iterator iter = _stages.find(name);
   if (iter == _stages.end()) {
-    std::ostringstream msg;
-    msg << "Could not find logging stage '" << name << "'.";
-    throw std::runtime_error(msg.str());
+    registerStage(name);
+    iter = _stages.find(name);
+    assert(iter != _stages.end());
   } // if
 
   return iter->second;

Modified: short/3D/PyLith/trunk/pylith/apps/PyLithApp.py
===================================================================
--- short/3D/PyLith/trunk/pylith/apps/PyLithApp.py	2009-05-10 20:44:14 UTC (rev 14966)
+++ short/3D/PyLith/trunk/pylith/apps/PyLithApp.py	2009-05-10 21:54:41 UTC (rev 14967)
@@ -78,7 +78,6 @@
     self._debug.log(resourceUsageString())
 
     self._setupLogging()
-    self._logger.eventBegin("PyLith main")
 
     # Create mesh (adjust to account for interfaces (faults) if necessary)
     self._logger.stagePush("Meshing")
@@ -105,10 +104,8 @@
     self._logger.stagePop()
 
     # Run problem
-    self._logger.stagePush("Run")
     self.problem.run(self)
     self._debug.log(resourceUsageString())
-    self._logger.stagePop()
 
     # Cleanup
     self._logger.stagePush("Finalize")
@@ -120,7 +117,6 @@
 
     self.compilePerformanceLog()
     self.perfLogger.show()
-    self._logger.eventEnd("PyLith main")
     return
   
 
@@ -147,15 +143,7 @@
     logger = EventLogger()
     logger.className("PyLith")
     logger.initialize()
-    logger.registerEvent("PyLith main")
 
-    stages = ["Meshing",
-              "Setup",
-              "Run",
-              "Finalize"]
-    for stage in stages:
-      logger.registerStage(stage)
-
     self._logger = logger
     return
   

Modified: short/3D/PyLith/trunk/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Implicit.py	2009-05-10 20:44:14 UTC (rev 14966)
+++ short/3D/PyLith/trunk/pylith/problems/Implicit.py	2009-05-10 21:54:41 UTC (rev 14967)
@@ -88,9 +88,6 @@
     """
     Initialize problem for implicit time integration.
     """
-    logEvent = "%sinit" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
-    
     Formulation.initialize(self, dimension, normalizer)
 
     self._info.log("Creating other fields.")
@@ -128,7 +125,6 @@
     for integrator in self.integratorsMesh + self.integratorsSubMesh:
       integrator.useSolnIncr(False)
 
-    self._logger.eventEnd(logEvent)
     return
 
 
@@ -145,8 +141,6 @@
     """
     Hook for doing stuff before advancing time step.
     """
-    logEvent = "%sprestep" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
     
     # If finishing first time step, then switch from solving for total
     # displacements to solving for incremental displacements
@@ -177,7 +171,6 @@
     if needNewJacobian:
       self._reformJacobian(t, dt)
 
-    self._logger.eventEnd(logEvent)
     return
 
 
@@ -185,9 +178,6 @@
     """
     Advance to next time step.
     """
-    logEvent = "%sstep" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
-
     dispIncr = self.fields.solveSoln()
     dispIncr.zero()
 
@@ -207,8 +197,6 @@
     #dispIncr.view("DISPINCR SOLUTION")
     #residual.view("RESIDUAL")
     # END TEMPORARY
-
-    self._logger.eventEnd(logEvent)
     return
 
 
@@ -216,9 +204,6 @@
     """
     Hook for doing stuff after advancing time step.
     """
-    logEvent = "%spoststep" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
-    
     # Update displacement field from time t to time t+dt.
     dispIncr = self.fields.get("dispIncr(t->t+dt)")
     disp = self.fields.solution()
@@ -227,7 +212,6 @@
     Formulation.poststep(self, t, dt)
 
     self._stepCount += 1
-    self._logger.eventEnd(logEvent)
     return
 
 

Modified: short/3D/PyLith/trunk/pylith/problems/Problem.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Problem.py	2009-05-10 20:44:14 UTC (rev 14966)
+++ short/3D/PyLith/trunk/pylith/problems/Problem.py	2009-05-10 21:54:41 UTC (rev 14967)
@@ -147,9 +147,6 @@
     """
     Verify compatibility of configuration.
     """
-    logEvent = "%sverify" % self._loggingPrefix    
-    self._logger.eventBegin(logEvent)
-    
     self._info.log("Verifying compatibility of problem configuration.")
     if self.dimension != self.mesh.dimension():
       raise ValueError, \
@@ -186,7 +183,6 @@
     idValues = numpy.array(materialIds.keys(), dtype=numpy.int32)
     self.mesh.checkMaterialIds(idValues)
 
-    self._logger.eventEnd(logEvent)
     return
   
 
@@ -255,14 +251,6 @@
     logger.className("Problem")
     logger.initialize()
 
-    events = ["preinit",
-              "verify",
-              "init",
-              "run",
-              "finalize"]
-    for event in events:
-      logger.registerEvent("%s%s" % (self._loggingPrefix, event))
-
     self._logger = logger
     return
   

Modified: short/3D/PyLith/trunk/pylith/problems/TimeDependent.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeDependent.py	2009-05-10 20:44:14 UTC (rev 14966)
+++ short/3D/PyLith/trunk/pylith/problems/TimeDependent.py	2009-05-10 21:54:41 UTC (rev 14967)
@@ -76,15 +76,11 @@
     bc/quadrature, etc.).
     """
     self._setupLogging()
-    logEvent = "%spreinit" % self._loggingPrefix    
-    self._logger.eventBegin(logEvent)
     
     self._info.log("Pre-initializing problem.")
     self.mesh = mesh
     self.formulation.preinitialize(mesh, self.materials, self.bc,
                                    self.interfaces, self.gravityField)
-
-    self._logger.eventEnd(logEvent)
     return
 
 
@@ -92,13 +88,8 @@
     """
     Verify compatibility of configuration.
     """
-    logEvent = "%sverify" % self._loggingPrefix    
-    self._logger.eventBegin(logEvent)
-    
     Problem.verifyConfiguration(self)
     self.formulation.verifyConfiguration()
-
-    self._logger.eventEnd(logEvent)
     return
   
 
@@ -107,14 +98,9 @@
     Setup integrators for each element family (material/quadrature,
     bc/quadrature, etc.).
     """
-    logEvent = "%sinit" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
-
     self._info.log("Initializing problem.")
     self.checkpointTimer.initialize(self.normalizer)
     self.formulation.initialize(self.dimension, self.normalizer)
-
-    self._logger.eventEnd(logEvent)
     return
 
 
@@ -122,8 +108,6 @@
     """
     Solve time dependent problem.
     """
-    logEvent = "%srun" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
 
     self._info.log("Solving problem.")
     self.checkpointTimer.toplevel = app # Set handle for saving state
@@ -131,6 +115,7 @@
     t = self.formulation.getStartTime()
     timeScale = self.normalizer.timeScale()
     while t < self.formulation.getTotalTime():
+      self._logger.stagePush("Prestep")
       tsec = self.normalizer.dimensionalize(t, timeScale)
       self._info.log("Main time loop, current time is t=%s" % tsec)
       
@@ -144,19 +129,22 @@
       self._info.log("Preparing to advance solution from time t=%s to t=%s." %\
                      (tsec, tsec+dtsec))
       self.formulation.prestep(t, dt)
+      self._logger.stagePop()
 
       self._info.log("Advancing solution from t=%s to t=%s." % \
                      (tsec, tsec+dtsec))
+      self._logger.stagePush("Step")
       self.formulation.step(t, dt)
+      self._logger.stagePop()
 
       self._info.log("Finishing advancing solution from t=%s to t=%s." % \
                      (tsec, tsec+dtsec))
+      self._logger.stagePush("Poststep")
       self.formulation.poststep(t, dt)
+      self._logger.stagePop()
 
       # Update time
       t += dt
-
-    self._logger.eventEnd(logEvent)
     return
 
 
@@ -164,12 +152,7 @@
     """
     Cleanup after running problem.
     """
-    logEvent = "%sfinalize" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
-
     self.formulation.finalize()
-
-    self._logger.eventEnd(logEvent)
     return
 
 

Modified: short/3D/PyLith/trunk/unittests/libtests/utils/TestEventLogger.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/utils/TestEventLogger.cc	2009-05-10 20:44:14 UTC (rev 14966)
+++ short/3D/PyLith/trunk/unittests/libtests/utils/TestEventLogger.cc	2009-05-10 21:54:41 UTC (rev 14967)
@@ -177,6 +177,7 @@
   for (int i=0; i < numStages; ++i)
     logger.registerStage(stages[i]);
 
+
   const int order[] = { 1, 0, 2 };
   int ids[numStages];
   for (int i=0; i < numStages; ++i)
@@ -187,6 +188,9 @@
        s_iter != logger._stages.end();
        ++s_iter, ++i)
     CPPUNIT_ASSERT_EQUAL(s_iter->second, ids[i]);
+  
+  const int idNew = logger.stageId("stage D");
+  CPPUNIT_ASSERT_EQUAL(idNew, logger.stageId("stage D"));
 } // testStageId
 
 // ----------------------------------------------------------------------



More information about the CIG-COMMITS mailing list