[cig-commits] r15283 - in short/3D/PyLith/trunk/templates: . materials materials/tests

brad at geodynamics.org brad at geodynamics.org
Mon Jun 15 16:30:06 PDT 2009


Author: brad
Date: 2009-06-15 16:30:06 -0700 (Mon, 15 Jun 2009)
New Revision: 15283

Added:
   short/3D/PyLith/trunk/templates/Makefile.am
   short/3D/PyLith/trunk/templates/materials/tests/
   short/3D/PyLith/trunk/templates/materials/tests/Makefile.am
   short/3D/PyLith/trunk/templates/materials/tests/TestPlaneStrainState.py
   short/3D/PyLith/trunk/templates/materials/tests/testcontrib.py
Modified:
   short/3D/PyLith/trunk/templates/materials/
   short/3D/PyLith/trunk/templates/materials/PlaneStrainState.cc
   short/3D/PyLith/trunk/templates/materials/PlaneStrainState.hh
   short/3D/PyLith/trunk/templates/materials/PlaneStrainState.i
   short/3D/PyLith/trunk/templates/materials/PlaneStrainState.py
   short/3D/PyLith/trunk/templates/materials/materialscontrib.i
Log:
Finished creating template for user-defined bulk constitutive models.

Added: short/3D/PyLith/trunk/templates/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/templates/Makefile.am	                        (rev 0)
+++ short/3D/PyLith/trunk/templates/Makefile.am	2009-06-15 23:30:06 UTC (rev 15283)
@@ -0,0 +1,31 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+EXTRA_DIST = \
+	README \
+	materials/README \
+	materials/configure.ac \
+	materials/Makefile.am \
+	materials/aclocal.m4 \
+	materials/Makefile.in \
+	materials/portinfo.in \
+	materials/configure \
+	materials/PlaneStrainState.hh \
+	materials/PlaneStrainState.cc \
+	materials/PlaneStrainState.i \
+	materials/PlaneStrainState.i \
+	materials/__init__.py \
+	materials/PlaneStrainState.py \
+	materials/tests/testcontrib.py \
+	materials/tests/TestPlaneStrainState.py
+
+# End of file 


Property changes on: short/3D/PyLith/trunk/templates/materials
___________________________________________________________________
Name: svn:ignore
   + configure
Makefile.in
materialscontrib.py
materialscontrib_wrap.cxx


Modified: short/3D/PyLith/trunk/templates/materials/PlaneStrainState.cc
===================================================================
--- short/3D/PyLith/trunk/templates/materials/PlaneStrainState.cc	2009-06-15 22:54:22 UTC (rev 15282)
+++ short/3D/PyLith/trunk/templates/materials/PlaneStrainState.cc	2009-06-15 23:30:06 UTC (rev 15283)
@@ -55,7 +55,7 @@
       const int numProperties = 3;
 
       // Physical properties. 
