[cig-commits] r6016 - in
short/3D/PyLith/branches/pylith-0.8/pylith3d:
examples/lintet/tractest libpylith3d pylith3d
leif at geodynamics.org
leif at geodynamics.org
Tue Feb 13 16:23:48 PST 2007
Author: leif
Date: 2007-02-13 16:23:47 -0800 (Tue, 13 Feb 2007)
New Revision: 6016
Modified:
short/3D/PyLith/branches/pylith-0.8/pylith3d/examples/lintet/tractest/tractest.keyval
short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/matinit_drv.F
short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/stress_mat_drv.F
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/KeyValParser.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_scan.py
Log:
Ripped-out calls to PetscCommSynchronizeTags, per Matt's instructions.
The function no longer exists in the development version of PETSc:
changeset: 10000:21bdefd4c2d2
user: bsmith at barry-smiths-computer.local
date: Fri Feb 9 19:34:16 2007 -0600
summary: removed PetscCommSynchronizeTags and PetscCommCheckTags
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/examples/lintet/tractest/tractest.keyval
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/examples/lintet/tractest/tractest.keyval 2007-02-14 00:21:03 UTC (rev 6015)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/examples/lintet/tractest/tractest.keyval 2007-02-14 00:23:47 UTC (rev 6016)
@@ -14,6 +14,9 @@
#winklerScaleX = 1.0
#winklerScaleY = 1.0
#winklerScaleZ = 1.0
+winklerScaleZ = tomato
+zoo = bar
+fileRoot=tractesthh
#
#
# Parameters controlling stress integration and numerical computation
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/matinit_drv.F
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/matinit_drv.F 2007-02-14 00:21:03 UTC (rev 6015)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/matinit_drv.F 2007-02-14 00:23:47 UTC (rev 6016)
@@ -524,7 +524,6 @@
c
c... check stiffness matrix for zero or negative diagonals
c
- call PetscCommSynchronizeTags(MPI_COMM_WORLD, ierr)
call MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY, ierr)
call MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY, ierr)
if (ierr.ne.0) then
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/stress_mat_drv.F
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/stress_mat_drv.F 2007-02-14 00:21:03 UTC (rev 6015)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/stress_mat_drv.F 2007-02-14 00:23:47 UTC (rev 6016)
@@ -529,7 +529,6 @@
c... assemble stiffness matrix and check for zero or negative
c diagonal entries
c
- call PetscCommSynchronizeTags(MPI_COMM_WORLD, ierr)
call MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY, ierr)
call MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY, ierr)
call ckdiag(A,ierr,errstrng)
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/KeyValParser.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/KeyValParser.py 2007-02-14 00:21:03 UTC (rev 6015)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/KeyValParser.py 2007-02-14 00:23:47 UTC (rev 6016)
@@ -38,12 +38,10 @@
def parse(self, stream):
registry = Registry("root")
- node = registry.getNode("pylith3d")
- node = node.getNode("scanner")
lineNumber = 1
for line in stream:
locator = locators.file(stream.name, lineNumber)
- self.parseLine(line, node, locator)
+ self.parseLine(line, registry, locator)
lineNumber = lineNumber + 1
return registry
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_scan.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_scan.py 2007-02-14 00:21:03 UTC (rev 6015)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_scan.py 2007-02-14 00:23:47 UTC (rev 6016)
@@ -33,7 +33,7 @@
import os
-class Pylith3d_scan(Component):
+class Scanner(Component):
def __init__(self):
@@ -44,19 +44,20 @@
self.trace.log("Hello from pl3dscan.__init__!")
- self.rank = 0
+ self.macros = {}
+ self.defineMacros({'rank': '0'})
return
def configureProperties(self, context):
- """set the values of all the properties and facilities in my inventory"""
+ """set the values of all the properties in my inventory"""
#
# First, configure my properties as defined by the framework.
#
- super(Pylith3d_scan, self).configureProperties(context)
+ super(Scanner, self).configureProperties(context)
#
# Second, open input files. Log I/O errors.
@@ -74,7 +75,7 @@
unused = self.IOFileCategory(False, 0, "unused")
required = self.IOFileCategory(True, 1, None)
- Inventory = Pylith3d_scan.Inventory
+ Inventory = Scanner.Inventory
analysisType = self.inventory.analysisType
@@ -99,18 +100,6 @@
self._differentialForceInputFile = inputFile(Inventory.differentialForceInputFile, unused)
self._slipperyWinklerInputFile = inputFile(Inventory.slipperyWinklerInputFile, unused)
- def openKeywordEqualsValueFile(filename, flags, mode):
- from CodecKeyVal import CodecKeyVal
- from os.path import splitext
- base, ext = splitext(filename)
- assert ext == ".keyval"
- codec = CodecKeyVal()
- shelf = codec.open(base, mode)
- return shelf
-
- self._keywordEqualsValueFile = inputFileStream(Inventory.keywordEqualsValueFile, optional,
- opener=openKeywordEqualsValueFile)
-
# The call to glob() is somewhat crude -- basically, determine
# if any files might be in the way.
self._ucdOutputRoot = macroString(Inventory.ucdOutputRoot)
@@ -139,21 +128,6 @@
sys.exit("%s: configuration error(s)" % self.name)
#
- # Third, read the data from the .keyval file -- potentially
- # reconfiguring some of my properties.
- #
-
- if self._keywordEqualsValueFile:
- registry = self._keywordEqualsValueFile['inventory']
- registry = registry.getFacility("pylith3d")
- registry = registry.getFacility("scanner")
- if registry:
- # Transfer .keyval input to my private registry...
- self.updateConfiguration(registry)
- # ..and from there to my inventory.
- self.inventory.configureProperties(context)
-
- #
# Finally, decorate any missing traits with my name.
#
@@ -163,6 +137,8 @@
def _configure(self):
+ super(Scanner, self)._configure()
+
# get values for extra input (category 2)
self.winklerScaleX = self.inventory.winklerScaleX
@@ -217,9 +193,11 @@
import string
from mpi import MPI_Comm_rank, MPI_COMM_WORLD
- self.rank = MPI_Comm_rank(MPI_COMM_WORLD)
+ rank = MPI_Comm_rank(MPI_COMM_WORLD)
+ self.defineMacros({'rank': str(rank)})
+
outputFile = self.outputFile
- Inventory = Pylith3d_scan.Inventory
+ Inventory = Scanner.Inventory
optional = self.IOFileCategory(True, 0, "optional")
# Re-initialize these with the newly acquired rank.
self._asciiOutputFile = outputFile(Inventory.asciiOutputFile, optional)
@@ -660,23 +638,14 @@
self.tryOpen = tryOpen
self.fatalPoints = fatalPoints
self.label = label
+
+ def defineMacros(self, macros):
+ self.macros.update(macros)
def macroString(self, trait):
from pyre.util import expandMacros
- class InventoryAdapter(object):
- def __init__(self, inventory, builtins):
- self.inventory = inventory
- self.builtins = builtins
- def __getitem__(self, key):
- builtin = self.builtins.get(key)
- if builtin is None:
- return expandMacros(str(self.inventory.getTraitValue(key)), self)
- return builtin
descriptor = self.inventory.getTraitDescriptor(trait.name)
- builtins = {
- 'rank': str(self.rank),
- }
- return expandMacros(descriptor.value, InventoryAdapter(self.inventory, builtins))
+ return expandMacros(descriptor.value, self.macros)
def ioFileStream(self, trait, flags, mode, category, opener=None):
value = self.macroString(trait)
@@ -708,7 +677,6 @@
os.remove(value)
return value
-
class Inventory(Component.Inventory):
import pyre.inventory
@@ -721,14 +689,6 @@
default="PyLith-0.8 Simulation")
title.meta['tip'] = "Title for this simulation"
- # Basename for all files (may be overridden by specific filename entries).
- fileRoot = pyre.inventory.str("fileRoot", default="pt1")
- fileRoot.meta['tip'] = "Root pathname for simulation (all filenames derive from this)."
- inputFileRoot = pyre.inventory.str("inputFileRoot", default="${fileRoot}")
- inputFileRoot.meta['tip'] = "Root input pathname for simulation (all input filenames derive from this)."
- outputFileRoot = pyre.inventory.str("outputFileRoot", default="${fileRoot}.${rank}")
- outputFileRoot.meta['tip'] = "Root output pathname for simulation (all output filenames derive from this)."
-
# Output filenames (all are optional).
asciiOutputFile = OutputFile("asciiOutputFile",default="${outputFileRoot}.ascii")
asciiOutputFile.meta['tip'] = "Pathname for ascii output file (overrides default from outputFileRoot)."
@@ -763,9 +723,6 @@
fullOutputInputFile.meta['tip'] = "Pathname for file defining when to provide output (overrides default from inputFileRoot)."
# Optional input files.
- keywordEqualsValueFile = InputFile("keywordEqualsValueFile",default="${inputFileRoot}.keyval")
- keywordEqualsValueFile.meta['tip'] = "Pathname for keyword = value file (overrides default from inputFileRoot)."
-
winklerInputFile = InputFile("winklerInputFile",default="${inputFileRoot}.wink")
winklerInputFile.meta['tip'] = "Pathname for Winkler force input file (overrides default from inputFileRoot)."
@@ -837,7 +794,7 @@
autoRotateSlipperyNodes.meta['tip'] = "Whether to performa automatic rotation for slippery nodes (presently unused)."
#
- # category 2 parameters formerly placed in *.keyval files
+ # category 2 parameters traditionally placed in *.keyval files
#
from pyre.units.pressure import Pa
@@ -886,6 +843,102 @@
+from pyre.applications import ComponentHarnessAdapter
+#from pyre.applications.ComponentHarness import ComponentHarness as ComponentHarnessAdapter
+
+
+class ScannerComponentHarness(ComponentHarnessAdapter, Component):
+
+
+ class Inventory(Component.Inventory):
+
+ import pyre.inventory
+ MacroString = pyre.inventory.str
+ InputFile = pyre.inventory.str
+
+ # Basename for all files (may be overridden by specific filename entries).
+ fileRoot = MacroString("fileRoot", default="pt1")
+ fileRoot.meta['tip'] = "Root pathname for simulation (all filenames derive from this)."
+ inputFileRoot = MacroString("inputFileRoot", default="${fileRoot}")
+ inputFileRoot.meta['tip'] = "Root input pathname for simulation (all input filenames derive from this)."
+ outputFileRoot = MacroString("outputFileRoot", default="${fileRoot}.${rank}")
+ outputFileRoot.meta['tip'] = "Root output pathname for simulation (all output filenames derive from this)."
+
+ # Optional input files.
+ keywordEqualsValueFile = InputFile("keywordEqualsValueFile",default="${inputFileRoot}.keyval")
+ keywordEqualsValueFile.meta['tip'] = "Pathname for keyword = value file (overrides default from inputFileRoot)."
+
+
+ def __init__(self):
+ Component.__init__(self, "pl3dscan", "scanner")
+ ComponentHarnessAdapter.__init__(self)
+
+
+ def _configure(self):
+ super(ScannerComponentHarness, self)._configure()
+ self.fileRoot = self.inventory.fileRoot
+ self.inputFileRoot = self.inventory.fileRoot
+ self.outputFileRoot = self.inventory.outputFileRoot
+ self.keywordEqualsValueFile = self.inventory.keywordEqualsValueFile
+
+
+ def _init(self):
+ super(ScannerComponentHarness, self)._init()
+ self.scanner = self.harnessComponent()
+
+
+ def createComponent(self):
+ """create the harnessed component"""
+
+ return Scanner()
+
+
+ def prepareComponentConfiguration(self, component):
+ """prepare the settings for the harnessed component"""
+
+ # Expand macros.
+
+ macros = self.getMacros()
+ component.defineMacros(macros)
+
+ # Read traits from the .keyval file.
+
+ from pyre.util import expandMacros
+ from CodecKeyVal import CodecKeyVal
+ from os.path import splitext
+
+ filename = expandMacros(self.keywordEqualsValueFile, macros)
+ base, ext = splitext(filename)
+ assert ext == ".keyval"
+ codec = CodecKeyVal()
+ shelf = codec.open(base, 'r')
+
+ if shelf:
+ registry = shelf['inventory']
+ if registry:
+ self.componentRegistry.update(registry)
+
+ return super(ScannerComponentHarness, self).prepareComponentConfiguration(component)
+
+
+ def getMacros(self):
+ from pyre.util import expandMacros
+
+ macros = {
+ 'fileRoot': self.fileRoot,
+ }
+
+ # Expand occurrences of '${fileRoot}'. (Expansion of other
+ # macros is deferred until later.)
+ macros['inputFileRoot'] = expandMacros(self.inputFileRoot, macros)
+ macros['outputFileRoot'] = expandMacros(self.outputFileRoot, macros)
+
+ return macros
+
+
+Pylith3d_scan = ScannerComponentHarness
+
+
# version
# $Id: Pylith3d_scan.py,v 1.19 2005/06/24 20:22:03 willic3 Exp $
More information about the cig-commits
mailing list