[cig-commits] r15089 - short/3D/PyLith/trunk/unittests/libtests/materials
brad at geodynamics.org
brad at geodynamics.org
Sat May 30 10:54:22 PDT 2009
Author: brad
Date: 2009-05-30 10:54:21 -0700 (Sat, 30 May 2009)
New Revision: 15089
Modified:
short/3D/PyLith/trunk/unittests/libtests/materials/TestEffectiveStress.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestEffectiveStress.hh
Log:
Added quadratic test.
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestEffectiveStress.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestEffectiveStress.cc 2009-05-30 04:42:36 UTC (rev 15088)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestEffectiveStress.cc 2009-05-30 17:54:21 UTC (rev 15089)
@@ -50,6 +50,31 @@
namespace pylith {
namespace materials {
namespace _EffectiveStress {
+ class Quadratic {
+ public :
+ Quadratic(void) {};
+ ~Quadratic(void) {};
+ double effStressFunc(const double x) {
+ return 1.0e-2 - pow(x - 1.0e-3, 2);
+ };
+ double effStressDerivFunc(const double x) {
+ return -2*(x-1.0e-03);
+ };
+ double effStressFuncDerivFunc(double* f,
+ double* df,
+ const double x) {
+ *f = effStressFunc(x);
+ *df = effStressDerivFunc(x);
+ };
+ }; // Quadratic
+ } // _EffectiveStress
+ } // materials
+} // pylith
+
+// ----------------------------------------------------------------------
+namespace pylith {
+ namespace materials {
+ namespace _EffectiveStress {
class Cubic {
public :
Cubic(void) {};
@@ -93,6 +118,27 @@
} // testCalculateLinear
// ----------------------------------------------------------------------
+// Test calculate() with quadratic function.
+void
+pylith::materials::TestEffectiveStress::testCalculateQuadratic(void)
+{ // testCalculateQuadratic
+ const double valueE = 0.101;
+
+ _EffectiveStress::Quadratic material;
+
+ const int ntests = 4;
+ const double guesses[ntests] = { 1.0, 1.0e-1, 2.0e-2, 1.0e-2 };
+ const double scale = 1.0e-2;
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < ntests; ++i) {
+ const double value =
+ EffectiveStress::calculate<_EffectiveStress::Quadratic>(guesses[i], scale,
+ &material);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, value/valueE, tolerance);
+ } // for
+} // testCalculateQuadratic
+
+// ----------------------------------------------------------------------
// Test calculate() with cubic function.
void
pylith::materials::TestEffectiveStress::testCalculateCubic(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestEffectiveStress.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestEffectiveStress.hh 2009-05-30 04:42:36 UTC (rev 15088)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestEffectiveStress.hh 2009-05-30 17:54:21 UTC (rev 15089)
@@ -38,6 +38,7 @@
CPPUNIT_TEST_SUITE( TestEffectiveStress );
CPPUNIT_TEST( testCalculateLinear );
+ CPPUNIT_TEST( testCalculateQuadratic );
CPPUNIT_TEST( testCalculateCubic );
CPPUNIT_TEST_SUITE_END();
@@ -48,6 +49,9 @@
/// Test calculate() with linear function.
void testCalculateLinear(void);
+ /// Test calculate() with quadratic function.
+ void testCalculateQuadratic(void);
+
/// Test calculate() with cubic function.
void testCalculateCubic(void);
More information about the CIG-COMMITS
mailing list