[cig-commits] r22176 - short/3D/PyLith/trunk/libsrc/pylith/meshio

brad at geodynamics.org brad at geodynamics.org
Wed Jun 5 11:29:56 PDT 2013


Author: brad
Date: 2013-06-05 11:29:56 -0700 (Wed, 05 Jun 2013)
New Revision: 22176

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc
Log:
Fix bug associated with trying to recreate field every time step (only create if necessary as in previous implementation).

Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc	2013-06-05 18:29:04 UTC (rev 22175)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc	2013-06-05 18:29:56 UTC (rev 22176)
@@ -240,29 +240,26 @@
 
   // Create field if necessary for interpolated values or recreate
   // field if mismatch in size between buffer and field.
-  std::ostringstream fieldName;
-  const char* context = field.label();
-  fieldName << context << " (interpolated)" << std::endl;
+  const std::string& fieldName = std::string(field.label()) + " (interpolated)";
+  if (!_fields->hasField(fieldName.c_str())) {
+    _fields->add(fieldName.c_str(), field.label());
+  } // if
 
-  if (_fields->hasField(fieldName.str().c_str())) {
-    std::ostringstream msg;
-    msg << "Field " << fieldName << "already present in manager" << std::endl;
-    throw std::logic_error(msg.str());
+  topology::Field& fieldInterp = _fields->get(fieldName.c_str());
+  if (numVertices*fiberDim != fieldInterp.sectionSize()) {
+    fieldInterp.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+    fieldInterp.allocate();
   } // if
-  _fields->add(fieldName.str().c_str(), field.label());
-  
-  topology::Field& fieldInterp = _fields->get(fieldName.str().c_str());
-  fieldInterp.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
-  fieldInterp.allocate();
+
   fieldInterp.zero();
   fieldInterp.label(field.label());
   fieldInterp.vectorFieldType(field.vectorFieldType());
   fieldInterp.scale(field.scale());
 
+  const char* context = fieldName.c_str();
   fieldInterp.createScatter(*_pointsMesh, context);
 
-  PetscVec fieldInterpVec = fieldInterp.vector(context);
-  assert(fieldInterpVec);
+  PetscVec fieldInterpVec = fieldInterp.vector(context);assert(fieldInterpVec);
   err = DMInterpolationSetDof(_interpolator, fiberDim);PYLITH_CHECK_ERROR(err);
   err = DMInterpolationEvaluate(_interpolator, dmMesh, field.localVector(), fieldInterpVec);PYLITH_CHECK_ERROR(err);
 



More information about the CIG-COMMITS mailing list