[cig-commits] r14319 - in short/3D/PyLith/branches/pylith-swig: . libsrc/feassemble libsrc/materials pylith/feassemble unittests/pytests/feassemble unittests/pytests/materials
brad at geodynamics.org
brad at geodynamics.org
Sat Mar 14 15:14:44 PDT 2009
Author: brad
Date: 2009-03-14 15:14:43 -0700 (Sat, 14 Mar 2009)
New Revision: 14319
Modified:
short/3D/PyLith/branches/pylith-swig/TODO
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/IntegratorElasticity.cc
short/3D/PyLith/branches/pylith-swig/libsrc/materials/Material.cc
short/3D/PyLith/branches/pylith-swig/pylith/feassemble/ElasticityImplicit.py
short/3D/PyLith/branches/pylith-swig/pylith/feassemble/IntegratorElasticity.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/feassemble/TestElasticityImplicit.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestMaterial.py
Log:
Worked on Python elasticity integrator tests (not finished).
Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO 2009-03-14 04:26:25 UTC (rev 14318)
+++ short/3D/PyLith/branches/pylith-swig/TODO 2009-03-14 22:14:43 UTC (rev 14319)
@@ -23,6 +23,8 @@
DirichletPoints (Python) - rate == None -> dbRate == 0
DirichletBoundary (Python) - rate == None -> dbRate == 0
+ Maxwell materials
+
1. Reduce memory use (new labels) [Matt]
2. Nondimensionalize [Brad]
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/IntegratorElasticity.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/IntegratorElasticity.cc 2009-03-14 04:26:25 UTC (rev 14318)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/IntegratorElasticity.cc 2009-03-14 22:14:43 UTC (rev 14319)
@@ -98,9 +98,13 @@
const ALE::Obj<SieveMesh::label_sequence>& cells =
sieveMesh->getLabelStratum("material-id", materialId);
+ std::cout << "Before compute geometry." << std::endl;
+
// Compute geometry for quadrature operations.
_quadrature->computeGeometry(mesh, cells);
+ std::cout << "Before material initialize" << std::endl;
+
// Initialize material.
_material->initialize(mesh, _quadrature);
@@ -108,8 +112,10 @@
_initCellVector();
_initCellMatrix();
+ std::cout << "Before setting up logger" << std::endl;
+
// Setup event logger.
- _logger = new utils::EventLogger;
+ delete _logger; _logger = new utils::EventLogger;
assert(0 != _logger);
_logger->className("ElasticityIntegrator");
_logger->initialize();
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/materials/Material.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/materials/Material.cc 2009-03-14 04:26:25 UTC (rev 14318)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/materials/Material.cc 2009-03-14 22:14:43 UTC (rev 14319)
@@ -103,6 +103,10 @@
const int numQuadPts = quadrature->numQuadPts();
const int spaceDim = quadrature->spaceDim();
+ std::cout << "numQuadPts: " << numQuadPts
+ << ", spaceDim: " << spaceDim
+ << std::endl;
+
// Get cells associated with material
const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
assert(!sieveMesh.isNull());
@@ -111,7 +115,10 @@
assert(!cells.isNull());
const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
const spatialdata::geocoords::CoordSys* cs = mesh.coordsys();
+ assert(0 != cs);
+ std::cout << "Creating fields" << std::endl;
+
// Create field to hold physical properties.
delete _properties; _properties = new topology::Field<topology::Mesh>(mesh);
assert(0 != _properties);
@@ -122,13 +129,18 @@
const ALE::Obj<RealSection>& propertiesSection = _properties->section();
assert(!propertiesSection.isNull());
+ std::cout << "Creating arrays" << std::endl;
+
// Create arrays for querying.
const int numDBProperties = _metadata.numDBProperties();
double_array quadPtsGlobal(numQuadPts*spaceDim);
double_array propertiesQuery(numDBProperties);
double_array propertiesCell(numQuadPts*numDBProperties);
+ std::cout << "Setting up dbProperties" << std::endl;
+
// Setup database for quering for physical properties
+ assert(0 != _dbProperties);
_dbProperties->open();
_dbProperties->queryVals(_metadata.dbProperties(),
_metadata.numDBProperties());
Modified: short/3D/PyLith/branches/pylith-swig/pylith/feassemble/ElasticityImplicit.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/feassemble/ElasticityImplicit.py 2009-03-14 04:26:25 UTC (rev 14318)
+++ short/3D/PyLith/branches/pylith-swig/pylith/feassemble/ElasticityImplicit.py 2009-03-14 22:14:43 UTC (rev 14319)
@@ -39,6 +39,23 @@
return
+ def initialize(self, totalTime, numTimeSteps, normalizer):
+ """
+ Do initialization.
+ """
+ logEvent = "%sinit" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ print "AAA"
+ IntegratorElasticity.initialize(self, totalTime, numTimeSteps, normalizer)
+ print "BBB"
+ ModuleElasticityImplicit.initialize(self, self.mesh)
+ print "CCC"
+
+ self._logger.eventEnd(logEvent)
+ return
+
+
# FACTORIES ////////////////////////////////////////////////////////////
def integrator():
Modified: short/3D/PyLith/branches/pylith-swig/pylith/feassemble/IntegratorElasticity.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/feassemble/IntegratorElasticity.py 2009-03-14 04:26:25 UTC (rev 14318)
+++ short/3D/PyLith/branches/pylith-swig/pylith/feassemble/IntegratorElasticity.py 2009-03-14 22:14:43 UTC (rev 14319)
@@ -36,6 +36,10 @@
self.output = None
self.availableFields = None
self.name = "Integrator Elasticity"
+
+ # Setup journal (not a Component, so not setup already)
+ import journal
+ self._info = journal.info(name)
return
@@ -47,14 +51,14 @@
self.output = material.output
self.availableFields = material.availableFields
self.matQuadrature = material.quadrature
- self.material(material)
+ self.matLabel = material.matLabel
- ModuleElasticity
-
Integrator.preinitialize(self, mesh)
- material.preinitialize()
- self.output.preinitialize(self)
+ material.preinitialize(mesh)
+ #self.output.preinitialize(self)
+ self.quadrature(material.quadrature)
+ self.material(material)
return
@@ -66,7 +70,7 @@
self._logger.eventBegin(logEvent)
Integrator.verifyConfiguration(self)
- self.output.verifyConfiguration(self.mesh)
+ #self.output.verifyConfiguration(self.mesh)
self._logger.eventEnd(logEvent)
return
@@ -80,13 +84,15 @@
self._logger.eventBegin(logEvent)
self._info.log("Initializing integrator for material '%s'." % \
- self.material.label)
+ self.matLabel)
+ print "DDD"
Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
+ print "EEE"
- self.output.initialize(normalizer, self.matQuadrature)
- self.output.writeInfo()
- self.output.open(totalTime, numTimeSteps)
+ #self.output.initialize(normalizer, self.matQuadrature)
+ #self.output.writeInfo()
+ #self.output.open(totalTime, numTimeSteps)
self._logger.eventEnd(logEvent)
return
@@ -102,7 +108,7 @@
Integrator.poststep(self, t, dt, totalTime, fields)
self._info.log("Writing material data.")
- self.output.writeData(t+dt, fields)
+ #self.output.writeData(t+dt, fields)
self._logger.eventEnd(logEvent)
return
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/feassemble/TestElasticityImplicit.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/feassemble/TestElasticityImplicit.py 2009-03-14 04:26:25 UTC (rev 14318)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/feassemble/TestElasticityImplicit.py 2009-03-14 22:14:43 UTC (rev 14319)
@@ -38,11 +38,156 @@
def test_preinitialize(self):
"""
Test preiniitlaize().
+
+ WARNING: This is not a rigorous test of preinitialize() because we
+ neither set the input fields or verify the results.
"""
- self._preinitialize()
+ (mesh, integrator) = self._preinitialize()
+
+ # No test of result.
return
+ def test_verifyConfiguration(self):
+ """
+ Test verifyConfiguration().
+
+ WARNING: This is not a rigorous test of verifyConfiguration()
+ because we neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ integrator.verifyConfiguration()
+
+ # No test of result.
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+
+ WARNING: This is not a rigorous test of initialize() because we
+ neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ # No test of result.
+ return
+
+
+ def test_timeStep(self):
+ """
+ Test timeStep().
+
+ WARNING: This is not a rigorous test of timeStep() because we
+ neither set the input fields or verify the results.
+ """
+ dt = 2.3
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+ integrator.timeStep(dt)
+
+ # No test of result.
+ return
+
+
+ def test_stableTimeStep(self):
+ """
+ Test stableTimeStep().
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ self.assertEqual(1.0e+30, integrator.stableTimeStep())
+ return
+
+
+ def test_needNewJacobian(self):
+ """
+ Test needNewJacobian().
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ self.assertEqual(True, integrator.needNewJacobian())
+ return
+
+
+ def test_useSolnIncr(self):
+ """
+ Test useSolnIncr().
+
+ WARNING: This is not a rigorous test of useSolnIncr() because we
+ neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ integrator.useSolnIncr(True)
+
+ # No test of result.
+ return
+
+
+ def test_integrateResidual(self):
+ """
+ Test integrateResidual().
+
+ WARNING: This is not a rigorous test of integrateResidual()
+ because we neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ residual = fields.get("residual")
+ t = 3.4
+ integrator.integrateResidual(residual, t, fields)
+
+ # No test of result.
+ return
+
+
+ def test_integrateJacobian(self):
+ """
+ Test integrateJacobian().
+
+ WARNING: This is not a rigorous test of integrateJacobian()
+ because we neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ from pylith.topology.Jacobian import Jacobian
+ jacobian = Jacobian(fields)
+ jacobian.zero()
+ t = 7.3
+ integrator.integrateJacobian(jacobian, t, fields)
+ self.assertEqual(False, integrator.needNewJacobian())
+
+ # No test of result.
+ return
+
+
+ def test_poststep(self):
+ """
+ Test poststep().
+
+ WARNING: This is not a rigorous test of poststep() because we
+ neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ t = 7.3
+ dt = 0.1
+ totalTime = 23.0
+ integrator.poststep(t, dt, totalTime, fields)
+
+ # No test of result
+ return
+
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _preinitialize(self):
@@ -90,7 +235,7 @@
material = ElasticPlaneStrain()
material.inventory.label = "elastic plane strain"
material.inventory.id = 0
- material.inventory.db = db
+ material.inventory.dbProperties = db
material.inventory.quadrature = quadrature
material._configure()
@@ -111,9 +256,16 @@
"""
dt = 2.3
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
from pyre.units.time import s
+ print "AA"
integrator.initialize(totalTime=0.0*s, numTimeSteps=1, normalizer=normalizer)
+ print "BB"
integrator.timeStep(dt)
+ print "CC"
# Setup fields
from pylith.topology.SolutionFields import SolutionFields
@@ -128,7 +280,7 @@
fields.copyLayout("residual")
residual.zero()
- return
+ return fields
# End of file
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestMaterial.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestMaterial.py 2009-03-14 04:26:25 UTC (rev 14318)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestMaterial.py 2009-03-14 22:14:43 UTC (rev 14319)
@@ -150,7 +150,7 @@
from pylith.materials.ElasticStrain1D import ElasticStrain1D
material = ElasticStrain1D()
material.inventory.quadrature = quadrature
- material.inventory.db = db
+ material.inventory.dbProperties = db
material.inventory.label = "my material"
material.inventory.id = 54
material._configure()
More information about the CIG-COMMITS
mailing list