[cig-commits] r7001 - short/3D/PyLith/trunk/libsrc/materials

brad at geodynamics.org brad at geodynamics.org
Wed May 30 11:56:07 PDT 2007


Author: brad
Date: 2007-05-30 11:56:06 -0700 (Wed, 30 May 2007)
New Revision: 7001

Modified:
   short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc
   short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc
   short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc
   short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
Log:
Added some validation of material values.

Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc	2007-05-30 17:10:56 UTC (rev 7000)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc	2007-05-30 18:56:06 UTC (rev 7001)
@@ -17,6 +17,8 @@
 #include "pylith/utils/array.hh" // USES double_array
 
 #include <assert.h> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
 
 // ----------------------------------------------------------------------
 namespace pylith {
@@ -123,6 +125,14 @@
  
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
+  if (lambda < 0.0) {
+    std::ostringstream msg;
+    msg << "Attempted to set Lame's constant lambda to negative value.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
 
   (*paramVals)[_ElasticIsotropic3D::pidDensity][0] = density;
   (*paramVals)[_ElasticIsotropic3D::pidMu][0] = mu;

Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc	2007-05-30 17:10:56 UTC (rev 7000)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc	2007-05-30 18:56:06 UTC (rev 7001)
@@ -17,6 +17,8 @@
 #include "pylith/utils/array.hh" // USES double_array
 
 #include <assert.h> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
 
 // ----------------------------------------------------------------------
 namespace pylith {
@@ -124,7 +126,15 @@
  
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
-
+  if (lambda < 0.0) {
+    std::ostringstream msg;
+    msg << "Attempted to set Lame's constant lambda to negative value.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+  
   (*paramVals)[_ElasticPlaneStrain::pidDensity][0] = density;
   (*paramVals)[_ElasticPlaneStrain::pidMu][0] = mu;
   (*paramVals)[_ElasticPlaneStrain::pidLambda][0] = lambda;

Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc	2007-05-30 17:10:56 UTC (rev 7000)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc	2007-05-30 18:56:06 UTC (rev 7001)
@@ -17,6 +17,8 @@
 #include "pylith/utils/array.hh" // USES double_array
 
 #include <assert.h> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
 
 // ----------------------------------------------------------------------
 namespace pylith {
@@ -123,6 +125,14 @@
  
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
+  if (lambda < 0.0) {
+    std::ostringstream msg;
+    msg << "Attempted to set Lame's constant lambda to negative value.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
 
   (*paramVals)[_ElasticPlaneStress::pidDensity][0] = density;
   (*paramVals)[_ElasticPlaneStress::pidMu][0] = mu;

Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc	2007-05-30 17:10:56 UTC (rev 7000)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc	2007-05-30 18:56:06 UTC (rev 7001)
@@ -17,6 +17,8 @@
 #include "pylith/utils/array.hh" // USES double_array
 
 #include <assert.h> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
 
 // ----------------------------------------------------------------------
 namespace pylith {
@@ -128,8 +130,17 @@
  
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
+  if (lambda < 0.0) {
+    std::ostringstream msg;
+    msg << "Attempted to set Lame's constant lambda to negative value.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+
   assert(mu > 0);
-  const double maxwelltime = viscosity/mu;
+  const double maxwelltime = viscosity / mu;
 
   (*paramVals)[_MaxwellIsotropic3D::pidDensity][0] = density;
   (*paramVals)[_MaxwellIsotropic3D::pidMu][0] = mu;



More information about the cig-commits mailing list