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

brad at geodynamics.org brad at geodynamics.org
Sat Sep 20 19:43:12 PDT 2008


Author: brad
Date: 2008-09-20 19:43:12 -0700 (Sat, 20 Sep 2008)
New Revision: 12925

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/ElasticStrain1D.cc
   short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.cc
   short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.cc
   short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
Log:
Added check for positive values for physical properties.

Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc	2008-09-20 22:19:43 UTC (rev 12924)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc	2008-09-21 02:43:12 UTC (rev 12925)
@@ -103,6 +103,15 @@
   const double vs = dbValues[_ElasticIsotropic3D::didVs];
   const double vp = dbValues[_ElasticIsotropic3D::didVp];
  
+  if (density < 0.0 || vs < 0.0 || vp < 0.0) {
+    std::ostringstream msg;
+    msg << "Spatial database returned negative value for physical properties.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
 

Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc	2008-09-20 22:19:43 UTC (rev 12924)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc	2008-09-21 02:43:12 UTC (rev 12925)
@@ -102,6 +102,15 @@
   const double vs = dbValues[_ElasticPlaneStrain::didVs];
   const double vp = dbValues[_ElasticPlaneStrain::didVp];
  
+  if (density < 0.0 || vs < 0.0 || vp < 0.0) {
+    std::ostringstream msg;
+    msg << "Spatial database returned negative value for physical properties.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
 

Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc	2008-09-20 22:19:43 UTC (rev 12924)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc	2008-09-21 02:43:12 UTC (rev 12925)
@@ -100,6 +100,15 @@
   const double vs = dbValues[_ElasticPlaneStress::didVs];
   const double vp = dbValues[_ElasticPlaneStress::didVp];
  
+  if (density < 0.0 || vs < 0.0 || vp < 0.0) {
+    std::ostringstream msg;
+    msg << "Spatial database returned negative value for physical properties.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
 

Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.cc	2008-09-20 22:19:43 UTC (rev 12924)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.cc	2008-09-21 02:43:12 UTC (rev 12925)
@@ -98,6 +98,15 @@
   const double vp = dbValues[_ElasticStrain1D::didVp];
   const double vs = dbValues[_ElasticStrain1D::didVs];
 
+  if (density < 0.0 || vs < 0.0 || vp < 0.0) {
+    std::ostringstream msg;
+    msg << "Spatial database returned negative value for physical properties.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
 

Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.cc	2008-09-20 22:19:43 UTC (rev 12924)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.cc	2008-09-21 02:43:12 UTC (rev 12925)
@@ -97,6 +97,15 @@
   const double vs = dbValues[_ElasticStress1D::didVs];
   const double vp = dbValues[_ElasticStress1D::didVp];
  
+  if (density < 0.0 || vs < 0.0 || vp < 0.0) {
+    std::ostringstream msg;
+    msg << "Spatial database returned negative value for physical properties.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
 

Modified: short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.cc	2008-09-20 22:19:43 UTC (rev 12924)
+++ short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.cc	2008-09-21 02:43:12 UTC (rev 12925)
@@ -137,6 +137,15 @@
   const double vp = dbValues[_GenMaxwellIsotropic3D::didVp];
   const int numMaxwellModels = _GenMaxwellIsotropic3D::numMaxwellModels;
  
+  if (density < 0.0 || vs < 0.0 || vp < 0.0) {
+    std::ostringstream msg;
+    msg << "Spatial database returned negative value for physical properties.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
 
@@ -162,7 +171,17 @@
     double viscosity = dbValues[_GenMaxwellIsotropic3D::didViscosity1 + model];
     double muFac = muRatio*mu;
     double maxwellTime = 1.0e30;
-    if (muFac > 0.0) maxwellTime = viscosity / muFac;
+    if (muFac > 0.0)
+      maxwellTime = viscosity / muFac;
+    if (muRatio < 0.0 || viscosity < 0.0 || muFac < 0.0 || maxwellTime < 0.0) {
+      std::ostringstream msg;
+      msg << "Found negative value(s) for physical properties.\n"
+	  << "muRatio: " << muRatio << "\n"
+	  << "viscosity: " << viscosity << "\n"
+	  << "muFac: " << muFac << "\n"
+	  << "maxwellTime: " << maxwellTime << "\n";
+      throw std::runtime_error(msg.str());
+    } // if
     propValues[_GenMaxwellIsotropic3D::pidShearRatio + model] = muRatio;
     propValues[_GenMaxwellIsotropic3D::pidMaxwellTime + model] = maxwellTime;
   } // for

Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc	2008-09-20 22:19:43 UTC (rev 12924)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc	2008-09-21 02:43:12 UTC (rev 12925)
@@ -116,6 +116,16 @@
   const double vp = dbValues[_MaxwellIsotropic3D::didVp];
   const double viscosity = dbValues[_MaxwellIsotropic3D::didViscosity];
  
+  if (density < 0.0 || vs < 0.0 || vp < 0.0 || viscosity < 0.0) {
+    std::ostringstream msg;
+    msg << "Spatial database returned negative value for physical properties.\n"
+	<< "density: " << density << "\n"
+	<< "vp: " << vp << "\n"
+	<< "vs: " << vs << "\n"
+	<< "viscosity: " << viscosity << "\n";
+    throw std::runtime_error(msg.str());
+  } // if
+
   const double mu = density * vs*vs;
   const double lambda = density * vp*vp - 2.0*mu;
 



More information about the cig-commits mailing list