[cig-commits] r14501 - in short/3D/PyLith/branches/pylith-swig/pylith: apps utils
brad at geodynamics.org
brad at geodynamics.org
Fri Mar 27 16:02:56 PDT 2009
Author: brad
Date: 2009-03-27 16:02:56 -0700 (Fri, 27 Mar 2009)
New Revision: 14501
Added:
short/3D/PyLith/branches/pylith-swig/pylith/apps/PetscApplication.py
short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscComponent.py
Modified:
short/3D/PyLith/branches/pylith-swig/pylith/apps/PyLithApp.py
Log:
Added PetscApplication and PetscComponent.
Added: short/3D/PyLith/branches/pylith-swig/pylith/apps/PetscApplication.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/apps/PetscApplication.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/pylith/apps/PetscApplication.py 2009-03-27 23:02:56 UTC (rev 14501)
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/apps/PetscApplication.py
+##
+## @brief Python PETSc application for creating an MPI application
+## that uses PETSc.
+
+from mpi import Application
+
+# PetscApplication class
+class PetscApplication(Application):
+ """
+ Python PETSc application for creating an MPI application that uses
+ PETSc.
+
+ Inventory:
+ petsc Manager for PETSc options
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ import pyre.inventory
+
+ # Dummy facility for passing options to PETSc
+ from pylith.utils.PetscManager import PetscManager
+ petsc = pyre.inventory.facility("petsc", family="petsc_manager",
+ factory=PetscManager)
+ petsc.meta['tip'] = "Manager for PETSc options."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="petscapp"):
+ """
+ Constructor.
+ """
+ Application.__init__(self, name)
+ return
+
+
+ def onComputeNodes(self, *args, **kwds):
+ """
+ Run the application in parallel on the compute nodes.
+ """
+ self.petsc.initialize()
+ self.main(*args, **kwds)
+ self.cleanup()
+ self.petc.finalize()
+ return
+
+
+ def cleanup(self):
+ """
+ Deallocate data structures.
+ """
+ for component in self.components():
+ if isinstance(component, PetscComponent):
+ component.cleanup()
+ self._cleanup()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Application._configure(self)
+ self.petsc = self.inventory.petsc
+ return
+
+
+ def _cleanup(self):
+ """
+ Deallocate locally managed data structures.
+ """
+ return
+
+
+# End of file
Modified: short/3D/PyLith/branches/pylith-swig/pylith/apps/PyLithApp.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/apps/PyLithApp.py 2009-03-27 22:47:29 UTC (rev 14500)
+++ short/3D/PyLith/branches/pylith-swig/pylith/apps/PyLithApp.py 2009-03-27 23:02:56 UTC (rev 14501)
@@ -10,7 +10,7 @@
# ----------------------------------------------------------------------
#
-## @file pylith/PyLithApp.py
+## @file pylith/apps/PyLithApp.py
##
## @brief Python PyLith application
Added: short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscComponent.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscComponent.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscComponent.py 2009-03-27 23:02:56 UTC (rev 14501)
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/utils/PetscComponent.py
+##
+## @brief Python PetscComponent object for aid in deallocating data
+## structures before calling PetscFinalize().
+
+from pyre.components.Component import Component
+
+# PetscComponent class
+class PetscComponent(Component):
+ """
+ Python PetscComponent object for aid in deallocating data structures
+ before calling PetscFinalize().
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name, facility):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name, facility)
+ return
+
+
+ def cleanup(self):
+ """
+ Deallocate data structures.
+ """
+ for component in self.components():
+ if isinstance(component, PetscComponent):
+ component.cleanup()
+ self._cleanup()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _cleanup(self):
+ """
+ Deallocate locally managed data structures.
+ """
+ return
+
+
+# End of file
More information about the CIG-COMMITS
mailing list