[cig-commits] r9266 - in short/3D/PyLith/trunk/unittests/libtests/materials: . data
willic3 at geodynamics.org
willic3 at geodynamics.org
Fri Feb 8 10:52:24 PST 2008
Author: willic3
Date: 2008-02-08 10:52:24 -0800 (Fri, 08 Feb 2008)
New Revision: 9266
Added:
short/3D/PyLith/trunk/unittests/libtests/materials/TestGenMaxwellIsotropic3D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestGenMaxwellIsotropic3D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElastic.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElasticData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElasticData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDep.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDepData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDepData.hh
Modified:
short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/materials/data/generate.sh
Log:
Set up and debugged unit tests for generalized Maxwell model.
All tests now pass.
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am 2008-02-07 14:49:22 UTC (rev 9265)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am 2008-02-08 18:52:24 UTC (rev 9266)
@@ -28,6 +28,7 @@
TestElasticPlaneStress.cc \
TestElasticStrain1D.cc \
TestElasticStress1D.cc \
+ TestGenMaxwellIsotropic3D.cc \
TestMaxwellIsotropic3D.cc \
test_materials.cc
@@ -43,6 +44,8 @@
data/ElasticPlaneStressData.cc \
data/ElasticStrain1DData.cc \
data/ElasticStress1DData.cc \
+ data/GenMaxwellIsotropic3DElasticData.cc \
+ data/GenMaxwellIsotropic3DTimeDepData.cc \
data/MaxwellIsotropic3DElasticData.cc \
data/MaxwellIsotropic3DTimeDepData.cc
@@ -54,6 +57,8 @@
data/ElasticPlaneStressData.hh \
data/ElasticStrain1DData.hh \
data/ElasticStress1DData.hh \
+ data/GenMaxwellIsotropic3DElasticData.hh \
+ data/GenMaxwellIsotropic3DTimeDepData.hh \
data/MaxwellIsotropic3DElasticData.hh \
data/MaxwellIsotropic3DTimeDepData.hh \
data/header.hh
Added: short/3D/PyLith/trunk/unittests/libtests/materials/TestGenMaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestGenMaxwellIsotropic3D.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestGenMaxwellIsotropic3D.cc 2008-02-08 18:52:24 UTC (rev 9266)
@@ -0,0 +1,323 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestGenMaxwellIsotropic3D.hh" // Implementation of class methods
+
+#include "data/GenMaxwellIsotropic3DElasticData.hh" // USES GenMaxwellIsotropic3DElasticData
+#include "data/GenMaxwellIsotropic3DTimeDepData.hh" // USES GenMaxwellIsotropic3DTimeDepData
+
+#include "pylith/materials/GenMaxwellIsotropic3D.hh" // USES GenMaxwellIsotropic3D
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestGenMaxwellIsotropic3D );
+
+// ----------------------------------------------------------------------
+// Test timeStep()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testTimeStep(void)
+{ // testTimeStep
+ GenMaxwellIsotropic3D 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(false, 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::TestGenMaxwellIsotropic3D::testUseElasticBehavior(void)
+{ // testUseElasticBehavior
+ GenMaxwellIsotropic3D material;
+
+ material.useElasticBehavior(true);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::GenMaxwellIsotropic3D::_calcStressElastic,
+ material._calcStressFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::GenMaxwellIsotropic3D::_calcElasticConstsElastic,
+ material._calcElasticConstsFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::GenMaxwellIsotropic3D::_updateStateElastic,
+ material._updateStateFn);
+
+ material.useElasticBehavior(false);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::GenMaxwellIsotropic3D::_calcStressViscoelastic,
+ material._calcStressFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::GenMaxwellIsotropic3D::_calcElasticConstsViscoelastic,
+ material._calcElasticConstsFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::GenMaxwellIsotropic3D::_updateStateViscoelastic,
+ material._updateStateFn);
+} // testUseElasticBehavior
+
+// ----------------------------------------------------------------------
+// Test usesUpdateState()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testUsesUpdateState(void)
+{ // testUsesUpdateState
+ GenMaxwellIsotropic3D material;
+ CPPUNIT_ASSERT_EQUAL(true, material.usesUpdateState());
+} // testUsesUpdateState
+
+// ----------------------------------------------------------------------
+// Test DBValues()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testDBValues(void)
+{ // testDBValues
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DElasticData data;
+ material.useElasticBehavior(true);
+ _testDBValues(&material, data);
+} // testDBValues
+
+// ----------------------------------------------------------------------
+// Test parameters()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testParameters(void)
+{ // testParameters
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DElasticData data;
+ material.useElasticBehavior(true);
+ _testParameters(&material, data);
+} // testParameters
+
+// ----------------------------------------------------------------------
+// Test _dbToParameters()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testDBToParameters(void)
+{ // testDBToParameters
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DElasticData data;
+ material.useElasticBehavior(true);
+ _testDBToParameters(&material, data);
+} // testDBToParameters
+
+// ----------------------------------------------------------------------
+// Test calcDensity()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testCalcDensity(void)
+{ // testCalcDensity
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DElasticData data;
+ material.useElasticBehavior(true);
+ _testCalcDensity(&material, data);
+} // testCalcDensity
+
+// ----------------------------------------------------------------------
+// Test calcStressElastic()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testCalcStressElastic(void)
+{ // testCalcStressElastic
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DElasticData data;
+ material.useElasticBehavior(true);
+ _testCalcStress(&material, data);
+} // testCalcStressElastic
+
+// ----------------------------------------------------------------------
+// Test calcElasticConstsElastic()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testCalcElasticConstsElastic(void)
+{ // testElasticConstsElastic
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DElasticData data;
+ material.useElasticBehavior(true);
+ _testCalcElasticConsts(&material, data);
+} // testElasticConstsElastic
+
+// ----------------------------------------------------------------------
+// Test updateStateElastic()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testUpdateStateElastic(void)
+{ // testUpdateStateElastic
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DElasticData data;
+
+ const int_array& numParamValues = material._getNumParamValues();
+ const int numParams = numParamValues.size();
+ const int numParamsQuadPt = material._numParamsQuadPt;;
+
+ const int tensorSize = 6;
+ double_array totalStrain(tensorSize);
+ for (int i=0; i < tensorSize; ++i)
+ totalStrain[i] = i;
+
+ const double meanStrain =
+ (totalStrain[0] + totalStrain[1] + totalStrain[2]) / 3.0;
+
+ double_array parameters(numParamsQuadPt);
+ double_array parametersE(numParamsQuadPt);
+ for (int i=0, index=0; i < numParams; ++i)
+ for (int j=0; j < numParamValues[i]; ++j, ++index) {
+ parametersE[index] = i+j;
+ parameters[index] = i+j;
+ } // for
+
+ // Set up vector parameters, which are the only ones updated.
+ const int numMaxwellModels = 3;
+ const int pidStrainT = 3 + 2 * numMaxwellModels;
+ const int pidVisStrain = pidStrainT + tensorSize;
+ for (int i=0; i < 3; ++i) {
+ parametersE[pidStrainT + i] = totalStrain[i];
+ for (int j=0; j < numMaxwellModels; ++j)
+ parametersE[pidVisStrain + i + j * tensorSize] =
+ totalStrain[i] - meanStrain;
+ } // for
+
+ for (int i=3; i < 6; ++i) {
+ parametersE[pidStrainT + i] = totalStrain[i];
+ for (int j=0; j < numMaxwellModels; ++j)
+ parametersE[pidVisStrain + i + j * tensorSize] =
+ totalStrain[i];
+ } // for
+
+ material._updateState(¶meters[0], numParamsQuadPt,
+ &totalStrain[0], tensorSize);
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < numParamsQuadPt; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(parametersE[i], parameters[i], tolerance);
+} // testUpdateStateElastic
+
+// ----------------------------------------------------------------------
+// Test calcStressTimeDep()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testCalcStressTimeDep(void)
+{ // testCalcStressTimeDep
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DTimeDepData data;
+ material.useElasticBehavior(false);
+ double dt = 2.0e+5;
+ material.timeStep(dt);
+ _testCalcStress(&material, data);
+} // testCalcStressTimeDep
+
+// ----------------------------------------------------------------------
+// Test calcElasticConstsTimeDep()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testCalcElasticConstsTimeDep(void)
+{ // testElasticConstsTimeDep
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DTimeDepData data;
+ material.useElasticBehavior(false);
+ double dt = 2.0e+5;
+ material.timeStep(dt);
+ _testCalcElasticConsts(&material, data);
+} // testElasticConstsTimeDep
+
+// ----------------------------------------------------------------------
+// Test updateStateTimeDep()
+void
+pylith::materials::TestGenMaxwellIsotropic3D::testUpdateStateTimeDep(void)
+{ // testUpdateStateTimeDep
+ GenMaxwellIsotropic3D material;
+ GenMaxwellIsotropic3DTimeDepData data;
+
+ const int_array& numParamValues = material._getNumParamValues();
+ const int numParams = numParamValues.size();
+ const int numParamsQuadPt = material._numParamsQuadPt;;
+
+ const int numMaxwellModels = 3;
+ const int tensorSize = 6;
+ const double mu = 3.0e10;
+
+ material.useElasticBehavior(false);
+ const double dt = 2.0e+5;
+ material.timeStep(dt);
+ const double shearRatio[] = {0.2, 0.3, 0.4};
+ const double viscosity[] = {1.0e+18, 2.0e17, 3.0e19};
+ double maxwellTime[] = {0.0, 0.0, 0.0};
+ for (int model = 0; model < numMaxwellModels; ++model)
+ maxwellTime[model] = viscosity[model]/(mu * shearRatio[model]);
+
+ double_array totalStrainTpdt(tensorSize);
+ double_array totalStrainT(tensorSize);
+ double_array visStrainT(numMaxwellModels * tensorSize);
+ for (int i=0; i < tensorSize; ++i) {
+ totalStrainTpdt[i] = i;
+ totalStrainT[i] = totalStrainTpdt[i] / 2.0;
+ visStrainT[i] = totalStrainTpdt[i] / 4.0;
+ visStrainT[i + tensorSize] = totalStrainTpdt[i] / 4.0;
+ visStrainT[i + 2 * tensorSize] = totalStrainTpdt[i] / 4.0;
+ } // for
+
+ const double meanStrainTpdt =
+ (totalStrainTpdt[0] + totalStrainTpdt[1] + totalStrainTpdt[2]) / 3.0;
+ const double meanStrainT =
+ (totalStrainT[0] + totalStrainT[1] + totalStrainT[2]) / 3.0;
+
+ const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+
+ double_array parameters(numParamsQuadPt);
+ double_array parametersE(numParamsQuadPt);
+ for (int i=0, index=0; i < numParams; ++i)
+ for (int j=0; j < numParamValues[i]; ++j, ++index) {
+ parametersE[index] = i+j;
+ parameters[index] = i+j;
+ } // for
+
+
+ const int pidMuTot = 1;
+ const int pidShearRatio = 3;
+ const int pidMaxwellTime = pidShearRatio + numMaxwellModels;
+ const int pidStrainT = pidMaxwellTime + numMaxwellModels;
+ const int pidVisStrain = pidStrainT + tensorSize;
+
+ parameters[pidMuTot] = mu;
+ parametersE[pidMuTot] = mu;
+
+ double dq[] = {0.0, 0.0, 0.0};
+ for (int model = 0; model < numMaxwellModels; ++model) {
+ parameters[pidShearRatio + model] = shearRatio[model];
+ parameters[pidMaxwellTime + model] = maxwellTime[model];
+ parametersE[pidShearRatio + model] = shearRatio[model];
+ parametersE[pidMaxwellTime + model] = maxwellTime[model];
+ dq[model] = maxwellTime[model] * (1.0 - exp(-dt/maxwellTime[model]))/dt;
+ }
+
+ double devStrainTpdt = 0.0;
+ double devStrainT = 0.0;
+ double deltaStrain = 0.0;
+ double visStrain = 0.0;
+
+ for (int iComp = 0; iComp < tensorSize; ++iComp) {
+ devStrainTpdt = totalStrainTpdt[iComp] - diag[iComp]*meanStrainTpdt;
+ devStrainT = totalStrainT[iComp] - diag[iComp]*meanStrainT;
+ deltaStrain = devStrainTpdt - devStrainT;
+ parameters[pidStrainT + iComp] = totalStrainT[iComp];
+ parametersE[pidStrainT + iComp] = totalStrainTpdt[iComp];
+ for (int model = 0; model < numMaxwellModels; ++model) {
+ int index = iComp + model * tensorSize;
+ parametersE[pidVisStrain + index] =
+ exp(-dt/maxwellTime[model]) *
+ visStrainT[index] + dq[model] * deltaStrain;
+ parameters[pidVisStrain + index] = visStrainT[index];
+ } // for
+ } // for
+
+ material._updateState(¶meters[0], numParamsQuadPt,
+ &totalStrainTpdt[0], tensorSize);
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < numParamsQuadPt; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(parametersE[i], parameters[i], tolerance);
+} // testUpdateStateTimeDep
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/materials/TestGenMaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestGenMaxwellIsotropic3D.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestGenMaxwellIsotropic3D.hh 2008-02-08 18:52:24 UTC (rev 9266)
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/materials/TestGenMaxwellIsotropic3D.hh
+ *
+ * @brief C++ TestGenMaxwellIsotropic3D object
+ *
+ * C++ unit testing for MaxwellIsotropic3D.
+ */
+
+#if !defined(pylith_materials_testgenmaxwellisotropic3d_hh)
+#define pylith_materials_testgenmaxwellisotropic3d_hh
+
+#include "TestElasticMaterial.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace materials {
+ class GenMaxwellIsotropic3D;
+ class TestGenMaxwellIsotropic3D;
+ class GenMaxwellIsotropic3DElasticData;
+ class GenMaxwellIsotropic3DTimeDepData;
+ } // materials
+} // pylith
+
+/// C++ unit testing for GenMaxwellIsotropic3D
+class pylith::materials::TestGenMaxwellIsotropic3D : public TestElasticMaterial
+{ // class TestGenMaxwellIsotropic3D
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestGenMaxwellIsotropic3D );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testUseElasticBehavior );
+ CPPUNIT_TEST( testUsesUpdateState );
+ CPPUNIT_TEST( testDBToParameters );
+ CPPUNIT_TEST( testDBValues );
+ CPPUNIT_TEST( testParameters );
+ CPPUNIT_TEST( testCalcDensity );
+ CPPUNIT_TEST( testCalcStressElastic );
+ CPPUNIT_TEST( testCalcStressTimeDep );
+ CPPUNIT_TEST( testCalcElasticConstsElastic );
+ CPPUNIT_TEST( testCalcElasticConstsTimeDep );
+ CPPUNIT_TEST( testUpdateStateElastic );
+ CPPUNIT_TEST( testUpdateStateTimeDep );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test timeStep()
+ void testTimeStep(void);
+
+ /// Test useElasticBehavior()
+ void testUseElasticBehavior(void);
+
+ /// Test usesUpdateState()
+ void testUsesUpdateState(void);
+
+ /// Test DBValues()
+ void testDBValues(void);
+
+ /// Test parameters()
+ void testParameters(void);
+
+ /// Test _dbToParameters()
+ void testDBToParameters(void);
+
+ /// Test calcDensity()
+ void testCalcDensity(void);
+
+ /// Test calcStressElastic()
+ void testCalcStressElastic(void);
+
+ /// Test calcStressTimeDep()
+ void testCalcStressTimeDep(void);
+
+ /// Test calcElasticConstsElastic()
+ void testCalcElasticConstsElastic(void);
+
+ /// Test calcElasticConstsTimeDep()
+ void testCalcElasticConstsTimeDep(void);
+
+ /// Test updateStateElastic()
+ void testUpdateStateElastic(void);
+
+ /// Test updateStateTimeDep()
+ void testUpdateStateTimeDep(void);
+
+}; // class TestGenMaxwellIsotropic3D
+
+#endif // pylith_materials_testgenmaxwellisotropic3d_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElastic.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElastic.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElastic.py 2008-02-08 18:52:24 UTC (rev 9266)
@@ -0,0 +1,174 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file unittests/libtests/materials/data/GenMaxwellIsotropic3DElastic.py
+
+## @brief Python application for generating C++ data files for testing
+## C++ GenMaxwellIsotropic3D object with elastic behavior.
+
+from ElasticMaterialApp import ElasticMaterialApp
+
+import numpy
+
+# ----------------------------------------------------------------------
+# GenMaxwellIsotropic3DElastic class
+class GenMaxwellIsotropic3DElastic(ElasticMaterialApp):
+ """
+ Python application for generating C++ data files for testing C++
+ GenMaxwellIsotropic3D object with elastic behavior.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="genmaxwellisotropic3delastic"):
+ """
+ Constructor.
+ """
+ ElasticMaterialApp.__init__(self, name)
+
+ self.dimension = 3
+ self.tensorSize = 6
+
+ self.numMaxwellModels = 3
+ self.numDBValues = 3 + 2*self.numMaxwellModels
+ self.dbValues = ["density", "vs", "vp",
+ "shear_ratio_1", "shear_ratio_2", "shear_ratio_3",
+ "viscosity_1", "viscosity_2", "viscosity_3"]
+ self.numParameters = 7
+ self.numParamValues = [1, 1, 1,
+ self.numMaxwellModels, self.numMaxwellModels,
+ self.tensorSize,
+ self.tensorSize*self.numMaxwellModels]
+ self.parameterNames = ["density", "mu", "lambda",
+ "shearRatio", "maxwellTime",
+ "strainT", "visStrain"]
+
+ self.dt = 2.0e5
+
+ densityA = 2500.0
+ vsA = 3000.0
+ vpA = vsA*3**0.5
+ shearRatioA = [0.5, 0.1, 0.2]
+ viscosityA = [1.0e18, 1.0e17, 1.0e19]
+ visStrainA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ strainTA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ strainA = [1.1e-4, 2.2e-4, 3.3e-4, 4.4e-4, 5.5e-4, 6.6e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
+ elasDataA = [densityA, vsA, vpA]
+ matDbA = elasDataA + shearRatioA + viscosityA
+
+ densityB = 2000.0
+ vsB = 1200.0
+ vpB = vsB*3**0.5
+ shearRatioB = [0.2, 0.2, 0.2]
+ viscosityB = [1.0e18, 1.0e19, 1.0e20]
+ visStrainB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ strainTB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ strainB = [1.2e-4, 2.3e-4, 3.4e-4, 4.5e-4, 5.6e-4, 6.7e-4]
+ muB = vsB*vsB*densityB
+ lambdaB = vpB*vpB*densityB - 2.0*muB
+ elasDataB = [densityB, vsB, vpB]
+ matDbB = elasDataB + shearRatioB + viscosityB
+
+ matDb = matDbA + matDbB
+
+ self.dbData = numpy.array(matDb, dtype=numpy.float64)
+
+ maxwellTimeA = [0.0, 0.0, 0.0]
+ maxwellTimeB = [0.0, 0.0, 0.0]
+ for model in range(self.numMaxwellModels):
+ if shearRatioA[model] != 0.0:
+ maxwellTimeA[model] = viscosityA[model]/(muA*shearRatioA[model])
+ if shearRatioB[model] != 0.0:
+ maxwellTimeB[model] = viscosityB[model]/(muB*shearRatioB[model])
+
+ vecParamsA = numpy.hstack((shearRatioA, maxwellTimeA, strainTA, visStrainA))
+ vecParamsB = numpy.hstack((shearRatioB, maxwellTimeB, strainTB, visStrainB))
+ vecParams = numpy.vstack((vecParamsA, vecParamsB))
+ scalarParams = numpy.array([ [densityA, muA, lambdaA],
+ [densityB, muB, lambdaB] ],
+ dtype=numpy.float64)
+ self.parameterData = numpy.hstack((scalarParams, vecParams))
+
+ 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, muA, lambdaA)
+ (self.elasticConsts[1,:], self.stress[1,:]) = \
+ self._calcStress(strainB, muB, lambdaB)
+ return
+
+
+ def _calcStress(self, strainV, 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 = GenMaxwellIsotropic3DElastic()
+ app.run()
+
+
+# End of file
Added: short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElasticData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElasticData.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElasticData.cc 2008-02-08 18:52:24 UTC (rev 9266)
@@ -0,0 +1,241 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// DO NOT EDIT THIS FILE
+// This file was generated from python application genmaxwellisotropic3delastic.
+
+#include "GenMaxwellIsotropic3DElasticData.hh"
+
+const int pylith::materials::GenMaxwellIsotropic3DElasticData::_dimension = 3;
+
+const int pylith::materials::GenMaxwellIsotropic3DElasticData::_numDBValues = 9;
+
+const int pylith::materials::GenMaxwellIsotropic3DElasticData::_numParameters = 7;
+
+const int pylith::materials::GenMaxwellIsotropic3DElasticData::_numParamsQuadPt = 33;
+
+const int pylith::materials::GenMaxwellIsotropic3DElasticData::_numLocs = 2;
+
+const int pylith::materials::GenMaxwellIsotropic3DElasticData::_numParamValues[] = {
+1,
+1,
+1,
+3,
+3,
+6,
+18,
+};
+
+const char* pylith::materials::GenMaxwellIsotropic3DElasticData::_dbValues[] = {
+"density",
+"vs",
+"vp",
+"shear_ratio_1",
+"shear_ratio_2",
+"shear_ratio_3",
+"viscosity_1",
+"viscosity_2",
+"viscosity_3",
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DElasticData::_dbData[] = {
+ 2.50000000e+03,
+ 3.00000000e+03,
+ 5.19615242e+03,
+ 5.00000000e-01,
+ 1.00000000e-01,
+ 2.00000000e-01,
+ 1.00000000e+18,
+ 1.00000000e+17,
+ 1.00000000e+19,
+ 2.00000000e+03,
+ 1.20000000e+03,
+ 2.07846097e+03,
+ 2.00000000e-01,
+ 2.00000000e-01,
+ 2.00000000e-01,
+ 1.00000000e+18,
+ 1.00000000e+19,
+ 1.00000000e+20,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DElasticData::_parameterData[] = {
+ 2.50000000e+03,
+ 2.25000000e+10,
+ 2.25000000e+10,
+ 5.00000000e-01,
+ 1.00000000e-01,
+ 2.00000000e-01,
+ 8.88888889e+07,
+ 4.44444444e+07,
+ 2.22222222e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 2.00000000e+03,
+ 2.88000000e+09,
+ 2.88000000e+09,
+ 2.00000000e-01,
+ 2.00000000e-01,
+ 2.00000000e-01,
+ 1.73611111e+09,
+ 1.73611111e+10,
+ 1.73611111e+11,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DElasticData::_density[] = {
+ 2.50000000e+03,
+ 2.00000000e+03,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DElasticData::_strain[] = {
+ 1.10000000e-04,
+ 2.20000000e-04,
+ 3.30000000e-04,
+ 4.40000000e-04,
+ 5.50000000e-04,
+ 6.60000000e-04,
+ 1.20000000e-04,
+ 2.30000000e-04,
+ 3.40000000e-04,
+ 4.50000000e-04,
+ 5.60000000e-04,
+ 6.70000000e-04,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DElasticData::_stress[] = {
+ 1.98000000e+07,
+ 2.47500000e+07,
+ 2.97000000e+07,
+ 1.98000000e+07,
+ 2.47500000e+07,
+ 2.97000000e+07,
+ 2.67840000e+06,
+ 3.31200000e+06,
+ 3.94560000e+06,
+ 2.59200000e+06,
+ 3.22560000e+06,
+ 3.85920000e+06,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DElasticData::_elasticConsts[] = {
+ 6.75000000e+10,
+ 2.25000000e+10,
+ 2.25000000e+10,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 6.75000000e+10,
+ 2.25000000e+10,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 6.75000000e+10,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 4.50000000e+10,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 4.50000000e+10,
+ 0.00000000e+00,
+ 4.50000000e+10,
+ 8.64000000e+09,
+ 2.88000000e+09,
+ 2.88000000e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 8.64000000e+09,
+ 2.88000000e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 8.64000000e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 5.76000000e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 5.76000000e+09,
+ 0.00000000e+00,
+ 5.76000000e+09,
+};
+
+pylith::materials::GenMaxwellIsotropic3DElasticData::GenMaxwellIsotropic3DElasticData(void)
+{ // constructor
+ dimension = _dimension;
+ numDBValues = _numDBValues;
+ numParameters = _numParameters;
+ numParamsQuadPt = _numParamsQuadPt;
+ numLocs = _numLocs;
+ numParamValues = const_cast<int*>(_numParamValues);
+ dbValues = const_cast<char**>(_dbValues);
+ dbData = const_cast<double*>(_dbData);
+ parameterData = const_cast<double*>(_parameterData);
+ density = const_cast<double*>(_density);
+ strain = const_cast<double*>(_strain);
+ stress = const_cast<double*>(_stress);
+ elasticConsts = const_cast<double*>(_elasticConsts);
+} // constructor
+
+pylith::materials::GenMaxwellIsotropic3DElasticData::~GenMaxwellIsotropic3DElasticData(void)
+{}
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElasticData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElasticData.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DElasticData.hh 2008-02-08 18:52:24 UTC (rev 9266)
@@ -0,0 +1,70 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// DO NOT EDIT THIS FILE
+// This file was generated from python application genmaxwellisotropic3delastic.
+
+#if !defined(pylith_materials_genmaxwellisotropic3delasticdata_hh)
+#define pylith_materials_genmaxwellisotropic3delasticdata_hh
+
+#include "ElasticMaterialData.hh"
+
+namespace pylith {
+ namespace materials {
+ class GenMaxwellIsotropic3DElasticData;
+ } // pylith
+} // materials
+
+class pylith::materials::GenMaxwellIsotropic3DElasticData : public ElasticMaterialData
+{
+
+public:
+
+ /// Constructor
+ GenMaxwellIsotropic3DElasticData(void);
+
+ /// Destructor
+ ~GenMaxwellIsotropic3DElasticData(void);
+
+private:
+
+ static const int _dimension;
+
+ static const int _numDBValues;
+
+ static const int _numParameters;
+
+ static const int _numParamsQuadPt;
+
+ static const int _numLocs;
+
+ static const int _numParamValues[];
+
+ static const char* _dbValues[];
+
+ static const double _dbData[];
+
+ static const double _parameterData[];
+
+ static const double _density[];
+
+ static const double _strain[];
+
+ static const double _stress[];
+
+ static const double _elasticConsts[];
+
+};
+
+#endif // pylith_materials_genmaxwellisotropic3delasticdata_hh
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDep.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDep.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDep.py 2008-02-08 18:52:24 UTC (rev 9266)
@@ -0,0 +1,250 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDep.py
+
+## @brief Python application for generating C++ data files for testing
+## C++ GenMaxwellIsotropic3D object with viscoelastic behavior.
+
+from ElasticMaterialApp import ElasticMaterialApp
+
+import numpy
+
+# ----------------------------------------------------------------------
+# GenMaxwellIsotropic3DTimeDep class
+class GenMaxwellIsotropic3DTimeDep(ElasticMaterialApp):
+ """
+ Python application for generating C++ data files for testing C++
+ GenMaxwellIsotropic3D object using viscoelastic behavior.
+ """
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="genmaxwellisotropic3dtimedep"):
+ """
+ Constructor.
+ """
+ ElasticMaterialApp.__init__(self, name)
+
+ # import pdb
+ # pdb.set_trace()
+
+ self.dimension = 3
+ self.tensorSize = 6
+
+ self.numMaxwellModels = 3
+ self.numDBValues = 3+2*self.numMaxwellModels
+ self.dbValues = ["density", "vs", "vp" ,
+ "shear_ratio_1", "shear_ratio_2", "shear_ratio_3",
+ "viscosity_1", "viscosity_2", "viscosity_3"]
+ self.numParameters = 7
+ self.numParamValues = [1, 1, 1,
+ self.numMaxwellModels, self.numMaxwellModels,
+ self.tensorSize,
+ self.tensorSize*self.numMaxwellModels]
+ self.parameterNames = ["density", "mu", "lambda",
+ "shearRatio", "maxwellTime",
+ "strainT", "visStrain"]
+
+ self.dt = 2.0e5
+
+ densityA = 2500.0
+ vsA = 3000.0
+ vpA = vsA*3**0.5
+ shearRatioA = [0.5, 0.1, 0.2]
+ viscosityA = [1.0e18, 1.0e17, 1.0e19]
+ visStrainA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ strainA = [1.1e-4, 2.2e-4, 3.3e-4, 4.4e-4, 5.5e-4, 6.6e-4]
+ meanStrainA = (strainA[0] + strainA[1] + strainA[2])/3.0
+ elasDataA = [densityA, vsA, vpA]
+ matDbA = elasDataA + shearRatioA + viscosityA
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
+
+ densityB = 2000.0
+ vsB = 1200.0
+ vpB = vsB*3**0.5
+ shearRatioB = [0.2, 0.2, 0.2]
+ viscosityB = [1.0e18, 1.0e19, 1.0e20]
+ visStrainB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ strainB = [1.2e-4, 2.3e-4, 3.4e-4, 4.5e-4, 5.6e-4, 6.7e-4]
+ meanStrainB = (strainB[0] + strainB[1] + strainB[2])/3.0
+ elasDataB = [densityB, vsB, vpB]
+ matDbB = elasDataB + shearRatioB + viscosityB
+ muB = vsB*vsB*densityB
+ lambdaB = vpB*vpB*densityB - 2.0*muB
+
+ matDb = matDbA + matDbB
+ self.dbData = numpy.array(matDb, dtype=numpy.float64)
+
+ diag = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
+
+ # Simplest approach for now is to assume this is the first step after the
+ # elastic solution. In that case, both the total strain from the last step
+ # (strainT) and the total viscous strain (visStrain) are defined by the
+ # assigned elastic strain.
+ strainTA = strainA[:]
+ strainTB = strainB[:]
+
+ maxwellTimeA = [0.0, 0.0, 0.0]
+ maxwellTimeB = [0.0, 0.0, 0.0]
+ for model in range(self.numMaxwellModels):
+ if shearRatioA[model] != 0.0:
+ maxwellTimeA[model] = viscosityA[model]/(muA*shearRatioA[model])
+ for i in range(self.tensorSize):
+ visStrainA[i+self.tensorSize*model] = strainA[i] - diag[i] * meanStrainA
+ if shearRatioB[model] != 0.0:
+ maxwellTimeB[model] = viscosityB[model]/(muB*shearRatioB[model])
+ for i in range(self.tensorSize):
+ visStrainB[i+self.tensorSize*model] = strainB[i] - diag[i] * meanStrainB
+
+ vecParamsA = numpy.hstack((shearRatioA, maxwellTimeA, strainTA, visStrainA))
+ vecParamsB = numpy.hstack((shearRatioB, maxwellTimeB, strainTB, visStrainB))
+ vecParams = numpy.vstack((vecParamsA, vecParamsB))
+ scalarParams = numpy.array([ [densityA, muA, lambdaA],
+ [densityB, muB, lambdaB] ],
+ dtype=numpy.float64)
+ self.parameterData = numpy.hstack((scalarParams, vecParams))
+
+ 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, muA, lambdaA,
+ shearRatioA, maxwellTimeA,
+ strainTA, visStrainA)
+ (self.elasticConsts[1,:], self.stress[1,:]) = \
+ self._calcStress(strainB, muB, lambdaB,
+ shearRatioB, maxwellTimeB,
+ strainTB, visStrainB)
+ return
+
+
+ def _calcStress(self, strainV, muV, lambdaV,
+ shearRatioV, maxwellTimeV, strainTV, visStrainV):
+ """
+ Compute stress and derivative of elasticity matrix.
+ This assumes behavior is always viscoelastic.
+ """
+ import math
+ # import pdb
+
+ bulkModulus = lambdaV + 2.0 * muV/3.0
+
+ diag = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
+ traceStrainT = strainTV[0] + strainTV[1] + strainTV[2]
+ traceStrainTpdt = strainV[0] + strainV[1] + strainV[2]
+ meanStrainT = traceStrainT/3.0
+ meanStrainTpdt = traceStrainTpdt/3.0
+ meanStressTpdt = bulkModulus * traceStrainTpdt
+
+ timeFrac = 1.0e-10
+ numTerms = 5
+ visFrac = 0.0
+ visFac = 0.0
+ dq = [0.0, 0.0, 0.0]
+ for model in range(self.numMaxwellModels):
+ visFrac += shearRatioV[model]
+ if shearRatioV[model] != 0.0:
+ if self.dt < timeFrac*maxwellTimeV[model]:
+ fSign = 1.0
+ factorial = 1.0
+ fraction = 1.0
+ dq[model] = 1.0
+ for iTerm in range(2, numTerms + 1):
+ factorial *= iTerm
+ fSign *= -1.0
+ fraction *= self.dt/maxwellTimeV[model]
+ dq[model] += fSign*fraction/factorial
+ elif maxwellTimeV[model] < timeFrac*self.dt:
+ dq[model] = maxwellTimeV[model]/dt
+ else:
+ dq[model] = maxwellTimeV[model] * \
+ (1.0-math.exp(-self.dt/maxwellTimeV[model]))/self.dt
+ visFac += shearRatioV[model] * dq[model]
+
+ elasFrac = 1.0 - visFrac
+ shearFac = muV*(elasFrac + visFac)/3.0
+
+ C1111 = bulkModulus + 4.0*shearFac
+ C1122 = bulkModulus - 2.0*shearFac
+ C1133 = C1122
+ C1112 = 0.0
+ C1123 = 0.0
+ C1113 = 0.0
+ C2222 = C1111
+ C2233 = C1122
+ C2212 = 0.0
+ C2223 = 0.0
+ C2213 = 0.0
+ C3333 = C1111
+ C3312 = 0.0
+ C3323 = 0.0
+ C3313 = 0.0
+ C1212 = 6.0*shearFac
+ C1223 = 0.0
+ C1213 = 0.0
+ C2323 = C1212
+ C2313 = 0.0
+ C1313 = C1212
+ 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)
+
+ stressV = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+
+ elasFac = 2.0*muV
+ devStrainTpdt = 0.0
+ devStrainT = 0.0
+ deltaStrain = 0.0
+ devStressTpdt = 0.0
+ visStrain = 0.0
+ for iComp in range(self.tensorSize):
+ devStrainTpdt = strainV[iComp] - diag[iComp]*meanStrainTpdt
+ devStrainT = strainTV[iComp] - diag[iComp]*meanStrainT
+ deltaStrain = devStrainTpdt - devStrainT
+ devStressTpdt = elasFrac*devStrainTpdt
+ for model in range(self.numMaxwellModels):
+ if shearRatioV[model] != 0.0:
+ visStrain = math.exp(-self.dt/maxwellTimeV[model]) * \
+ visStrainV[iComp + self.tensorSize * model] + \
+ dq[model] * deltaStrain
+ devStressTpdt += shearRatioV[model] * visStrain
+ devStressTpdt = elasFac * devStressTpdt
+ stressV[iComp] = diag[iComp]*meanStressTpdt + devStressTpdt
+
+ stress = numpy.reshape(stressV, (6,1))
+ return (elasticConsts, numpy.ravel(stress))
+
+
+# MAIN /////////////////////////////////////////////////////////////////
+if __name__ == "__main__":
+
+ app = GenMaxwellIsotropic3DTimeDep()
+ app.run()
+
+
+# End of file
Added: short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDepData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDepData.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDepData.cc 2008-02-08 18:52:24 UTC (rev 9266)
@@ -0,0 +1,241 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// DO NOT EDIT THIS FILE
+// This file was generated from python application genmaxwellisotropic3dtimedep.
+
+#include "GenMaxwellIsotropic3DTimeDepData.hh"
+
+const int pylith::materials::GenMaxwellIsotropic3DTimeDepData::_dimension = 3;
+
+const int pylith::materials::GenMaxwellIsotropic3DTimeDepData::_numDBValues = 9;
+
+const int pylith::materials::GenMaxwellIsotropic3DTimeDepData::_numParameters = 7;
+
+const int pylith::materials::GenMaxwellIsotropic3DTimeDepData::_numParamsQuadPt = 33;
+
+const int pylith::materials::GenMaxwellIsotropic3DTimeDepData::_numLocs = 2;
+
+const int pylith::materials::GenMaxwellIsotropic3DTimeDepData::_numParamValues[] = {
+1,
+1,
+1,
+3,
+3,
+6,
+18,
+};
+
+const char* pylith::materials::GenMaxwellIsotropic3DTimeDepData::_dbValues[] = {
+"density",
+"vs",
+"vp",
+"shear_ratio_1",
+"shear_ratio_2",
+"shear_ratio_3",
+"viscosity_1",
+"viscosity_2",
+"viscosity_3",
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DTimeDepData::_dbData[] = {
+ 2.50000000e+03,
+ 3.00000000e+03,
+ 5.19615242e+03,
+ 5.00000000e-01,
+ 1.00000000e-01,
+ 2.00000000e-01,
+ 1.00000000e+18,
+ 1.00000000e+17,
+ 1.00000000e+19,
+ 2.00000000e+03,
+ 1.20000000e+03,
+ 2.07846097e+03,
+ 2.00000000e-01,
+ 2.00000000e-01,
+ 2.00000000e-01,
+ 1.00000000e+18,
+ 1.00000000e+19,
+ 1.00000000e+20,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DTimeDepData::_parameterData[] = {
+ 2.50000000e+03,
+ 2.25000000e+10,
+ 2.25000000e+10,
+ 5.00000000e-01,
+ 1.00000000e-01,
+ 2.00000000e-01,
+ 8.88888889e+07,
+ 4.44444444e+07,
+ 2.22222222e+09,
+ 1.10000000e-04,
+ 2.20000000e-04,
+ 3.30000000e-04,
+ 4.40000000e-04,
+ 5.50000000e-04,
+ 6.60000000e-04,
+ -1.10000000e-04,
+ 0.00000000e+00,
+ 1.10000000e-04,
+ 4.40000000e-04,
+ 5.50000000e-04,
+ 6.60000000e-04,
+ -1.10000000e-04,
+ 0.00000000e+00,
+ 1.10000000e-04,
+ 4.40000000e-04,
+ 5.50000000e-04,
+ 6.60000000e-04,
+ -1.10000000e-04,
+ 0.00000000e+00,
+ 1.10000000e-04,
+ 4.40000000e-04,
+ 5.50000000e-04,
+ 6.60000000e-04,
+ 2.00000000e+03,
+ 2.88000000e+09,
+ 2.88000000e+09,
+ 2.00000000e-01,
+ 2.00000000e-01,
+ 2.00000000e-01,
+ 1.73611111e+09,
+ 1.73611111e+10,
+ 1.73611111e+11,
+ 1.20000000e-04,
+ 2.30000000e-04,
+ 3.40000000e-04,
+ 4.50000000e-04,
+ 5.60000000e-04,
+ 6.70000000e-04,
+ -1.10000000e-04,
+ -2.71050543e-20,
+ 1.10000000e-04,
+ 4.50000000e-04,
+ 5.60000000e-04,
+ 6.70000000e-04,
+ -1.10000000e-04,
+ -2.71050543e-20,
+ 1.10000000e-04,
+ 4.50000000e-04,
+ 5.60000000e-04,
+ 6.70000000e-04,
+ -1.10000000e-04,
+ -2.71050543e-20,
+ 1.10000000e-04,
+ 4.50000000e-04,
+ 5.60000000e-04,
+ 6.70000000e-04,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DTimeDepData::_density[] = {
+ 2.50000000e+03,
+ 2.00000000e+03,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DTimeDepData::_strain[] = {
+ 1.10000000e-04,
+ 2.20000000e-04,
+ 3.30000000e-04,
+ 4.40000000e-04,
+ 5.50000000e-04,
+ 6.60000000e-04,
+ 1.20000000e-04,
+ 2.30000000e-04,
+ 3.40000000e-04,
+ 4.50000000e-04,
+ 5.60000000e-04,
+ 6.70000000e-04,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DTimeDepData::_stress[] = {
+ 1.98078741e+07,
+ 2.47500000e+07,
+ 2.96921259e+07,
+ 1.97685037e+07,
+ 2.47106296e+07,
+ 2.96527555e+07,
+ 2.67841620e+06,
+ 3.31200000e+06,
+ 3.94558380e+06,
+ 2.59193371e+06,
+ 3.22551751e+06,
+ 3.85910131e+06,
+};
+
+const double pylith::materials::GenMaxwellIsotropic3DTimeDepData::_elasticConsts[] = {
+ 6.74761278e+10,
+ 2.25119361e+10,
+ 2.25119361e+10,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 6.74761278e+10,
+ 2.25119361e+10,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 6.74761278e+10,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 4.49641917e+10,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 4.49641917e+10,
+ 0.00000000e+00,
+ 4.49641917e+10,
+ 8.63995090e+09,
+ 2.88002455e+09,
+ 2.88002455e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 8.63995090e+09,
+ 2.88002455e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 8.63995090e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 5.75992635e+09,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 5.75992635e+09,
+ 0.00000000e+00,
+ 5.75992635e+09,
+};
+
+pylith::materials::GenMaxwellIsotropic3DTimeDepData::GenMaxwellIsotropic3DTimeDepData(void)
+{ // constructor
+ dimension = _dimension;
+ numDBValues = _numDBValues;
+ numParameters = _numParameters;
+ numParamsQuadPt = _numParamsQuadPt;
+ numLocs = _numLocs;
+ numParamValues = const_cast<int*>(_numParamValues);
+ dbValues = const_cast<char**>(_dbValues);
+ dbData = const_cast<double*>(_dbData);
+ parameterData = const_cast<double*>(_parameterData);
+ density = const_cast<double*>(_density);
+ strain = const_cast<double*>(_strain);
+ stress = const_cast<double*>(_stress);
+ elasticConsts = const_cast<double*>(_elasticConsts);
+} // constructor
+
+pylith::materials::GenMaxwellIsotropic3DTimeDepData::~GenMaxwellIsotropic3DTimeDepData(void)
+{}
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDepData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDepData.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/GenMaxwellIsotropic3DTimeDepData.hh 2008-02-08 18:52:24 UTC (rev 9266)
@@ -0,0 +1,70 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// DO NOT EDIT THIS FILE
+// This file was generated from python application genmaxwellisotropic3dtimedep.
+
+#if !defined(pylith_materials_genmaxwellisotropic3dtimedepdata_hh)
+#define pylith_materials_genmaxwellisotropic3dtimedepdata_hh
+
+#include "ElasticMaterialData.hh"
+
+namespace pylith {
+ namespace materials {
+ class GenMaxwellIsotropic3DTimeDepData;
+ } // pylith
+} // materials
+
+class pylith::materials::GenMaxwellIsotropic3DTimeDepData : public ElasticMaterialData
+{
+
+public:
+
+ /// Constructor
+ GenMaxwellIsotropic3DTimeDepData(void);
+
+ /// Destructor
+ ~GenMaxwellIsotropic3DTimeDepData(void);
+
+private:
+
+ static const int _dimension;
+
+ static const int _numDBValues;
+
+ static const int _numParameters;
+
+ static const int _numParamsQuadPt;
+
+ static const int _numLocs;
+
+ static const int _numParamValues[];
+
+ static const char* _dbValues[];
+
+ static const double _dbData[];
+
+ static const double _parameterData[];
+
+ static const double _density[];
+
+ static const double _strain[];
+
+ static const double _stress[];
+
+ static const double _elasticConsts[];
+
+};
+
+#endif // pylith_materials_genmaxwellisotropic3dtimedepdata_hh
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/generate.sh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/generate.sh 2008-02-07 14:49:22 UTC (rev 9265)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/generate.sh 2008-02-08 18:52:24 UTC (rev 9266)
@@ -25,6 +25,11 @@
--data.object=ElasticIsotropic3DData \
--data.parent=ElasticMaterialData
+ python GenMaxwellIsotropic3DElastic.py \
+ --data.namespace=pylith,materials \
+ --data.object=GenMaxwellIsotropic3DElasticData \
+ --data.parent=ElasticMaterialData
+
python MaxwellIsotropic3DElastic.py \
--data.namespace=pylith,materials \
--data.object=MaxwellIsotropic3DElasticData \
@@ -59,6 +64,11 @@
# //////////////////////////////////////////////////////////////////////
if [ $1 == "viscoelastic" ] || [ $1 == "all" ]; then
+ python GenMaxwellIsotropic3DTimeDep.py \
+ --data.namespace=pylith,materials \
+ --data.object=GenMaxwellIsotropic3DTimeDepData \
+ --data.parent=ElasticMaterialData
+
python MaxwellIsotropic3DTimeDep.py \
--data.namespace=pylith,materials \
--data.object=MaxwellIsotropic3DTimeDepData \
More information about the cig-commits
mailing list