-      const Metadata::ParamDescription properties[] = {
+      const pylith::materials::Metadata::ParamDescription properties[] = {
 	{ "density", 1, pylith::topology::FieldBase::SCALAR },
 	{ "mu", 1, pylith::topology::FieldBase::SCALAR },
 	{ "lambda", 1, pylith::topology::FieldBase::SCALAR },
@@ -75,7 +75,7 @@
       const int numStateVars = 2;
       
       /// State variables.
-      const Metadata::ParamDescription stateVars[] = {
+      const pylith::materials::Metadata::ParamDescription stateVars[] = {
 	{ "total_strain", tensorSize, pylith::topology::FieldBase::TENSOR },
 	{ "stress", tensorSize, pylith::topology::FieldBase::TENSOR },
       };
@@ -108,9 +108,9 @@
   contrib::materials::PlaneStrainState::db_vs + 1;
 
 // Indices of state variables in the state variables array.
-const int contrib::materials::MaxwellIsotropic3D::s_totalStrain = 0;
+const int contrib::materials::PlaneStrainState::s_totalStrain = 0;
 
-const int contrib::materials::MaxwellIsotropic3D::s_stress = 
+const int contrib::materials::PlaneStrainState::s_stress = 
   contrib::materials::PlaneStrainState::s_totalStrain + 
   contrib::materials::_PlaneStrainState::tensorSize;
 
@@ -120,13 +120,13 @@
   pylith::materials::ElasticMaterial(_PlaneStrainState::dimension,
 				     _PlaneStrainState::tensorSize,
 				     _PlaneStrainState::numElasticConsts,
-    pylith::materialsMetadata(_PlaneStrainState::properties,
-			      _PlaneStrainState::numProperties,
-			      _PlaneStrainState::dbProperties,
-			      _PlaneStrainState::numDBProperties,
-			      _PlaneStrainState::stateVars,
-			      _PlaneStrainState::numStateVars,
-			      0, 0))
+     pylith::materials::Metadata(_PlaneStrainState::properties,
+				 _PlaneStrainState::numProperties,
+				 _PlaneStrainState::dbProperties,
+				 _PlaneStrainState::numDBProperties,
+				 _PlaneStrainState::stateVars,
+				 _PlaneStrainState::numStateVars,
+				 0, 0))
 { // constructor
 } // constructor
 
@@ -374,7 +374,7 @@
 // Get stable time step for implicit time integration.
 double
 contrib::materials::PlaneStrainState::stableTimeStepImplicit(
-					const topology::Mesh& mesh) {
+				    const pylith::topology::Mesh& mesh) {
   // Override the ElasticMaterial::stableTimeStepImplicit() function
   // (which calls _stableTimeStepImplicit() for each quadrature point
   // ) with an optimized calculation of the stable time step. This is

Modified: short/3D/PyLith/trunk/templates/materials/PlaneStrainState.hh
===================================================================
--- short/3D/PyLith/trunk/templates/materials/PlaneStrainState.hh	2009-06-15 22:54:22 UTC (rev 15282)
+++ short/3D/PyLith/trunk/templates/materials/PlaneStrainState.hh	2009-06-15 23:30:06 UTC (rev 15283)
@@ -73,7 +73,7 @@
    * @param mesh Finite-element mesh.
    * @returns Time step
    */
-  double stableTimeStepImplicit(const topology::Mesh& mesh);
+  double stableTimeStepImplicit(const pylith::topology::Mesh& mesh);
 
   // PROTECTED METHODS //////////////////////////////////////////////////
 protected :

Modified: short/3D/PyLith/trunk/templates/materials/PlaneStrainState.i
===================================================================
--- short/3D/PyLith/trunk/templates/materials/PlaneStrainState.i	2009-06-15 22:54:22 UTC (rev 15282)
+++ short/3D/PyLith/trunk/templates/materials/PlaneStrainState.i	2009-06-15 23:30:06 UTC (rev 15283)
@@ -49,7 +49,7 @@
        * @param mesh Finite-element mesh.
        * @returns Time step
        */
-      double stableTimeStepImplicit(const topology::Mesh& mesh);
+      double stableTimeStepImplicit(const pylith::topology::Mesh& mesh);
       
       // PROTECTED METHODS //////////////////////////////////////////////
     protected :

Modified: short/3D/PyLith/trunk/templates/materials/PlaneStrainState.py
===================================================================
--- short/3D/PyLith/trunk/templates/materials/PlaneStrainState.py	2009-06-15 22:54:22 UTC (rev 15282)
+++ short/3D/PyLith/trunk/templates/materials/PlaneStrainState.py	2009-06-15 23:30:06 UTC (rev 15283)
@@ -15,12 +15,13 @@
 ##
 ## Factory: material.
 
-from ElasticMaterial import ElasticMaterial # ISA ElasticMaterial
+# ISA ElasticMaterial
+from pylith.materials.ElasticMaterial import ElasticMaterial
 
 # Import the SWIG module PlanseStrainState object and rename it
 # ModulePlaneStrainState so that it doesn't clash with the local
 # Python class with the same name.
-from materials import PlaneStrainState as ModulePlaneStrainState
+from materialscontrib import PlaneStrainState as ModulePlaneStrainState
 
 # PlaneStrainState class
 class PlaneStrainState(ElasticMaterial, ModulePlaneStrainState):

Modified: short/3D/PyLith/trunk/templates/materials/materialscontrib.i
===================================================================
--- short/3D/PyLith/trunk/templates/materials/materialscontrib.i	2009-06-15 22:54:22 UTC (rev 15282)
+++ short/3D/PyLith/trunk/templates/materials/materialscontrib.i	2009-06-15 23:30:06 UTC (rev 15283)
@@ -17,7 +17,11 @@
 
 // Header files for module C++ code.
 %{
+#include "pylith/materials/materialsfwd.hh" // forward declarations
+
 #include "PlaneStrainState.hh"
+
+#include "pylith/utils/arrayfwd.hh"
 %}
 
 // Convert standard C++ exceptions to Python exceptions.

Added: short/3D/PyLith/trunk/templates/materials/tests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/templates/materials/tests/Makefile.am	                        (rev 0)
+++ short/3D/PyLith/trunk/templates/materials/tests/Makefile.am	2009-06-15 23:30:06 UTC (rev 15283)
@@ -0,0 +1,22 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+TESTS = testcontrib.py
+dist_check_SCRIPTS = testcontrib.py
+
+TESTS_ENVIRONMENT = $(PYTHON)
+
+noinst_PYTHON = \
+	TestPlaneStrainState.py 
+
+
+# End of file 

Added: short/3D/PyLith/trunk/templates/materials/tests/TestPlaneStrainState.py
===================================================================
--- short/3D/PyLith/trunk/templates/materials/tests/TestPlaneStrainState.py	                        (rev 0)
+++ short/3D/PyLith/trunk/templates/materials/tests/TestPlaneStrainState.py	2009-06-15 23:30:06 UTC (rev 15283)
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+# We cannot test the low-level functionality of the PlaneStrainState
+# object because it is not exposed to Python. You should really setup
+# C++ unit tests using CppUnit as is done for PyLith in addition to
+# the simple Python unit tests here.
+
+import unittest
+
+
+class TestPlaneStrainState(unittest.TestCase):
+  """
+  Unit testing of PlaneStrainState object.
+  """
+
+  def setUp(self):
+    """
+    Setup test subject.
+    """
+    from pylith.materials.contrib.PlaneStrainState import PlaneStrainState
+    self.material = PlaneStrainState()
+    return
+  
+
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    self.assertEqual(2, 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(3, self.material.tensorSize())
+    return
+
+
+  def testNeedNewJacobian(self):
+    """
+    Test needNewJacobian().
+    """
+    # Default should be False.
+    self.failIf(self.material.needNewJacobian())
+
+    # Changing time step should not require new Jacobian.
+    self.material.timeStep(1.0)
+    self.material.timeStep(2.0)
+    self.failIf(self.material.needNewJacobian())
+    return
+  
+
+  def test_factory(self):
+    """
+    Test factory method.
+    """
+    from pylith.materials.contrib.PlaneStrainState import material
+    m = material()
+    return
+
+
+# End of file 

Added: short/3D/PyLith/trunk/templates/materials/tests/testcontrib.py
===================================================================
--- short/3D/PyLith/trunk/templates/materials/tests/testcontrib.py	                        (rev 0)
+++ short/3D/PyLith/trunk/templates/materials/tests/testcontrib.py	2009-06-15 23:30:06 UTC (rev 15283)
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+import unittest
+
+def suite():
+
+  suite = unittest.TestSuite()
+
+  from TestPlaneStrainState import TestPlaneStrainState
+  suite.addTest(unittest.makeSuite(TestPlaneStrainState))
+
+  return suite
+
+def main():
+  unittest.TextTestRunner(verbosity=2).run(suite())
+  return
+
+if __name__ == '__main__':
+  main()
+  
+
+# End of file 


Property changes on: short/3D/PyLith/trunk/templates/materials/tests/testcontrib.py
___________________________________________________________________
Name: svn:executable
   + *



More information about the CIG-COMMITS mailing list