[cig-commits] r5698 - in
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d: .
MaterialModel
leif at geodynamics.org
leif at geodynamics.org
Mon Jan 8 19:02:52 PST 2007
Author: leif
Date: 2007-01-08 19:02:51 -0800 (Mon, 08 Jan 2007)
New Revision: 5698
Modified:
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/ElementTypeDef.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/KeywordValueParse.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearElastic.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearGenMaxwellViscoelastic.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearMaxwellViscoelastic.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearMaxwellViscoelasticESF.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicPowerLawMaxwellViscoelastic.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/MaterialModel.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Materials.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_run.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_scan.py
short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_setup.py
Log:
Transformed "Hello" print statements into 'journal' log messages.
Made MaterialModel subclasses call MaterialModel.__init__().
Nuked gratuitous use of 'exec'.
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/ElementTypeDef.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/ElementTypeDef.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/ElementTypeDef.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -38,7 +38,7 @@
import pylith3d
- print "Hello from ElementTypeDef.getdef!"
+ self.trace.log("Hello from ElementTypeDef.getdef!")
self.numberVolumeElementNodes = self.elementNodes[elementType - 1]
self.numberSurfaceElementNodes = self.elementNodes2d[elementType - 1]
@@ -125,8 +125,12 @@
def __init__(self):
- print ""
- print "Hello from ElementTypeDef.__init__!"
+
+ import journal
+ self.trace = journal.debug("pylith3d.trace")
+
+ self.trace.log("Hello from ElementTypeDef.__init__!")
+
self.numberVolumeElementNodes = 0
self.numberVolumeElementGaussPoints = 0
self.numberVolumeElementEquations = 0
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/KeywordValueParse.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/KeywordValueParse.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/KeywordValueParse.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -36,7 +36,7 @@
uparser = pyre.units.parser()
- # print "Hello from KeywordValueParse.parseline!"
+ self.trace.log("Hello from KeywordValueParse.parseline!")
self.keyvals[3] = False
comment = line.find('#')
@@ -69,8 +69,11 @@
def __init__(self):
- print ""
- print "Hello from KeywordValueParse.__init__!"
+ import journal
+ self.trace = journal.debug("pylith3d.trace")
+
+ self.trace.log("Hello from KeywordValueParse.__init__!")
+
self.keyvals = [None, None, None,None]
return
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearElastic.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearElastic.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearElastic.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -51,6 +51,8 @@
Only 2 state variables (stress and strain) are required to describe
this material."""
+ MaterialModel.__init__(self)
+
# print "Hello from IsotropicLinearElastic.__init__!"
# print ""
self.materialModel = 1
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearGenMaxwellViscoelastic.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearGenMaxwellViscoelastic.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearGenMaxwellViscoelastic.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -97,6 +97,8 @@
def __init__(self):
+ MaterialModel.__init__(self)
+
# print "Hello from IsotropicLinearGenMaxwellViscoelastic.__init__!"
# print ""
self.materialModel = 7
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearMaxwellViscoelastic.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearMaxwellViscoelastic.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearMaxwellViscoelastic.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -33,6 +33,8 @@
class IsotropicLinearMaxwellViscoelastic(MaterialModel):
def __init__(self):
+ MaterialModel.__init__(self)
+
# print "Hello from IsotropicLinearMaxwellViscoelastic.__init__!"
# print ""
self.materialModel = 5
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearMaxwellViscoelasticESF.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearMaxwellViscoelasticESF.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicLinearMaxwellViscoelasticESF.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -33,6 +33,8 @@
class IsotropicLinearMaxwellViscoelasticESF(MaterialModel):
def __init__(self):
+ MaterialModel.__init__(self)
+
# print "Hello from IsotropicLinearMaxwellViscoelasticESF.__init__!"
# print ""
self.materialModel = 8
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicPowerLawMaxwellViscoelastic.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicPowerLawMaxwellViscoelastic.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/IsotropicPowerLawMaxwellViscoelastic.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -33,6 +33,8 @@
class IsotropicPowerLawMaxwellViscoelastic(MaterialModel):
def __init__(self):
+ MaterialModel.__init__(self)
+
# print "Hello from IsotropicPowerLawMaxwellViscoelastic.__init__!"
# print ""
self.materialModel = 6
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/MaterialModel.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/MaterialModel.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/MaterialModel/MaterialModel.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -38,7 +38,7 @@
lineparse = KeywordValueParse()
- # print "Hello from MaterialModel.readprop!"
+ self.trace.log("Hello from MaterialModel.readprop!")
endMaterial = False
while not endMaterial:
@@ -62,9 +62,12 @@
def __init__(self):
- print ""
- print "Hello from MaterialModel.__init__!"
- self.propertyList = [0.0] * self.numberProperties
+ import journal
+ self.trace = journal.debug("pylith3d.trace")
+
+ self.trace.log("Hello from MaterialModel.__init__!")
+
+ #self.propertyList = [0.0] * self.numberProperties
return
# version
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Materials.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Materials.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Materials.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -34,7 +34,7 @@
def readprop(self, propertyFile):
- # print "Hello from Materials.readprop!"
+ self.trace.log("Hello from Materials.readprop!")
file = open(propertyFile, 'r')
while 1:
@@ -44,8 +44,9 @@
materialType = None
exec line
if materialType != None:
- matchoose = 'matmodel = ' + materialType + '.' + materialType + '()'
- exec matchoose
+ matmodule = globals()[materialType]
+ matclass = getattr(matmodule, materialType)
+ matmodel = matclass()
matmodel.readprop(file)
self.numberMaterials += 1
self.materialNumber += [self.numberMaterials]
@@ -63,8 +64,11 @@
def __init__(self):
- print ""
- print "Hello from Materials.__init__!"
+ import journal
+ self.trace = journal.debug("pylith3d.trace")
+
+ self.trace.log("Hello from Materials.__init__!")
+
self.numberMaterials = 0
self.materialNumber = []
self.materialModel = []
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_run.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_run.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_run.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -44,8 +44,8 @@
pl3dscan = scanner
pl3dsetup = setup
- print ""
- print "Hello from pl3drun.initialize (begin)!"
+ self.trace.log("Hello from pl3drun.initialize (begin)!")
+
print "Importing information from other modules:"
# The only parameters required from Pylith3d_scan are those in the
@@ -173,8 +173,7 @@
self.plotOutputFile = pl3dsetup.plotOutputFile
self.ucdOutputRoot = pl3dsetup.ucdOutputRoot
- print ""
- print "Hello from pl3drun.initialize (end)!"
+ self.trace.log("Hello from pl3drun.initialize (end)!")
return
@@ -283,8 +282,8 @@
# and should not be accessed directly except as a member of the list.
# They should not have been defined previously.
- print ""
- print "Hello from pl3drun.run (begin)!"
+ self.trace.log("Hello from pl3drun.run (begin)!")
+
print "Beginning problem solution:"
# Output approximate memory usage
@@ -652,16 +651,19 @@
self.iterateEvent)
pylith3d.destroyPETScMat(self.A,self.rhs,self.sol)
pylith3d.PetscFinalize()
- print ""
- print "Hello from pl3drun.run (end)!"
+
+ self.trace.log("Hello from pl3drun.run (end)!")
+
return
def __init__(self):
Component.__init__(self, "pl3drun", "solver")
- print ""
- print "Hello from pl3drun.__init__!"
+ import journal
+ self.trace = journal.debug("pylith3d.trace")
+
+ self.trace.log("Hello from pl3drun.__init__!")
return
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-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_scan.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -43,8 +43,11 @@
from pyre.units.length import m
from pyre.units.time import s
- print ""
- print "Hello from pl3dscan.__init__ (begin)!"
+ import journal
+ self.trace = journal.debug("pylith3d.trace")
+
+ self.trace.log("Hello from pl3dscan.__init__ (begin)!")
+
print "Setting default keyword values:"
# default values for extra input (category 2)
@@ -89,8 +92,7 @@
self.f77PlotOutput = 12
self.f77UcdOutput = 13
- print ""
- print "Hello from pl3dscan.__init__ (end)!"
+ self.trace.log("Hello from pl3dscan.__init__ (end)!")
return
@@ -108,8 +110,8 @@
matinfo = Materials()
keyparse = KeywordValueParse()
- print ""
- print "Hello from pl3dscan.preinitialize (begin)!"
+ self.trace.log("Hello from pl3dscan.preinitialize (begin)!")
+
print "Scanning ascii files to determine dimensions:"
# Initialization of all parameters
@@ -250,12 +252,10 @@
if not line: break
keyvals = keyparse.parseline(line)
if keyvals[3]:
- if type(keyvals[2]) == str:
- exec 'self.' + keyvals[0] + '=' + "keyvals[2]"
- elif type(keyvals[2]) == pyre.units.unit.unit:
- exec 'self.' + keyvals[0] + '=' + 'uparser.parse(str(keyvals[2]))'
- else:
- exec 'self.' + keyvals[0] + '=' + str(keyvals[2])
+ if hasattr(self, keyvals[0]):
+ setattr(self, keyvals[0], keyvals[2])
+ else:
+ self._error.log("invalid keyword: %s" % keyvals[0])
stream.close()
# Define information needed from other functions:
@@ -545,8 +545,7 @@
self._numberSlipperyWinklerEntries = self._slipperyWinklerInfo[0]
self._numberSlipperyWinklerForces = self._slipperyWinklerInfo[1]
- print ""
- print "Hello from pl3dscan.preinitialize (end)!"
+ self.trace.log("Hello from pl3dscan.preinitialize (end)!")
return
Modified: short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_setup.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_setup.py 2007-01-09 01:19:44 UTC (rev 5697)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/pylith3d/Pylith3d_setup.py 2007-01-09 03:02:51 UTC (rev 5698)
@@ -50,8 +50,8 @@
pl3dscan = scanner
pl3dscan.preinitialize()
- print ""
- print "Hello from pl3dsetup.initialize (begin)!"
+ self.trace.log("Hello from pl3dsetup.initialize (begin)!")
+
print "Importing values from scanning phase:"
# Parameters needed from Pylith3d_scan.py.
@@ -262,8 +262,7 @@
self.numberSlipperyWinklerEntries = pl3dscan._numberSlipperyWinklerEntries
self.numberSlipperyWinklerForces = pl3dscan._numberSlipperyWinklerForces
- print ""
- print "Hello from pl3dsetup.initialize (end)!"
+ self.trace.log("Hello from pl3dsetup.initialize (end)!")
return
@@ -274,8 +273,8 @@
from ElementTypeDef import ElementTypeDef
import pylith3d
- print ""
- print "Hello from pl3dsetup.read (begin)!"
+ self.trace.log("Hello from pl3dsetup.read (begin)!")
+
print "Reading problem definition and allocating necessary storage:"
@@ -731,8 +730,7 @@
self.f77FileInput,
self.slipperyWinklerInputFile)
- print ""
- print "Hello from pl3dsetup.read (end)!"
+ self.trace.log("Hello from pl3dsetup.read (end)!")
return
@@ -742,8 +740,8 @@
import pylith3d
- print ""
- print "Hello from pl3dsetup.numberequations (begin)!"
+ self.trace.log("Hello from pl3dsetup.numberequations (begin)!")
+
print "Numbering global equations:"
# Initialize variables that are defined in this function.
@@ -887,8 +885,7 @@
self.numberSlipperyWinklerForces,
self.numberSlipperyWinklerEntries)
- print ""
- print "Hello from pl3dsetup.numberequations (end)!"
+ self.trace.log("Hello from pl3dsetup.numberequations (end)!")
return
@@ -900,8 +897,8 @@
import pylith3d
- print ""
- print "Hello from pl3dsetup.sortmesh (begin)!"
+ self.trace.log("Hello from pl3dsetup.sortmesh (begin)!")
+
print "Renumbering elements, split nodes, and slippery nodes:"
# Initialize variables that are defined in this function.
@@ -986,8 +983,7 @@
self.numberSlipperyNodeEntries,
self.numberVolumeElements)
- print ""
- print "Hello from pl3dsetup.sortmesh (end)!"
+ self.trace.log("Hello from pl3dsetup.sortmesh (end)!")
return
@@ -998,8 +994,8 @@
import pylith3d
- print ""
- print "Hello from pl3dsetup.sparsesetup (begin)!"
+ self.trace.log("Hello from pl3dsetup.sparsesetup (begin)!")
+
print "Setting up sparse matrix storage:"
self.autoprestrStage, \
@@ -1146,7 +1142,8 @@
print "maximumNonzeroTermsPerRow: %i" % self.maximumNonzeroTermsPerRow
print "averageNonzeroTermsPerRow: %g" % self.averageNonzeroTermsPerRow
print ""
- print "Hello from pl3dsetup.sparsesetup (end)!"
+
+ self.trace.log("Hello from pl3dsetup.sparsesetup (end)!")
return
@@ -1156,8 +1153,8 @@
import pylith3d
- print ""
- print "Hello from pl3dsetup.allocateremaining (begin)!"
+ self.trace.log("Hello from pl3dsetup.allocateremaining (begin)!")
+
print "Allocating remaining storage:"
# Initialize variables that are defined in this function.
@@ -1490,8 +1487,7 @@
self.listNtimdat)
self.memorySize += 9*self.intSize
- print ""
- print "Hello from pl3dsetup.allocateremaining (end)!"
+ self.trace.log("Hello from pl3dsetup.allocateremaining (end)!")
return
@@ -1504,8 +1500,8 @@
import pylith3d
- print ""
- print "Hello from pl3dsetup.meshwriteascii (begin)!"
+ self.trace.log("Hello from pl3dsetup.meshwriteascii (begin)!")
+
print "Outputting Ascii mesh information:"
# Write out global parameters
@@ -1798,8 +1794,7 @@
self.f77AsciiOutput,
self.asciiOutputFile)
- print ""
- print "Hello from pl3dsetup.meshwrite (end)!"
+ self.trace.log("Hello from pl3dsetup.meshwrite (end)!")
return
@@ -1807,9 +1802,11 @@
def __init__(self):
Component.__init__(self, "pl3dsetup", "setup")
- print ""
- print "Hello from pl3dsetup.__init__!"
+ import journal
+ self.trace = journal.debug("pylith3d.trace")
+ self.trace.log("Hello from pl3dsetup.__init__!")
+
return
More information about the cig-commits
mailing list