[cig-commits] r19663 - in short/3D/PyLith/branches/v1.6-stable: modulesrc/utils unittests/pytests/bc unittests/pytests/faults unittests/pytests/feassemble unittests/pytests/materials unittests/pytests/topology unittests/pytests/utils

brad at geodynamics.org brad at geodynamics.org
Wed Feb 22 20:58:55 PST 2012


Author: brad
Date: 2012-02-22 20:58:54 -0800 (Wed, 22 Feb 2012)
New Revision: 19663

Added:
   short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/constdefs.i
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/TestConstants.py
Modified:
   short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/Makefile.am
   short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/utils.i
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/bc/TestAbsorbingDampers.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/bc/TestNeumann.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/faults/TestFaultCohesiveDyn.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/faults/TestFaultCohesiveKin.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityExplicit.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityExplicitLgDeform.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityImplicit.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityImplicitLgDeform.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticIsotropic3D.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticPlaneStrain.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticPlaneStress.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticStrain1D.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticStress1D.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/topology/TestRefineUniform.py
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/Makefile.am
   short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/testutils.py
Log:
Created python wrapper for PYLITH_MAXDOUBLE and PYLITH_MAXFLOAT. Updated python unit tests to use wrappers.

Modified: short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/Makefile.am
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/Makefile.am	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/Makefile.am	2012-02-23 04:58:54 UTC (rev 19663)
@@ -40,7 +40,8 @@
 utils_swig_sources = \
 	utils.i \
 	EventLogger.i \
-	TestArray.i
+	TestArray.i \
+	constdefs.i
 
 utils_swig_generated = \
 	utils_wrap.cxx \

Added: short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/constdefs.i
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/constdefs.i	                        (rev 0)
+++ short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/constdefs.i	2012-02-23 04:58:54 UTC (rev 19663)
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/utils/constdefs.i
+ *
+ * @brief PyLith constants.
+ */
+
+// ----------------------------------------------------------------------
+// PYLITH_MAXDOUBLE
+%inline %{
+  double
+  maxdouble(void)
+  { // maxdouble
+    return pylith::PYLITH_MAXDOUBLE;
+  } // maxdouble
+%} // inline
+
+// ----------------------------------------------------------------------
+// PYLITH_MAXFLOAT
+%inline %{
+  float
+  maxfloat(void)
+  { // maxfloat
+    return pylith::PYLITH_MAXFLOAT;
+  } // maxfloat
+%} // inline
+
+
+// End of file 

Modified: short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/utils.i
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/utils.i	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/modulesrc/utils/utils.i	2012-02-23 04:58:54 UTC (rev 19663)
@@ -23,6 +23,7 @@
 %{
 #include "pylith/utils/EventLogger.hh"
 #include "pylith/utils/TestArray.hh"
+#include "pylith/utils/constdefs.h"
 
 #include <petsclog.h> // USES PetscLogEventBegin/End() in inline methods
 #include "pylith/utils/arrayfwd.hh" // USES double_array
@@ -54,6 +55,7 @@
 // Interfaces
 %include "EventLogger.i"
 %include "TestArray.i"
+%include "constdefs.i"
 
 // End of file
 

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/bc/TestAbsorbingDampers.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/bc/TestAbsorbingDampers.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/bc/TestAbsorbingDampers.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -80,7 +80,8 @@
     """
     (mesh, bc, fields) = self._initialize()
 
-    self.assertEqual(1.0e+30, bc.stableTimeStep(mesh))
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, bc.stableTimeStep(mesh)/maxdouble(), 7)
     return
 
   

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/bc/TestNeumann.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/bc/TestNeumann.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/bc/TestNeumann.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -80,7 +80,8 @@
     """
     (mesh, bc, fields) = self._initialize()
 
-    self.assertEqual(1.0e+30, bc.stableTimeStep(mesh))
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, bc.stableTimeStep(mesh)/maxdouble(), 7)
     return
 
   

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/faults/TestFaultCohesiveDyn.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/faults/TestFaultCohesiveDyn.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/faults/TestFaultCohesiveDyn.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -88,7 +88,7 @@
     fault.inventory.faultLabel = "fault"
     fault._configure()
 
