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

brad at geodynamics.org brad at geodynamics.org
Sat Oct 13 11:42:31 PDT 2012


Author: brad
Date: 2012-10-13 11:42:30 -0700 (Sat, 13 Oct 2012)
New Revision: 20836

Modified:
   short/3D/PyLith/trunk/pylith/problems/Formulation.py
   short/3D/PyLith/trunk/pylith/problems/Implicit.py
   short/3D/PyLith/trunk/pylith/problems/TimeStep.py
   short/3D/PyLith/trunk/pylith/problems/TimeStepUniform.py
Log:
Manual merge of time step stuff from v1.7-trunk.

Modified: short/3D/PyLith/trunk/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Formulation.py	2012-10-13 14:27:29 UTC (rev 20835)
+++ short/3D/PyLith/trunk/pylith/problems/Formulation.py	2012-10-13 18:42:30 UTC (rev 20836)
@@ -223,7 +223,7 @@
     """
     Get start time for simulation.
     """
-    return 0.0
+    return self.timeStep.startTimeN
 
 
   def getTotalTime(self):

Modified: short/3D/PyLith/trunk/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Implicit.py	2012-10-13 14:27:29 UTC (rev 20835)
+++ short/3D/PyLith/trunk/pylith/problems/Implicit.py	2012-10-13 18:42:30 UTC (rev 20836)
@@ -97,7 +97,6 @@
     Formulation.__init__(self, name)
     ModuleImplicit.__init__(self)
     self._loggingPrefix = "TSIm "
-    self._stepCount = None
     return
 
 
@@ -171,27 +170,11 @@
     self.solver.initialize(self.fields, self.jacobian, self)
     self._debug.log(resourceUsageString())
 
-    # Initial time step solves for total displacement field, not increment
-    self._stepCount = 0
-    for constraint in self.constraints:
-      constraint.useSolnIncr(False)
-    for integrator in self.integratorsMesh + self.integratorsSubMesh:
-      integrator.useSolnIncr(False)
-
     memoryLogger.stagePop()
     memoryLogger.setDebug(0)
     return
 
 
-  def getStartTime(self):
-    """
-    Get time at which time stepping should start.
-    """
-    dt = self.timeStep.timeStep(self.mesh,
-                                self.integratorsMesh + self.integratorsSubMesh)
-    return -dt
-
-
   def prestep(self, t, dt):
     """
     Hook for doing stuff before advancing time step.
@@ -199,30 +182,14 @@
     from pylith.mpi.Communicator import mpi_comm_world
     comm = mpi_comm_world()
     
-    # If finishing first time step, then switch from solving for total
-    # displacements to solving for incremental displacements
-    needNewJacobian = False
-    if 1 == self._stepCount:
-      if 0 == comm.rank:
-        self._info.log("Switching from total field solution to incremental " \
-                         "field solution.")
-      for constraint in self.constraints:
-        constraint.useSolnIncr(True)
-      for integrator in self.integratorsMesh + self.integratorsSubMesh:
-        integrator.useSolnIncr(True)
-      needNewJacobian = True
-
     if 0 == comm.rank:
       self._info.log("Setting constraints.")
     dispIncr = self.fields.get("dispIncr(t->t+dt)")
     dispIncr.zero()
-    if 0 == self._stepCount:
-      for constraint in self.constraints:
-        constraint.setField(t+dt, dispIncr)
-    else:
-      for constraint in self.constraints:
-        constraint.setFieldIncr(t, t+dt, dispIncr)
+    for constraint in self.constraints:
+      constraint.setFieldIncr(t, t+dt, dispIncr)
 
+    needNewJacobian = False
     for integrator in self.integratorsMesh + self.integratorsSubMesh:
       integrator.timeStep(dt)
       if integrator.needNewJacobian():
@@ -285,7 +252,6 @@
       output.writeData(t+dt, self.fields)
     self._writeData(t+dt)
 
-    self._stepCount += 1
     return
 
 

Modified: short/3D/PyLith/trunk/pylith/problems/TimeStep.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStep.py	2012-10-13 14:27:29 UTC (rev 20835)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStep.py	2012-10-13 18:42:30 UTC (rev 20836)
@@ -33,6 +33,34 @@
   Factory: time_step.
   """
 
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(PetscComponent.Inventory):
+    """
+    Python object for managing TimeStepUniform facilities and properties.
+    """
+
+    ## @class Inventory
+    ## Python abstract base class for managing TimeStep facilities and properties.
+    ##
+    ## \b Properties
+    ## @li \b total_time Time duration for simulation.
+    ## @li \b start_time Starting time for simulation.
+    ##
+    ## \b Facilities
+    ## @li None
+
+    import pyre.inventory
+
+    from pyre.units.time import second
+    totalTime = pyre.inventory.dimensional("total_time", default=0.0*second,
+                          validator=pyre.inventory.greaterEqual(0.0*second))
+    totalTime.meta['tip'] = "Time duration for simulation."
+
+    startTime = pyre.inventory.dimensional("start_time", default=0.0*second)
+    startTime.meta['tip'] = "Time duration for simulation."
+
+
   # PUBLIC METHODS /////////////////////////////////////////////////////
 
   def __init__(self, name="timestep"):
