[cig-commits] r13446 - in short/3D/PyLith/trunk/pylith: bc faults feassemble meshio problems utils

brad at geodynamics.org brad at geodynamics.org
Wed Dec 3 11:22:16 PST 2008


Author: brad
Date: 2008-12-03 11:22:16 -0800 (Wed, 03 Dec 2008)
New Revision: 13446

Modified:
   short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py
   short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py
   short/3D/PyLith/trunk/pylith/faults/Fault.py
   short/3D/PyLith/trunk/pylith/feassemble/Constraint.py
   short/3D/PyLith/trunk/pylith/feassemble/Integrator.py
   short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py
   short/3D/PyLith/trunk/pylith/meshio/DataWriter.py
   short/3D/PyLith/trunk/pylith/meshio/DataWriterVTK.py
   short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
   short/3D/PyLith/trunk/pylith/meshio/OutputSoln.py
   short/3D/PyLith/trunk/pylith/meshio/OutputSolnSubset.py
   short/3D/PyLith/trunk/pylith/problems/Formulation.py
   short/3D/PyLith/trunk/pylith/problems/TimeDependent.py
   short/3D/PyLith/trunk/pylith/problems/TimeStep.py
   short/3D/PyLith/trunk/pylith/problems/TimeStepAdapt.py
   short/3D/PyLith/trunk/pylith/problems/TimeStepUser.py
   short/3D/PyLith/trunk/pylith/utils/CheckpointTimer.py
Log:
Fixed nondimensionalization bugs.

Modified: short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -147,6 +147,7 @@
     self.cppHandle.referenceTime = self.tRef.value
     self.dbRate.initialize()
     self.cppHandle.dbRate = self.dbRate.cppHandle
+    self.cppHandle.normalizer = normalizer.cppHandle
 
     BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
 

Modified: short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -132,6 +132,7 @@
     self.cppHandle.referenceTime = self.tRef.value
     self.dbRate.initialize()
     self.cppHandle.dbRate = self.dbRate.cppHandle
+    self.cppHandle.normalizer = normalizer.cppHandle
 
     BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
 

Modified: short/3D/PyLith/trunk/pylith/faults/Fault.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/Fault.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/faults/Fault.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -197,7 +197,7 @@
     self.cppHandle.faultMesh(self.faultMesh.cppHandle)
 
     if None != self.output:
-      self.output.initialize(self.quadrature.cppHandle)
+      self.output.initialize(normalizer, self.quadrature)
       self.output.writeInfo()
       self.output.open(totalTime, numTimeSteps)
 

Modified: short/3D/PyLith/trunk/pylith/feassemble/Constraint.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/Constraint.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/feassemble/Constraint.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -99,7 +99,7 @@
     Set time step for advancing from time t to time t+dt.
     """
     assert(None != self.cppHandle)
-    self.cppHandle.timeStep = dt.value
+    self.cppHandle.timeStep = dt
     return
 
 
@@ -153,7 +153,7 @@
     self._logger.eventBegin(logEvent)
 
     assert(None != self.cppHandle)
-    self.cppHandle.setField(t.value, field, self.mesh.cppHandle)
+    self.cppHandle.setField(t, field, self.mesh.cppHandle)
 
     self._logger.eventEnd(logEvent)
     return

Modified: short/3D/PyLith/trunk/pylith/feassemble/Integrator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/Integrator.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/feassemble/Integrator.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -107,7 +107,7 @@
     Set time step for advancing from time t to time t+dt.
     """
     assert(None != self.cppHandle)
-    self.cppHandle.timeStep = dt.value
+    self.cppHandle.timeStep = dt
     return
 
 
@@ -119,8 +119,7 @@
     self._logger.eventBegin(logEvent)
     
     assert(None != self.cppHandle)
-    from pyre.units.time import second
-    dt = self.cppHandle.stableTimeStep*second
+    dt = self.cppHandle.stableTimeStep
 
     self._logger.eventEnd(logEvent)
     return dt
@@ -162,7 +161,7 @@
     self._logger.eventBegin(logEvent)
     
     assert(None != self.cppHandle)
