[cig-commits] r7282 - in short/3D/PyLith/trunk: . libsrc/feassemble
libsrc/materials unittests/libtests/materials
brad at geodynamics.org
brad at geodynamics.org
Sun Jun 17 23:02:55 PDT 2007
Author: brad
Date: 2007-06-17 23:02:52 -0700 (Sun, 17 Jun 2007)
New Revision: 7282
Modified:
short/3D/PyLith/trunk/TODO
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.hh
short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.icc
short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh
short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh
Log:
Added usesUpdateState() method to ElasticMaterial. Simplified useElasticBehavior implementation (use pointers to member functions instead of if statements). Fixed pointer versus reference conflict in MaxwellIsotropic3D::updateState(). Updated unit tests to reflect suite of changes.
Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/TODO 2007-06-18 06:02:52 UTC (rev 7282)
@@ -20,16 +20,42 @@
MAIN PRIORITIES (Brad)
======================================================================
+ElasticityImplicit
+ calcTotalStrain_fn_type
+ elasticityResidual_fn_type
+ elasticityJacobian_fn_type
+
+ _calcTotalStrainFn
+ _elasticityResidualFn
+ _elasticityJacobianFn
+
+ _elasticityResidual1D
+ _elasticityResidual2D
+ _elasticityResidual3D
+ _elasticityJacobian1D
+ _elasticityJacobian2D
+ _elasticityJacobian3D
+
+
add ability to have comments in meshio and spatial data files (if easy
to do, would use '#' as delimiter).
-1. Additional unit tests
-
FaultCohesiveKin
multiple cohesive cells for hex8 mesh
normal okay with rollover of fault dip?
+Create meshes for benchmarks
+
+ strike-slip
+ tet (LaGriT)
+ hex (CUBIT)
+ reverse
+ tet (LaGriT)
+ hex (CUBIT)
+
+1. Additional unit tests
+
b. ElasticityExplicit and ElasticityImplicit
i. multiple materials
ii. partially constrained DOF
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -402,7 +402,7 @@
assert(!disp.isNull());
// No need to update state if using elastic behavior
- if (_material->useElasticBehavior())
+ if (!_material->usesUpdateState())
return;
// Get cell information
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -583,7 +583,7 @@
assert(!disp.isNull());
// No need to update state if using elastic behavior
- if (_material->useElasticBehavior())
+ if (!_material->usesUpdateState())
return;
// Get cell information
@@ -656,6 +656,7 @@
} // else
_material->updateState(totalStrain);
} // for
+ _material->useElasticBehavior(false);
} // updateState
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -24,8 +24,7 @@
// ----------------------------------------------------------------------
// Default constructor.
pylith::materials::ElasticMaterial::ElasticMaterial(void) :
- _numQuadPts(0),
- _useElasticBehavior(true)
+ _numQuadPts(0)
{ // constructor
} // constructor
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -120,14 +120,16 @@
*
* @param flag True to use elastic, false to use inelastic.
*/
+ virtual
void useElasticBehavior(const bool flag);
- /** Get flag indicating whether elastic or inelastic constitutive
- * relations are used.
+ /** Get flag indicating whether material implements an empty
+ * _updateState() method.
*
- * @returns True if using elastic and false if using inelastic.
+ * @returns False if _updateState() is empty, true otherwise.
*/
- bool useElasticBehavior(void) const;
+ virtual
+ bool usesUpdateState(void) const;
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
@@ -237,12 +239,6 @@
*/
std::vector<double_array> _elasticConsts;
- /** Flag indicating whether elastic (true) or inelastic (false)
- * constitutive model should be used. Always true for purely elastic
- * materials.
- */
- bool _useElasticBehavior;
-
}; // class ElasticMaterial
#include "ElasticMaterial.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.icc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.icc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -18,15 +18,14 @@
inline
void
pylith::materials::ElasticMaterial::useElasticBehavior(const bool flag) {
- _useElasticBehavior = flag;
} // useElasticBehavior
-// Get flag indicating whether elastic or inelastic constitutive
+// Get flag indicating whether material implements an empty
inline
bool
-pylith::materials::ElasticMaterial::useElasticBehavior(void) const {
- return _useElasticBehavior;
-} // useElasticBehavior
+pylith::materials::ElasticMaterial::usesUpdateState(void) const {
+ return false;
+} // usesUpdateState
// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -60,7 +60,10 @@
// ----------------------------------------------------------------------
// Default constructor.
-pylith::materials::MaxwellIsotropic3D::MaxwellIsotropic3D(void)
+pylith::materials::MaxwellIsotropic3D::MaxwellIsotropic3D(void) :
+ _calcElasticConstsFn(&pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic),
+ _calcStressFn(&pylith::materials::MaxwellIsotropic3D::_calcStressElastic),
+ _updateStateFn(&pylith::materials::MaxwellIsotropic3D::_updateStateElastic)
{ // constructor
_dimension = 3;
} // constructor
@@ -179,12 +182,14 @@
} // _calcDensity
// ----------------------------------------------------------------------
-// Compute stress tensor at location from parameters.
+// Compute stress tensor at location from parameters as an elastic
+// material.
void
-pylith::materials::MaxwellIsotropic3D::_calcStress(double_array* const stress,
- const std::vector<double_array>& parameters,
- const double_array& totalStrain)
-{ // _calcStress
+pylith::materials::MaxwellIsotropic3D::_calcStressElastic(
+ double_array* const stress,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain)
+{ // _calcStressElastic
assert(0 != stress);
assert(_MaxwellIsotropic3D::tensorSize == stress->size());
assert(_MaxwellIsotropic3D::numParameters == parameters.size());
@@ -214,66 +219,104 @@
const double meanStrainTpdt = traceStrainTpdt/3.0;
const double s123 = lambda * traceStrainTpdt;
- if (useElasticBehavior()) {
- (*stress)[0] = s123 + 2.0*mu*e11;
- (*stress)[1] = s123 + 2.0*mu*e22;
- (*stress)[2] = s123 + 2.0*mu*e33;
- (*stress)[3] = 2.0 * mu * e12;
- (*stress)[4] = 2.0 * mu * e23;
- (*stress)[5] = 2.0 * mu * e13;
- } else {
- const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
- const double meanStressTpdt = bulkmodulus * traceStrainTpdt;
- const double meanStrainT = (parameters[_MaxwellIsotropic3D::pidStrainT][0] +
- parameters[_MaxwellIsotropic3D::pidStrainT][1] +
- parameters[_MaxwellIsotropic3D::pidStrainT][2])/3.0;
+ (*stress)[0] = s123 + 2.0*mu*e11;
+ (*stress)[1] = s123 + 2.0*mu*e22;
+ (*stress)[2] = s123 + 2.0*mu*e33;
+ (*stress)[3] = 2.0 * mu * e12;
+ (*stress)[4] = 2.0 * mu * e23;
+ (*stress)[5] = 2.0 * mu * e13;
+} // _calcStressElastic
- // The code below should probably be in a separate function since it
- // is used more than once. I should also probably cover the possibility
- // that Maxwell time is zero (although this should never happen).
- const double timeFrac = 1.0e-5;
- const int numTerms = 5;
- double dq = 0.0;
- if(maxwelltime < timeFrac*_dt) {
- double fSign = 1.0;
- double factorial = 1.0;
- double fraction = 1.0;
- dq = 1.0;
- for (int iTerm=2; iTerm <= numTerms; ++iTerm) {
- factorial *= iTerm;
- fSign *= -1.0;
- fraction *= _dt/maxwelltime;
- dq += fSign*fraction/factorial;
- } // for
- } else
- dq = maxwelltime*(1.0-exp(-_dt/maxwelltime))/_dt;
- const double expFac = exp(-_dt/maxwelltime);
- const double elasFac = 2.0*mu;
- double devStrainTpdt = 0.0;
- double devStrainT = 0.0;
- double devStressTpdt = 0.0;
- double visStrain = 0.0;
- for (int iComp=0; iComp < _MaxwellIsotropic3D::tensorSize; ++iComp) {
- devStrainTpdt = totalStrain[iComp] - diag[iComp]*meanStrainTpdt;
- devStrainT = parameters[_MaxwellIsotropic3D::pidStrainT][iComp] -
- diag[iComp]*meanStrainT;
- visStrain = expFac*parameters[_MaxwellIsotropic3D::pidVisStrain][iComp] +
- dq*(devStrainTpdt - devStrainT);
- devStressTpdt = elasFac*visStrain;
- // Later I will want to put in initial stresses.
- (*stress)[iComp] =diag[iComp]*meanStressTpdt+devStressTpdt;
+// ----------------------------------------------------------------------
+// Compute stress tensor at location from parameters as a viscoelastic
+// material.
+void
+pylith::materials::MaxwellIsotropic3D::_calcStressViscoelastic(
+ double_array* const stress,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain)
+{ // _calcStressViscoelastic
+ assert(0 != stress);
+ assert(_MaxwellIsotropic3D::tensorSize == stress->size());
+ assert(_MaxwellIsotropic3D::numParameters == parameters.size());
+ assert(_MaxwellIsotropic3D::tensorSize == totalStrain.size());
+ assert(1 == parameters[_MaxwellIsotropic3D::pidDensity].size());
+ assert(1 == parameters[_MaxwellIsotropic3D::pidMu].size());
+ assert(1 == parameters[_MaxwellIsotropic3D::pidLambda].size());
+ assert(6 == parameters[_MaxwellIsotropic3D::pidStrainT].size());
+ assert(6 == parameters[_MaxwellIsotropic3D::pidVisStrain].size());
+
+ const double density = parameters[_MaxwellIsotropic3D::pidDensity][0];
+ const double mu = parameters[_MaxwellIsotropic3D::pidMu][0];
+ const double lambda = parameters[_MaxwellIsotropic3D::pidLambda][0];
+ const double maxwelltime = parameters[_MaxwellIsotropic3D::pidMaxwellTime][0];
+
+ const double lambda2mu = lambda + 2.0 * mu;
+ const double bulkmodulus = lambda + 2.0 * mu/3.0;
+
+ 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];
+
+ const double traceStrainTpdt = e11 + e22 + e33;
+ const double meanStrainTpdt = traceStrainTpdt/3.0;
+ const double s123 = lambda * traceStrainTpdt;
+
+ const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+ const double meanStressTpdt = bulkmodulus * traceStrainTpdt;
+ const double meanStrainT = (parameters[_MaxwellIsotropic3D::pidStrainT][0] +
+ parameters[_MaxwellIsotropic3D::pidStrainT][1] +
+ parameters[_MaxwellIsotropic3D::pidStrainT][2])/3.0;
+
+ // The code below should probably be in a separate function since it
+ // is used more than once. I should also probably cover the possibility
+ // that Maxwell time is zero (although this should never happen).
+ const double timeFrac = 1.0e-5;
+ const int numTerms = 5;
+ double dq = 0.0;
+ if(maxwelltime < timeFrac*_dt) {
+ double fSign = 1.0;
+ double factorial = 1.0;
+ double fraction = 1.0;
+ dq = 1.0;
+ for (int iTerm=2; iTerm <= numTerms; ++iTerm) {
+ factorial *= iTerm;
+ fSign *= -1.0;
+ fraction *= _dt/maxwelltime;
+ dq += fSign*fraction/factorial;
} // for
- } //else
+ } else
+ dq = maxwelltime*(1.0-exp(-_dt/maxwelltime))/_dt;
+
+ const double expFac = exp(-_dt/maxwelltime);
+ const double elasFac = 2.0*mu;
+ double devStrainTpdt = 0.0;
+ double devStrainT = 0.0;
+ double devStressTpdt = 0.0;
+ double visStrain = 0.0;
+ for (int iComp=0; iComp < _MaxwellIsotropic3D::tensorSize; ++iComp) {
+ devStrainTpdt = totalStrain[iComp] - diag[iComp]*meanStrainTpdt;
+ devStrainT = parameters[_MaxwellIsotropic3D::pidStrainT][iComp] -
+ diag[iComp]*meanStrainT;
+ visStrain = expFac*parameters[_MaxwellIsotropic3D::pidVisStrain][iComp] +
+ dq*(devStrainTpdt - devStrainT);
+ devStressTpdt = elasFac*visStrain;
+ // Later I will want to put in initial stresses.
+ (*stress)[iComp] =diag[iComp]*meanStressTpdt+devStressTpdt;
+ } // for
} // _calcStress
// ----------------------------------------------------------------------
// Compute derivative of elasticity matrix at location from parameters.
void
-pylith::materials::MaxwellIsotropic3D::_calcElasticConsts(
- double_array* const elasticConsts,
- const std::vector<double_array>& parameters,
- const double_array& totalStrain)
-{ // _calcElasticConsts
+pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic(
+ double_array* const elasticConsts,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain)
+{ // _calcElasticConstsElastic
assert(0 != elasticConsts);
assert(_MaxwellIsotropic3D::numElasticConsts == elasticConsts->size());
assert(_MaxwellIsotropic3D::numParameters == parameters.size());
@@ -287,86 +330,43 @@
const double lambda2mu = lambda + 2.0 * mu;
const double bulkmodulus = lambda + 2.0 * mu/3.0;
- if (useElasticBehavior()) {
- (*elasticConsts)[ 0] = lambda2mu; // C1111
- (*elasticConsts)[ 1] = lambda; // C1122
- (*elasticConsts)[ 2] = lambda; // C1133
- (*elasticConsts)[ 3] = 0; // C1112
- (*elasticConsts)[ 4] = 0; // C1123
- (*elasticConsts)[ 5] = 0; // C1113
- (*elasticConsts)[ 6] = lambda2mu; // C2222
- (*elasticConsts)[ 7] = lambda; // C2233
- (*elasticConsts)[ 8] = 0; // C2212
- (*elasticConsts)[ 9] = 0; // C2223
- (*elasticConsts)[10] = 0; // C2213
- (*elasticConsts)[11] = lambda2mu; // C3333
- (*elasticConsts)[12] = 0; // C3312
- (*elasticConsts)[13] = 0; // C3323
- (*elasticConsts)[14] = 0; // C3313
- (*elasticConsts)[15] = 2.0 * mu; // C1212
- (*elasticConsts)[16] = 0; // C1223
- (*elasticConsts)[17] = 0; // C1213
- (*elasticConsts)[18] = 2.0 * mu; // C2323
- (*elasticConsts)[19] = 0; // C2313
- (*elasticConsts)[20] = 2.0 * mu; // C1313
- } else {
- const double timeFrac = 1.0e-5;
- const int numTerms = 5;
- double dq = 0.0;
- if(maxwelltime < timeFrac*_dt) {
- double fSign = 1.0;
- double factorial = 1.0;
- double fraction = 1.0;
- dq = 1.0;
- for (int iTerm=2; iTerm <= numTerms; ++iTerm) {
- factorial *= iTerm;
- fSign *= -1.0;
- fraction *= _dt/maxwelltime;
- dq += fSign*fraction/factorial;
- } // for
- } else
- dq = maxwelltime*(1.0-exp(-_dt/maxwelltime))/_dt;
- const double visFac = mu*dq/3.0;
- (*elasticConsts)[ 0] = bulkmodulus + 4.0*visFac; // C1111
- (*elasticConsts)[ 1] = bulkmodulus - 2.0*visFac; // C1122
- (*elasticConsts)[ 2] = (*elasticConsts)[1]; // C1133
- (*elasticConsts)[ 3] = 0; // C1112
- (*elasticConsts)[ 4] = 0; // C1123
- (*elasticConsts)[ 5] = 0; // C1113
- (*elasticConsts)[ 6] = (*elasticConsts)[0]; // C2222
- (*elasticConsts)[ 7] = (*elasticConsts)[1]; // C2233
- (*elasticConsts)[ 8] = 0; // C2212
- (*elasticConsts)[ 9] = 0; // C2223
- (*elasticConsts)[10] = 0; // C2213
- (*elasticConsts)[11] = (*elasticConsts)[0]; // C3333
- (*elasticConsts)[12] = 0; // C3312
- (*elasticConsts)[13] = 0; // C3323
- (*elasticConsts)[14] = 0; // C3313
- (*elasticConsts)[15] = 3.0 * visFac; // C1212
- (*elasticConsts)[16] = 0; // C1223
- (*elasticConsts)[17] = 0; // C1213
- (*elasticConsts)[18] = (*elasticConsts)[15]; // C2323
- (*elasticConsts)[19] = 0; // C2313
- (*elasticConsts)[20] = (*elasticConsts)[15]; // C1313
- } // else
-
-} // _calcElasticConsts
+ (*elasticConsts)[ 0] = lambda2mu; // C1111
+ (*elasticConsts)[ 1] = lambda; // C1122
+ (*elasticConsts)[ 2] = lambda; // C1133
+ (*elasticConsts)[ 3] = 0; // C1112
+ (*elasticConsts)[ 4] = 0; // C1123
+ (*elasticConsts)[ 5] = 0; // C1113
+ (*elasticConsts)[ 6] = lambda2mu; // C2222
+ (*elasticConsts)[ 7] = lambda; // C2233
+ (*elasticConsts)[ 8] = 0; // C2212
+ (*elasticConsts)[ 9] = 0; // C2223
+ (*elasticConsts)[10] = 0; // C2213
+ (*elasticConsts)[11] = lambda2mu; // C3333
+ (*elasticConsts)[12] = 0; // C3312
+ (*elasticConsts)[13] = 0; // C3323
+ (*elasticConsts)[14] = 0; // C3313
+ (*elasticConsts)[15] = 2.0 * mu; // C1212
+ (*elasticConsts)[16] = 0; // C1223
+ (*elasticConsts)[17] = 0; // C1213
+ (*elasticConsts)[18] = 2.0 * mu; // C2323
+ (*elasticConsts)[19] = 0; // C2313
+ (*elasticConsts)[20] = 2.0 * mu; // C1313
+} // _calcElasticConstsElastic
// ----------------------------------------------------------------------
-// Update state variables.
+// Compute derivative of elasticity matrix at location from parameters
+// as an elastic material.
void
-pylith::materials::MaxwellIsotropic3D::_updateState(
- std::vector<double_array>& parameters,
- const double_array& totalStrain)
-{ // _updateState
+pylith::materials::MaxwellIsotropic3D::_calcElasticConstsViscoelastic(
+ double_array* const elasticConsts,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain)
+{ // _calcElasticConstsViscoelastic
+ assert(0 != elasticConsts);
+ assert(_MaxwellIsotropic3D::numElasticConsts == elasticConsts->size());
assert(_MaxwellIsotropic3D::numParameters == parameters.size());
assert(_MaxwellIsotropic3D::tensorSize == totalStrain.size());
- assert(1 == parameters[_MaxwellIsotropic3D::pidDensity].size());
- assert(1 == parameters[_MaxwellIsotropic3D::pidMu].size());
- assert(1 == parameters[_MaxwellIsotropic3D::pidLambda].size());
- assert(6 == parameters[_MaxwellIsotropic3D::pidStrainT].size());
- assert(6 == parameters[_MaxwellIsotropic3D::pidVisStrain].size());
-
+
const double density = parameters[_MaxwellIsotropic3D::pidDensity][0];
const double mu = parameters[_MaxwellIsotropic3D::pidMu][0];
const double lambda = parameters[_MaxwellIsotropic3D::pidLambda][0];
@@ -375,6 +375,72 @@
const double lambda2mu = lambda + 2.0 * mu;
const double bulkmodulus = lambda + 2.0 * mu/3.0;
+ const double timeFrac = 1.0e-5;
+ const int numTerms = 5;
+ double dq = 0.0;
+ if(maxwelltime < timeFrac*_dt) {
+ double fSign = 1.0;
+ double factorial = 1.0;
+ double fraction = 1.0;
+ dq = 1.0;
+ for (int iTerm=2; iTerm <= numTerms; ++iTerm) {
+ factorial *= iTerm;
+ fSign *= -1.0;
+ fraction *= _dt/maxwelltime;
+ dq += fSign*fraction/factorial;
+ } // for
+ } else
+ dq = maxwelltime*(1.0-exp(-_dt/maxwelltime))/_dt;
+
+ const double visFac = mu*dq/3.0;
+ (*elasticConsts)[ 0] = bulkmodulus + 4.0*visFac; // C1111
+ (*elasticConsts)[ 1] = bulkmodulus - 2.0*visFac; // C1122
+ (*elasticConsts)[ 2] = (*elasticConsts)[1]; // C1133
+ (*elasticConsts)[ 3] = 0; // C1112
+ (*elasticConsts)[ 4] = 0; // C1123
+ (*elasticConsts)[ 5] = 0; // C1113
+ (*elasticConsts)[ 6] = (*elasticConsts)[0]; // C2222
+ (*elasticConsts)[ 7] = (*elasticConsts)[1]; // C2233
+ (*elasticConsts)[ 8] = 0; // C2212
+ (*elasticConsts)[ 9] = 0; // C2223
+ (*elasticConsts)[10] = 0; // C2213
+ (*elasticConsts)[11] = (*elasticConsts)[0]; // C3333
+ (*elasticConsts)[12] = 0; // C3312
+ (*elasticConsts)[13] = 0; // C3323
+ (*elasticConsts)[14] = 0; // C3313
+ (*elasticConsts)[15] = 3.0 * visFac; // C1212
+ (*elasticConsts)[16] = 0; // C1223
+ (*elasticConsts)[17] = 0; // C1213
+ (*elasticConsts)[18] = (*elasticConsts)[15]; // C2323
+ (*elasticConsts)[19] = 0; // C2313
+ (*elasticConsts)[20] = (*elasticConsts)[15]; // C1313
+} // _calcElasticConstsViscoelastic
+
+// ----------------------------------------------------------------------
+// Update state variables.
+void
+pylith::materials::MaxwellIsotropic3D::_updateStateElastic(
+ std::vector<double_array>* parameters,
+ const double_array& totalStrain)
+{ // _updateStateElastic
+ assert(0 != parameters);
+
+ assert(_MaxwellIsotropic3D::numParameters == parameters->size());
+ assert(_MaxwellIsotropic3D::tensorSize == totalStrain.size());
+ assert(1 == (*parameters)[_MaxwellIsotropic3D::pidDensity].size());
+ assert(1 == (*parameters)[_MaxwellIsotropic3D::pidMu].size());
+ assert(1 == (*parameters)[_MaxwellIsotropic3D::pidLambda].size());
+ assert(6 == (*parameters)[_MaxwellIsotropic3D::pidStrainT].size());
+ assert(6 == (*parameters)[_MaxwellIsotropic3D::pidVisStrain].size());
+
+ const double density = (*parameters)[_MaxwellIsotropic3D::pidDensity][0];
+ const double mu = (*parameters)[_MaxwellIsotropic3D::pidMu][0];
+ const double lambda = (*parameters)[_MaxwellIsotropic3D::pidLambda][0];
+ const double maxwelltime = (*parameters)[_MaxwellIsotropic3D::pidMaxwellTime][0];
+
+ const double lambda2mu = lambda + 2.0 * mu;
+ const double bulkmodulus = lambda + 2.0 * mu/3.0;
+
const double e11 = totalStrain[0];
const double e22 = totalStrain[1];
const double e33 = totalStrain[2];
@@ -385,52 +451,88 @@
const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
- if (useElasticBehavior()) {
- for (int iComp=0; iComp < _MaxwellIsotropic3D::tensorSize; ++iComp) {
- parameters[_MaxwellIsotropic3D::pidStrainT][iComp] = totalStrain[iComp];
- parameters[_MaxwellIsotropic3D::pidVisStrain][iComp] =
- totalStrain[iComp] - diag[iComp]*meanStrainTpdt;
- } // for
- useElasticBehavior(false);
- } else {
- const double meanStrainT = parameters[_MaxwellIsotropic3D::pidStrainT][0] +
- parameters[_MaxwellIsotropic3D::pidStrainT][1] +
- parameters[_MaxwellIsotropic3D::pidStrainT][2];
+ for (int iComp=0; iComp < _MaxwellIsotropic3D::tensorSize; ++iComp) {
+ (*parameters)[_MaxwellIsotropic3D::pidStrainT][iComp] = totalStrain[iComp];
+ (*parameters)[_MaxwellIsotropic3D::pidVisStrain][iComp] =
+ totalStrain[iComp] - diag[iComp]*meanStrainTpdt;
+ } // for
+} // _calcStressElastic
- // The code below should probably be in a separate function since it
- // is used more than once. I should also probably cover the possibility
- // that Maxwell time is zero (although this should never happen).
- const double timeFrac = 1.0e-5;
- const int numTerms = 5;
- double dq = 0.0;
- if(maxwelltime < timeFrac*_dt) {
- double fSign = 1.0;
- double factorial = 1.0;
- double fraction = 1.0;
- dq = 1.0;
- for (int iTerm=2; iTerm <= numTerms; ++iTerm) {
- factorial *= iTerm;
- fSign *= -1.0;
- fraction *= _dt/maxwelltime;
- dq += fSign*fraction/factorial;
- } // for
- } else
- dq = maxwelltime*(1.0-exp(-_dt/maxwelltime))/_dt;
- const double expFac = exp(-_dt/maxwelltime);
- double devStrainTpdt = 0.0;
- double devStrainT = 0.0;
- double visStrain = 0.0;
- for (int iComp=0; iComp < _MaxwellIsotropic3D::tensorSize; ++iComp) {
- devStrainTpdt = totalStrain[iComp] - diag[iComp]*meanStrainTpdt;
- devStrainT = parameters[_MaxwellIsotropic3D::pidStrainT][iComp] -
- diag[iComp]*meanStrainT;
- visStrain = expFac*parameters[_MaxwellIsotropic3D::pidVisStrain][iComp] +
- dq*(devStrainTpdt - devStrainT);
- parameters[_MaxwellIsotropic3D::pidVisStrain][iComp] = visStrain;
- parameters[_MaxwellIsotropic3D::pidStrainT][iComp] = totalStrain[iComp];
+// ----------------------------------------------------------------------
+// Update state variables.
+void
+pylith::materials::MaxwellIsotropic3D::_updateStateViscoelastic(
+ std::vector<double_array>* parameters,
+ const double_array& totalStrain)
+{ // _updateStateViscoelastic
+ assert(0 != parameters);
+
+ assert(_MaxwellIsotropic3D::numParameters == parameters->size());
+ assert(_MaxwellIsotropic3D::tensorSize == totalStrain.size());
+ assert(1 == (*parameters)[_MaxwellIsotropic3D::pidDensity].size());
+ assert(1 == (*parameters)[_MaxwellIsotropic3D::pidMu].size());
+ assert(1 == (*parameters)[_MaxwellIsotropic3D::pidLambda].size());
+ assert(6 == (*parameters)[_MaxwellIsotropic3D::pidStrainT].size());
+ assert(6 == (*parameters)[_MaxwellIsotropic3D::pidVisStrain].size());
+
+ const double density = (*parameters)[_MaxwellIsotropic3D::pidDensity][0];
+ const double mu = (*parameters)[_MaxwellIsotropic3D::pidMu][0];
+ const double lambda = (*parameters)[_MaxwellIsotropic3D::pidLambda][0];
+ const double maxwelltime = (*parameters)[_MaxwellIsotropic3D::pidMaxwellTime][0];
+
+ const double lambda2mu = lambda + 2.0 * mu;
+ const double bulkmodulus = lambda + 2.0 * mu/3.0;
+
+ const double e11 = totalStrain[0];
+ const double e22 = totalStrain[1];
+ const double e33 = totalStrain[2];
+
+ const double traceStrainTpdt = e11 + e22 + e33;
+ const double meanStrainTpdt = traceStrainTpdt/3.0;
+ const double s123 = lambda * traceStrainTpdt;
+
+ const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+
+ const double meanStrainT =
+ (*parameters)[_MaxwellIsotropic3D::pidStrainT][0] +
+ (*parameters)[_MaxwellIsotropic3D::pidStrainT][1] +
+ (*parameters)[_MaxwellIsotropic3D::pidStrainT][2];
+
+ // The code below should probably be in a separate function since it
+ // is used more than once. I should also probably cover the possibility
+ // that Maxwell time is zero (although this should never happen).
+ const double timeFrac = 1.0e-5;
+ const int numTerms = 5;
+ double dq = 0.0;
+ if(maxwelltime < timeFrac*_dt) {
+ double fSign = 1.0;
+ double factorial = 1.0;
+ double fraction = 1.0;
+ dq = 1.0;
+ for (int iTerm=2; iTerm <= numTerms; ++iTerm) {
+ factorial *= iTerm;
+ fSign *= -1.0;
+ fraction *= _dt/maxwelltime;
+ dq += fSign*fraction/factorial;
} // for
- } //else
-} // _calcStress
+ } else
+ dq = maxwelltime*(1.0-exp(-_dt/maxwelltime))/_dt;
+ const double expFac = exp(-_dt/maxwelltime);
+ double devStrainTpdt = 0.0;
+ double devStrainT = 0.0;
+ double visStrain = 0.0;
+ for (int iComp=0; iComp < _MaxwellIsotropic3D::tensorSize; ++iComp) {
+ devStrainTpdt = totalStrain[iComp] - diag[iComp]*meanStrainTpdt;
+ devStrainT = (*parameters)[_MaxwellIsotropic3D::pidStrainT][iComp] -
+ diag[iComp] * meanStrainT;
+ visStrain = expFac *
+ (*parameters)[_MaxwellIsotropic3D::pidVisStrain][iComp] +
+ dq * (devStrainTpdt - devStrainT);
+ (*parameters)[_MaxwellIsotropic3D::pidVisStrain][iComp] = visStrain;
+ (*parameters)[_MaxwellIsotropic3D::pidStrainT][iComp] = totalStrain[iComp];
+ } // for
+} // _calcStressViscoelastic
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -55,6 +55,19 @@
*/
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);
+
+ /** Get flag indicating whether material implements an empty
+ * _updateState() method.
+ *
+ * @returns False if _updateState() is empty, true otherwise.
+ */
+ bool usesUpdateState(void) const;
+
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
@@ -148,9 +161,90 @@
* @param parameters Parameters at locations.
* @param totalStrain Total strain at locations.
*/
- void _updateState(std::vector<double_array>& parameters,
+ void _updateState(std::vector<double_array>* parameters,
const double_array& totalStrain);
+ // PRIVATE TYPEDEFS ///////////////////////////////////////////////////
+private :
+
+ /// Member prototype for _calcStress()
+ typedef void (pylith::materials::MaxwellIsotropic3D::*calcStress_fn_type)
+ (double_array* const,
+ const std::vector<double_array>&,
+ const double_array&);
+
+ /// Member prototype for _calcElasticConsts()
+ typedef void (pylith::materials::MaxwellIsotropic3D::*calcElasticConsts_fn_type)
+ (double_array* const,
+ const std::vector<double_array>&,
+ const double_array&);
+
+ /// Member prototype for _updateState()
+ typedef void (pylith::materials::MaxwellIsotropic3D::*updateState_fn_type)
+ (std::vector<double_array>* const,
+ const double_array&);
+
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Compute stress tensor from parameters as an elastic material.
+ *
+ * @param stress Array for stress tensor
+ * @param parameters Parameters at locations.
+ * @param totalStrain Total strain at locations.
+ */
+ void _calcStressElastic(double_array* const stress,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain);
+
+ /** Compute stress tensor from parameters as an viscoelastic material.
+ *
+ * @param stress Array for stress tensor
+ * @param parameters Parameters at locations.
+ * @param totalStrain Total strain at locations.
+ */
+ void _calcStressViscoelastic(double_array* const stress,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain);
+
+ /** Compute derivatives of elasticity matrix from parameters as an
+ * elastic material.
+ *
+ * @param elasticConsts Array for elastic constants
+ * @param parameters Parameters at locations.
+ * @param totalStrain Total strain at locations.
+ */
+ void _calcElasticConstsElastic(double_array* const elasticConsts,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain);
+
+ /** Compute derivatives of elasticity matrix from parameters as a
+ * viscoelastic material.
+ *
+ * @param elasticConsts Array for elastic constants
+ * @param parameters Parameters at locations.
+ * @param totalStrain Total strain at locations.
+ */
+ void _calcElasticConstsViscoelastic(double_array* const elasticConsts,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain);
+
+ /** Update state variables after solve as an elastic material.
+ *
+ * @param parameters Parameters at locations.
+ * @param totalStrain Total strain at locations.
+ */
+ void _updateStateElastic(std::vector<double_array>* parameters,
+ const double_array& totalStrain);
+
+ /** Update state variables after solve as a viscoelastic material.
+ *
+ * @param parameters Parameters at locations.
+ * @param totalStrain Total strain at locations.
+ */
+ void _updateStateViscoelastic(std::vector<double_array>* parameters,
+ const double_array& totalStrain);
+
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
@@ -160,7 +254,18 @@
/// Not implemented
const MaxwellIsotropic3D& operator=(const MaxwellIsotropic3D& m);
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+ /// Method to use for _calcElasticConsts().
+ calcElasticConsts_fn_type _calcElasticConstsFn;
+
+ /// Method to use for _calcStress().
+ calcStress_fn_type _calcStressFn;
+
+ /// Method to use for _updateState().
+ updateState_fn_type _updateStateFn;
+
}; // class MaxwellIsotropic3D
#include "MaxwellIsotropic3D.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -14,6 +14,10 @@
#error "MaxwellIsotropic3D.icc can only be included from MaxwellIsotropic3D.hh"
#endif
+#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
+
+#include <assert.h> // USES assert()
+
// Set current time step.
inline
void
@@ -24,5 +28,65 @@
_dt = dt;
} // timeStep
+// Set whether elastic or inelastic constitutive relations are used.
+inline
+void
+pylith::materials::MaxwellIsotropic3D::useElasticBehavior(const bool flag) {
+ if (flag) {
+ _calcStressFn =
+ &pylith::materials::MaxwellIsotropic3D::_calcStressElastic;
+ _calcElasticConstsFn =
+ &pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic;
+ _updateStateFn =
+ &pylith::materials::MaxwellIsotropic3D::_updateStateElastic;
+ } else {
+ _calcStressFn =
+ &pylith::materials::MaxwellIsotropic3D::_calcStressViscoelastic;
+ _calcElasticConstsFn =
+ &pylith::materials::MaxwellIsotropic3D::_calcElasticConstsViscoelastic;
+ _updateStateFn =
+ &pylith::materials::MaxwellIsotropic3D::_updateStateViscoelastic;
+ } // if/else
+} // useElasticBehavior
+// Get flag indicating whether material implements an empty
+inline
+bool
+pylith::materials::MaxwellIsotropic3D::usesUpdateState(void) const {
+ return true;
+} // usesUpdateState
+
+// Compute stress tensor from parameters.
+inline
+void
+pylith::materials::MaxwellIsotropic3D::_calcStress(
+ double_array* const stress,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain) {
+ assert(0 != _calcStressFn);
+ CALL_MEMBER_FN(*this, _calcStressFn)(stress, parameters, totalStrain);
+} // _calcStress
+
+// Compute derivatives of elasticity matrix from parameters.
+inline
+void
+pylith::materials::MaxwellIsotropic3D::_calcElasticConsts(
+ double_array* const elasticConsts,
+ const std::vector<double_array>& parameters,
+ const double_array& totalStrain) {
+ assert(0 != _calcElasticConstsFn);
+ CALL_MEMBER_FN(*this, _calcElasticConstsFn)
+ (elasticConsts, parameters, totalStrain);
+} // _calcElasticConsts
+
+// Update state variables after solve.
+inline
+void
+pylith::materials::MaxwellIsotropic3D::_updateState(
+ std::vector<double_array>* parameters,
+ const double_array& totalStrain) {
+ assert(0 != _updateStateFn);
+ CALL_MEMBER_FN(*this, _updateStateFn)(parameters, totalStrain);
+} // _updateState
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -22,6 +22,15 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestElasticIsotropic3D );
// ----------------------------------------------------------------------
+// Test usesUpdateState()
+void
+pylith::materials::TestElasticIsotropic3D::testUsesUpdateState(void)
+{ // testUsesUpdateState
+ ElasticIsotropic3D material;
+ CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateState());
+} // testUsesUpdateState
+
+// ----------------------------------------------------------------------
// Test DBValues()
void
pylith::materials::TestElasticIsotropic3D::testDBValues(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -38,6 +38,8 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticIsotropic3D );
+
+ CPPUNIT_TEST( testUsesUpdateState );
CPPUNIT_TEST( testDBToParameters );
CPPUNIT_TEST( testDBValues );
CPPUNIT_TEST( testParameters );
@@ -45,11 +47,15 @@
CPPUNIT_TEST( testCalcStress );
CPPUNIT_TEST( testCalcElasticConsts );
CPPUNIT_TEST( testUpdateState );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
+ /// Test usesUpdateState()
+ void testUsesUpdateState();
+
/// Test DBValues()
void testDBValues(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -25,22 +25,6 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestElasticMaterial );
// ----------------------------------------------------------------------
-// Test useElasticBehavior()
-void
-pylith::materials::TestElasticMaterial::testUseElasticBehavior(void)
-{ // testUseElasticBehavior
- ElasticIsotropic3D material;
-
- bool flag = true;
- material.useElasticBehavior(flag);
- CPPUNIT_ASSERT_EQUAL(flag, material._useElasticBehavior);
-
- flag = false;
- material.useElasticBehavior(flag);
- CPPUNIT_ASSERT_EQUAL(flag, material._useElasticBehavior);
-} // testUseElasticBehavior
-
-// ----------------------------------------------------------------------
// Test calcDensity()
void
pylith::materials::TestElasticMaterial::testCalcDensity(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -38,18 +38,16 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticMaterial );
- CPPUNIT_TEST( testUseElasticBehavior );
+
CPPUNIT_TEST( testCalcDensity );
CPPUNIT_TEST( testCalcStress );
CPPUNIT_TEST( testCalcDerivElastic );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
- /// Test useElasticBehavior()
- void testUseElasticBehavior(void);
-
/// Test calcDensity()
void testCalcDensity(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -22,6 +22,15 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestElasticPlaneStrain );
// ----------------------------------------------------------------------
+// Test usesUpdateState()
+void
+pylith::materials::TestElasticPlaneStrain::testUsesUpdateState(void)
+{ // testUsesUpdateState
+ ElasticPlaneStrain material;
+ CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateState());
+} // testUsesUpdateState
+
+// ----------------------------------------------------------------------
// Test DBValues()
void
pylith::materials::TestElasticPlaneStrain::testDBValues(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -38,6 +38,8 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticPlaneStrain );
+
+ CPPUNIT_TEST( testUsesUpdateState );
CPPUNIT_TEST( testDBToParameters );
CPPUNIT_TEST( testDBValues );
CPPUNIT_TEST( testParameters );
@@ -45,11 +47,15 @@
CPPUNIT_TEST( testCalcStress );
CPPUNIT_TEST( testCalcElasticConsts );
CPPUNIT_TEST( testUpdateState );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
+ /// Test usesUpdateState()
+ void testUsesUpdateState();
+
/// Test DBValues()
void testDBValues(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -22,6 +22,15 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestElasticPlaneStress );
// ----------------------------------------------------------------------
+// Test usesUpdateState()
+void
+pylith::materials::TestElasticPlaneStress::testUsesUpdateState(void)
+{ // testUsesUpdateState
+ ElasticPlaneStress material;
+ CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateState());
+} // testUsesUpdateState
+
+// ----------------------------------------------------------------------
// Test DBValues()
void
pylith::materials::TestElasticPlaneStress::testDBValues(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -38,6 +38,8 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticPlaneStress );
+
+ CPPUNIT_TEST( testUsesUpdateState );
CPPUNIT_TEST( testDBToParameters );
CPPUNIT_TEST( testDBValues );
CPPUNIT_TEST( testParameters );
@@ -45,11 +47,15 @@
CPPUNIT_TEST( testCalcStress );
CPPUNIT_TEST( testCalcElasticConsts );
CPPUNIT_TEST( testUpdateState );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
+ /// Test usesUpdateState()
+ void testUsesUpdateState();
+
/// Test DBValues()
void testDBValues(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -22,6 +22,15 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestElasticStrain1D );
// ----------------------------------------------------------------------
+// Test usesUpdateState()
+void
+pylith::materials::TestElasticStrain1D::testUsesUpdateState(void)
+{ // testUsesUpdateState
+ ElasticStrain1D material;
+ CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateState());
+} // testUsesUpdateState
+
+// ----------------------------------------------------------------------
// Test DBValues()
void
pylith::materials::TestElasticStrain1D::testDBValues(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -38,6 +38,8 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticStrain1D );
+
+ CPPUNIT_TEST( testUsesUpdateState );
CPPUNIT_TEST( testDBToParameters );
CPPUNIT_TEST( testDBValues );
CPPUNIT_TEST( testParameters );
@@ -45,11 +47,15 @@
CPPUNIT_TEST( testCalcStress );
CPPUNIT_TEST( testCalcElasticConsts );
CPPUNIT_TEST( testUpdateState );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
+ /// Test usesUpdateState()
+ void testUsesUpdateState();
+
/// Test DBValues()
void testDBValues(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -22,6 +22,15 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestElasticStress1D );
// ----------------------------------------------------------------------
+// Test usesUpdateState()
+void
+pylith::materials::TestElasticStress1D::testUsesUpdateState(void)
+{ // testUsesUpdateState
+ ElasticStress1D material;
+ CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateState());
+} // testUsesUpdateState
+
+// ----------------------------------------------------------------------
// Test DBValues()
void
pylith::materials::TestElasticStress1D::testDBValues(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -38,6 +38,8 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticStress1D );
+
+ CPPUNIT_TEST( testUsesUpdateState );
CPPUNIT_TEST( testDBToParameters );
CPPUNIT_TEST( testDBValues );
CPPUNIT_TEST( testParameters );
@@ -45,11 +47,15 @@
CPPUNIT_TEST( testCalcStress );
CPPUNIT_TEST( testCalcElasticConsts );
CPPUNIT_TEST( testUpdateState );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
+ /// Test usesUpdateState()
+ void testUsesUpdateState();
+
/// Test DBValues()
void testDBValues(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc 2007-06-18 06:02:52 UTC (rev 7282)
@@ -23,6 +23,59 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestMaxwellIsotropic3D );
// ----------------------------------------------------------------------
+// Test timeStep()
+void
+pylith::materials::TestMaxwellIsotropic3D::testTimeStep(void)
+{ // testTimeStep
+ MaxwellIsotropic3D 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::TestMaxwellIsotropic3D::testUseElasticBehavior(void)
+{ // testUseElasticBehavior
+ MaxwellIsotropic3D material;
+
+ material.useElasticBehavior(true);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_calcStressElastic,
+ material._calcStressFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic,
+ material._calcElasticConstsFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updateStateElastic,
+ material._updateStateFn);
+
+ 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::_updateStateViscoelastic,
+ material._updateStateFn);
+} // testUseElasticBehavior
+
+// ----------------------------------------------------------------------
+// Test usesUpdateState()
+void
+pylith::materials::TestMaxwellIsotropic3D::testUsesUpdateState(void)
+{ // testUsesUpdateState
+ MaxwellIsotropic3D material;
+ CPPUNIT_ASSERT_EQUAL(true, material.usesUpdateState());
+} // testUsesUpdateState
+
+// ----------------------------------------------------------------------
// Test DBValues()
void
pylith::materials::TestMaxwellIsotropic3D::testDBValues(void)
@@ -150,25 +203,5 @@
material.updateState(totalStrain);
} // testUpdateStateTimeDep
-// ----------------------------------------------------------------------
-// Test timeStep()
-void
-pylith::materials::TestMaxwellIsotropic3D::testTimeStep(void)
-{ // testTimeStep
- MaxwellIsotropic3D 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
-
-
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh 2007-06-18 06:00:27 UTC (rev 7281)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh 2007-06-18 06:02:52 UTC (rev 7282)
@@ -39,6 +39,10 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestMaxwellIsotropic3D );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testUseElasticBehavior );
+ CPPUNIT_TEST( testUsesUpdateState );
CPPUNIT_TEST( testDBToParameters );
CPPUNIT_TEST( testDBValues );
CPPUNIT_TEST( testParameters );
@@ -49,12 +53,21 @@
CPPUNIT_TEST( testCalcElasticConstsTimeDep );
CPPUNIT_TEST( testUpdateStateElastic );
CPPUNIT_TEST( testUpdateStateTimeDep );
- CPPUNIT_TEST( testTimeStep );
+
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);
@@ -85,9 +98,6 @@
/// Test updateStateTimeDep()
void testUpdateStateTimeDep(void);
- /// Test timeStep()
- void testTimeStep(void);
-
}; // class TestMaxwellIsotropic3D
#endif // pylith_materials_testmaxwellisotropic3d_hh
More information about the cig-commits
mailing list