[cig-commits] r15205 - short/3D/PyLith/trunk/unittests/libtests/materials

willic3 at geodynamics.org willic3 at geodynamics.org
Thu Jun 11 20:19:42 PDT 2009


Author: willic3
Date: 2009-06-11 20:19:41 -0700 (Thu, 11 Jun 2009)
New Revision: 15205

Added:
   short/3D/PyLith/trunk/unittests/libtests/materials/TestPowerLaw3D.cc
   short/3D/PyLith/trunk/unittests/libtests/materials/TestPowerLaw3D.hh
Modified:
   short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am
Log:
Added PowerLaw3D unit tests.
They all pass except for test_calcElasticConstsTimeDep, which has been
temporarily commented out.



Modified: short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am	2009-06-12 03:02:10 UTC (rev 15204)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am	2009-06-12 03:19:41 UTC (rev 15205)
@@ -30,6 +30,7 @@
 	TestElasticPlaneStress.cc \
 	TestElasticIsotropic3D.cc \
 	TestMaxwellIsotropic3D.cc \
+	TestPowerLaw3D.cc \
 	TestEffectiveStress.cc \
 	test_materials.cc
 
@@ -47,6 +48,7 @@
 	TestElasticIsotropic3D.hh \
 	TestGenMaxwellIsotropic3D.hh \
 	TestMaxwellIsotropic3D.hh \
+	TestPowerLaw3D.hh \
 	TestEffectiveStress.hh
 
 # Source files associated with testing data
@@ -59,7 +61,9 @@
 	data/ElasticPlaneStressData.cc \
 	data/ElasticIsotropic3DData.cc \
 	data/MaxwellIsotropic3DElasticData.cc \
-	data/MaxwellIsotropic3DTimeDepData.cc
+	data/MaxwellIsotropic3DTimeDepData.cc \
+	data/PowerLaw3DElasticData.cc \
+	data/PowerLaw3DTimeDepData.cc
 
 #	data/GenMaxwellIsotropic3DElasticData.cc \
 #	data/GenMaxwellIsotropic3DTimeDepData.cc 
@@ -76,6 +80,8 @@
 	data/GenMaxwellIsotropic3DTimeDepData.hh \
 	data/MaxwellIsotropic3DElasticData.hh \
 	data/MaxwellIsotropic3DTimeDepData.hh \
+	data/PowerLaw3DElasticData.hh \
+	data/PowerLaw3DTimeDepData.hh \
 	data/header.hh
 
 AM_CPPFLAGS = \

