[cig-commits] r7022 - in short/3D/PyLith/trunk/unittests/libtests/materials: . data

willic3 at geodynamics.org willic3 at geodynamics.org
Thu May 31 14:58:02 PDT 2007


Author: willic3
Date: 2007-05-31 14:58:02 -0700 (Thu, 31 May 2007)
New Revision: 7022

Added:
   short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc
   short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh
   short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3D.py
Log:
Incomplete unit tests for Maxwell viscoelastic material.



Added: short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc	2007-05-31 21:27:36 UTC (rev 7021)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc	2007-05-31 21:58:02 UTC (rev 7022)
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestMaxwellIsotropic3D.hh" // Implementation of class methods
+
+#include "data/MaxwellIsotropic3DData.hh" // USES MaxwellIsotropic3DData
+
+#include "pylith/materials/MaxwellIsotropic3D.hh" // USES MaxwellIsotropic3D
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestMaxwellIsotropic3D );
+
+// ----------------------------------------------------------------------
+// Test DBValues()
+void
+pylith::materials::TestMaxwellIsotropic3D::testDBValues(void)
+{ // testDBValues
+  MaxwellIsotropic3D material;
+  MaxwellIsotropic3DData data;
+  _testDBValues(&material, data);
+} // testDBValues
+
+// ----------------------------------------------------------------------
+// Test parameters()
+void
+pylith::materials::TestMaxwellIsotropic3D::testParameters(void)
+{ // testParameters
+  MaxwellIsotropic3D material;
+  MaxwellIsotropic3DData data;
+  _testParameters(&material, data);
+} // testParameters
+
+// ----------------------------------------------------------------------
+// Test _dbToParameters()
+void
+pylith::materials::TestMaxwellIsotropic3D::testDBToParameters(void)
+{ // testDBToParameters
+  MaxwellIsotropic3D material;
+  MaxwellIsotropic3DData data;
+  _testDBToParameters(&material, data);
+} // testDBToParameters
+
+// ----------------------------------------------------------------------
+// Test calcDensity()
+void
+pylith::materials::TestMaxwellIsotropic3D::testCalcDensity(void)
+{ // testCalcDensity
+  MaxwellIsotropic3D material;
+  MaxwellIsotropic3DData data;
+  _testCalcDensity(&material, data);
+} // testCalcDensity
+
+// ----------------------------------------------------------------------
+// Test calcStress()
+void
+pylith::materials::TestMaxwellIsotropic3D::testCalcStress(void)
+{ // testCalcStress
+  MaxwellIsotropic3D material;
+  MaxwellIsotropic3DData data;
+  _testCalcStress(&material, data);
+} // testCalcStress
+
+// ----------------------------------------------------------------------
+// Test calcElasticConsts()
+void
+pylith::materials::TestMaxwellIsotropic3D::testCalcElasticConsts(void)
+{ // testElasticConsts
+  MaxwellIsotropic3D material;
+  MaxwellIsotropic3DData data;
+  _testCalcElasticConsts(&material, data);
+} // testElasticConsts
+
+// ----------------------------------------------------------------------
+// Test updateState()
+void
+pylith::materials::TestMaxwellIsotropic3D::testUpdateState(void)
+{ // testUpdateState
+  MaxwellIsotropic3D material;
+
+  std::vector<double_array> totalStrain;
+  material.updateState(totalStrain);
+} // testUpdateState
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh	2007-05-31 21:27:36 UTC (rev 7021)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh	2007-05-31 21:58:02 UTC (rev 7022)
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/materials/TestMaxwellIsotropic3D.hh
+ *
+ * @brief C++ TestMaxwellIsotropic3D object
+ *
+ * C++ unit testing for MaxwellIsotropic3D.
+ */
+
+#if !defined(pylith_materials_testmaxwellisotropic3d_hh)
+#define pylith_materials_testmaxwellisotropic3d_hh
+
+#include "TestElasticMaterial.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace materials {
+    class MaxwellIsotropic3D;
+    class TestMaxwellIsotropic3D;
+    class MaxwellIsotropic3DData;
+  } // materials
+} // pylith
+
+/// C++ unit testing for MaxwellIsotropic3D
+class pylith::materials::TestMaxwellIsotropic3D : public TestElasticMaterial
+{ // class TestMaxwellIsotropic3D
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestMaxwellIsotropic3D );
+  CPPUNIT_TEST( testDBToParameters );
+  CPPUNIT_TEST( testDBValues );
+  CPPUNIT_TEST( testParameters );
+  CPPUNIT_TEST( testCalcDensity );
+  CPPUNIT_TEST( testCalcStress );
+  CPPUNIT_TEST( testCalcElasticConsts );
+  CPPUNIT_TEST( testUpdateState );
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Test DBValues()
+  void testDBValues(void);
+
+  /// Test parameters()
+  void testParameters(void);
+
+  /// Test _dbToParameters()
+  void testDBToParameters(void);
+
+  /// Test calcDensity()
+  void testCalcDensity(void);
+
+  /// Test calcStress()
+  void testCalcStress(void);
+
+  /// Test calcElasticConsts()
+  void testCalcElasticConsts(void);
+
+  /// Test updateState()
+  void testUpdateState(void);
+
+}; // class TestMaxwellIsotropic3D
+
+#endif // pylith_materials_testmaxwellisotropic3d_hh
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3D.py	2007-05-31 21:27:36 UTC (rev 7021)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3D.py	2007-05-31 21:58:02 UTC (rev 7022)
@@ -0,0 +1,144 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file unittests/libtests/materials/data/MaxwellIsotropic3D.py
+
+## @brief Python application for generating C++ data files for testing
+## C++ MaxwellIsotropic3D object.
+
+from ElasticMaterialApp import ElasticMaterialApp
+
+import numpy
+
+# ----------------------------------------------------------------------
+# MaxwellIsotropic3D class
+class MaxwellIsotropic3D(ElasticMaterialApp):
+  """
+  Python application for generating C++ data files for testing C++
+  MaxwellIsotropic3D object.
+  """
+  
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+  
+  def __init__(self, name="maxwellisotropic3d"):
+    """
+    Constructor.
+    """
+    ElasticMaterialApp.__init__(self, name)
+
+    self.dimension = 3
+
+    self.numDBValues = 4
+    self.dbValues = ["density", "vs", "vp" , "viscosity"]
+    self.numParameters = 6
+    self.numParamValues = [1, 1, 1, 1, 6, 6]
+    self.parameterNames = ["density", "mu", "lambda", "maxwellTime", "strainT", "visStrain"]
+
+    densityA = 2500.0
+    vsA = 3000.0
+    vpA = vsA*3**0.5
+    viscosityA = 1.0e18
+    strainA = [1.1e-4, 2.2e-4, 3.3e-4, 4.4e-4, 5.5e-4, 6.6e-4]
+    
+    densityB = 2000.0
+    vsB = 1200.0
+    vpB = vsB*3**0.5
+    viscosityB = 1.0e19
+    strainB = [1.2e-4, 2.3e-4, 3.4e-4, 4.5e-4, 5.6e-4, 6.7e-4]
+
+    self.dbData = numpy.array([ [densityA, vsA, vpA, viscosityA],
+                                [densityB, vsB, vpB, viscosityB] ],
+                              dtype=numpy.float64)
+    muA = vsA*vsA*densityA
+    lambdaA = vpA*vpA*densityA - 2.0*muA
+    maxwellTimeA = viscosityA/muA
+    strainTA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+    visStrainA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+    muB = vsB*vsB*densityB
+    lambdaB = vpB*vpB*densityB - 2.0*muB
+    maxwellTimeB = viscosityB/muB
+    strainTB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+    visStrainB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+    self.parameterData = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA, strainTA, visStrainA],
+                                       [densityB, muB, lambdaB, maxwellTimeB, strainTB, visStrainB] ],
+                                     dtype=numpy.float64)
+    
+    self.numLocs = 2
+    numElasticConsts = 21
+    self.density = numpy.array([densityA, densityB],
+                               dtype=numpy.float64)
+
+    self.strain = numpy.array([strainA, strainB],
+                               dtype=numpy.float64)
+    self.stress = numpy.zeros( (self.numLocs, 6), dtype=numpy.float64)
+    self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
+                                      dtype=numpy.float64)
+
+    (self.elasticConsts[0,:], self.stress[0,:]) = \
+                              self._calcStress(strainA, densityA, muA, lambdaA)
+    (self.elasticConsts[1,:], self.stress[1,:]) = \
+                              self._calcStress(strainB, densityB, muB, lambdaB)
+    return
+
+
+  def _calcStress(self, strainV, densityV, muV, lambdaV):
+    """
+    Compute stress and derivative of elasticity matrix.
+    """
+    C1111 = lambdaV + 2.0*muV
+    C1122 = lambdaV
+    C1133 = lambdaV
+    C1112 = 0.0
+    C1123 = 0.0
+    C1113 = 0.0
+    C2222 = lambdaV + 2.0*muV
+    C2233 = lambdaV
+    C2212 = 0.0
+    C2223 = 0.0
+    C2213 = 0.0
+    C3333 = lambdaV + 2.0*muV
+    C3312 = 0.0
+    C3323 = 0.0
+    C3313 = 0.0
+    C1212 = 2.0*muV
+    C1223 = 0.0
+    C1213 = 0.0
+    C2323 = 2.0*muV
+    C2313 = 0.0
+    C1313 = 2.0*muV
+    elasticConsts = numpy.array([C1111, C1122, C1133, C1112, C1123, C1113,
+                                 C2222, C2233, C2212, C2223, C2213,
+                                 C3333, C3312, C3323, C3313,
+                                 C1212, C1223, C1213,
+                                 C2323, C2313,
+                                 C1313], dtype=numpy.float64)
+
+    strain = numpy.reshape(strainV, (6,1))
+    elastic = numpy.array([ [C1111, C1122, C1133, C1112, C1123, C1113],
+                            [C1122, C2222, C2233, C2212, C2223, C2213],
+                            [C1133, C2233, C3333, C3312, C3323, C3313],
+                            [C1112, C2212, C3312, C1212, C1223, C1213],
+                            [C1123, C2223, C3323, C1223, C2323, C2313],
+                            [C1113, C2213, C3313, C1213, C2313, C1313] ],
+                          dtype=numpy.float64)
+    stress = numpy.dot(elastic, strain)
+    return (elasticConsts, numpy.ravel(stress))
+  
+
+# MAIN /////////////////////////////////////////////////////////////////
+if __name__ == "__main__":
+
+  app = MaxwellIsotropic3D()
+  app.run()
+
+
+# End of file 



More information about the cig-commits mailing list