-    nvertices = fault.numVertices(mesh)
+    nvertices = fault.numVerticesNoMesh(mesh)
     firstFaultVertex = 0
     firstLagrangeVertex = nvertices
     firstFaultCell      = 2*nvertices
@@ -132,7 +132,8 @@
     """
     (mesh, fault, fields) = self._initialize()
 
-    self.assertEqual(1.0e+30, fault.stableTimeStep(mesh))
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, fault.stableTimeStep(mesh)/maxdouble(), 7)
     return
 
   
@@ -315,7 +316,7 @@
     fault.inventory.friction = friction
     fault._configure()
 
-    nvertices = fault.numVertices(mesh)
+    nvertices = fault.numVerticesNoMesh(mesh)
     firstFaultVertex = 0
     firstLagrangeVertex = nvertices
     firstFaultCell      = 2*nvertices

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/faults/TestFaultCohesiveKin.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/faults/TestFaultCohesiveKin.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/faults/TestFaultCohesiveKin.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -117,7 +117,7 @@
     fault.inventory.faultLabel = "fault"
     fault._configure()
 
-    nvertices = fault.numVertices(mesh)
+    nvertices = fault.numVerticesNoMesh(mesh)
     firstFaultVertex = 0
     firstLagrangeVertex = nvertices
     firstFaultCell      = 2*nvertices
@@ -161,7 +161,8 @@
     """
     (mesh, fault, fields) = self._initialize()
 
-    self.assertEqual(1.0e+30, fault.stableTimeStep(mesh))
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, fault.stableTimeStep(mesh)/maxdouble(), 7)
     return
 
   
@@ -347,7 +348,7 @@
     eqsrc.inventory.slipfn = slipfn
     eqsrc._configure()
 
-    nvertices = fault.numVertices(mesh)
+    nvertices = fault.numVerticesNoMesh(mesh)
     firstFaultVertex = 0
     firstLagrangeVertex = nvertices
     firstFaultCell      = 2*nvertices

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityExplicit.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityExplicit.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityExplicit.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -121,7 +121,8 @@
     (mesh, integrator) = self._preinitialize()
     fields = self._initialize(mesh, integrator)
 
-    self.assertEqual(1.0e+30, integrator.stableTimeStep(mesh))
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, integrator.stableTimeStep(mesh)/maxdouble(), 7)
     return
 
 

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityExplicitLgDeform.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityExplicitLgDeform.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityExplicitLgDeform.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -121,7 +121,8 @@
     (mesh, integrator) = self._preinitialize()
     fields = self._initialize(mesh, integrator)
 
-    self.assertEqual(1.0e+30, integrator.stableTimeStep(mesh))
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, integrator.stableTimeStep(mesh)/maxdouble(), 7)
     return
 
 

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityImplicit.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityImplicit.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityImplicit.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -105,7 +105,8 @@
     (mesh, integrator) = self._preinitialize()
     fields = self._initialize(mesh, integrator)
 
-    self.assertEqual(1.0e+30, integrator.stableTimeStep(mesh))
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, integrator.stableTimeStep(mesh)/maxdouble(), 7)
     return
 
 

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityImplicitLgDeform.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityImplicitLgDeform.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/feassemble/TestElasticityImplicitLgDeform.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -105,7 +105,8 @@
     (mesh, integrator) = self._preinitialize()
     fields = self._initialize(mesh, integrator)
 
-    self.assertEqual(1.0e+30, integrator.stableTimeStep(mesh))
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, integrator.stableTimeStep(mesh)/maxdouble(), 7)
     return
 
 

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticIsotropic3D.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticIsotropic3D.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticIsotropic3D.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -85,7 +85,8 @@
     from pylith.topology.Mesh import Mesh
     mesh = Mesh()
     dt = self.material.stableTimeStepImplicit(mesh)