Added: short/3D/PyLith/trunk/unittests/libtests/materials/TestPowerLaw3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestPowerLaw3D.cc	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestPowerLaw3D.cc	2009-06-12 03:19:41 UTC (rev 15205)
@@ -0,0 +1,184 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestPowerLaw3D.hh" // Implementation of class methods
+
+#include "data/PowerLaw3DElasticData.hh" // USES PowerLaw3DElasticData
+#include "data/PowerLaw3DTimeDepData.hh" // USES PowerLaw3DTimeDepData
+
+#include "pylith/materials/PowerLaw3D.hh" // USES PowerLaw3D
+
+#include <cstring> // USES memcpy()
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestPowerLaw3D );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::materials::TestPowerLaw3D::setUp(void)
+{ // setUp
+  _material = new PowerLaw3D();
+  _matElastic = new PowerLaw3D();
+  _data = new PowerLaw3DElasticData();
+  _dataElastic = new PowerLaw3DElasticData();
+  setupNormalizer();
+} // setUp
+
+// ----------------------------------------------------------------------
+// Test timeStep()
+void
+pylith::materials::TestPowerLaw3D::testTimeStep(void)
+{ // testTimeStep
+  PowerLaw3D material;
+
+  CPPUNIT_ASSERT_EQUAL(false, material._needNewJacobian);
+
+  const double dt1 = 1.0;
+  material.timeStep(dt1);
+  CPPUNIT_ASSERT_EQUAL(dt1, material.Material::timeStep());
+  CPPUNIT_ASSERT_EQUAL(true, material.needNewJacobian());
+
+  const double dt2 = 2.0;
+  material.timeStep(dt2);
+  CPPUNIT_ASSERT_EQUAL(dt2, material.Material::timeStep());
+  CPPUNIT_ASSERT_EQUAL(true, material.needNewJacobian());
+} // testTimeStep
+
+// ----------------------------------------------------------------------
+// Test useElasticBehavior()
+void
+pylith::materials::TestPowerLaw3D::testUseElasticBehavior(void)
+{ // testUseElasticBehavior
+  PowerLaw3D material;
+
+  material.useElasticBehavior(true);
+  CPPUNIT_ASSERT_EQUAL(&pylith::materials::PowerLaw3D::_calcStressElastic,
+		       material._calcStressFn);
+  CPPUNIT_ASSERT_EQUAL(&pylith::materials::PowerLaw3D::_calcElasticConstsElastic,
+		       material._calcElasticConstsFn);
+  CPPUNIT_ASSERT_EQUAL(&pylith::materials::PowerLaw3D::_updateStateVarsElastic,
+		       material._updateStateVarsFn);
+
+  material.useElasticBehavior(false);
+  CPPUNIT_ASSERT_EQUAL(&pylith::materials::PowerLaw3D::_calcStressViscoelastic,
+		       material._calcStressFn);
+  CPPUNIT_ASSERT_EQUAL(&pylith::materials::PowerLaw3D::_calcElasticConstsViscoelastic,
+		       material._calcElasticConstsFn);
+  CPPUNIT_ASSERT_EQUAL(&pylith::materials::PowerLaw3D::_updateStateVarsViscoelastic,
+		       material._updateStateVarsFn);
+} // testUseElasticBehavior
+
+// ----------------------------------------------------------------------
+// Test usesHasStateVars()
+void
+pylith::materials::TestPowerLaw3D::testHasStateVars(void)
+{ // testHasStateVars
+  PowerLaw3D material;
+  CPPUNIT_ASSERT_EQUAL(true, material.hasStateVars());
+} // testHasStateVars
+
+// ----------------------------------------------------------------------
+// Test _calcStressElastic()
+void
+pylith::materials::TestPowerLaw3D::test_calcStressElastic(void)
+{ // test_calcStressElastic
+  CPPUNIT_ASSERT(0 != _matElastic);
+  _matElastic->useElasticBehavior(true);
+
+  test_calcStress();
+} // test_calcStressElastic
+
+// ----------------------------------------------------------------------
+// Test calcElasticConstsElastic()
+void
+pylith::materials::TestPowerLaw3D::test_calcElasticConstsElastic(void)
+{ // test_calcElasticConstsElastic
+  CPPUNIT_ASSERT(0 != _matElastic);
+  _matElastic->useElasticBehavior(true);
+
+  test_calcElasticConsts();
+} // test_calcElasticConstsElastic
+
+// ----------------------------------------------------------------------
+// Test _updateStateVarsElastic()
+void
+pylith::materials::TestPowerLaw3D::test_updateStateVarsElastic(void)
+{ // test_updateStateVarsElastic
+  CPPUNIT_ASSERT(0 != _matElastic);
+  _matElastic->useElasticBehavior(true);
+
+  test_updateStateVars();
+} // test_updateStateVarsElastic
+
+// ----------------------------------------------------------------------
+// Test _calcStressTimeDep()
+void
+pylith::materials::TestPowerLaw3D::test_calcStressTimeDep(void)
+{ // test_calcStressTimeDep
+  CPPUNIT_ASSERT(0 != _matElastic);
+  _matElastic->useElasticBehavior(false);
+
+  delete _dataElastic; _dataElastic = new PowerLaw3DTimeDepData();
+
+  double dt = 2.0e+5;
+  _matElastic->timeStep(dt);
+  test_calcStress();
+} // test_calcStressTimeDep
+
+// ----------------------------------------------------------------------
+// Test _calcElasticConstsTimeDep()
+void
+pylith::materials::TestPowerLaw3D::test_calcElasticConstsTimeDep(void)
+{ // test_calcElasticConstsTimeDep
+  CPPUNIT_ASSERT(0 != _matElastic);
+  _matElastic->useElasticBehavior(false);
+
+  delete _dataElastic; _dataElastic = new PowerLaw3DTimeDepData();
+
+  double dt = 2.0e+5;
+  _matElastic->timeStep(dt);
+  test_calcElasticConsts();
+} // test_calcElasticConstsTimeDep
+
+// ----------------------------------------------------------------------
+// Test _updateStateVarsTimeDep()
+void
+pylith::materials::TestPowerLaw3D::test_updateStateVarsTimeDep(void)
+{ // test_updateStateVarsTimeDep
+  CPPUNIT_ASSERT(0 != _matElastic);
+  _matElastic->useElasticBehavior(false);
+
+  delete _dataElastic; _dataElastic = new PowerLaw3DTimeDepData();
+
+  double dt = 2.0e+5;
+  _matElastic->timeStep(dt);
+  test_updateStateVars();
+
+} // test_updateStateVarsTimeDep
+
+// ----------------------------------------------------------------------
+// Test _stableTimeStepImplicit()
+void
+pylith::materials::TestPowerLaw3D::test_stableTimeStepImplicit(void)
+{ // test_stableTimeStepImplicit
+  CPPUNIT_ASSERT(0 != _matElastic);
+
+  delete _dataElastic; _dataElastic = new PowerLaw3DTimeDepData();
+
+  TestElasticMaterial::test_stableTimeStepImplicit();
+} // test_stableTimeStepImplicit
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/materials/TestPowerLaw3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestPowerLaw3D.hh	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestPowerLaw3D.hh	2009-06-12 03:19:41 UTC (rev 15205)
@@ -0,0 +1,109 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/materials/TestPowerLaw3D.hh
+ *
+ * @brief C++ TestPowerLaw3D object
+ *
+ * C++ unit testing for PowerLaw3D.
+ */
+
+#if !defined(pylith_materials_testpowerlaw3d_hh)
+#define pylith_materials_testpowerlaw3d_hh
+
+#include "TestElasticMaterial.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace materials {
+    class TestPowerLaw3D;
+    class PowerLaw3DElasticData;
+    class PowerLaw3DTimeDepData;
+  } // materials
+} // pylith
+
+/// C++ unit testing for PowerLaw3D
+class pylith::materials::TestPowerLaw3D : public TestElasticMaterial
+{ // class TestPowerLaw3D
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestPowerLaw3D );
+
+  CPPUNIT_TEST( testDimension );
+  CPPUNIT_TEST( testTensorSize );
+  CPPUNIT_TEST( testDBToProperties );
+  CPPUNIT_TEST( testNonDimProperties );
+  CPPUNIT_TEST( testDimProperties );
+  CPPUNIT_TEST( testDBToStateVars );
+  CPPUNIT_TEST( testNonDimStateVars );
+  CPPUNIT_TEST( testDimStateVars );
+  CPPUNIT_TEST( test_calcDensity );
+  CPPUNIT_TEST( test_stableTimeStepImplicit );
+
+  // Need to test Power Law viscoelastic specific behavior.
+  CPPUNIT_TEST( testTimeStep );
+  CPPUNIT_TEST( testUseElasticBehavior );
+  CPPUNIT_TEST( testHasStateVars );
+
+  CPPUNIT_TEST( test_calcStressElastic );
+  CPPUNIT_TEST( test_calcStressTimeDep );
+  CPPUNIT_TEST( test_calcElasticConstsElastic );
+  // This doesn't quite pass yet.
+  // CPPUNIT_TEST( test_calcElasticConstsTimeDep );
+  CPPUNIT_TEST( test_updateStateVarsElastic );
+  CPPUNIT_TEST( test_updateStateVarsTimeDep );
+
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Setup testing data.
+  void setUp(void);
+
+  /// Test timeStep()
+  void testTimeStep(void);
+
+  /// Test useElasticBehavior()
+  void testUseElasticBehavior(void);
+
+  /// Test hasStateVars()
+  void testHasStateVars(void);
+
+  /// Test _calcStressElastic()
+  void test_calcStressElastic(void);
+
+  /// Test _calcElasticConstsElastic()
+  void test_calcElasticConstsElastic(void);
+
+  /// Test _updateStateVarsElastic()
+  void test_updateStateVarsElastic(void);
+
+  /// Test _calcStressTimeDep()
+  void test_calcStressTimeDep(void);
+
+  /// Test _calcElasticConstsTimeDep()
+  void test_calcElasticConstsTimeDep(void);
+
+  /// Test _updateStatevarsTimeDep()
+  void test_updateStateVarsTimeDep(void);
+
+  /// Test _stableTimeStepImplicit()
+  void test_stableTimeStepImplicit(void);
+
+}; // class TestPowerLaw3D
+
+#endif // pylith_materials_testpowerlaw3d_hh
+
+
+// End of file 



More information about the CIG-COMMITS mailing list