[cig-commits] r15255 - in short/3D/PyLith/trunk/libsrc: feassemble materials

brad at geodynamics.org brad at geodynamics.org
Sun Jun 14 22:08:27 PDT 2009


Author: brad
Date: 2009-06-14 22:08:26 -0700 (Sun, 14 Jun 2009)
New Revision: 15255

Modified:
   short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc
   short/3D/PyLith/trunk/libsrc/materials/Material.cc
   short/3D/PyLith/trunk/libsrc/materials/Material.hh
Log:
Fixed logic for determinging how to calculate stress and total strain (need to account for what is available as state variables).

Modified: short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc	2009-06-15 04:45:27 UTC (rev 15254)
+++ short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc	2009-06-15 05:08:26 UTC (rev 15255)
@@ -331,14 +331,12 @@
   assert(0 != _material);
   assert(0 != _normalizer);
 
-  // We assume the material stores the total_strain field if
-  // hasStateVars() is TRUE.
-
   if (0 == _outputFields)
     _outputFields =
       new topology::Fields<topology::Field<topology::Mesh> >(mesh);
   
-  if (!_material->hasStateVars() && 0 == strcasecmp(name, "total_strain")) {
+  if (0 == strcasecmp(name, "total_strain") &&
+      !_material->hasStateVar("total_strain")) {
     assert(0 != fields);
     _allocateTensorField(mesh);
     topology::Field<topology::Mesh>& buffer = 
@@ -349,7 +347,8 @@
     _calcStrainStressField(&buffer, name, fields);
     return buffer;
 
-  } else if (!_material->hasStateVars() && 0 == strcasecmp(name, "stress")) {
+  } else if (0 == strcasecmp(name, "stress") &&
+	     !_material->hasStateVar("total_strain")) {
     assert(0 != fields);
     _allocateTensorField(mesh);
     topology::Field<topology::Mesh>& buffer = 

Modified: short/3D/PyLith/trunk/libsrc/materials/Material.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.cc	2009-06-15 04:45:27 UTC (rev 15254)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.cc	2009-06-15 05:08:26 UTC (rev 15255)
@@ -286,6 +286,28 @@
 } // stateVarsField
 
 // ----------------------------------------------------------------------
+// Check whether material has a field as a property.
+bool
+pylith::materials::Material::hasProperty(const char* name)
+{ // hasProperty
+  int propertyIndex = -1;
+  int stateVarIndex = -1;
+  _findField(&propertyIndex, &stateVarIndex, name);
+  return (propertyIndex >= 0);
+} // hasProperty
+
+// ----------------------------------------------------------------------
+// Check whether material has a field as a state variable.
+bool
+pylith::materials::Material::hasStateVar(const char* name)
+{ // hasStateVar
+  int propertyIndex = -1;
+  int stateVarIndex = -1;
+  _findField(&propertyIndex, &stateVarIndex, name);
+  return (stateVarIndex >= 0);
+} // hasStateVar
+
+// ----------------------------------------------------------------------
 // Get physical property or state variable field.
 void
 pylith::materials::Material::getField(topology::Field<topology::Mesh> *field, const char* name) const
@@ -297,6 +319,12 @@
   int propertyIndex = -1;
   int stateVarIndex = -1;
   _findField(&propertyIndex, &stateVarIndex, name);
+  if (propertyIndex < 0 && stateVarIndex < 0) {
+    std::ostringstream msg;
+    msg << "Unknown physical property or state variable '" << name
+	<< "' for material '" << _label << "'.";
+    throw std::runtime_error(msg.str());
+  } // else
 
   // Get cell information
   const ALE::Obj<SieveMesh>& sieveMesh = field->mesh().sieveMesh();
@@ -520,13 +548,6 @@
       *stateVarIndex = i;
       return;
     } // if
-
-  if (*propertyIndex < 0 && *stateVarIndex < 0) {
-    std::ostringstream msg;
-    msg << "Unknown physical property or state variable '" << name
-	<< "' for material '" << _label << "'.";
-    throw std::runtime_error(msg.str());
-  } // else
 } // _findField
   
 

Modified: short/3D/PyLith/trunk/libsrc/materials/Material.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.hh	2009-06-15 04:45:27 UTC (rev 15254)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.hh	2009-06-15 05:08:26 UTC (rev 15255)
@@ -151,6 +151,22 @@
   /// current state.
   void resetNeedNewJacobian(void);
 
+  /** Check whether material has a field as a property.
+   *
+   * @param name Name of field.
+   *
+   * @returns True if material has field as a property, false otherwise.
+   */
+  bool hasProperty(const char* name);
+
+  /** Check whether material has a field as a state variable.
+   *
+   * @param name Name of field.
+   *
+   * @returns True if material has field as a state variable, false otherwise.
+   */
+  bool hasStateVar(const char* name);
+
   /** Get physical property or state variable field. Data is returned
    * via the argument.
    *
@@ -159,13 +175,13 @@
    */
   void getField(topology::Field<topology::Mesh> *field, const char* name) const;
 
-  /** Get the properties field.
+  /** Get the field with all properties.
    *
    * @returns Properties field.
    */
   const topology::Field<topology::Mesh>* propertiesField() const;
 
-  /** Get the state variables field.
+  /** Get the field with all of the state variables.
    *
    * @returns State variables field.
    */



More information about the CIG-COMMITS mailing list