[cig-commits] r15216 - in short/3D/PyLith/trunk: libsrc/materials modulesrc/materials pylith/materials unittests/pytests/materials

brad at geodynamics.org brad at geodynamics.org
Fri Jun 12 13:04:18 PDT 2009


Author: brad
Date: 2009-06-12 13:04:17 -0700 (Fri, 12 Jun 2009)
New Revision: 15216

Added:
   short/3D/PyLith/trunk/unittests/pytests/materials/TestPowerLaw3D.py
Modified:
   short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
   short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.hh
   short/3D/PyLith/trunk/modulesrc/materials/Makefile.am
   short/3D/PyLith/trunk/modulesrc/materials/materials.i
   short/3D/PyLith/trunk/pylith/materials/__init__.py
   short/3D/PyLith/trunk/unittests/pytests/materials/TestMaxwellIsotropic3D.py
   short/3D/PyLith/trunk/unittests/pytests/materials/testmaterials.py
Log:
Added SWIG and Python code for power-law.

Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc	2009-06-12 19:47:02 UTC (rev 15215)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc	2009-06-12 20:04:17 UTC (rev 15216)
@@ -62,12 +62,12 @@
       
       /// State variables.
       const Metadata::ParamDescription stateVars[] = {
-	{ "total_strain", 6, pylith::topology::FieldBase::TENSOR },
-	{ "viscous_strain", 6, pylith::topology::FieldBase::TENSOR },
+	{ "total_strain", tensorSize, pylith::topology::FieldBase::TENSOR },
+	{ "viscous_strain", tensorSize, pylith::topology::FieldBase::TENSOR },
       };
 
       // Values expected in state variables spatial database
-      const int numDBStateVars = 12;
+      const int numDBStateVars = 2*tensorSize;
       const char* dbStateVars[] = {"total-strain-xx",
 				   "total-strain-yy",
 				   "total-strain-zz",

Modified: short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.hh	2009-06-12 19:47:02 UTC (rev 15215)
+++ short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.hh	2009-06-12 20:04:17 UTC (rev 15216)
@@ -26,9 +26,10 @@
 #if !defined(pylith_materials_powerlaw3d_hh)
 #define pylith_materials_powerlaw3d_hh
 
+// Include directives ---------------------------------------------------
 #include "ElasticMaterial.hh" // ISA ElasticMaterial
 
-/// 3-D, isotropic, linear Maxwell viscoelastic material.
+// Powerlaw3D -----------------------------------------------------------
 class pylith::materials::PowerLaw3D : public ElasticMaterial
 { // class PowerLaw3D
   friend class TestPowerLaw3D; // unit testing

Modified: short/3D/PyLith/trunk/modulesrc/materials/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/Makefile.am	2009-06-12 19:47:02 UTC (rev 15215)
+++ short/3D/PyLith/trunk/modulesrc/materials/Makefile.am	2009-06-12 20:04:17 UTC (rev 15216)
@@ -26,7 +26,8 @@
 	ElasticPlaneStrain.i \
 	ElasticPlaneStress.i \
 	ElasticIsotropic3D.i \
-	MaxwellIsotropic3D.i
+	MaxwellIsotropic3D.i \
+	PowerLaw3D.i
 
 swig_generated = \
 	materials_wrap.cxx \

Modified: short/3D/PyLith/trunk/modulesrc/materials/materials.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/materials.i	2009-06-12 19:47:02 UTC (rev 15215)
+++ short/3D/PyLith/trunk/modulesrc/materials/materials.i	2009-06-12 20:04:17 UTC (rev 15216)
@@ -28,6 +28,7 @@
 #include "pylith/materials/ElasticIsotropic3D.hh"
 #include "pylith/materials/MaxwellIsotropic3D.hh"
 //#include "pylith/materials/GenMaxwellIsotropic3D.hh"
+#include "pylith/materials/PowerLaw3D.hh"
 
 #include "pylith/utils/arrayfwd.hh"
 %}
@@ -63,6 +64,7 @@
 %include "ElasticIsotropic3D.i"
 %include "MaxwellIsotropic3D.i"
 //%include "GenMaxwellIsotropic3D.i"
+%include "PowerLaw3D.i"
 
 
 // End of file

Modified: short/3D/PyLith/trunk/pylith/materials/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/__init__.py	2009-06-12 19:47:02 UTC (rev 15215)
+++ short/3D/PyLith/trunk/pylith/materials/__init__.py	2009-06-12 20:04:17 UTC (rev 15216)
@@ -24,6 +24,7 @@
            'Homogeneous',
            'Material',
            'MaxwellIsotropic3D',
+           'PowerLaw3D',
            ]
 
 

Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestMaxwellIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestMaxwellIsotropic3D.py	2009-06-12 19:47:02 UTC (rev 15215)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestMaxwellIsotropic3D.py	2009-06-12 20:04:17 UTC (rev 15216)
@@ -65,7 +65,7 @@
     # Default should be False.
     self.failIf(self.material.needNewJacobian())
 
