[cig-commits] r14833 - in short/3D/PyLith/branches/pylith-swig: libsrc/materials modulesrc/materials pylith/materials unittests/libtests/materials unittests/libtests/materials/data unittests/pytests/materials
brad at geodynamics.org
brad at geodynamics.org
Fri May 1 14:38:05 PDT 2009
Author: brad
Date: 2009-05-01 14:38:04 -0700 (Fri, 01 May 2009)
New Revision: 14833
Added:
short/3D/PyLith/branches/pylith-swig/modulesrc/materials/MaxwellIsotropic3D.i
Modified:
short/3D/PyLith/branches/pylith-swig/libsrc/materials/MaxwellIsotropic3D.cc
short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Makefile.am
short/3D/PyLith/branches/pylith-swig/modulesrc/materials/materials.i
short/3D/PyLith/branches/pylith-swig/pylith/materials/MaxwellIsotropic3D.py
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/Makefile.am
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestElasticMaterial.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMaxwellIsotropic3D.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMaxwellIsotropic3D.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/ElasticIsotropic3D.py
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElastic.py
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDep.py
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/generate.sh
short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestMaxwellIsotropic3D.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/testmaterials.py
Log:
Worked on updating Maxwell viscoelastic model unit tests.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/materials/MaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/materials/MaxwellIsotropic3D.cc 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/materials/MaxwellIsotropic3D.cc 2009-05-01 21:38:04 UTC (rev 14833)
@@ -58,7 +58,7 @@
const char* dbProperties[] = {"density", "vs", "vp" , "viscosity"};
/// Number of state variables.
- const int numStateVars = 6;
+ const int numStateVars = 2;
/// State variables.
const Metadata::ParamDescription stateVars[] = {
@@ -96,7 +96,7 @@
pylith::materials::MaxwellIsotropic3D::p_mu + 1;
const int pylith::materials::MaxwellIsotropic3D::p_maxwellTime =
- pylith::materials::MaxwellIsotropic3D::p_maxwellTime + 1;
+ pylith::materials::MaxwellIsotropic3D::p_lambda + 1;
// Indices of database values (order must match dbProperties)
const int pylith::materials::MaxwellIsotropic3D::db_density = 0;
@@ -329,6 +329,7 @@
return dtStable;
} // _stableTimeStepImplicit
+#include <iostream>
// ----------------------------------------------------------------------
// Compute viscous strain for current time step.
// material.
@@ -359,6 +360,9 @@
const int tensorSize = _tensorSize;
const double maxwellTime = properties[p_maxwellTime];
+ // :TODO: Need to account for initial values for state variables
+ // and the initial strain??
+
const double e11 = totalStrain[0];
const double e22 = totalStrain[1];
const double e33 = totalStrain[2];
@@ -366,7 +370,7 @@
const double e23 = totalStrain[4];
const double e13 = totalStrain[5];
- const double meanStrainTpdt = (e11 + e22 + e33)/3.0;
+ const double meanStrainTpdt = (e11 + e22 + e33) / 3.0;
const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
@@ -428,15 +432,15 @@
const double lambda = properties[p_lambda];
const double mu2 = 2.0 * mu;
- const double e11 = totalStrain[0];
- const double e22 = totalStrain[1];
- const double e33 = totalStrain[2];
- const double e12 = totalStrain[3];
- const double e23 = totalStrain[4];
- const double e13 = totalStrain[5];
+ // :TODO: Need to consider initial state variables????
+ const double e11 = totalStrain[0] - initialStrain[0];
+ const double e22 = totalStrain[1] - initialStrain[1];
+ const double e33 = totalStrain[2] - initialStrain[2];
+ const double e12 = totalStrain[3] - initialStrain[3];
+ const double e23 = totalStrain[4] - initialStrain[4];
+ const double e13 = totalStrain[5] - initialStrain[5];
- const double traceStrainTpdt = e11 + e22 + e33;
- const double s123 = lambda * traceStrainTpdt;
+ const double s123 = lambda * (e11 + e22 + e33);
stress[0] = s123 + mu2*e11 + initialStress[0];
stress[1] = s123 + mu2*e22 + initialStress[1];
@@ -445,7 +449,7 @@
stress[4] = mu2 * e23 + initialStress[4];
stress[5] = mu2 * e13 + initialStress[5];
- PetscLogFlops(19);
+ PetscLogFlops(25);
} // _calcStressElastic
// ----------------------------------------------------------------------
@@ -487,14 +491,16 @@
const double maxwellTime = properties[p_maxwellTime];
const double mu2 = 2.0 * mu;
- const double bulkModulus = lambda + mu2/3.0;
+ const double bulkModulus = lambda + mu2 / 3.0;
- const double e11 = totalStrain[0];
- const double e22 = totalStrain[1];
- const double e33 = totalStrain[2];
+ // :TODO: Need to determine how to incorporate initial strain and
+ // state variables
+ const double e11 = totalStrain[0] - initialStrain[0];
+ const double e22 = totalStrain[1] - initialStrain[1];
+ const double e33 = totalStrain[2] - initialStrain[2];
const double traceStrainTpdt = e11 + e22 + e33;
- const double meanStrainTpdt = traceStrainTpdt/3.0;
+ const double meanStrainTpdt = traceStrainTpdt / 3.0;
const double meanStressTpdt = bulkModulus * traceStrainTpdt;
const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Makefile.am 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Makefile.am 2009-05-01 21:38:04 UTC (rev 14833)
@@ -25,7 +25,8 @@
ElasticStress1D.i \
ElasticPlaneStrain.i \
ElasticPlaneStress.i \
- ElasticIsotropic3D.i
+ ElasticIsotropic3D.i \
+ MaxwellIsotropic3D.i
swig_generated = \
materials_wrap.cxx \
Added: short/3D/PyLith/branches/pylith-swig/modulesrc/materials/MaxwellIsotropic3D.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/materials/MaxwellIsotropic3D.i (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/materials/MaxwellIsotropic3D.i 2009-05-01 21:38:04 UTC (rev 14833)
@@ -0,0 +1,205 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/MaxwellIsotropic3D.ii
+ *
+ * @brief Python interface to C++ MaxwellIsotropic3D object.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class MaxwellIsotropic3D : public ElasticMaterial
+ { // class MaxwellIsotropic3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor
+ MaxwellIsotropic3D(void);
+
+ /// Destructor
+ ~MaxwellIsotropic3D(void);
+
+ /** Set current time step.
+ *
+ * @param dt Current time step.
+ */
+ void timeStep(const double dt);
+
+ /** Set whether elastic or inelastic constitutive relations are used.
+ *
+ * @param flag True to use elastic, false to use inelastic.
+ */
+ void useElasticBehavior(const bool flag);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute properties from values in spatial database.
+ *
+ * Order of values in arrays matches order used in dbValues() and
+ * parameterNames().
+ *
+ * @param propValues Array of property values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToProperties(double* const propValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _nondimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _dimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Compute initial state variables from values in spatial database.
+ *
+ * @param stateValues Array of state variable values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToStateVars(double* const stateValues,
+ const double_array& dbValues) const;
+
+ // Note: We do not need to dimensionalize or nondimensionalize state
+ // variables because there are strains, which are dimensionless.
+
+
+ /** Compute density from properties.
+ *
+ * @param density Array for density.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ */
+ void _calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
+
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
+ *
+ * @param stress Array for stress tensor.
+ * @param stressSize Size of stress tensor.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
+ */
+ void _calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars);
+
+ /** Compute derivatives of elasticity matrix from properties.
+ *
+ * @param elasticConsts Array for elastic constants.
+ * @param numElasticConsts Number of elastic constants.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _calcElasticConsts(double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Update state variables (for next time step).
+ *
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _updateStateVars(double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
+ */
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+
+ }; // class MaxwellIsotropic3D
+
+ } // materials
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/materials/materials.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/materials/materials.i 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/materials/materials.i 2009-05-01 21:38:04 UTC (rev 14833)
@@ -26,6 +26,8 @@
#include "pylith/materials/ElasticPlaneStrain.hh"
#include "pylith/materials/ElasticPlaneStress.hh"
#include "pylith/materials/ElasticIsotropic3D.hh"
+#include "pylith/materials/MaxwellIsotropic3D.hh"
+//#include "pylith/materials/GenMaxwellIsotropic3D.hh"
#include "pylith/utils/arrayfwd.hh"
%}
@@ -59,6 +61,8 @@
%include "ElasticPlaneStrain.i"
%include "ElasticPlaneStress.i"
%include "ElasticIsotropic3D.i"
+%include "MaxwellIsotropic3D.i"
+//%include "GenMaxwellIsotropic3D.i"
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/pylith/materials/MaxwellIsotropic3D.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/materials/MaxwellIsotropic3D.py 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/pylith/materials/MaxwellIsotropic3D.py 2009-05-01 21:38:04 UTC (rev 14833)
@@ -12,16 +12,19 @@
## @file pylith/materials/MaxwellIsotropic3D.py
##
-## @brief Python object implementing 3-D isotropic linear Maxwell viscoelastic material.
+## @brief Python object implementing 3-D isotropic linear Maxwell
+## viscoelastic material.
##
## Factory: material.
from ElasticMaterial import ElasticMaterial
+from materials import MaxwellIsotropic3D as ModuleMaxwellIsotropic3D
# MaxwellIsotropic3D class
-class MaxwellIsotropic3D(ElasticMaterial):
+class MaxwellIsotropic3D(ElasticMaterial, ModuleMaxwellIsotropic3D):
"""
- Python object implementing 3-D isotropic linear Maxwell viscoelastic material.
+ Python object implementing 3-D isotropic linear Maxwell viscoelastic
+ material.
Factory: material.
"""
@@ -44,14 +47,11 @@
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- if None == self.cppHandle:
- import pylith.materials.materials as bindings
- self.cppHandle = bindings.MaxwellIsotropic3D()
- self.dimension = self.cppHandle.dimension
+ ModuleMaxwellIsotropic3D.__init__(self)
return
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/Makefile.am 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/Makefile.am 2009-05-01 21:38:04 UTC (rev 14833)
@@ -29,10 +29,10 @@
TestElasticPlaneStrain.cc \
TestElasticPlaneStress.cc \
TestElasticIsotropic3D.cc \
+ TestMaxwellIsotropic3D.cc \
test_materials.cc
-# TestGenMaxwellIsotropic3D.cc \
-# TestMaxwellIsotropic3D.cc
+ TestGenMaxwellIsotropic3D.cc
@@ -55,12 +55,12 @@
data/ElasticStress1DData.cc \
data/ElasticPlaneStrainData.cc \
data/ElasticPlaneStressData.cc \
- data/ElasticIsotropic3DData.cc
+ data/ElasticIsotropic3DData.cc \
+ data/MaxwellIsotropic3DElasticData.cc \
+ data/MaxwellIsotropic3DTimeDepData.cc
# data/GenMaxwellIsotropic3DElasticData.cc \
-# data/GenMaxwellIsotropic3DTimeDepData.cc \
-# data/MaxwellIsotropic3DElasticData.cc \
-# data/MaxwellIsotropic3DTimeDepData.cc
+# data/GenMaxwellIsotropic3DTimeDepData.cc
noinst_HEADERS += \
data/MaterialData.hh \
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestElasticMaterial.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestElasticMaterial.cc 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestElasticMaterial.cc 2009-05-01 21:38:04 UTC (rev 14833)
@@ -490,12 +490,17 @@
const double tolerance = 1.0e-06;
for (int i=0; i < tensorSize; ++i)
+ {
+ std::cout << "stress: " << stress[i]
+ << ", stressE: " << stressE[i]
+ << std::endl;
if (fabs(stressE[i]) > tolerance)
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, stress[i]/stressE[i],
tolerance);
else
CPPUNIT_ASSERT_DOUBLES_EQUAL(stressE[i], stress[i],
tolerance);
+ }
} // for
} // _testCalcStress
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMaxwellIsotropic3D.cc 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMaxwellIsotropic3D.cc 2009-05-01 21:38:04 UTC (rev 14833)
@@ -19,6 +19,8 @@
#include "pylith/materials/MaxwellIsotropic3D.hh" // USES MaxwellIsotropic3D
+#include <cstring> // USES memcpy()
+
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestMaxwellIsotropic3D );
@@ -31,6 +33,7 @@
_matElastic = new MaxwellIsotropic3D();
_data = new MaxwellIsotropic3DElasticData();
_dataElastic = new MaxwellIsotropic3DElasticData();
+ setupNormalizer();
} // setUp
// ----------------------------------------------------------------------
@@ -65,107 +68,116 @@
material._calcStressFn);
CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic,
material._calcElasticConstsFn);
- CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updatePropertiesElastic,
- material._updatePropertiesFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updateStateVarsElastic,
+ material._updateStateVarsFn);
material.useElasticBehavior(false);
CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_calcStressViscoelastic,
material._calcStressFn);
CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_calcElasticConstsViscoelastic,
material._calcElasticConstsFn);
- CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updatePropertiesViscoelastic,
- material._updatePropertiesFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updateStateVarsViscoelastic,
+ material._updateStateVarsFn);
} // testUseElasticBehavior
// ----------------------------------------------------------------------
-// Test usesUpdateProperties()
+// Test usesHasStateVars()
void
-pylith::materials::TestMaxwellIsotropic3D::testUsesUpdateProperties(void)
-{ // testUsesUpdateProperties
+pylith::materials::TestMaxwellIsotropic3D::testHasStateVars(void)
+{ // testHasStateVars
MaxwellIsotropic3D material;
- CPPUNIT_ASSERT_EQUAL(true, material.usesUpdateProperties());
-} // testUsesUpdateProperties
+ CPPUNIT_ASSERT_EQUAL(true, material.hasStateVars());
+} // testHasStateVars
// ----------------------------------------------------------------------
-// Test calcStressElastic()
+// Test _calcStressElastic()
void
-pylith::materials::TestMaxwellIsotropic3D::testCalcStressElastic(void)
-{ // testCalcStressElastic
+pylith::materials::TestMaxwellIsotropic3D::test_calcStressElastic(void)
+{ // test_calcStressElastic
CPPUNIT_ASSERT(0 != _matElastic);
_matElastic->useElasticBehavior(true);
test_calcStress();
-} // testCalcStressElastic
+} // test_calcStressElastic
// ----------------------------------------------------------------------
// Test calcElasticConstsElastic()
void
-pylith::materials::TestMaxwellIsotropic3D::testCalcElasticConstsElastic(void)
-{ // testElasticConstsElastic
+pylith::materials::TestMaxwellIsotropic3D::test_calcElasticConstsElastic(void)
+{ // test_calcElasticConstsElastic
CPPUNIT_ASSERT(0 != _matElastic);
_matElastic->useElasticBehavior(true);
test_calcElasticConsts();
-} // testElasticConstsElastic
+} // test_calcElasticConstsElastic
// ----------------------------------------------------------------------
-// Test updatePropertiesElastic()
+// Test _updateStateVarsElastic()
void
-pylith::materials::TestMaxwellIsotropic3D::testUpdatePropertiesElastic(void)
-{ // testUpdatePropertiesElastic
+pylith::materials::TestMaxwellIsotropic3D::test_updateStateVarsElastic(void)
+{ // test_updateStateVarsElastic
MaxwellIsotropic3D material;
- MaxwellIsotropic3DElasticData data;
+ material.useElasticBehavior(true);
- const int numParams = data.numParameters;
- const int numParamsQuadPt = data.numParamsQuadPt;
+ const bool computeStateVars = true;
+
+ const int numLocs = _dataElastic->numLocs;
+ const int numPropsQuadPt = _dataElastic->numPropsQuadPt;
+ const int numVarsQuadPt = _dataElastic->numVarsQuadPt;
+ const int tensorSize = material.tensorSize();
+
+ double_array stress(tensorSize);
+ double_array properties(numPropsQuadPt);
+ double_array stateVars(numVarsQuadPt);
+ double_array strain(tensorSize);
+ double_array initialStress(tensorSize);
+ double_array initialStrain(tensorSize);
+
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &_dataElastic->properties[iLoc*numPropsQuadPt],
+ numPropsQuadPt*sizeof(double));
+ memcpy(&stateVars[0], &_dataElastic->stateVars[iLoc*numVarsQuadPt],
+ numVarsQuadPt*sizeof(double));
+ memcpy(&strain[0], &_dataElastic->strain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStress[0], &_dataElastic->initialStress[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStrain[0], &_dataElastic->initialStrain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
- const int tensorSize = 6;
- const int initialStateSize = 6;
- double_array totalStrain(tensorSize);
- double_array initialState(initialStateSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrain[i] = i;
- initialState[i] = 0.1*i;
- } // for
+ const double meanStrain = (strain[0] + strain[1] + strain[2]) / 3.0;
+
+ // Compute expected state variables
+ double_array stateVarsE(numVarsQuadPt);
+ const int s_totalStrain = 0;
+ const int s_viscousStrain = s_totalStrain + tensorSize;
- const double meanStrain =
- (totalStrain[0] + totalStrain[1] + totalStrain[2]) / 3.0;
+ // State variable 'total_strain' should match 'strain'
+ for (int i=0; i < tensorSize; ++i)
+ stateVarsE[s_totalStrain+i] = strain[i];
+
+ // State variable 'viscous_strain'
+ const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+ for (int i=0; i < tensorSize; ++i)
+ stateVarsE[s_viscousStrain+i] = strain[i] - diag[i]*meanStrain;
+
+ material._updateStateVars(&stateVars[0], stateVars.size(),
+ &properties[0], properties.size(),
+ &strain[0], strain.size(),
+ &initialStress[0], initialStress.size(),
+ &initialStrain[0], initialStrain.size());
- double_array parameters(numParamsQuadPt);
- double_array parametersE(numParamsQuadPt);
- for (int i=0, index=0; i < numParams; ++i)
- for (int j=0; j < data.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 pidStrainT = 4;
- const int pidVisStrain = pidStrainT + 6;
- for (int i=0; i < 3; ++i) {
- parametersE[pidStrainT+i] = totalStrain[i];
- parametersE[pidVisStrain+i] = totalStrain[i] - meanStrain;
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < numVarsQuadPt; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stateVarsE[i], stateVars[i], tolerance);
} // for
-
- for (int i=3; i < 6; ++i) {
- parametersE[pidStrainT+i] = totalStrain[i];
- parametersE[pidVisStrain+i] = totalStrain[i];
- } // for
-
- material._updateProperties(¶meters[0], numParamsQuadPt,
- &totalStrain[0], tensorSize,
- &initialState[0], initialStateSize);
+} // test_updateStateVarsElastic
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParamsQuadPt; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(parametersE[i], parameters[i], tolerance);
-} // testUpdatePropertiesElastic
-
// ----------------------------------------------------------------------
-// Test calcStressTimeDep()
+// Test _calcStressTimeDep()
void
-pylith::materials::TestMaxwellIsotropic3D::testCalcStressTimeDep(void)
-{ // testCalcStressTimeDep
+pylith::materials::TestMaxwellIsotropic3D::test_calcStressTimeDep(void)
+{ // test_calcStressTimeDep
CPPUNIT_ASSERT(0 != _matElastic);
_matElastic->useElasticBehavior(false);
@@ -174,13 +186,13 @@
double dt = 2.0e+5;
_matElastic->timeStep(dt);
test_calcStress();
-} // testCalcStressTimeDep
+} // test_calcStressTimeDep
// ----------------------------------------------------------------------
-// Test calcElasticConstsTimeDep()
+// Test _calcElasticConstsTimeDep()
void
-pylith::materials::TestMaxwellIsotropic3D::testCalcElasticConstsTimeDep(void)
-{ // testElasticConstsTimeDep
+pylith::materials::TestMaxwellIsotropic3D::test_calcElasticConstsTimeDep(void)
+{ // test_calcElasticConstsTimeDep
CPPUNIT_ASSERT(0 != _matElastic);
_matElastic->useElasticBehavior(false);
@@ -189,85 +201,91 @@
double dt = 2.0e+5;
_matElastic->timeStep(dt);
test_calcElasticConsts();
-} // testElasticConstsTimeDep
+} // test_calcElasticConstsTimeDep
// ----------------------------------------------------------------------
-// Test updatePropertiesTimeDep()
+// Test _updateStateVarsTimeDep()
void
-pylith::materials::TestMaxwellIsotropic3D::testUpdatePropertiesTimeDep(void)
-{ // testUpdatePropertiesTimeDep
+pylith::materials::TestMaxwellIsotropic3D::test_updateStateVarsTimeDep(void)
+{ // test_updateStateVarsTimeDep
MaxwellIsotropic3D material;
- MaxwellIsotropic3DTimeDepData data;
-
- const int numParams = data.numParameters;
- const int numParamsQuadPt = data.numParamsQuadPt;
-
material.useElasticBehavior(false);
const double dt = 2.0e+5;
material.timeStep(dt);
- const double viscosity = 1.0e+18;
- const double mu = 3.0e+10;
- const double maxwelltime = viscosity / mu;
-
- const int tensorSize = 6;
- const int initialStateSize = 6;
- double_array totalStrainTpdt(tensorSize);
- double_array totalStrainT(tensorSize);
- double_array visStrainT(tensorSize);
- double_array initialState(initialStateSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrainTpdt[i] = i;
- totalStrainT[i] = totalStrainTpdt[i] / 2.0;
- visStrainT[i] = totalStrainTpdt[i] / 4.0;
- initialState[i] = 0.1*i;
- } // for
- const double meanStrainTpdt =
- (totalStrainTpdt[0] + totalStrainTpdt[1] + totalStrainTpdt[2]) / 3.0;
- const double meanStrainT =
- (totalStrainT[0] + totalStrainT[1] + totalStrainT[2]) / 3.0;
+ const bool computeStateVars = true;
+
+ const int numLocs = _dataElastic->numLocs;
+ const int numPropsQuadPt = _dataElastic->numPropsQuadPt;
+ const int numVarsQuadPt = _dataElastic->numVarsQuadPt;
+ const int tensorSize = material.tensorSize();
+
+ double_array stress(tensorSize);
+ double_array properties(numPropsQuadPt);
+ double_array stateVars(numVarsQuadPt);
+ double_array strain(tensorSize);
+ double_array initialStress(tensorSize);
+ double_array initialStrain(tensorSize);
+
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &_dataElastic->properties[iLoc*numPropsQuadPt],
+ numPropsQuadPt*sizeof(double));
+ memcpy(&stateVars[0], &_dataElastic->stateVars[iLoc*numVarsQuadPt],
+ numVarsQuadPt*sizeof(double));
+ memcpy(&strain[0], &_dataElastic->strain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStress[0], &_dataElastic->initialStress[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStrain[0], &_dataElastic->initialStrain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
- const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+ const double meanStrain = (strain[0] + strain[1] + strain[2]) / 3.0;
+
+ // Compute expected state variables
+ double_array stateVarsE(numVarsQuadPt);
+ const int s_totalStrain = 0;
+ const int s_viscousStrain = s_totalStrain + tensorSize;
- double_array parameters(numParamsQuadPt);
- double_array parametersE(numParamsQuadPt);
- for (int i=0, index=0; i < numParams; ++i)
- for (int j=0; j < data.numParamValues[i]; ++j, ++index) {
- parametersE[index] = i+j;
- parameters[index] = i+j;
- } // for
+ // State variable 'total_strain' should match 'strain'
+ for (int i=0; i < tensorSize; ++i)
+ stateVarsE[s_totalStrain+i] = strain[i];
+
+ // State variable 'viscous_strain'
+ const double meanStrainTpdt =
+ (strain[0] + strain[1] + strain[2]) / 3.0;
+ const double meanStrainT =
+ (stateVars[s_totalStrain+0] +
+ stateVars[s_totalStrain+1] +
+ stateVars[s_totalStrain+2]) / 3.0;
- const int pidMaxwellTime = 3;
- const int pidStrainT = pidMaxwellTime + 1;
- const int pidVisStrain = pidStrainT + 6;
+ const int p_maxwellTime = 3;
+ const double maxwellTime = properties[p_maxwellTime];
+ const double dq = maxwellTime*(1.0-exp(-dt/maxwellTime))/dt;
+ const double expFac = exp(-dt/maxwellTime);
+ double devStrainTpdt = 0.0;
+ double devStrainT = 0.0;
- parameters[pidMaxwellTime] = maxwelltime;
- parametersE[pidMaxwellTime] = maxwelltime;
+ const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+ for (int i=0; i < tensorSize; ++i) {
+ devStrainTpdt = strain[i] - diag[i]*meanStrainTpdt;
+ devStrainT = stateVars[s_totalStrain+i] - diag[i]*meanStrainT;
+ stateVarsE[s_viscousStrain+i] =
+ expFac * stateVars[s_viscousStrain+i] +
+ dq * (devStrainTpdt - devStrainT);
+ } //for
- const double dq = maxwelltime*(1.0-exp(-dt/maxwelltime))/dt;
- const double expFac = exp(-dt/maxwelltime);
- double devStrainTpdt = 0.0;
- double devStrainT = 0.0;
+ material._updateStateVars(&stateVars[0], stateVars.size(),
+ &properties[0], properties.size(),
+ &strain[0], strain.size(),
+ &initialStress[0], initialStress.size(),
+ &initialStrain[0], initialStrain.size());
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < numVarsQuadPt; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stateVarsE[i], stateVars[i], tolerance);
+ } // for
+} // test_updateStateVarsTimeDep
- for (int i=0; i < tensorSize; ++i) {
- devStrainTpdt = totalStrainTpdt[i] - diag[i]*meanStrainTpdt;
- devStrainT = totalStrainT[i] - diag[i]*meanStrainT;
- parameters[pidStrainT+i] = totalStrainT[i];
- parameters[pidVisStrain+i] = visStrainT[i];
- parametersE[pidStrainT+i] = totalStrainTpdt[i];
- parametersE[pidVisStrain+i] =
- expFac * visStrainT[i] + dq * (devStrainTpdt - devStrainT);
- } //for
-
- material._updateProperties(¶meters[0], numParamsQuadPt,
- &totalStrainTpdt[0], tensorSize,
- &initialState[0], initialStateSize);
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParamsQuadPt; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(parametersE[i], parameters[i], tolerance);
-} // testUpdatePropertiesTimeDep
-
// ----------------------------------------------------------------------
// Test _stableTimeStepImplicit()
void
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMaxwellIsotropic3D.hh 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMaxwellIsotropic3D.hh 2009-05-01 21:38:04 UTC (rev 14833)
@@ -39,27 +39,28 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestMaxwellIsotropic3D );
+ 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( testCalcStressElastic );
- CPPUNIT_TEST( testCalcStressTimeDep );
- CPPUNIT_TEST( testCalcElasticConstsElastic );
- CPPUNIT_TEST( testCalcElasticConstsTimeDep );
- CPPUNIT_TEST( testUpdatePropertiesElastic );
- CPPUNIT_TEST( testUpdatePropertiesTimeDep );
CPPUNIT_TEST( test_stableTimeStepImplicit );
+ // Need to test Maxwell viscoelastic specific behavior.
CPPUNIT_TEST( testTimeStep );
CPPUNIT_TEST( testUseElasticBehavior );
CPPUNIT_TEST( testHasStateVars );
+ CPPUNIT_TEST( test_calcStressElastic );
+ CPPUNIT_TEST( test_calcStressTimeDep );
+ CPPUNIT_TEST( test_calcElasticConstsElastic );
+ CPPUNIT_TEST( test_calcElasticConstsTimeDep );
+ CPPUNIT_TEST( test_updateStateVarsElastic );
+ CPPUNIT_TEST( test_updateStateVarsTimeDep );
CPPUNIT_TEST_SUITE_END();
@@ -75,26 +76,26 @@
/// Test useElasticBehavior()
void testUseElasticBehavior(void);
- /// Test usesUpdateProperties()
- void testUsesUpdateProperties(void);
+ /// Test hasStateVars()
+ void testHasStateVars(void);
- /// Test calcStressElastic()
- void testCalcStressElastic(void);
+ /// Test _calcStressElastic()
+ void test_calcStressElastic(void);
- /// Test calcStressTimeDep()
- void testCalcStressTimeDep(void);
+ /// Test _calcElasticConstsElastic()
+ void test_calcElasticConstsElastic(void);
- /// Test calcElasticConstsElastic()
- void testCalcElasticConstsElastic(void);
+ /// Test _updateStateVarsElastic()
+ void test_updateStateVarsElastic(void);
- /// Test calcElasticConstsTimeDep()
- void testCalcElasticConstsTimeDep(void);
+ /// Test _calcStressTimeDep()
+ void test_calcStressTimeDep(void);
- /// Test updatePropertiesElastic()
- void testUpdatePropertiesElastic(void);
+ /// Test _calcElasticConstsTimeDep()
+ void test_calcElasticConstsTimeDep(void);
- /// Test updatePropertiesTimeDep()
- void testUpdatePropertiesTimeDep(void);
+ /// Test _updateStatevarsTimeDep()
+ void test_updateStateVarsTimeDep(void);
/// Test _stableTimeStepImplicit()
void test_stableTimeStepImplicit(void);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/ElasticIsotropic3D.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/ElasticIsotropic3D.py 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/ElasticIsotropic3D.py 2009-05-01 21:38:04 UTC (rev 14833)
@@ -74,7 +74,8 @@
self.dbProperties = numpy.array([ [densityA, vsA, vpA],
[densityB, vsB, vpB] ],
dtype=numpy.float64)
- self.properties = numpy.array([ [densityA, muA, lambdaA], [densityB, muB, lambdaB] ],
+ self.properties = numpy.array([ [densityA, muA, lambdaA],
+ [densityB, muB, lambdaB] ],
dtype=numpy.float64)
mu0 = self.pressureScale
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElastic.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElastic.py 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElastic.py 2009-05-01 21:38:04 UTC (rev 14833)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 3
+numElasticConsts = 21
+tensorSize = 6
+
# MaxwellIsotropic3DElastic class
class MaxwellIsotropic3DElastic(ElasticMaterialApp):
"""
@@ -35,81 +39,109 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 3
+ numLocs = 2
- self.numDBValues = 4
- self.numInitialStateValues = 6
- self.dbValues = ["density", "vs", "vp", "viscosity"]
- self.initialStateDBValues = ["stress_xx", "stress_yy", "stress_zz",
- "stress_xy", "stress_yz", "stress_xy"]
- self.numParameters = 6
- self.numParamValues = [1, 1, 1, 1, 6, 6]
- self.parameterNames = ["density", "mu", "lambda", "maxwellTime", "strainT", "visStrain"]
+ self.dimension = dimension
+ self.numLocs = numLocs
- self.dt = 2.0e5
+ self.dbPropertyValues = ["density", "vs", "vp", "viscosity"]
+ self.numPropertyValues = numpy.array([1, 1, 1, 1], dtype=numpy.int32)
+ self.dbStateVarValues = ["total-strain-xx",
+ "total-strain-yy",
+ "total-strain-zz",
+ "total-strain-xy",
+ "total-strain-yz",
+ "total-strain-xz",
+ "viscous-strain-xx",
+ "viscous-strain-yy",
+ "viscous-strain-zz",
+ "viscous-strain-xy",
+ "viscous-strain-yz",
+ "viscous-strain-xz",
+ ]
+ self.numStateVarValues = numpy.array([6, 6], dtype=numpy.int32)
+
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]
- initialStateA = [1.2e4, 2.3e4, 3.4e4, 4.5e4, 5.6e4, 6.7e4]
+ strainA = [1.1e-4, 1.2e-4, 1.3e-4, 1.4e-4, 1.5e-4, 1.6e-4]
+ initialStressA = [2.1e4, 2.2e4, 2.3e4, 2.4e4, 2.5e4, 2.6e4]
+ initialStrainA = [3.1e-4, 3.2e-4, 3.3e-4, 3.4e-4, 3.5e-4, 3.6e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
+ maxwellTimeA = viscosityA / muA
densityB = 2000.0
vsB = 1200.0
vpB = vsB*3**0.5
viscosityB = 1.0e18
- strainB = [1.2e-4, 2.3e-4, 3.4e-4, 4.5e-4, 5.6e-4, 6.7e-4]
- initialStateB = [2.1e4, 3.2e4, 4.3e4, 5.4e4, 6.5e4, 7.6e4]
-
- 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]
-
+ strainB = [4.1e-4, 4.2e-4, 4.3e-4, 4.4e-4, 4.5e-4, 4.6e-4]
+ initialStressB = [5.1e4, 5.2e4, 5.3e4, 5.4e4, 5.5e4, 5.6e4]
+ initialStrainB = [6.1e-4, 6.2e-4, 6.3e-4, 6.4e-4, 6.5e-4, 6.6e-4]
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]
+ maxwellTimeB = viscosityB / muB
- vecParamsA = numpy.hstack((strainTA, visStrainA))
- vecParamsB = numpy.hstack((strainTB, visStrainB))
- vecParams = numpy.vstack((vecParamsA, vecParamsB))
- scalarParams = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA],
- [densityB, muB, lambdaB, maxwellTimeB] ],
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
+
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA, viscosityA],
+ [densityB, vsB, vpB, viscosityB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA],
+ [densityB, muB, lambdaB, maxwellTimeB] ],
dtype=numpy.float64)
- self.parameterData = numpy.hstack((scalarParams, vecParams))
- self.numLocs = 2
- numElasticConsts = 21
- self.density = numpy.array([densityA, densityB],
+ # TEMPORARY, need to determine how to use initial state variables
+ self.dbStateVars = numpy.zeros( (numLocs, tensorSize+tensorSize),
+ dtype=numpy.float64)
+ self.stateVars = numpy.zeros( (numLocs, tensorSize+tensorSize),
+ dtype=numpy.float64)
+
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ time0 = self.timeScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0, maxwellTimeA/time0],
+ [densityB/density0, muB/mu0, lambdaB/mu0, maxwellTimeB/time0] ],
+ dtype=numpy.float64)
+
+ self.stateVarsNondim = self.stateVars # no scaling
+
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
+ dtype=numpy.float64)
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
+ dtype=numpy.float64)
+
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
- self.strain = numpy.array([strainA, strainB],
+ self.strain = numpy.array([strainA,
+ strainB],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 6), dtype=numpy.float64)
- self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
- dtype=numpy.float64)
+
+ self.stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
+ self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts), \
+ dtype=numpy.float64)
(self.elasticConsts[0,:], self.stress[0,:]) = \
- self._calcStress(strainA, muA, lambdaA,
- initialStateA)
+ self._calcStress(strainA, muA, lambdaA, \
+ initialStressA, initialStrainA)
(self.elasticConsts[1,:], self.stress[1,:]) = \
- self._calcStress(strainB, muB, lambdaB,
- initialStateB)
+ self._calcStress(strainB, muB, lambdaB, \
+ initialStressB, initialStrainB)
+ self.dtStableImplicit = 0.1*min(maxwellTimeA, maxwellTimeB)
return
- def _calcStress(self, strainV, muV, lambdaV, initialStateV):
+ def _calcStress(self, strainV, muV, lambdaV, initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
"""
@@ -142,7 +174,8 @@
C1313], dtype=numpy.float64)
strain = numpy.reshape(strainV, (6,1))
- initialState = numpy.reshape(initialStateV, (6,1))
+ initialStress = numpy.reshape(initialStressV, (tensorSize,1))
+ initialStrain = numpy.reshape(initialStrainV, (tensorSize,1))
elastic = numpy.array([ [C1111, C1122, C1133, C1112, C1123, C1113],
[C1122, C2222, C2233, C2212, C2223, C2213],
[C1133, C2233, C3333, C3312, C3323, C3313],
@@ -150,7 +183,7 @@
[C1123, C2223, C3323, C1223, C2323, C2313],
[C1113, C2213, C3313, C1213, C2313, C1313] ],
dtype=numpy.float64)
- stress = numpy.dot(elastic, strain) + initialState
+ stress = numpy.dot(elastic, strain-initialStrain) + initialStress
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.cc 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.cc 2009-05-01 21:38:04 UTC (rev 14833)
@@ -17,44 +17,65 @@
const int pylith::materials::MaxwellIsotropic3DElasticData::_dimension = 3;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numDBValues = 4;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numLocs = 2;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numInitialStateValues = 6;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numProperties = 4;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numParameters = 6;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numStateVars = 2;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numParamsQuadPt = 16;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numDBProperties = 4;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numLocs = 2;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numDBStateVars = 12;
-const double pylith::materials::MaxwellIsotropic3DElasticData::_dtStableImplicit = 1.00000000e+30;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numPropsQuadPt = 4;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numParamValues[] = {
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numVarsQuadPt = 12;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_densityScale = 1.00000000e+03;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_dtStableImplicit = 4.44444444e+06;
+
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numPropertyValues[] = {
1,
1,
1,
1,
+};
+
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numStateVarValues[] = {
6,
6,
};
-const char* pylith::materials::MaxwellIsotropic3DElasticData::_dbValues[] = {
+const char* pylith::materials::MaxwellIsotropic3DElasticData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
"viscosity",
};
-const char* pylith::materials::MaxwellIsotropic3DElasticData::_initialStateDBValues[] = {
-"stress_xx",
-"stress_yy",
-"stress_zz",
-"stress_xy",
-"stress_yz",
-"stress_xy",
+const char* pylith::materials::MaxwellIsotropic3DElasticData::_dbStateVarValues[] = {
+"total-strain-xx",
+"total-strain-yy",
+"total-strain-zz",
+"total-strain-xy",
+"total-strain-yz",
+"total-strain-xz",
+"viscous-strain-xx",
+"viscous-strain-yy",
+"viscous-strain-zz",
+"viscous-strain-xy",
+"viscous-strain-yz",
+"viscous-strain-xz",
};
-const double pylith::materials::MaxwellIsotropic3DElasticData::_dbData[] = {
+const double pylith::materials::MaxwellIsotropic3DElasticData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -65,26 +86,45 @@
1.00000000e+18,
};
-const double pylith::materials::MaxwellIsotropic3DElasticData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double pylith::materials::MaxwellIsotropic3DElasticData::_dbStateVars[] = {
+ 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::MaxwellIsotropic3DElasticData::_parameterData[] = {
+const double pylith::materials::MaxwellIsotropic3DElasticData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
4.44444444e+07,
+ 2.00000000e+03,
+ 2.88000000e+09,
+ 2.88000000e+09,
+ 3.47222222e+08,
+};
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_stateVars[] = {
0.00000000e+00,
0.00000000e+00,
0.00000000e+00,
@@ -97,10 +137,6 @@
0.00000000e+00,
0.00000000e+00,
0.00000000e+00,
- 2.00000000e+03,
- 2.88000000e+09,
- 2.88000000e+09,
- 3.47222222e+08,
0.00000000e+00,
0.00000000e+00,
0.00000000e+00,
@@ -115,21 +151,44 @@
0.00000000e+00,
};
-const double pylith::materials::MaxwellIsotropic3DElasticData::_initialState[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double pylith::materials::MaxwellIsotropic3DElasticData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 4.44444444e+07,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
+ 3.47222222e+08,
};
+const double pylith::materials::MaxwellIsotropic3DElasticData::_stateVarsNondim[] = {
+ 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::MaxwellIsotropic3DElasticData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -137,32 +196,32 @@
const double pylith::materials::MaxwellIsotropic3DElasticData::_strain[] = {
1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
+ 1.20000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.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,
+ 4.60000000e-04,
};
const double pylith::materials::MaxwellIsotropic3DElasticData::_stress[] = {
- 1.98120000e+07,
- 2.47730000e+07,
- 2.97340000e+07,
- 1.98450000e+07,
- 2.48060000e+07,
- 2.97670000e+07,
- 2.69940000e+06,
- 3.34400000e+06,
- 3.98860000e+06,
- 2.64600000e+06,
- 3.29060000e+06,
- 3.93520000e+06,
+ -2.24790000e+07,
+ -2.24780000e+07,
+ -2.24770000e+07,
+ -8.97600000e+06,
+ -8.97500000e+06,
+ -8.97400000e+06,
+ -2.82900000e+06,
+ -2.82800000e+06,
+ -2.82700000e+06,
+ -1.09800000e+06,
+ -1.09700000e+06,
+ -1.09600000e+06,
};
const double pylith::materials::MaxwellIsotropic3DElasticData::_elasticConsts[] = {
@@ -210,26 +269,70 @@
5.76000000e+09,
};
+const double pylith::materials::MaxwellIsotropic3DElasticData::_initialStress[] = {
+ 2.10000000e+04,
+ 2.20000000e+04,
+ 2.30000000e+04,
+ 2.40000000e+04,
+ 2.50000000e+04,
+ 2.60000000e+04,
+ 5.10000000e+04,
+ 5.20000000e+04,
+ 5.30000000e+04,
+ 5.40000000e+04,
+ 5.50000000e+04,
+ 5.60000000e+04,
+};
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_initialStrain[] = {
+ 3.10000000e-04,
+ 3.20000000e-04,
+ 3.30000000e-04,
+ 3.40000000e-04,
+ 3.50000000e-04,
+ 3.60000000e-04,
+ 6.10000000e-04,
+ 6.20000000e-04,
+ 6.30000000e-04,
+ 6.40000000e-04,
+ 6.50000000e-04,
+ 6.60000000e-04,
+};
+
+const double* pylith::materials::MaxwellIsotropic3DElasticData::_stateVarsUpdated = 0;
+
pylith::materials::MaxwellIsotropic3DElasticData::MaxwellIsotropic3DElasticData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::MaxwellIsotropic3DElasticData::~MaxwellIsotropic3DElasticData(void)
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.hh 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.hh 2009-05-01 21:38:04 UTC (rev 14833)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int _numStateVarValues[];
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char* _dbStateVarValues[];
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double _dbStateVars[];
- static const double _initialState[];
+ static const double _properties[];
+ static const double _stateVars[];
+
+ static const double _propertiesNondim[];
+
+ static const double _stateVarsNondim[];
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_maxwellisotropic3delasticdata_hh
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDep.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDep.py 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDep.py 2009-05-01 21:38:04 UTC (rev 14833)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 3
+numElasticConsts = 21
+tensorSize = 6
+
# MaxwellIsotropic3DTimeDep class
class MaxwellIsotropic3DTimeDep(ElasticMaterialApp):
"""
@@ -35,97 +39,136 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 3
+ numLocs = 2
- self.numDBValues = 4
- self.numInitialStateValues = 6
- self.dbValues = ["density", "vs", "vp" , "viscosity"]
- self.initialStateDBValues = ["stress_xx", "stress_yy", "stress_zz",
- "stress_xy", "stress_yz", "stress_xy"]
- self.numParameters = 6
- self.numParamValues = [1, 1, 1, 1, 6, 6]
- self.parameterNames = ["density", "mu", "lambda", "maxwellTime", "strainT", "visStrain"]
+ self.dimension = dimension
+ self.numLocs = numLocs
+ self.dbPropertyValues = ["density", "vs", "vp", "viscosity"]
+ self.propertyValues = ["density", "mu", "lambda", "maxwellTime"]
+ self.numPropertyValues = numpy.array([1, 1, 1, 1], dtype=numpy.int32)
+
+ self.dbStateVarValues = ["total-strain-xx",
+ "total-strain-yy",
+ "total-strain-zz",
+ "total-strain-xy",
+ "total-strain-yz",
+ "total-strain-xz",
+ "viscous-strain-xx",
+ "viscous-strain-yy",
+ "viscous-strain-zz",
+ "viscous-strain-xy",
+ "viscous-strain-yz",
+ "viscous-strain-xz",
+ ]
+ self.stateVarValues = ["total-strain", "viscous-strain"]
+ self.numStateVarValues = numpy.array([6, 6], dtype=numpy.int32)
+
self.dt = 2.0e5
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]
+ strainA = [1.1e-4, 1.2e-4, 1.3e-4, 1.4e-4, 1.5e-4, 1.6e-4]
+ initialStressA = [2.1e4, 2.2e4, 2.3e4, 2.4e4, 2.5e4, 2.6e4]
+ #initialStrainA = [3.6e-4, 3.5e-4, 3.4e-4, 3.3e-4, 3.2e-4, 3.1e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
+ maxwellTimeA = viscosityA / muA
meanStrainA = (strainA[1] + strainA[2] + strainA[3])/3.0
- initialStateA = [1.2e4, 2.3e4, 3.4e4, 4.5e4, 5.6e4, 6.7e4]
-
+
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]
+ strainB = [4.1e-4, 4.2e-4, 4.3e-4, 4.4e-4, 4.5e-4, 4.6e-4]
+ initialStressB = [5.1e4, 5.2e4, 5.3e4, 5.4e4, 5.5e4, 5.6e4]
+ #initialStrainB = [6.1e-4, 6.2e-4, 6.3e-4, 6.6e-4, 6.5e-4, 6.4e-4]
+ muB = vsB*vsB*densityB
+ lambdaB = vpB*vpB*densityB - 2.0*muB
+ maxwellTimeB = viscosityB / muB
meanStrainB = (strainB[1] + strainB[2] + strainB[3])/3.0
- initialStateB = [2.1e4, 3.2e4, 4.3e4, 5.4e4, 6.5e4, 7.6e4]
- diag = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
+ # TEMPORARY, need to determine how to use initial strain
+ initialStrainA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ initialStrainB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+
+ diag = numpy.array([1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
+ dtype=numpy.float64)
- 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
- visStrainA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
- muB = vsB*vsB*densityB
- lambdaB = vpB*vpB*densityB - 2.0*muB
- maxwellTimeB = viscosityB/muB
- visStrainB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA, viscosityA],
+ [densityB, vsB, vpB, viscosityB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA],
+ [densityB, muB, lambdaB, maxwellTimeB] ],
+ dtype=numpy.float64)
- # 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[:]
- for i in range(6):
- visStrainA[i] = strainA[i] - diag[i] * meanStrainA
- visStrainB[i] = strainB[i] - diag[i] * meanStrainB
+ # TEMPORARY, need to determine how to use initial state variables
+ self.dbStateVars = numpy.zeros( (numLocs, tensorSize),
+ dtype=numpy.float64)
- vecParamsA = numpy.hstack((strainTA, visStrainA))
- vecParamsB = numpy.hstack((strainTB, visStrainB))
- vecParams = numpy.vstack((vecParamsA, vecParamsB))
- scalarParams = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA],
- [densityB, muB, lambdaB, maxwellTimeB] ],
- dtype=numpy.float64)
- self.parameterData = numpy.hstack((scalarParams, vecParams))
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ time0 = self.timeScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0, maxwellTimeA/time0],
+ [densityB/density0, muB/mu0, lambdaB/mu0, maxwellTimeB/time0] ],
+ dtype=numpy.float64)
+
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
+ dtype=numpy.float64)
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
+ dtype=numpy.float64)
- self.numLocs = 2
- numElasticConsts = 21
- self.density = numpy.array([densityA, densityB],
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
+ # 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 (total_strain) and the total viscous strain
+ # (viscous_strain) are defined by the assigned elastic strain.
+ totalStrainA = strainA
+ totalStrainB = strainB
+ viscousStrainA = numpy.array(strainA) - diag*meanStrainA
+ viscousStrainB = numpy.array(strainB) - diag*meanStrainB
+ self.stateVars = numpy.array([ [viscousStrainA, totalStrainA],
+ [viscousStrainB, totalStrainB] ],
+ dtype=numpy.float64)
+ self.stateVarsNondim = self.stateVars # no scaling
+
self.strain = numpy.array([strainA, strainB],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 6), dtype=numpy.float64)
+ self.stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
dtype=numpy.float64)
(self.elasticConsts[0,:], self.stress[0,:]) = \
self._calcStress(strainA, muA, lambdaA,
- maxwellTimeA, strainTA,
- visStrainA, initialStateA)
+ maxwellTimeA,
+ totalStrainA, viscousStrainA,
+ initialStressA, initialStrainA)
(self.elasticConsts[1,:], self.stress[1,:]) = \
self._calcStress(strainB, muB, lambdaB,
- maxwellTimeB, strainTB,
- visStrainB, initialStateB)
+ maxwellTimeB,
+ totalStrainB, viscousStrainB,
+ initialStressB, initialStrainB)
self.dtStableImplicit = 0.1*min(maxwellTimeA, maxwellTimeB)
return
- def _calcStress(self, strainV, muV, lambdaV, maxwellTimeV, strainTV,
- visStrainV, initialStateV):
+ def _calcStress(self, strainV, muV, lambdaV, maxwellTimeV, totalStrainV,
+ viscousStrainV, initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
This assumes behavior is always viscoelastic.
@@ -133,12 +176,17 @@
import math
bulkModulus = lambdaV + 2.0 * muV/3.0
+ diag = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
- diag = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
- traceStrainT = strainTV[0] + strainTV[1] + strainTV[2]
+ totalStrainR = numpy.array(totalStrainV) - numpy.array(initialStrainV)
+ print totalStrainV
+ print initialStrainV
+ print totalStrainR
+
+ traceStrainT = totalStrainR[0] + totalStrainR[1] + totalStrainR[2]
traceStrainTpdt = strainV[0] + strainV[1] + strainV[2]
- meanStrainT = traceStrainT/3.0
- meanStrainTpdt = traceStrainTpdt/3.0
+ meanStrainT = traceStrainT / 3.0
+ meanStrainTpdt = traceStrainTpdt / 3.0
meanStressTpdt = bulkModulus * traceStrainTpdt
timeFrac = 1.0e-5
numTerms = 5
@@ -189,20 +237,22 @@
stressV = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
expFac = math.exp(-self.dt/maxwellTimeV)
+ print "expFac:",expFac
+ print "viscousStrain",viscousStrainV
elasFac = 2.0*muV
devStrainTpdt = 0.0
devStrainT = 0.0
devStressTpdt = 0.0
- visStrain = 0.0
- for iComp in range(6):
+ viscousStrain = 0.0
+ for iComp in range(tensorSize):
devStrainTpdt = strainV[iComp] - diag[iComp]*meanStrainTpdt
- devStrainT = strainTV[iComp] - diag[iComp]*meanStrainT
- visStrain = expFac*visStrainV[iComp] + dq*(devStrainTpdt - devStrainT)
- devStressTpdt = elasFac*visStrain
+ devStrainT = totalStrainR[iComp] - diag[iComp]*meanStrainT
+ viscousStrain = expFac*viscousStrainV[iComp] + dq*(devStrainTpdt - devStrainT)
+ devStressTpdt = elasFac*viscousStrain
stressV[iComp] = diag[iComp]*meanStressTpdt + devStressTpdt + \
- initialStateV[iComp]
+ initialStressV[iComp]
- stress = numpy.reshape(stressV, (6,1))
+ stress = numpy.reshape(stressV, (tensorSize,1))
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.cc 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.cc 2009-05-01 21:38:04 UTC (rev 14833)
@@ -17,44 +17,65 @@
const int pylith::materials::MaxwellIsotropic3DTimeDepData::_dimension = 3;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numDBValues = 4;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numLocs = 2;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numInitialStateValues = 6;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numProperties = 4;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numParameters = 6;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numStateVars = 2;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numParamsQuadPt = 16;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numDBProperties = 4;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numLocs = 2;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numDBStateVars = 12;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numPropsQuadPt = 4;
+
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numVarsQuadPt = 12;
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_densityScale = 1.00000000e+03;
+
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_dtStableImplicit = 4.44444444e+06;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numParamValues[] = {
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numPropertyValues[] = {
1,
1,
1,
1,
+};
+
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numStateVarValues[] = {
6,
6,
};
-const char* pylith::materials::MaxwellIsotropic3DTimeDepData::_dbValues[] = {
+const char* pylith::materials::MaxwellIsotropic3DTimeDepData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
"viscosity",
};
-const char* pylith::materials::MaxwellIsotropic3DTimeDepData::_initialStateDBValues[] = {
-"stress_xx",
-"stress_yy",
-"stress_zz",
-"stress_xy",
-"stress_yz",
-"stress_xy",
+const char* pylith::materials::MaxwellIsotropic3DTimeDepData::_dbStateVarValues[] = {
+"total-strain-xx",
+"total-strain-yy",
+"total-strain-zz",
+"total-strain-xy",
+"total-strain-yz",
+"total-strain-xz",
+"viscous-strain-xx",
+"viscous-strain-yy",
+"viscous-strain-zz",
+"viscous-strain-xy",
+"viscous-strain-yz",
+"viscous-strain-xz",
};
-const double pylith::materials::MaxwellIsotropic3DTimeDepData::_dbData[] = {
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -65,71 +86,97 @@
1.00000000e+19,
};
-const double pylith::materials::MaxwellIsotropic3DTimeDepData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_dbStateVars[] = {
+ 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::MaxwellIsotropic3DTimeDepData::_parameterData[] = {
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
4.44444444e+07,
- 1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
- 4.40000000e-04,
- 5.50000000e-04,
- 6.60000000e-04,
- -2.20000000e-04,
- -1.10000000e-04,
- 0.00000000e+00,
- 4.40000000e-04,
- 5.50000000e-04,
- 6.60000000e-04,
2.00000000e+03,
2.88000000e+09,
2.88000000e+09,
3.47222222e+09,
+};
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_stateVars[] = {
+ -2.00000000e-05,
+ -1.00000000e-05,
+ 0.00000000e+00,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 1.10000000e-04,
1.20000000e-04,
- 2.30000000e-04,
- 3.40000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ -2.00000000e-05,
+ -1.00000000e-05,
+ -5.42101086e-20,
+ 4.40000000e-04,
4.50000000e-04,
- 5.60000000e-04,
- 6.70000000e-04,
- -2.20000000e-04,
- -1.10000000e-04,
- 0.00000000e+00,
+ 4.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
+ 4.40000000e-04,
4.50000000e-04,
- 5.60000000e-04,
- 6.70000000e-04,
+ 4.60000000e-04,
};
-const double pylith::materials::MaxwellIsotropic3DTimeDepData::_initialState[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 4.44444444e+07,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
+ 3.47222222e+09,
};
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_stateVarsNondim[] = {
+ -2.00000000e-05,
+ -1.00000000e-05,
+ 0.00000000e+00,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 1.10000000e-04,
+ 1.20000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ -2.00000000e-05,
+ -1.00000000e-05,
+ -5.42101086e-20,
+ 4.40000000e-04,
+ 4.50000000e-04,
+ 4.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
+ 4.40000000e-04,
+ 4.50000000e-04,
+ 4.60000000e-04,
+};
+
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -137,32 +184,32 @@
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_strain[] = {
1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
+ 1.20000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.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,
+ 4.60000000e-04,
};
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_stress[] = {
- 1.49064499e+07,
- 1.98452250e+07,
- 2.47840000e+07,
- 1.97561002e+07,
- 2.46948752e+07,
- 2.96336503e+07,
- 2.06587299e+06,
- 2.71043649e+06,
- 3.35500000e+06,
- 2.64585071e+06,
- 3.29041421e+06,
- 3.93497772e+06,
+ 1.26250409e+07,
+ 1.30740205e+07,
+ 1.35230000e+07,
+ 6.29571369e+06,
+ 6.74469324e+06,
+ 7.19367279e+06,
+ 5.98380664e+06,
+ 6.04240332e+06,
+ 6.10100000e+06,
+ 2.58825402e+06,
+ 2.64685071e+06,
+ 2.70544739e+06,
};
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_elasticConsts[] = {
@@ -210,26 +257,70 @@
5.75983412e+09,
};
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_initialStress[] = {
+ 2.10000000e+04,
+ 2.20000000e+04,
+ 2.30000000e+04,
+ 2.40000000e+04,
+ 2.50000000e+04,
+ 2.60000000e+04,
+ 5.10000000e+04,
+ 5.20000000e+04,
+ 5.30000000e+04,
+ 5.40000000e+04,
+ 5.50000000e+04,
+ 5.60000000e+04,
+};
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_initialStrain[] = {
+ 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::MaxwellIsotropic3DTimeDepData::_stateVarsUpdated = 0;
+
pylith::materials::MaxwellIsotropic3DTimeDepData::MaxwellIsotropic3DTimeDepData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::MaxwellIsotropic3DTimeDepData::~MaxwellIsotropic3DTimeDepData(void)
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.hh 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.hh 2009-05-01 21:38:04 UTC (rev 14833)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int _numStateVarValues[];
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char* _dbStateVarValues[];
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double _dbStateVars[];
- static const double _initialState[];
+ static const double _properties[];
+ static const double _stateVars[];
+
+ static const double _propertiesNondim[];
+
+ static const double _stateVarsNondim[];
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_maxwellisotropic3dtimedepdata_hh
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/generate.sh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/generate.sh 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/generate.sh 2009-05-01 21:38:04 UTC (rev 14833)
@@ -25,16 +25,16 @@
--data.object=ElasticIsotropic3DData \
--data.parent=ElasticMaterialData
+ python MaxwellIsotropic3DElastic.py \
+ --data.namespace=pylith,materials \
+ --data.object=MaxwellIsotropic3DElasticData \
+ --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 \
-# --data.parent=ElasticMaterialData
-
# 2-D ----------------------------------------------------------------
python ElasticPlaneStrain.py \
@@ -64,10 +64,10 @@
# //////////////////////////////////////////////////////////////////////
if [ $1 == "viscoelastic" ] || [ $1 == "all" ]; then
- python GenMaxwellIsotropic3DTimeDep.py \
- --data.namespace=pylith,materials \
- --data.object=GenMaxwellIsotropic3DTimeDepData \
- --data.parent=ElasticMaterialData
+ #python GenMaxwellIsotropic3DTimeDep.py \
+ # --data.namespace=pylith,materials \
+ # --data.object=GenMaxwellIsotropic3DTimeDepData \
+ # --data.parent=ElasticMaterialData
python MaxwellIsotropic3DTimeDep.py \
--data.namespace=pylith,materials \
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestMaxwellIsotropic3D.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestMaxwellIsotropic3D.py 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestMaxwellIsotropic3D.py 2009-05-01 21:38:04 UTC (rev 14833)
@@ -24,35 +24,58 @@
Unit testing of MaxwellIsotropic3D object.
"""
+ def setUp(self):
+ """
+ Setup test subject.
+ """
+ self.material = MaxwellIsotropic3D()
+ return
+
+
def test_constructor(self):
"""
Test constructor.
"""
- from pylith.materials.MaxwellIsotropic3D import MaxwellIsotropic3D
- material = MaxwellIsotropic3D()
- material._createCppHandle()
- self.assertNotEqual(None, material.cppHandle)
+ self.assertEqual(3, self.material.dimension())
return
- def test_dimension(self):
+ def test_useElasticBehavior(self):
"""
- Test dimension().
+ Test useElasticBehavior().
"""
- material = MaxwellIsotropic3D()
- material._createCppHandle()
- self.assertEqual(3, material.dimension)
+ self.material.useElasticBehavior(False)
return
- def test_useElasticBehavior(self):
+ def testHasStateVars(self):
+ self.failUnless(self.material.hasStateVars())
+ return
+
+
+ def testStableTimeStepImplicit(self):
+ maxfloat = 1.0e+30
+ self.assertEqual(maxfloat, self.material.stableTimeStepImplicit())
+ return
+
+
+ def testTensorSize(self):
+ self.assertEqual(6, self.material.tensorSize())
+ return
+
+
+ def testNeedNewJacobian(self):
"""
- Test useElasticBehavior().
+ Test needNewJacobian().
"""
- material = MaxwellIsotropic3D()
- material._createCppHandle()
- material.useElasticBehavior(False)
+ # Default should be False.
+ self.failIf(self.material.needNewJacobian())
+
+ # Changing time step should not require new Jacobian.
+ self.material.timeStep(1.0)
+ self.material.timeStep(2.0)
+ self.failUnless(self.material.needNewJacobian())
return
+
-
# End of file
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/testmaterials.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/testmaterials.py 2009-05-01 15:38:05 UTC (rev 14832)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/testmaterials.py 2009-05-01 21:38:04 UTC (rev 14833)
@@ -71,8 +71,8 @@
from TestElasticIsotropic3D import TestElasticIsotropic3D
suite.addTest(unittest.makeSuite(TestElasticIsotropic3D))
- #from TestMaxwellIsotropic3D import TestMaxwellIsotropic3D
- #suite.addTest(unittest.makeSuite(TestMaxwellIsotropic3D))
+ from TestMaxwellIsotropic3D import TestMaxwellIsotropic3D
+ suite.addTest(unittest.makeSuite(TestMaxwellIsotropic3D))
#from TestGenMaxwellIsotropic3D import TestGenMaxwellIsotropic3D
#suite.addTest(unittest.makeSuite(TestGenMaxwellIsotropic3D))
More information about the CIG-COMMITS
mailing list