-    self.failIf(dt < 1.0e+30)
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, dt/maxdouble())
   
 
   def test_factory(self):

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticPlaneStrain.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticPlaneStrain.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticPlaneStrain.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -85,7 +85,8 @@
     from pylith.topology.Mesh import Mesh
     mesh = Mesh()
     dt = self.material.stableTimeStepImplicit(mesh)
-    self.failIf(dt < 1.0e+30)
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, dt/maxdouble())
   
 
   def test_factory(self):

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticPlaneStress.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticPlaneStress.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticPlaneStress.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -85,7 +85,8 @@
     from pylith.topology.Mesh import Mesh
     mesh = Mesh()
     dt = self.material.stableTimeStepImplicit(mesh)
-    self.failIf(dt < 1.0e+30)
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, dt/maxdouble())
   
 
   def test_factory(self):

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticStrain1D.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticStrain1D.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticStrain1D.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -85,7 +85,8 @@
     from pylith.topology.Mesh import Mesh
     mesh = Mesh()
     dt = self.material.stableTimeStepImplicit(mesh)
-    self.failIf(dt < 1.0e+30)
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, dt/maxdouble())
   
 
   def test_factory(self):

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticStress1D.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticStress1D.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/materials/TestElasticStress1D.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -85,7 +85,8 @@
     from pylith.topology.Mesh import Mesh
     mesh = Mesh()
     dt = self.material.stableTimeStepImplicit(mesh)
-    self.failIf(dt < 1.0e+30)
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, dt/maxdouble())
   
 
   def test_factory(self):

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/topology/TestRefineUniform.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/topology/TestRefineUniform.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/topology/TestRefineUniform.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -94,7 +94,7 @@
       fault.inventory.faultLabel = faultGroup
       fault._configure()
 
-      nvertices = fault.numVertices(mesh)
+      nvertices = fault.numVerticesNoMesh(mesh)
       firstFaultVertex = 0
       firstLagrangeVertex = nvertices
       firstFaultCell      = 2*nvertices

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/Makefile.am
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/Makefile.am	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/Makefile.am	2012-02-23 04:58:54 UTC (rev 19663)
@@ -28,7 +28,8 @@
 
 noinst_PYTHON = \
 	TestEventLogger.py \
-	TestPetscManager.py
+	TestPetscManager.py \
+	TestConstants.py
 
 
 # End of file 

Added: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/TestConstants.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/TestConstants.py	                        (rev 0)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/TestConstants.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2011 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/utils/TestEventLogger.py
+
+## @brief Unit testing of EventLogger object.
+
+import unittest
+
+
+# ----------------------------------------------------------------------
+class TestConstants(unittest.TestCase):
+  """
+  Unit testing of constants.
+  """
+  
+
+  def test_maxdouble(self):
+    """
+    Test maxdouble()
+    """
+    from pylith.utils.utils import maxdouble
+    self.assertAlmostEqual(1.0, maxdouble()/1.0e+99, 7)
+    return
+
+
+  def test_maxflat(self):
+    """
+    Test maxflat()
+    """
+    from pylith.utils.utils import maxfloat
+    self.assertAlmostEqual(1.0, maxfloat()/1.0e+30, 7)
+    return
+
+
+# End of file 

Modified: short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/testutils.py
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/testutils.py	2012-02-22 23:17:41 UTC (rev 19662)
+++ short/3D/PyLith/branches/v1.6-stable/unittests/pytests/utils/testutils.py	2012-02-23 04:58:54 UTC (rev 19663)
@@ -65,6 +65,9 @@
     from TestEventLogger import TestEventLogger
     suite.addTest(unittest.makeSuite(TestEventLogger))
 
+    from TestConstants import TestConstants
+    suite.addTest(unittest.makeSuite(TestConstants))
+
     return suite
 
 



More information about the CIG-COMMITS mailing list