[cig-commits] r20557 - short/3D/PyLith/trunk/libsrc/pylith/meshio
knepley at geodynamics.org
knepley at geodynamics.org
Sun Aug 5 13:56:50 PDT 2012
Author: knepley
Date: 2012-08-05 13:56:49 -0700 (Sun, 05 Aug 2012)
New Revision: 20557
Modified:
short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.cc
Log:
Added support for labels for VTK (need to clear up at CloseTimestep)
Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.cc 2012-08-05 13:40:23 UTC (rev 20556)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.cc 2012-08-05 20:56:49 UTC (rev 20557)
@@ -19,6 +19,7 @@
#include <portinfo>
#include <petscdmmesh_viewers.hh> // USES VTKViewer
+#include <petscdmcomplex.h>
#include <cassert> // USES assert()
#include <sstream> // USES std::ostringstream
@@ -126,6 +127,18 @@
err = PetscViewerSetFormat(_viewer, PETSC_VIEWER_ASCII_VTK);CHECK_PETSC_ERROR(err);
err = PetscViewerFileSetName(_viewer, filename.c_str());CHECK_PETSC_ERROR(err);
err = PetscObjectReference((PetscObject) complexMesh);CHECK_PETSC_ERROR(err); /* Needed because viewer destroys the DM */
+
+ /* Create VTK label in DM: Cleared in closeTimestep() */
+ if (label) {
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& cells = sieveMesh->getLabelStratum(label, labelId);
+ const typename mesh_type::SieveMesh::label_sequence::const_iterator cBegin = cells->begin();
+ const typename mesh_type::SieveMesh::label_sequence::const_iterator cEnd = cells->end();
+
+ for(typename mesh_type::SieveMesh::label_sequence::const_iterator c_iter = cBegin; c_iter != cEnd; ++c_iter) {
+ err = DMComplexSetLabelValue(complexMesh, "vtk", *c_iter, 1);CHECK_PETSC_ERROR(err);
+ }
+ }
} else {
err = PetscViewerCreate(mesh.comm(), &_viewer);
CHECK_PETSC_ERROR(err);
@@ -178,6 +191,15 @@
void
pylith::meshio::DataWriterVTK<mesh_type,field_type>::closeTimeStep(void)
{ // closeTimeStep
+#if 0
+ DM complexMesh = mesh.dmMesh();
+ PetscErrorCode err;
+
+ if (complexMesh) {
+ err = DMComplexClearLabelStratum(complexMesh, "vtk", 1);CHECK_PETSC_ERROR(err);
+ err = DMComplexClearLabelStratum(complexMesh, "vtk", 2);CHECK_PETSC_ERROR(err);
+ }
+#endif
PetscViewerDestroy(&_viewer); _viewer = 0;
_wroteVertexHeader = false;
_wroteCellHeader = false;
More information about the CIG-COMMITS
mailing list