[cig-commits] r13915 - short/3D/PyLith/branches/pylith-swig/pylith/utils

brad at geodynamics.org brad at geodynamics.org
Wed Jan 21 21:21:03 PST 2009


Author: brad
Date: 2009-01-21 21:21:03 -0800 (Wed, 21 Jan 2009)
New Revision: 13915

Modified:
   short/3D/PyLith/branches/pylith-swig/pylith/utils/EventLogger.py
   short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscManager.py
Log:
Updated to SWIG.

Modified: short/3D/PyLith/branches/pylith-swig/pylith/utils/EventLogger.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/utils/EventLogger.py	2009-01-22 05:20:40 UTC (rev 13914)
+++ short/3D/PyLith/branches/pylith-swig/pylith/utils/EventLogger.py	2009-01-22 05:21:03 UTC (rev 13915)
@@ -16,8 +16,10 @@
 ##
 ## Each logger object manages the events for a single "logging class".
 
+from utils import EventLogger as ModuleEventLogger
+
 # EventLogger class
-class EventLogger(object):
+class EventLogger(ModuleEventLogger):
   """
   Python object for managing event logging using PETSc.
 
@@ -30,62 +32,25 @@
     """
     Constructor.
     """
-    self.cppHandle = None
-    self._createCppHandle()
+    ModuleEventLogger.__init__(self)
     self.events = {} # dict of events with counts for current logging.
     return
 
 
-  def setClassName(self, name):
-    """
-    Set name of logging class.
-    """
-    self._createCppHandle()
-    self.cppHandle.className = name
-    return
-
-
-  def getClassName(self):
-    """
-    Set name of logging class.
-    """
-    assert(None != self.cppHandle)
-    return self.cppHandle.className
-
-
-  def initialize(self):
-    """
-    Setup logging class.
-    """    
-    assert(None != self.cppHandle)
-    self.cppHandle.initialize()
-    return
-
-
   def registerEvent(self, name):
     """
     Register event.
     """
     self.events[name] = 0 # Set log count to 0
-    assert(None != self.cppHandle)
-    return self.cppHandle.registerEvent(name)
+    return ModuleEventLogger.registerEvent(self, name)
 
 
-  def eventId(self, name):
-    """
-    Get event identifier.
-    """    
-    assert(None != self.cppHandle)
-    return self.cppHandle.eventId(name)
-
-
   def eventBegin(self, name):
     """
     Log event begin.
     """
     if self.events[name] == 0: # prevent double counting
-      assert(None != self.cppHandle)
-      self.cppHandle.eventBegin(self.cppHandle.eventId(name))
+      ModuleEventLogger.eventBegin(self, self.eventId(name))
     self.events[name] += 1
     return
 
@@ -97,55 +62,16 @@
     if self.events[name] > 0:
       self.events[name] -= 1
     if 0 == self.events[name]: # prevent double counting
-      assert(None != self.cppHandle)
-      self.cppHandle.eventEnd(self.cppHandle.eventId(name))
-    
+      ModuleEventLogger.eventEnd(self, self.eventId(name))
     return
 
 
-  def registerStage(self, name):
-    """
-    Register stage.
-    """
-    assert(None != self.cppHandle)
-    return self.cppHandle.registerStage(name)
-
-
-  def stageId(self, name):
-    """
-    Get stage identifier.
-    """    
-    assert(None != self.cppHandle)
-    return self.cppHandle.stageId(name)
-
-
   def stagePush(self, name):
     """
     Log stage begin.
     """
-    assert(None != self.cppHandle)
-    self.cppHandle.stagePush(self.cppHandle.stageId(name))
+    ModuleEventLogger.stagePush(self, self.stageId(name))
     return
 
 
-  def stagePop(self):
-    """
-    Log stage end.
-    """
-    assert(None != self.cppHandle)
-    self.cppHandle.stagePop()
-    return
-
-
-  # PRIVATE METHODS ////////////////////////////////////////////////////
-
-  def _createCppHandle(self):
-    """
-    Create handle to corresponding C++ object.
-    """
-    if None == self.cppHandle:
-      import pylith.utils.utils as bindings
-      self.cppHandle = bindings.EventLogger()
-  
-  
 # End of file 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscManager.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscManager.py	2009-01-22 05:20:40 UTC (rev 13914)
+++ short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscManager.py	2009-01-22 05:21:03 UTC (rev 13915)
@@ -20,6 +20,7 @@
 ## Factory: petsc_manager
 
 from pyre.components.Component import Component
+import pylith.utils.petsc as petsc
 
 # PetscManager class
 class PetscManager(Component):
@@ -45,14 +46,13 @@
     Initialize PETSc.
     """
     self._info.log("Initializing PETSc.")
-    import pylith.utils.petsc as bindings
     import sys
     args = [sys.executable]
     options = self._getOptions()
     if len(options) > 0:
       for arg in options:
         args.append(arg)
-    bindings.petsc_initialize(args)
+    petsc.initialize(args)
     return
 
 
@@ -61,8 +61,7 @@
     Finalize PETSc.
     """
     self._info.log("Finalizing PETSc.")
-    import pylith.utils.petsc as bindings
-    bindings.petsc_finalize()
+    petsc.finalize()
     return
   
 



More information about the CIG-COMMITS mailing list