-    # Changing time step should not require new Jacobian.
+    # Changing time step should require new Jacobian.
     self.material.timeStep(1.0)
     self.material.timeStep(2.0)
     self.failUnless(self.material.needNewJacobian())

Added: short/3D/PyLith/trunk/unittests/pytests/materials/TestPowerLaw3D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestPowerLaw3D.py	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestPowerLaw3D.py	2009-06-12 20:04:17 UTC (rev 15216)
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/materials/TestPowerLaw3D.py
+
+## @brief Unit testing of PowerLaw3D object.
+
+import unittest
+
+from pylith.materials.PowerLaw3D import PowerLaw3D
+
+# ----------------------------------------------------------------------
+class TestPowerLaw3D(unittest.TestCase):
+  """
+  Unit testing of PowerLaw3D object.
+  """
+
+  def setUp(self):
+    """
+    Setup test subject.
+    """
+    self.material = PowerLaw3D()
+    return
+  
+
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    self.assertEqual(3, self.material.dimension())
+    return
+
+
+  def test_useElasticBehavior(self):
+    """
+    Test useElasticBehavior().
+    """
+    self.material.useElasticBehavior(False)
+    return
+
+
+  def testHasStateVars(self):
+    self.failUnless(self.material.hasStateVars())
+    return
+
+
+  def testTensorSize(self):
+    self.assertEqual(6, self.material.tensorSize())
+    return
+
+
+  def testNeedNewJacobian(self):
+    """
+    Test needNewJacobian().
+    """
+    # Default should be False.
+    self.failIf(self.material.needNewJacobian())
+
+    # Should require a new Jacobian even if time step is the same.
+    self.material.timeStep(1.0)
+    self.failUnless(self.material.needNewJacobian())
+    self.material.timeStep(2.0)
+    self.failUnless(self.material.needNewJacobian())
+
+    self.material.timeStep(2.0)
+    self.failUnless(self.material.needNewJacobian())
+    return
+  
+
+  def test_factory(self):
+    """
+    Test factory method.
+    """
+    from pylith.materials.PowerLaw3D import material
+    m = material()
+    return
+
+
+# End of file 

Modified: short/3D/PyLith/trunk/unittests/pytests/materials/testmaterials.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/testmaterials.py	2009-06-12 19:47:02 UTC (rev 15215)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/testmaterials.py	2009-06-12 20:04:17 UTC (rev 15216)
@@ -77,6 +77,9 @@
     #from TestGenMaxwellIsotropic3D import TestGenMaxwellIsotropic3D
     #suite.addTest(unittest.makeSuite(TestGenMaxwellIsotropic3D))
 
+    from TestPowerLaw3D import TestPowerLaw3D
+    suite.addTest(unittest.makeSuite(TestPowerLaw3D))
+
     from TestMaterial import TestMaterial
     suite.addTest(unittest.makeSuite(TestMaterial))
 



More information about the CIG-COMMITS mailing list