-    self.cppHandle.integrateResidual(residual, t.value, fields.cppHandle,
+    self.cppHandle.integrateResidual(residual, t, fields.cppHandle,
                                      self.mesh.cppHandle,
 				     self.mesh.coordsys.cppHandle)
     self._logger.eventEnd(logEvent)
@@ -177,7 +176,7 @@
     self._logger.eventBegin(logEvent)
     
     assert(None != self.cppHandle)
-    self.cppHandle.integrateJacobian(jacobian, t.value, fields.cppHandle,
+    self.cppHandle.integrateJacobian(jacobian, t, fields.cppHandle,
                                      self.mesh.cppHandle)
     self._logger.eventEnd(logEvent)
     return
@@ -192,7 +191,7 @@
     self._logger.eventBegin(logEvent)
     
     assert(None != self.cppHandle)
-    self.cppHandle.integrateResidualAssembled(residual, t.value,
+    self.cppHandle.integrateResidualAssembled(residual, t,
                                               fields.cppHandle,
                                               self.mesh.cppHandle,
                                               self.mesh.coordsys.cppHandle)
@@ -209,7 +208,7 @@
     self._logger.eventBegin(logEvent)
     
     assert(None != self.cppHandle)
-    self.cppHandle.integrateJacobianAssembled(jacobian, t.value,
+    self.cppHandle.integrateJacobianAssembled(jacobian, t,
                                               fields.cppHandle,
                                               self.mesh.cppHandle)
     self._logger.eventEnd(logEvent)
@@ -224,7 +223,7 @@
     self._logger.eventBegin(logEvent)
 
     assert(None != self.cppHandle)
-    self.cppHandle.updateState(t.value, fields.cppHandle, self.mesh.cppHandle)
+    self.cppHandle.updateState(t, fields.cppHandle, self.mesh.cppHandle)
 
     self._logger.eventEnd(logEvent)
     return

Modified: short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -92,7 +92,7 @@
     Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
 
     self.material.initialize(self.mesh, totalTime, numTimeSteps, normalizer)
-    self.output.initialize(self.quadrature)
+    self.output.initialize(normalizer, self.quadrature)
     self.output.writeInfo()
     self.output.open(totalTime, numTimeSteps)
 

Modified: short/3D/PyLith/trunk/pylith/meshio/DataWriter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/DataWriter.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/meshio/DataWriter.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -61,7 +61,7 @@
     return
 
 
-  def initialize(self):
+  def initialize(self, normalizer):
     """
     Initialize writer.
     """

Modified: short/3D/PyLith/trunk/pylith/meshio/DataWriterVTK.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/DataWriterVTK.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/meshio/DataWriterVTK.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -68,14 +68,20 @@
     return
 
 
-  def initialize(self):
+  def initialize(self, normalizer):
     """
     Initialize writer.
     """
-    DataWriter.initialize(self)
+    DataWriter.initialize(self, normalizer)
+
+    # Nondimensionalize
+    timeScale = normalizer.timeScale()
+    self.timeConstant = normalizer.nondimensionalize(self.timeConstant,
+                                                     timeScale)
+    
     self.cppHandle.filename = self.filename
     self.cppHandle.timeFormat = self.timeFormat
-    self.cppHandle.timeConstant = self.timeConstant.value
+    self.cppHandle.timeConstant = self.timeConstant
     return
   
 

Modified: short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputManager.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputManager.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -138,20 +138,24 @@
     return
 
 
-  def initialize(self, quadrature=None):
+  def initialize(self, normalizer, quadrature=None):
     """
     Initialize output manager.
     """
     logEvent = "%sinit" % self._loggingPrefix
     self._logger.eventBegin(logEvent)    
 
+    # Nondimensionalize time step
+    lengthScale = normalizer.timeScale()
+    self.dt = normalizer.nondimensionalize(self.dt, lengthScale)
+
     # Initialize coordinate system
     if self.coordsys is None:
       raise ValueError, "Coordinate system for output is unknown."
     self.coordsys.initialize()
 
     self.cellFilter.initialize(quadrature)
-    self.writer.initialize()
+    self.writer.initialize(normalizer)
     self._sync()
 
     self._logger.eventEnd(logEvent)
@@ -205,22 +209,21 @@
     self._logger.eventBegin(logEvent)    
 
     if len(self.vertexInfoFields) > 0 or len(self.cellInfoFields) > 0:
-      from pyre.units.time import s
-      t = 0.0*s
-      self.open(totalTime=0.0*s, numTimeSteps=0)
+      t = 0.0
+      self.open(totalTime=0.0, numTimeSteps=0)
       (mesh, label, labelId) = self.dataProvider.getDataMesh()
-      self.cppHandle.openTimeStep(t.value,
+      self.cppHandle.openTimeStep(t,
                                   mesh.cppHandle, mesh.coordsys.cppHandle,
                                   label, labelId)
 
       for name in self.vertexInfoFields:
         (field, fieldType) = self.dataProvider.getVertexField(name)
-        self.cppHandle.appendVertexField(t.value, name, field, fieldType, 
+        self.cppHandle.appendVertexField(t, name, field, fieldType, 
                                          mesh.cppHandle)
 
       for name in self.cellInfoFields:
         (field, fieldType) = self.dataProvider.getCellField(name)
-        self.cppHandle.appendCellField(t.value, name, field, fieldType, 
+        self.cppHandle.appendCellField(t, name, field, fieldType, 
                                        mesh.cppHandle, label, labelId)
 
       self.cppHandle.closeTimeStep()
@@ -242,18 +245,18 @@
              len(self.cellDataFields) ) > 0:
 
       (mesh, label, labelId) = self.dataProvider.getDataMesh()
-      self.cppHandle.openTimeStep(t.value,
+      self.cppHandle.openTimeStep(t,
                                   mesh.cppHandle, mesh.coordsys.cppHandle,
                                   label, labelId)
 
       for name in self.vertexDataFields:
         (field, fieldType) = self.dataProvider.getVertexField(name, fields)
-        self.cppHandle.appendVertexField(t.value, name, field, fieldType, 
+        self.cppHandle.appendVertexField(t, name, field, fieldType, 
                                          mesh.cppHandle)
 
       for name in self.cellDataFields:
         (field, fieldType) = self.dataProvider.getCellField(name, fields)
-        self.cppHandle.appendCellField(t.value, name, field, fieldType, 
+        self.cppHandle.appendCellField(t, name, field, fieldType, 
                                        mesh.cppHandle, label, labelId)
 
       self.cppHandle.closeTimeStep()

Modified: short/3D/PyLith/trunk/pylith/meshio/OutputSoln.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputSoln.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputSoln.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -79,7 +79,7 @@
     return
   
 
-  def initialize(self, mesh):
+  def initialize(self, mesh, normalizer):
     """
     Initialize output manager.
     """
@@ -87,7 +87,7 @@
     self._logger.eventBegin(logEvent)    
 
     self.mesh = mesh
-    OutputManager.initialize(self)
+    OutputManager.initialize(self, normalizer)
 
     self._logger.eventEnd(logEvent)
     return

Modified: short/3D/PyLith/trunk/pylith/meshio/OutputSolnSubset.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputSolnSubset.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputSolnSubset.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -94,7 +94,7 @@
     return
 
 
-  def initialize(self, mesh):
+  def initialize(self, mesh, normalizer):
     """
     Initialize output manager.
     """
@@ -107,7 +107,7 @@
     assert(None != self.cppHandle)
     self.cppHandle.mesh(self.mesh.cppHandle, mesh.cppHandle)
 
-    OutputManager.initialize(self)
+    OutputManager.initialize(self, normalizer)
 
     self._logger.eventEnd(logEvent)
     return

Modified: short/3D/PyLith/trunk/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Formulation.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/problems/Formulation.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -167,7 +167,7 @@
     logEvent = "%sinit" % self._loggingPrefix
     self._logger.eventBegin(logEvent)
 
-    self.timeStep.initialize()
+    self.timeStep.initialize(normalizer)
 
     numTimeSteps = self.timeStep.numTimeSteps()
     totalTime = self.timeStep.totalTime
@@ -193,7 +193,7 @@
 
     self._info.log("Setting up solution output.")
     for output in self.output.components():
-      output.initialize(self.mesh)
+      output.initialize(self.mesh, normalizer)
       output.writeInfo()
       output.open(totalTime, numTimeSteps)
     self._debug.log(resourceUsageString())

Modified: short/3D/PyLith/trunk/pylith/problems/TimeDependent.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeDependent.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/problems/TimeDependent.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -112,6 +112,7 @@
 
     self._info.log("Initializing problem.")
     self.normalizer.initialize()
+    self.checkpointTimer.initialize(self.normalizer)
     self.formulation.initialize(self.dimension, self.normalizer)
 
     self._logger.eventEnd(logEvent)
@@ -129,22 +130,28 @@
     self.checkpointTimer.toplevel = app # Set handle for saving state
     
     t = self.formulation.getStartTime()
+    timeScale = self.normalizer.timeScale()
     while t < self.formulation.getTotalTime():
-      self._info.log("Main time loop, current time is t=%s" % t)
+      tsec = self.normalizer.dimensionalize(t, timeScale)
+      self._info.log("Main time loop, current time is t=%s" % tsec)
       
       # Checkpoint if necessary
       self.checkpointTimer.update(t)
 
       # Get time step for advancing in time
       dt = self.formulation.getTimeStep()
+      dtsec = self.normalizer.dimensionalize(dt, timeScale)
 
-      self._info.log("Preparing to advance solution from time t=%s to t=%s." % (t, t+dt))
+      self._info.log("Preparing to advance solution from time t=%s to t=%s." %\
+                     (tsec, tsec+dtsec))
       self.formulation.prestep(t, dt)
 
-      self._info.log("Advancing solution from t=%s to t=%s." % (t, t+dt))
+      self._info.log("Advancing solution from t=%s to t=%s." % \
+                     (tsec, tsec+dtsec))
       self.formulation.step(t, dt)
 
-      self._info.log("Finishing advancing solution from t=%s to t=%s." % (t, t+dt))
+      self._info.log("Finishing advancing solution from t=%s to t=%s." % \
+                     (tsec, tsec+dtsec))
       self.formulation.poststep(t, dt)
 
       # Update time

Modified: short/3D/PyLith/trunk/pylith/problems/TimeStep.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStep.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStep.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -64,13 +64,18 @@
     return
   
 
-  def initialize(self):
+  def initialize(self, normalizer):
     """
     Initialize time step algorithm.
     """
     logEvent = "%sinit" % self._loggingPrefix
     self._logger.eventBegin(logEvent)
 
+    # Nondimensionalize time scales
+    timeScale = normalizer.timeScale()
+    self.totalTime = normalizer.nondimensionalize(self.totalTime, timeScale)
+    self.dt = normalizer.nondimensionalize(self.dt, timeScale)
+
     self._logger.eventEnd(logEvent)
     return
 

Modified: short/3D/PyLith/trunk/pylith/problems/TimeStepAdapt.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStepAdapt.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStepAdapt.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -82,6 +82,23 @@
     return
 
 
+  def initialize(self, normalizer):
+    """
+    Initialize time step algorithm.
+    """
+    logEvent = "%sinit" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)
+
+    TimeStep.initialize(self, normalizer)
+
+    # Nondimensionalize time scales
+    timeScale = normalizer.timeScale()
+    self.maxDt = normalizer.nondimensionalize(self.maxDt, timeScale)
+
+    self._logger.eventEnd(logEvent)
+    return
+
+
   def numTimeSteps(self):
     """
     Get number of total time steps (or best guess if adaptive).
@@ -95,15 +112,14 @@
     """
     Adjust stable time step for advancing forward in time.
     """
-    from pyre.units.time import second
-    dtStable = 1.0e+30*second
+    dtStable = 1.0e+30
     for integrator in integrators:
       dt = integrator.stableTimeStep()
       if dt < dtStable:
         dtStable = dt
     
     if self.skipped < self.adaptSkip and \
-          self.dt != 0.0*second and \
+          self.dt != 0.0 and \
           self.dt < dtStable:
       self.skipped += 1
     else:

Modified: short/3D/PyLith/trunk/pylith/problems/TimeStepUser.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStepUser.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStepUser.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -100,7 +100,7 @@
     return
 
 
-  def initialize(self):
+  def initialize(self, normalizer):
     """
     Initialize time step algorithm.
     """
@@ -112,6 +112,13 @@
     self._readSteps()
     assert(len(self.steps) > 0)
     assert(self.index == 0)
+
+    # Nondimensionalize time steps
+    timeScale = normalizer.timeScale()
+    for i in xrange(len(self.steps)):
+      self.steps[i] = normalizer.nondimensional(self.step, timeScale)
+
+    # Set current time step
     self.dt = self.steps[self.index]
 
     self._logger.eventEnd(logEvent)
@@ -123,7 +130,7 @@
     Get number of total time steps (or best guess if adaptive).
     """
     from pyre.units.time import second
-    t = 0.0*second
+    t = 0.0
     nsteps = 0
     index = 0
     while t <= self.totalTime:

Modified: short/3D/PyLith/trunk/pylith/utils/CheckpointTimer.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/CheckpointTimer.py	2008-12-03 19:21:45 UTC (rev 13445)
+++ short/3D/PyLith/trunk/pylith/utils/CheckpointTimer.py	2008-12-03 19:22:16 UTC (rev 13446)
@@ -79,11 +79,13 @@
     return
 
 
-  def initialize(self, toplevel):
+  def initialize(self, normalizer):
     """
     Initialize checkpoint timer.
     """
-    self.toplevel = toplevel
+    timeScale = normalizer.timeScale()
+    self.t = normalizer.nondimensionalize(self.t, timeScale)
+    self.dt = normalizer.nondimensionalize(self.dt, timeScale)
     return
   
 
@@ -92,8 +94,8 @@
     CheckpointTimer if necessary.
     """
 
-    if t.value > self.t.value + self.dt.value:
-      if app is None:
+    if t > self.t + self.dt:
+      if self.toplevel is None:
         raise ValueError, "Atttempting to checkpoint without " \
               "setting toplevel attribute in CheckpointTimer."
       self.toplevel.checkpoint()



More information about the CIG-COMMITS mailing list