@@ -43,8 +71,10 @@
     from pyre.units.time import second
     self.timeScale = 1.0*second
     self.totalTime = 0.0*second
+    self.startTime = 0.0*second
     self.dt = 0.0*second
     self.totalTimeN = 0.0 # Nondimensionalized total time
+    self.startTimeN = 0.0 # Nondimensionalized start time
     self.dtN = 0.0 # Nondimenionalized time step
     return
 
@@ -82,6 +112,7 @@
     # Nondimensionalize time scales
     timeScale = normalizer.timeScale()
     self.totalTimeN = normalizer.nondimensionalize(self.totalTime, timeScale)
+    self.startTimeN = normalizer.nondimensionalize(self.startTime, timeScale)
     self.dtN = normalizer.nondimensionalize(self.dt, timeScale)
     self.timeScale = timeScale
 
@@ -119,6 +150,8 @@
     Set members based using inventory.
     """
     PetscComponent._configure(self)
+    self.totalTime = self.inventory.totalTime
+    self.startTime = self.inventory.startTime
     return
 
 

Modified: short/3D/PyLith/trunk/pylith/problems/TimeStepUniform.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStepUniform.py	2012-10-13 14:27:29 UTC (rev 20835)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStepUniform.py	2012-10-13 18:42:30 UTC (rev 20836)
@@ -29,7 +29,7 @@
 # TimeStepUniform class
 class TimeStepUniform(TimeStep):
   """
-  Python abstract base class for marching format in time with a uniform time step.
+  Python object for marching format in time with a uniform time step.
 
   Factory: time_step.
   """
@@ -45,7 +45,6 @@
     ## Python object for managing TimeStepUniform facilities and properties.
     ##
     ## \b Properties
-    ## @li \b total_time Time duration for simulation.
     ## @li \b dt Time step for simulation.
     ##
     ## \b Facilities
@@ -54,10 +53,6 @@
     import pyre.inventory
 
     from pyre.units.time import second
-    totalTime = pyre.inventory.dimensional("total_time", default=0.0*second,
-                          validator=pyre.inventory.greaterEqual(0.0*second))
-    totalTime.meta['tip'] = "Time duration for simulation."
-
     dt = pyre.inventory.dimensional("dt", default=1.0*second,
                                     validator=pyre.inventory.greater(0.0*second))
     dt.meta['tip'] = "Time step for simulation."
@@ -101,7 +96,6 @@
     Set members based using inventory.
     """
     TimeStep._configure(self)
-    self.totalTime = self.inventory.totalTime
     self.dt = self.inventory.dt
     return
 



More information about the CIG-COMMITS mailing list