[cig-commits] r9248 - in short/3D/PyLith/trunk: pylith/bc pylith/feassemble pylith/problems tests/2d/bar_quad4
brad at geodynamics.org
brad at geodynamics.org
Tue Feb 5 15:39:17 PST 2008
Author: brad
Date: 2008-02-05 15:39:17 -0800 (Tue, 05 Feb 2008)
New Revision: 9248
Modified:
short/3D/PyLith/trunk/pylith/bc/AbsorbingDampers.py
short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py
short/3D/PyLith/trunk/pylith/bc/Neumann.py
short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.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
short/3D/PyLith/trunk/pylith/problems/Problem.py
short/3D/PyLith/trunk/pylith/problems/TimeDependent.py
short/3D/PyLith/trunk/tests/2d/bar_quad4/dislocation_dyn.cfg
Log:
Cleaned up verifying configuration across materials, integrators, and constraints. Should be called via integrator/constraint, not bc/materials/interfaces. Other minor cleanup to Python code in Formulation, Implicit, Explicit, and Problem.
Modified: short/3D/PyLith/trunk/pylith/bc/AbsorbingDampers.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/AbsorbingDampers.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/bc/AbsorbingDampers.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -74,25 +74,12 @@
return
- def initialize(self, totalTime, numTimeSteps):
- """
- Initialize AbsorbingDampers boundary condition.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.cppHandle.quadrature = self.quadrature.cppHandle
- BoundaryCondition.initialize(self, totalTime, numTimeSteps)
-
- self._logger.eventEnd(logEvent)
- return
-
-
def verifyConfiguration(self):
"""
Verify compatibility of configuration.
"""
BoundaryCondition.verifyConfiguration(self)
+ Integrator.verifyConfiguration(self)
if self.quadrature.cellDim != self.mesh.dimension()-1:
raise ValueError, \
"Quadrature scheme and mesh are incompatible.\n" \
@@ -103,6 +90,20 @@
return
+ def initialize(self, totalTime, numTimeSteps):
+ """
+ Initialize AbsorbingDampers boundary condition.
+ """
+ logEvent = "%sinit" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ self.cppHandle.quadrature = self.quadrature.cppHandle
+ BoundaryCondition.initialize(self, totalTime, numTimeSteps)
+
+ self._logger.eventEnd(logEvent)
+ return
+
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
Modified: short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -107,6 +107,15 @@
return
+ def verifyConfiguration(self):
+ """
+ Verify compatibility of configuration.
+ """
+ BoundaryCondition.verifyConfiguration(self)
+ Constraint.verifyConfiguration(self)
+ return
+
+
def initialize(self, totalTime, numTimeSteps):
"""
Initialize DirichletPoints boundary condition.
Modified: short/3D/PyLith/trunk/pylith/bc/Neumann.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/Neumann.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/bc/Neumann.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -72,25 +72,12 @@
return
- def initialize(self, totalTime, numTimeSteps):
- """
- Initialize Neumann boundary condition.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.cppHandle.quadrature = self.quadrature.cppHandle
- BoundaryCondition.initialize(self, totalTime, numTimeSteps)
-
- self._logger.eventEnd(logEvent)
- return
-
-
def verifyConfiguration(self):
"""
Verify compatibility of configuration.
"""
BoundaryCondition.verifyConfiguration(self)
+ Integrator.verifyConfiguration(self)
if self.quadrature.cellDim != self.mesh.dimension()-1:
raise ValueError, \
"Quadrature scheme and mesh are incompatible.\n" \
@@ -101,6 +88,20 @@
return
+ def initialize(self, totalTime, numTimeSteps):
+ """
+ Initialize Neumann boundary condition.
+ """
+ logEvent = "%sinit" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ self.cppHandle.quadrature = self.quadrature.cppHandle
+ BoundaryCondition.initialize(self, totalTime, numTimeSteps)
+
+ self._logger.eventEnd(logEvent)
+ return
+
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
Modified: short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -57,6 +57,15 @@
return
+ def verifyConfiguration(self):
+ """
+ Verify compatibility of configuration.
+ """
+ Integrator.verifyConfiguration(self)
+ self.material.verifyConfiguration()
+ return
+
+
def initialize(self, totalTime, numTimeSteps):
"""
Initialize material properties.
Modified: short/3D/PyLith/trunk/pylith/problems/Explicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Explicit.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/problems/Explicit.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -126,21 +126,15 @@
"""
logEvent = "%sstep" % self._loggingPrefix
self._logger.eventBegin(logEvent)
-
- self._info.log("Integrating constant term in operator.")
- residual = self.fields.getReal("residual")
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(residual)
- for integrator in self.integrators:
- integrator.timeStep(dt)
- integrator.integrateResidual(residual, t, self.fields)
- self._info.log("Completing residual.")
- bindings.completeSection(self.mesh.cppHandle, residual)
+ self._reformResidual(t, dt)
+
self._info.log("Solving equations.")
+ residual = self.fields.getReal("residual")
self.solver.solve(self.fields.getReal("dispTpdt"), self.jacobian, residual)
# BEGIN TEMPORARY
+ #import pylith.topology.topology as bindings
#bindings.sectionView(residual, "RHS");
#bindings.sectionView(self.fields.getReal("dispTpdt"), "SOLUTION");
#import pylith.utils.petsc as petscbindings
Modified: short/3D/PyLith/trunk/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Formulation.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/problems/Formulation.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -94,69 +94,14 @@
logEvent = "%spreinit" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- from pylith.feassemble.Integrator import implementsIntegrator
- from pylith.feassemble.Constraint import implementsConstraint
-
self.mesh = mesh
self.integrators = []
self.constraints = []
- self._info.log("Pre-initializing materials.")
- self._debug.log(resourceUsageString())
- for material in materials.bin:
- integrator = self.elasticityIntegrator()
- if not implementsIntegrator(integrator):
- raise TypeError, \
- "Could not use '%s' as an integrator for material '%s'. " \
- "Functionality missing." % (integrator.name, material.label)
- integrator.preinitialize(mesh, material)
- self.integrators.append(integrator)
- self._debug.log(resourceUsageString())
-
- self._info.log("Added elasticity integrator for material '%s'." % \
- material.label)
-
- self._info.log("Pre-initializing boundary conditions.")
- self._debug.log(resourceUsageString())
- for bc in boundaryConditions.bin:
- bc.preinitialize(mesh)
- foundType = False
- if implementsIntegrator(bc):
- foundType = True
- self.integrators.append(bc)
- self._info.log("Added boundary condition '%s' as an integrator." % \
- bc.label)
- if implementsConstraint(bc):
- foundType = True
- self.constraints.append(bc)
- self._info.log("Added boundary condition '%s' as a constraint." % \
- bc.label)
- if not foundType:
- raise TypeError, \
- "Could not determine whether boundary condition '%s' is an " \
- "integrator or a constraint." % bc.name
- self._debug.log(resourceUsageString())
-
- self._info.log("Pre-initializing interior interfaces.")
- for ic in interfaceConditions.bin:
- ic.preinitialize(mesh)
- foundType = False
- if implementsIntegrator(ic):
- foundType = True
- self.integrators.append(ic)
- self._info.log("Added interface condition '%s' as an integrator." % \
- ic.label)
- if implementsConstraint(ic):
- foundType = True
- self.constraints.append(ic)
- self._info.log("Added interface condition '%s' as a constraint." % \
- ic.label)
- if not foundType:
- raise TypeError, \
- "Could not determine whether interface condition '%s' is an " \
- "integrator or a constraint." % ic.name
- self._debug.log(resourceUsageString())
-
+ self._setupMaterials(materials)
+ self._setupBC(boundaryConditions)
+ self._setupInterfaces(interfaceConditions)
+
self._info.log("Pre-initializing output.")
for output in self.output.bin:
output.preinitialize(self)
@@ -194,9 +139,9 @@
from pylith.topology.FieldsManager import FieldsManager
self.fields = FieldsManager(self.mesh)
+ self._debug.log(resourceUsageString())
self._info.log("Initializing integrators.")
- self._debug.log(resourceUsageString())
for integrator in self.integrators:
integrator.initialize(totalTime, numTimeSteps)
self._debug.log(resourceUsageString())
@@ -320,16 +265,6 @@
return (field, fieldType)
- def getCellField(self):
- """
- Get cell field.
- """
- field = None
- fieldType = None
- raise ValueError, "Cell field '%s' not available." % name
- return (field, fieldType)
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -345,6 +280,88 @@
return
+ def _setupMaterials(self, materials):
+ """
+ Setup materials as integrators.
+ """
+ from pylith.feassemble.Integrator import implementsIntegrator
+
+ self._info.log("Pre-initializing materials.")
+ self._debug.log(resourceUsageString())
+ for material in materials.bin:
+ integrator = self.elasticityIntegrator()
+ if not implementsIntegrator(integrator):
+ raise TypeError, \
+ "Could not use '%s' as an integrator for material '%s'. " \
+ "Functionality missing." % (integrator.name, material.label)
+ integrator.preinitialize(self.mesh, material)
+ self.integrators.append(integrator)
+ self._debug.log(resourceUsageString())
+
+ self._info.log("Added elasticity integrator for material '%s'." % \
+ material.label)
+ return
+
+
+ def _setupBC(self, boundaryConditions):
+ """
+ Setup boundary conditions as integrators or constraints.
+ """
+ from pylith.feassemble.Integrator import implementsIntegrator
+ from pylith.feassemble.Constraint import implementsConstraint
+
+ self._info.log("Pre-initializing boundary conditions.")
+ self._debug.log(resourceUsageString())
+ for bc in boundaryConditions.bin:
+ bc.preinitialize(self.mesh)
+ foundType = False
+ if implementsIntegrator(bc):
+ foundType = True
+ self.integrators.append(bc)
+ self._info.log("Added boundary condition '%s' as an integrator." % \
+ bc.label)
+ if implementsConstraint(bc):
+ foundType = True
+ self.constraints.append(bc)
+ self._info.log("Added boundary condition '%s' as a constraint." % \
+ bc.label)
+ if not foundType:
+ raise TypeError, \
+ "Could not determine whether boundary condition '%s' is an " \
+ "integrator or a constraint." % bc.name
+ self._debug.log(resourceUsageString())
+ return
+
+
+ def _setupInterfaces(self, interfaceConditions):
+ """
+ Setup interfaces as integrators or constraints.
+ """
+ from pylith.feassemble.Integrator import implementsIntegrator
+ from pylith.feassemble.Constraint import implementsConstraint
+
+ self._info.log("Pre-initializing interior interfaces.")
+ for ic in interfaceConditions.bin:
+ ic.preinitialize(self.mesh)
+ foundType = False
+ if implementsIntegrator(ic):
+ foundType = True
+ self.integrators.append(ic)
+ self._info.log("Added interface condition '%s' as an integrator." % \
+ ic.label)
+ if implementsConstraint(ic):
+ foundType = True
+ self.constraints.append(ic)
+ self._info.log("Added interface condition '%s' as a constraint." % \
+ ic.label)
+ if not foundType:
+ raise TypeError, \
+ "Could not determine whether interface condition '%s' is an " \
+ "integrator or a constraint." % ic.name
+ self._debug.log(resourceUsageString())
+ return
+
+
def _reformJacobian(self, t, dt):
"""
Reform Jacobian matrix for operator.
@@ -361,6 +378,23 @@
return
+ def _reformResidual(self, t, dt):
+ """
+ Reform residual vector for operator.
+ """
+ self._info.log("Integrating residual term in operator.")
+ residual = self.fields.getReal("residual")
+ import pylith.topology.topology as bindings
+ bindings.zeroRealSection(residual)
+ for integrator in self.integrators:
+ integrator.timeStep(dt)
+ integrator.integrateResidual(residual, t, self.fields)
+
+ self._info.log("Completing residual.")
+ bindings.completeSection(self.mesh.cppHandle, residual)
+ return
+
+
def _setupLogging(self):
"""
Setup event logging.
Modified: short/3D/PyLith/trunk/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Implicit.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/problems/Implicit.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -158,21 +158,14 @@
logEvent = "%sstep" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- self._info.log("Integrating residual term in operator.")
- residual = self.fields.getReal("residual")
dispIncr = self.fields.getReal("dispIncr")
import pylith.topology.topology as bindings
- bindings.zeroRealSection(residual)
bindings.zeroRealSection(dispIncr)
- for integrator in self.integrators:
- integrator.timeStep(dt)
- integrator.integrateResidual(residual, t+dt, self.fields)
- self._info.log("Completing residual.")
- bindings.completeSection(self.mesh.cppHandle, residual)
+ self._reformResidual(t, dt)
- import pylith.utils.petsc as petsc
self._info.log("Solving equations.")
+ residual = self.fields.getReal("residual")
self.solver.solve(dispIncr, self.jacobian, residual)
self._logger.eventEnd(logEvent)
Modified: short/3D/PyLith/trunk/pylith/problems/Problem.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Problem.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/problems/Problem.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -37,7 +37,7 @@
## Python object for managing Problem facilities and properties.
##
## \b Properties
- ## @li None
+ ## @li \b dimension Spatial dimension of problem space.
##
## \b Facilities
## @li \b materials Materials in problem.
@@ -48,6 +48,10 @@
import pyre.inventory
from pylith.utils.ObjectBin import ObjectBin
+ dimension = pyre.inventory.int("dimension", default=3,
+ validator=pyre.inventory.choice([1,2,3]))
+ dimension.meta['tip'] = "Spatial dimension of problem space."
+
from pylith.materials.Homogeneous import Homogeneous
materials = pyre.inventory.facility("materials", family="object_bin",
factory=Homogeneous)
@@ -86,16 +90,21 @@
"""
Verify compatibility of configuration.
"""
- logEvent = "%sverify" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
+ self._info.log("Verifying compatibility of problem configuration.")
+ if self.dimension != self.mesh.dimension():
+ raise ValueError, \
+ "Spatial dimension of problem is '%d' but mesh contains cells " \
+ "for spatial dimension '%d'." % \
+ (self.dimension, mesh.dimension)
+
for material in self.materials.bin:
- material.verifyConfiguration()
- for bc in self.bc.bin:
- bc.verifyConfiguration()
- for interface in self.interfaces.bin:
- interface.verifyConfiguration()
- self._logger.eventEnd(logEvent)
+ if material.quadrature.spaceDim != self.dimension:
+ raise ValueError, \
+ "Spatial dimension of problem is '%d' but quadrature " \
+ "for material '%s' is for spatial dimension '%d'." % \
+ (self.dimension, material.label, material.quadrature.spaceDim)
+
return
@@ -139,6 +148,7 @@
Set members based using inventory.
"""
Component._configure(self)
+ self.dimension = self.inventory.dimension
self.materials = self.inventory.materials
self.bc = self.inventory.bc
self.interfaces = self.inventory.interfaces
Modified: short/3D/PyLith/trunk/pylith/problems/TimeDependent.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeDependent.py 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/pylith/problems/TimeDependent.py 2008-02-05 23:39:17 UTC (rev 9248)
@@ -40,7 +40,6 @@
## \b Properties
## @li \b total_time Time duration for simulation.
## @li \b default_dt Default time step.
- ## @li \b dimension Spatial dimension of problem space.
##
## \b Facilities
## @li \b formulation Formulation for solving PDE.
@@ -57,10 +56,6 @@
validator=pyre.inventory.greater(0.0*second))
dt.meta['tip'] = "Default time step for simulation."
- dimension = pyre.inventory.int("dimension", default=3,
- validator=pyre.inventory.choice([1,2,3]))
- dimension.meta['tip'] = "Spatial dimension of problem space."
-
from Implicit import Implicit
formulation = pyre.inventory.facility("formulation",
family="pde_formulation",
@@ -110,18 +105,6 @@
logEvent = "%sverify" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- self._info.log("Verifying compatibility of problem configuration.")
- if self.dimension != self.mesh.dimension():
- raise ValueError, \
- "Spatial dimension of problem is '%d' but mesh contains cells " \
- "for spatial dimension '%d'." % \
- (self.dimension, mesh.dimension)
- for material in self.materials.bin:
- if material.quadrature.spaceDim != self.dimension:
- raise ValueError, \
- "Spatial dimension of problem is '%d' but quadrature " \
- "for material '%s' is for spatial dimension '%d'." % \
- (self.dimension, material.label, material.quadrature.spaceDim)
Problem.verifyConfiguration(self)
self.formulation.verifyConfiguration()
@@ -222,7 +205,6 @@
Problem._configure(self)
self.totalTime = self.inventory.totalTime
self.dt = self.inventory.dt
- self.dimension = self.inventory.dimension
self.formulation = self.inventory.formulation
self.checkpointTimer = self.inventory.checkpointTimer
return
Modified: short/3D/PyLith/trunk/tests/2d/bar_quad4/dislocation_dyn.cfg
===================================================================
--- short/3D/PyLith/trunk/tests/2d/bar_quad4/dislocation_dyn.cfg 2008-02-05 23:36:58 UTC (rev 9247)
+++ short/3D/PyLith/trunk/tests/2d/bar_quad4/dislocation_dyn.cfg 2008-02-05 23:39:17 UTC (rev 9248)
@@ -72,7 +72,6 @@
id = 11
label = sides
db.label = Dirichlet BC
-db.iohandler.filename = dislocation_disp.spatialdb
# ----------------------------------------------------------------------
# faults
@@ -117,7 +116,7 @@
# output
# ----------------------------------------------------------------------
[pylithapp.problem.formulation.output.output.writer]
-filename = output/dislocation_dyn.vtk
+filename = output/dislocation-dyn.vtk
time_format = %05.3f
# Give basename for vtk fault output.
More information about the cig-commits
mailing list