[cig-commits] r9025 - in short/3D/PyLith/trunk/pylith: faults
meshio problems
brad at geodynamics.org
brad at geodynamics.org
Mon Jan 14 18:02:00 PST 2008
Author: brad
Date: 2008-01-14 18:01:59 -0800 (Mon, 14 Jan 2008)
New Revision: 9025
Modified:
short/3D/PyLith/trunk/pylith/faults/Fault.py
short/3D/PyLith/trunk/pylith/meshio/CellFilter.py
short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
short/3D/PyLith/trunk/pylith/problems/Explicit.py
short/3D/PyLith/trunk/pylith/problems/Formulation.py
short/3D/PyLith/trunk/pylith/problems/Implicit.py
Log:
Worked on setting up output for fault data.
Modified: short/3D/PyLith/trunk/pylith/faults/Fault.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/Fault.py 2008-01-15 00:29:40 UTC (rev 9024)
+++ short/3D/PyLith/trunk/pylith/faults/Fault.py 2008-01-15 02:01:59 UTC (rev 9025)
@@ -74,6 +74,7 @@
##
## \b Facilities
## @li \b quadrature Quadrature object for numerical integration
+ ## @li \b output Output manager associated with fault data.
import pyre.inventory
@@ -107,7 +108,12 @@
matDB.meta['tip'] = "Spatial database for bulk material properties " \
"(used in improving conditioning of Jacobian matrix)."
+ from pylith.meshio.OutputManager import OutputManager
+ output = pyre.inventory.facility("output", family="output_manager",
+ factory=OutputManager)
+ output.meta['tip'] = "Output manager associated with fault data."
+
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="fault"):
@@ -145,6 +151,7 @@
self.quadrature.preinitialize()
self.cppHandle.quadrature = self.quadrature.cppHandle
+ #self.cppHandle.output = self.output
return
@@ -160,6 +167,8 @@
(self.quadrature.cell.cellDim, faultDim)
# :TODO: Make sure mesh has group of vertices with label.
+
+ self.output.verifyConfiguration()
return
@@ -169,6 +178,7 @@
"""
self.quadrature.initialize()
self.matDB.initialize()
+ self.output.initialize(self.quadrature.cppHandle)
assert(None != self.cppHandle)
self.cppHandle.initialize(self.mesh.cppHandle,
@@ -178,6 +188,21 @@
return
+ def poststep(self, t, dt, totalTime):
+ """
+ Hook for doing stuff after advancing time step.
+ """
+ logEvent = "%spoststep" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ self._info.log("Writing fault data.")
+ #if output.writeFlag:
+ # self.cppHandle.writeData(t+dt)
+
+ self._logger.eventEnd(logEvent)
+ return
+
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -191,6 +216,7 @@
self.normalDir = map(float, self.inventory.normalDir)
self.quadrature = self.inventory.quadrature
self.matDB = self.inventory.matDB
+ self.output = self.inventory.output
return
Modified: short/3D/PyLith/trunk/pylith/meshio/CellFilter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/CellFilter.py 2008-01-15 00:29:40 UTC (rev 9024)
+++ short/3D/PyLith/trunk/pylith/meshio/CellFilter.py 2008-01-15 02:01:59 UTC (rev 9025)
@@ -71,7 +71,9 @@
"""
self._createCppHandle()
- if quadrature != None:
+ if None != self.cppHandle and quadrature != None:
+ # Only set quadrature if filter is specified and quadrature is
+ # provided.
assert(None != self.cppHandle)
self.cppHandle.quadrature = quadrature.cppHandle
return
Modified: short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputManager.py 2008-01-15 00:29:40 UTC (rev 9024)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputManager.py 2008-01-15 02:01:59 UTC (rev 9025)
@@ -106,8 +106,9 @@
self.cppHandle = None
self.coordsys = None
self.mesh = None
- self._t = None
- self._istep = None
+ self._stepCur = 0
+ self._stepWrite = None
+ self._tWrite = None
self.vertexFields = None
self.cellFields = None
self._fieldTranslator = copyTranslator
@@ -182,7 +183,7 @@
return
- def openTimeStep(self, t, istep):
+ def openTimeStep(self, t):
"""
Prepare for writing solution to file.
"""
@@ -191,16 +192,16 @@
self._info.log("Preparing for writing solution to file.")
write = False
- if self._istep == None or not "value" in dir(self._t):
+ if self._stepWrite == None or not "value" in dir(self._tWrite):
write = True
elif self.outputFreq == "skip":
- if istep > self._istep + self.skip:
+ if self._stepCur > self._stepWrite + self.skip:
write = True
- elif t >= self._t + self.dt:
+ elif t >= self._tWrite + self.dt:
write = True
if write:
- self._istep = istep
- self._t = t
+ self._stepWrite = self._stepCur
+ self._tWrite = t
self.writeFlag = write
assert(self.cppHandle != None)
@@ -223,6 +224,7 @@
self._info.log("Cleaning up afterwriting solution to file.")
self.writeFlag = False
+ self._stepCur += 1
assert(self.cppHandle != None)
self.cppHandle.closeTimeStep()
@@ -231,7 +233,7 @@
return
- def appendVertexField(self, t, istep, name, field, dim=0):
+ def appendVertexField(self, t, name, field, dim=0):
"""
Write field over vertices at time t to file.
"""
@@ -244,14 +246,12 @@
assert(self.mesh.cppHandle != None)
self.cppHandle.appendVertexField(t.value, name, field,
self.mesh.cppHandle, dim)
- self.istep = istep
- self.t = t
self._logger.eventEnd(logEvent)
return
- def appendCellField(self, t, istep, name, field, dim=0):
+ def appendCellField(self, t, name, field, dim=0):
"""
Write field over cells at time t to file.
"""
@@ -264,8 +264,6 @@
assert(self.mesh.cppHandle != None)
self.cppHandle.appendCellField(t.value, name, field,
self.mesh.cppHandle, dim)
- self.istep = istep
- self.t = t
self._logger.eventEnd(logEvent)
return
@@ -364,6 +362,9 @@
# MISCELLANEOUS ////////////////////////////////////////////////////////
def copyTranslator(name):
+ """
+ Field translator that simply copies the field name.
+ """
return name
Modified: short/3D/PyLith/trunk/pylith/problems/Explicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Explicit.py 2008-01-15 00:29:40 UTC (rev 9024)
+++ short/3D/PyLith/trunk/pylith/problems/Explicit.py 2008-01-15 02:01:59 UTC (rev 9025)
@@ -164,7 +164,7 @@
bindings.copyRealSection(self.fields.getReal("dispTpdt"),
self.fields.getReal("dispT"))
- self._info.log("Updating integrators states.")
+ self._info.log("Updating integrators' states.")
for integrator in self.integrators:
integrator.updateState(t, self.fields)
Modified: short/3D/PyLith/trunk/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Formulation.py 2008-01-15 00:29:40 UTC (rev 9024)
+++ short/3D/PyLith/trunk/pylith/problems/Formulation.py 2008-01-15 02:01:59 UTC (rev 9025)
@@ -46,7 +46,8 @@
##
## \b Facilities
## @li \b solver Algebraic solver.
- ## @li \b output Solution output.
+ ## @li \b output Output manager associated with solution over the
+ ## entire domain.
import pyre.inventory
@@ -58,6 +59,8 @@
from pylith.meshio.SingleOutput import SingleOutput
output = pyre.inventory.facility("output", family="object_bin",
factory=SingleOutput)
+ output.meta['tip'] = "Output managers associated with solution over " \
+ "the entire domain."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -71,7 +74,6 @@
self.constraints = None
self.fields = None
self.solnField = None
- self._istep = 0
return
@@ -247,13 +249,17 @@
logEvent = "%spoststep" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- self._info.log("Writing solution field.")
+ self._info.log("Writing solution fields.")
field = self.fields.getSolution()
for output in self.output.bin:
- output.openTimeStep(t+dt, self._istep)
- output.appendVertexField(t+dt, self._istep, self.solnField['label'], field, dim=3)
+ output.openTimeStep(t+dt)
+ output.appendVertexField(t+dt, self.solnField['label'],
+ field, dim=3)
output.closeTimeStep()
- self._istep += 1
+ #for integrator in integrators:
+ # integrator.poststep(t, dt, totalTime)
+ #for constraint in constraints:
+ # constraint.poststep(t, dt, totalTime)
self._logger.eventEnd(logEvent)
return
Modified: short/3D/PyLith/trunk/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Implicit.py 2008-01-15 00:29:40 UTC (rev 9024)
+++ short/3D/PyLith/trunk/pylith/problems/Implicit.py 2008-01-15 02:01:59 UTC (rev 9025)
@@ -72,6 +72,7 @@
self._loggingPrefix = "TSIm "
self.solnField = {'name': "dispTBctpdt",
'label': "displacements"}
+ self._step0 = None
return
@@ -108,6 +109,7 @@
self._debug.log(resourceUsageString())
# Initial time step solves for total displacement field, not increment
+ self._step0 = True
for constraint in self.constraints:
constraint.useSolnIncr(False)
for integrator in self.integrators:
@@ -200,7 +202,7 @@
# 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:
+ if self._step0 and (t + dt) < totalTime:
self._info.log("Switching from total field solution to incremental " \
"field solution.")
for constraint in self.constraints:
@@ -208,6 +210,7 @@
for integrator in self.integrators:
integrator.useSolnIncr(True)
self._reformJacobian(t, dt)
+ self._step0 = False
self._logger.eventEnd(logEvent)
More information about the cig-commits
mailing list