[cig-commits] r19507 - in short/3D/PyLith/trunk: libsrc/pylith/materials modulesrc/materials pylith/materials unittests/pytests/materials
brad at geodynamics.org
brad at geodynamics.org
Sat Jan 28 13:21:25 PST 2012
Author: brad
Date: 2012-01-28 13:21:25 -0800 (Sat, 28 Jan 2012)
New Revision: 19507
Modified:
short/3D/PyLith/trunk/libsrc/pylith/materials/DruckerPrager3D.cc
short/3D/PyLith/trunk/libsrc/pylith/materials/DruckerPrager3D.hh
short/3D/PyLith/trunk/modulesrc/materials/DruckerPrager3D.i
short/3D/PyLith/trunk/pylith/materials/DruckerPrager3D.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestDruckerPrager3D.py
Log:
Added ability to select from three options for fit to Mohr-Coulomb yield surface in Drucker-Prager bulk rheology.
Modified: short/3D/PyLith/trunk/libsrc/pylith/materials/DruckerPrager3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/materials/DruckerPrager3D.cc 2012-01-28 02:29:55 UTC (rev 19506)
+++ short/3D/PyLith/trunk/libsrc/pylith/materials/DruckerPrager3D.cc 2012-01-28 21:21:25 UTC (rev 19507)
@@ -148,6 +148,7 @@
_DruckerPrager3D::numStateVars,
_DruckerPrager3D::dbStateVars,
_DruckerPrager3D::numDBStateVars)),
+ _fitMohrCoulomb(MOHR_COULOMB_INSCRIBED),
_calcElasticConstsFn(0),
_calcStressFn(0),
_updateStateVarsFn(0)
@@ -162,6 +163,14 @@
} // destructor
// ----------------------------------------------------------------------
+// Set fit to Mohr-Coulomb surface.
+void
+pylith::materials::DruckerPrager3D::fitMohrCoulomb(FitMohrCoulombEnum value)
+{ // fitMohrCoulomb
+ _fitMohrCoulomb = value;
+} // fitMohrCoulomb
+
+// ----------------------------------------------------------------------
// Set whether elastic or inelastic constitutive relations are used.
void
pylith::materials::DruckerPrager3D::useElasticBehavior(const bool flag)
@@ -222,12 +231,39 @@
const PylithScalar mu = density * vs*vs;
const PylithScalar lambda = density * vp*vp - 2.0*mu;
- const PylithScalar denomFriction = sqrt(3.0) * (3.0 - sin(frictionAngle));
- const PylithScalar denomDilatation = sqrt(3.0) * (3.0 - sin(dilatationAngle));
- const PylithScalar alphaYield = 2.0 * sin(frictionAngle)/denomFriction;
- const PylithScalar beta = 6.0 * cohesion * cos(frictionAngle)/denomFriction;
- const PylithScalar alphaFlow = 2.0 * sin(dilatationAngle)/denomDilatation;
+ PylithScalar alphaYield = 0.0;
+ PylithScalar beta = 0.0;
+ PylithScalar alphaFlow = 0.0;
+ switch (_fitMohrCoulomb) { // switch
+ case MOHR_COULOMB_INSCRIBED: {
+ const PylithScalar denomFriction = sqrt(3.0) * (3.0 - sin(frictionAngle));
+ const PylithScalar denomDilatation = sqrt(3.0) * (3.0 - sin(dilatationAngle));
+ alphaYield = 2.0 * sin(frictionAngle)/denomFriction;
+ beta = 6.0 * cohesion * cos(frictionAngle)/denomFriction;
+ alphaFlow = 2.0 * sin(dilatationAngle)/denomDilatation;
+ break;
+ } // MOHR_COULOMB_INSCRIBED
+ case MOHR_COULOMB_MIDDLE: {
+ alphaYield = sin(frictionAngle)/3.0;
+ beta = cohesion * cos(frictionAngle);
+ alphaFlow = sin(dilatationAngle)/3.0;
+ break;
+ } // MOHR_COULOMB_MIDDLE
+ case MOHR_COULOMB_CIRCUMSCRIBED: {
+ const PylithScalar denomFriction = sqrt(3.0) * (3.0 + sin(frictionAngle));
+ const PylithScalar denomDilatation = sqrt(3.0) * (3.0 + sin(dilatationAngle));
+ alphaYield = 2.0 * sin(frictionAngle)/denomFriction;
+ beta = 6.0 * cohesion * cos(frictionAngle)/denomFriction;
+ alphaFlow = 2.0 * sin(dilatationAngle)/denomDilatation;
+ break;
+ } // MOHR_COULOMB_CIRCUMSCRIBED
+ default :
+ assert(0);
+ throw std::logic_error("Unknown Mohr-Coulomb fit.");
+ break;
+ } // switch
+
if (lambda <= 0.0) {
std::ostringstream msg;
msg << "Attempted to set Lame's constant lambda to nonpositive value.\n"
Modified: short/3D/PyLith/trunk/libsrc/pylith/materials/DruckerPrager3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/materials/DruckerPrager3D.hh 2012-01-28 02:29:55 UTC (rev 19506)
+++ short/3D/PyLith/trunk/libsrc/pylith/materials/DruckerPrager3D.hh 2012-01-28 21:21:25 UTC (rev 19507)
@@ -43,6 +43,15 @@
{ // class DruckerPrager3D
friend class TestDruckerPrager3D; // unit testing
+ // PUBLIC ENUMS ///////////////////////////////////////////////////////
+public :
+
+ enum FitMohrCoulombEnum {
+ MOHR_COULOMB_CIRCUMSCRIBED=0,
+ MOHR_COULOMB_MIDDLE=1,
+ MOHR_COULOMB_INSCRIBED=2,
+ }; // FitMohrCoulombType
+
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
@@ -52,6 +61,12 @@
/// Destructor
~DruckerPrager3D(void);
+ /** Set fit to Mohr-Coulomb surface.
+ *
+ * @param value Mohr-Coulomb surface match type.
+ */
+ void fitMohrCoulomb(FitMohrCoulombEnum value);
+
/** Set current time step.
*
* @param dt Current time step.
@@ -481,6 +496,9 @@
/// Method to use for _updateStateVars().
updateStateVars_fn_type _updateStateVarsFn;
+ /// Fit to Mohr Coulomb surface
+ FitMohrCoulombEnum _fitMohrCoulomb;
+
static const int p_density;
static const int p_mu;
static const int p_lambda;
Modified: short/3D/PyLith/trunk/modulesrc/materials/DruckerPrager3D.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/DruckerPrager3D.i 2012-01-28 02:29:55 UTC (rev 19506)
+++ short/3D/PyLith/trunk/modulesrc/materials/DruckerPrager3D.i 2012-01-28 21:21:25 UTC (rev 19507)
@@ -27,6 +27,15 @@
class pylith::materials::DruckerPrager3D : public ElasticMaterial
{ // class DruckerPrager3D
+ // PUBLIC ENUMS ///////////////////////////////////////////////////
+ public :
+
+ enum FitMohrCoulombEnum {
+ MOHR_COULOMB_CIRCUMSCRIBED=0,
+ MOHR_COULOMB_MIDDLE=1,
+ MOHR_COULOMB_INSCRIBED=2,
+ }; // FitMohrCoulombType
+
// PUBLIC METHODS /////////////////////////////////////////////////
public :
@@ -36,6 +45,12 @@
/// Destructor
~DruckerPrager3D(void);
+ /** Set fit to Mohr-Coulomb surface.
+ *
+ * @param value Mohr-Coulomb surface match type.
+ */
+ void fitMohrCoulomb(FitMohrCoulombEnum value);
+
/** Set current time step.
*
* @param dt Current time step.
Modified: short/3D/PyLith/trunk/pylith/materials/DruckerPrager3D.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/DruckerPrager3D.py 2012-01-28 02:29:55 UTC (rev 19506)
+++ short/3D/PyLith/trunk/pylith/materials/DruckerPrager3D.py 2012-01-28 21:21:25 UTC (rev 19507)
@@ -26,6 +26,16 @@
from ElasticMaterial import ElasticMaterial
from materials import DruckerPrager3D as ModuleDruckerPrager3D
+# Validator to fit to Mohr-Coulomb
+def validateFitMohrCoulomb(value):
+ """
+ Validate fit to Mohr-Coulomb yield surface.
+ """
+ if not value in ["inscribed", "middle", "circumscribed"]:
+ raise ValueError("Unknown fit to Mohr-Coulomb yield surface.")
+ return value
+
+
# DruckerPrager3D class
class DruckerPrager3D(ElasticMaterial, ModuleDruckerPrager3D):
"""
@@ -35,6 +45,30 @@
Factory: material.
"""
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(ElasticMaterial.Inventory):
+ """
+ Python object for managing FaultCohesiveKin facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing FaultCohesiveKin facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b fit_mohr_coulomb Fit to Mohr-Coulomb yield surface.
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+ from pylith.meshio.OutputMatElastic import OutputMatElastic
+ fitMohrCoulomb = pyre.inventory.str("fit_mohr_coulomb", default="inscribed",
+ validator=validateFitMohrCoulomb)
+ fitMohrCoulomb.meta['tip'] = "Fit to Mohr-Coulomb yield surface."
+
+
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="druckerprager3d"):
@@ -56,6 +90,23 @@
# PRIVATE METHODS ////////////////////////////////////////////////////
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ ElasticMaterial._configure(self)
+ if self.inventory.fitMohrCoulomb == "inscribed":
+ fitEnum = ModuleDruckerPrager3D.MOHR_COULOMB_INSCRIBED
+ elif self.inventory.fitMohrCoulomb == "middle":
+ fitEnum = ModuleDruckerPrager3D.MOHR_COULOMB_MIDDLE
+ elif self.inventory.fitMohrCoulomb == "circumscribed":
+ fitEnum = ModuleDruckerPrager3D.MOHR_COULOMB_CIRCUMSCRIBED
+ else:
+ raise ValueError("Unknown fit to Mohr-Coulomb yield surface.")
+ ModuleDruckerPrager3D.fitMohrCoulomb(self, fitEnum)
+ return
+
+
def _createModuleObj(self):
"""
Call constructor for module object for access to C++ object.
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestDruckerPrager3D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestDruckerPrager3D.py 2012-01-28 02:29:55 UTC (rev 19506)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestDruckerPrager3D.py 2012-01-28 21:21:25 UTC (rev 19507)
@@ -46,6 +46,14 @@
return
+ def test_fitMohrCoulomb(self):
+ """
+ Test useElasticBehavior().
+ """
+ self.material.fitMohrCoulomb(self.material.MOHR_COULOMB_MIDDLE)
+ return
+
+
def test_useElasticBehavior(self):
"""
Test useElasticBehavior().
More information about the CIG-COMMITS
mailing list