[cig-commits] r11302 - in short/3D/PyLith/trunk: libsrc/meshio unittests/libtests/meshio

knepley at geodynamics.org knepley at geodynamics.org
Sun Mar 2 11:13:47 PST 2008


Author: knepley
Date: 2008-03-02 11:13:46 -0800 (Sun, 02 Mar 2008)
New Revision: 11302

Modified:
   short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh
   short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
   short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc
Log:
Fixed submesh cell field output in VTK


Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh	2008-03-02 05:52:24 UTC (rev 11301)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh	2008-03-02 19:13:46 UTC (rev 11302)
@@ -125,7 +125,7 @@
 		      const char* name,
 		      const ALE::Obj<real_section_type>& field,
 		      const VectorFieldEnum fieldType,
-		      const ALE::Obj<ALE::Mesh>& mesh,
+              const ALE::Obj<ALE::Mesh>& mesh,
 		      const char* label =0,
 		      const int labelId =0) = 0;
 

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc	2008-03-02 05:52:24 UTC (rev 11301)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc	2008-03-02 19:13:46 UTC (rev 11302)
@@ -196,8 +196,8 @@
 				       const ALE::Obj<real_section_type>& field,
 				       const VectorFieldEnum fieldType,
 				       const ALE::Obj<ALE::Mesh>& mesh,
-				       const char* label,
-				       const int labelId)
+                       const char* label,
+                       const int labelId)
 { // writeCellField
   assert(0 != name);
   assert(!mesh.isNull());
@@ -206,9 +206,9 @@
   try {
     // Correctly handle boundary and fault meshes
     //const int depth = mesh->depth();
-    const int depth = 1;
-    const std::string labelName = 
-      (mesh->hasLabel("censored depth")) ? "censored depth" : "depth";
+    const int depth = (0 == label) ? 1 : labelId;
+    const std::string labelName = (0 == label) ?
+      ((mesh->hasLabel("censored depth")) ? "censored depth" : "depth") : label;
     const ALE::Obj<Mesh::numbering_type>& numbering = 
       mesh->getFactory()->getNumbering(mesh, labelName, depth);
     assert(!numbering.isNull());
@@ -226,17 +226,8 @@
       _wroteCellHeader = true;
     } // if
 
-    if (0 == label)
-      err = VTKViewer::writeField(field, name, fiberDim, numbering, _viewer, 
-				  enforceDim);
-    else {
-      const std::string labelName = 
-	(mesh->hasLabel("censored depth")) ? "censored depth" : "depth";
-      err = VTKViewer::writeField(field, name, fiberDim, numbering, _viewer, 
-				  enforceDim);      
-    } // if/else
-    if (err)
-      throw std::runtime_error("Coult not write cell field.");
+    VTKViewer::writeField(field, name, fiberDim, numbering, _viewer, 
+                          enforceDim);
 
   } catch (const std::exception& err) {
     std::ostringstream msg;

Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh	2008-03-02 05:52:24 UTC (rev 11301)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh	2008-03-02 19:13:46 UTC (rev 11302)
@@ -107,7 +107,7 @@
 		      const char* name,
 		      const ALE::Obj<real_section_type>& field,
 		      const VectorFieldEnum fieldType,
-		      const ALE::Obj<ALE::Mesh>& mesh,
+              const ALE::Obj<ALE::Mesh>& mesh,
 		      const char* label =0,
 		      const int labelId =0);
 

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc	2008-03-02 05:52:24 UTC (rev 11301)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc	2008-03-02 19:13:46 UTC (rev 11302)
@@ -193,20 +193,28 @@
   if (0 == _data->cellsLabel) {
     writer.open(_mesh, &cs, numTimeSteps);
     writer.openTimeStep(t, _mesh, &cs);
+    for (int i=0; i < nfields; ++i) {
+      writer.writeCellField(t, _data->cellFieldsInfo[i].name,
+                            cellFields[i], 
+                            _data->cellFieldsInfo[i].field_type,
+                            _mesh);
+      CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+      CPPUNIT_ASSERT(writer._wroteCellHeader);
+    } // for
   } else {
     const char* label = _data->cellsLabel;
     const int id = _data->labelId;
     writer.open(_mesh, &cs, numTimeSteps, label, id);
     writer.openTimeStep(t, _mesh, &cs, label, id);
+    for (int i=0; i < nfields; ++i) {
+      writer.writeCellField(t, _data->cellFieldsInfo[i].name,
+                            cellFields[i], 
+                            _data->cellFieldsInfo[i].field_type,
+                            _mesh, label, id);
+      CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+      CPPUNIT_ASSERT(writer._wroteCellHeader);
+    } // for
   } // else
-  for (int i=0; i < nfields; ++i) {
-    writer.writeCellField(t, _data->cellFieldsInfo[i].name,
-			  cellFields[i], 
-			  _data->cellFieldsInfo[i].field_type,
-			  _mesh);
-    CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
-    CPPUNIT_ASSERT(writer._wroteCellHeader);
-  } // for
   writer.closeTimeStep();
   writer.close();
   CPPUNIT_ASSERT(false == writer._wroteCellHeader);



More information about the cig-commits mailing list