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

willic3 at geodynamics.org willic3 at geodynamics.org
Fri Sep 28 10:51:47 PDT 2007


Author: willic3
Date: 2007-09-28 10:51:46 -0700 (Fri, 28 Sep 2007)
New Revision: 8051

Modified:
   short/3D/PyLith/trunk/pylith/problems/Formulation.py
   short/3D/PyLith/trunk/pylith/problems/Implicit.py
Log:
Added much more logging to Implicit.py and Formulation.py.
Also changed the way resource reporting is done, somewhat.
For each info.log entry, there is now a debug.log entry immediately
following, as well as another debug.log entry at the end of the section.
This lets us see the resource usage at the beginning and end of every
code section.



Modified: short/3D/PyLith/trunk/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Formulation.py	2007-09-28 01:18:22 UTC (rev 8050)
+++ short/3D/PyLith/trunk/pylith/problems/Formulation.py	2007-09-28 17:51:46 UTC (rev 8051)
@@ -88,6 +88,7 @@
     self.constraints = []
 
     self._info.log("Pre-initializing materials.")
+    self._debug.log(resourceUsageString())
     for material in materials.bin:
       integrator = self.elasticityIntegrator()
       if not implementsIntegrator(integrator):
@@ -96,10 +97,12 @@
               "Functionality missing." % (integrator.name, material.label)
       integrator.preinitialize(mesh, material)
       self.integrators.append(integrator)
+      self._debug.log(resourceUsageString())
       self._info.log("Added elasticity integrator for material '%s'." % \
                      material.label)
 
     self._info.log("Pre-initializing boundary conditions.")
+    self._debug.log(resourceUsageString())
     for bc in boundaryConditions.bin:
       bc.preinitialize(mesh)
       foundType = False
@@ -117,8 +120,10 @@
         raise TypeError, \
               "Could not determine whether boundary condition '%s' is an " \
               "integrator or a constraint." % bc.name
+    self._debug.log(resourceUsageString())
 
     self._info.log("Pre-initializing interior interfaces.")
+    self._debug.log(resourceUsageString())
     for ic in interfaceConditions.bin:
       ic.preinitialize(mesh)
       foundType = False
@@ -136,6 +141,7 @@
         raise TypeError, \
               "Could not determine whether interface condition '%s' is an " \
               "integrator or a constraint." % ic.name
+    self._debug.log(resourceUsageString())
     return
 
 
@@ -161,22 +167,26 @@
     self._debug.log(resourceUsageString())
 
     self._info.log("Initializing integrators.")
+    self._debug.log(resourceUsageString())
     for integrator in self.integrators:
       integrator.initialize()
     self._debug.log(resourceUsageString())
 
     self._info.log("Initializing constraints.")
+    self._debug.log(resourceUsageString())
     for constraint in self.constraints:
       constraint.initialize()
     self._debug.log(resourceUsageString())
 
     self._info.log("Setting up solution output.")
+    self._debug.log(resourceUsageString())
     for output in self.output.bin:
       output.open(self.mesh)
       output.writeTopology()
     self._debug.log(resourceUsageString())
 
     self._info.log("Creating solution field.")
+    self._debug.log(resourceUsageString())
     solnName = self.solnField['name']
     self.fields.addReal(solnName)
     self.fields.solutionField(solnName)
@@ -194,9 +204,12 @@
     """
     Hook for doing stuff after advancing time step.
     """
+    self._info.log("Writing solution field.")
+    self._debug.log(resourceUsageString())
     field = self.fields.getSolution()
     for output in self.output.bin:
       output.writeField(t+dt, self._istep, field, self.solnField['label'])
+    self._debug.log(resourceUsageString())
     self._istep += 1
     return
 
@@ -205,12 +218,15 @@
     """
     Cleanup after time stepping.
     """
+    self._info.log("Formulation finalize.")
+    self._debug.log(resourceUsageString())
     for integrator in self.integrators:
       integrator.finalize()
     for constraint in self.constraints:
       constraint.finalize()
     for output in self.output.bin:
       output.close()
+    self._debug.log(resourceUsageString())
     return
   
 

Modified: short/3D/PyLith/trunk/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Implicit.py	2007-09-28 01:18:22 UTC (rev 8050)
+++ short/3D/PyLith/trunk/pylith/problems/Implicit.py	2007-09-28 17:51:46 UTC (rev 8051)
@@ -87,12 +87,22 @@
     """
     Formulation.initialize(self, dimension, dt)
 
-    self._info.log("Creating other fields and matrices.")
+    self._info.log("Creating other fields.")
+    self._debug.log(resourceUsageString())
     self.fields.addReal("dispIncr")
     self.fields.addReal("residual")
     self.fields.copyLayout("dispTBctpdt")
+    self._debug.log(resourceUsageString())
+
+    self._info.log("Creating Jacobian matrix.")
+    self._debug.log(resourceUsageString())
     self.jacobian = self.mesh.createMatrix(self.fields.getSolution())
+    self._debug.log(resourceUsageString())
+
+    self._info.log("Initializing solver.")
+    self._debug.log(resourceUsageString())
     self.solver.initialize(self.mesh, self.fields.getSolution())
+    self._debug.log(resourceUsageString())
 
     # Initial time step solves for total displacement field, not increment
     for constraint in self.constraints:
@@ -126,16 +136,21 @@
     # Set dispTBctpdt to the BC t time t+dt. Unconstrained DOF are
     # unaffected and will be equal to their values at time t.
     self._info.log("Setting constraints.")
+    self._debug.log(resourceUsageString())
     dispTBctpdt = self.fields.getReal("dispTBctpdt")
     for constraint in self.constraints:
       constraint.setField(t+dt, dispTBctpdt)
+    self._debug.log(resourceUsageString())
 
     needNewJacobian = False
     for integrator in self.integrators:
       if integrator.needNewJacobian():
         needNewJacobian = True
     if needNewJacobian:
+      self._info.log("Reforming Jacobian.")
+      self._debug.log(resourceUsageString())
       self._reformJacobian(t, dt)
+      self._debug.log(resourceUsageString())
     return
 
 
@@ -155,13 +170,16 @@
     for integrator in self.integrators:
       integrator.timeStep(dt)
       integrator.integrateResidual(residual, t+dt, self.fields)
+    self._debug.log(resourceUsageString())
 
     self._info.log("Completing residual.")
+    self._debug.log(resourceUsageString())
     bindings.completeSection(self.mesh.cppHandle, residual)
     self._debug.log(resourceUsageString())
 
     import pylith.utils.petsc as petsc
     self._info.log("Solving equations.")
+    self._debug.log(resourceUsageString())
     self.solver.solve(dispIncr, self.jacobian, residual)
     self._debug.log(resourceUsageString())
     return
@@ -182,19 +200,23 @@
     bindings.addRealSections(disp, disp, dispIncr)
 
     self._info.log("Updating integrators states.")
+    self._debug.log(resourceUsageString())
     for integrator in self.integrators:
       integrator.updateState(t+dt, disp)
+    self._debug.log(resourceUsageString())
 
     # If finishing first time step, then switch from solving for total
     # displacements to solving for incremental displacements
     if 0 == self._istep and (t + dt) < totalTime:
       self._info.log("Switching from total field solution to incremental " \
                      "field solution.")
+      self._debug.log(resourceUsageString())
       for constraint in self.constraints:
         constraint.useSolnIncr(True)
       for integrator in self.integrators:
         integrator.useSolnIncr(True)
       self._reformJacobian(t, dt)
+      self._debug.log(resourceUsageString())
 
     Formulation.poststep(self, t, dt, totalTime)
     return



More information about the cig-commits mailing list