[cig-commits] r19613 - in short/3D/PyLith/trunk: libsrc/pylith/meshio libsrc/pylith/topology unittests/libtests/meshio unittests/libtests/meshio/data
brad at geodynamics.org
brad at geodynamics.org
Fri Feb 10 17:36:48 PST 2012
Author: brad
Date: 2012-02-10 17:36:47 -0800 (Fri, 10 Feb 2012)
New Revision: 19613
Added:
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterDataPoints.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterDataPoints.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataPointsTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataPointsTri3.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_points_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_points_vertex_t10.vtk
Modified:
short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.hh
short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc
short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.hh
short/3D/PyLith/trunk/libsrc/pylith/topology/Field.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/Makefile.am
Log:
More work on OutputSolnPoints unit tests. Unit tests for tri3 points with VTK writer are implemented but don't pass.
Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.hh 2012-02-10 20:33:15 UTC (rev 19612)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/DataWriterVTK.hh 2012-02-11 01:36:47 UTC (rev 19613)
@@ -37,6 +37,7 @@
friend class TestDataWriterVTKSubMesh; // unit testing
friend class TestDataWriterVTKBCMesh; // unit testing
friend class TestDataWriterVTKFaultMesh; // unit testing
+ friend class TestDataWriterVTKPoints; // unit testing
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc 2012-02-10 20:33:15 UTC (rev 19612)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.cc 2012-02-11 01:36:47 UTC (rev 19613)
@@ -85,7 +85,7 @@
const PylithScalar* points,
const int numPoints,
const int spaceDim)
-{ // createPointsMesh
+{ // setupInterpolator
assert(mesh);
assert(points);
@@ -123,16 +123,53 @@
assert(cs);
assert(cs->spaceDim() == spaceDim);
- err = DMMeshInterpolationSetDim(dm, spaceDim, _interpolator);CHECK_PETSC_ERROR(err);
- err = DMMeshInterpolationAddPoints(dm, numPoints, (PetscReal*) points, _interpolator);CHECK_PETSC_ERROR(err);
+ err = DMMeshInterpolationSetDim(dm, spaceDim,
+ _interpolator);CHECK_PETSC_ERROR(err);
+ err = DMMeshInterpolationAddPoints(dm, numPoints, (PetscReal*)points,
+ _interpolator);CHECK_PETSC_ERROR(err);
err = DMMeshInterpolationSetUp(dm, _interpolator);CHECK_PETSC_ERROR(err);
err = DMDestroy(&dm);CHECK_PETSC_ERROR(err);
CHECK_PETSC_ERROR(err);
-} // createPointsMesh
+ if (!_fields) {
+ _fields = new topology::Fields<topology::Field<topology::Mesh> >(*_pointsMesh);
+ } // if
+} // setupInterpolator
// ----------------------------------------------------------------------
+// Prepare for output.
+void
+pylith::meshio::OutputSolnPoints::open(const topology::Mesh& mesh,
+ const int numTimeSteps,
+ const char* label,
+ const int labelId)
+{ // open
+ assert(!label);
+ assert(!labelId);
+
+ assert(_pointsMesh);
+ OutputManager<topology::Mesh, topology::Field<topology::Mesh> >::open(*_pointsMesh, numTimeSteps, label, labelId);
+} // open
+
+
+// ----------------------------------------------------------------------
+// Setup file for writing fields at time step.
+void
+pylith::meshio::OutputSolnPoints::openTimeStep(const PylithScalar t,
+ const topology::Mesh& mesh,
+ const char* label,
+ const int labelId)
+{ // openTimeStep
+ assert(!label);
+ assert(!labelId);
+
+ assert(_pointsMesh);
+ OutputManager<topology::Mesh, topology::Field<topology::Mesh> >::openTimeStep(t, *_pointsMesh, label, labelId);
+} // openTimeStep
+
+
+// ----------------------------------------------------------------------
// Append finite-element vertex field to file.
void
pylith::meshio::OutputSolnPoints::appendVertexField(const PylithScalar t,
@@ -148,8 +185,19 @@
pointsSieveMesh->depthStratum(0);
assert(!vertices.isNull());
- const int fiberDim = (vertices->begin() != vertices->end()) ?
- field.section()->getFiberDimension(*vertices->begin()) : 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+ const std::string labelName =
+ (sieveMesh->hasLabel("censored depth")) ? "censored depth" : "depth";
+ assert(!sieveMesh->getLabelStratum(labelName, 0).isNull());
+ assert(!field.section().isNull());
+ int fiberDimLocal =
+ (sieveMesh->getLabelStratum(labelName, 0)->size() > 0) ?
+ field.section()->getFiberDimension(*sieveMesh->getLabelStratum(labelName, 0)->begin()) : 0;
+ int fiberDim = 0;
+ MPI_Allreduce(&fiberDimLocal, &fiberDim, 1, MPI_INT, MPI_MAX,
+ field.mesh().comm());
+ assert(fiberDim > 0);
// Create field if necessary for interpolated values or recreate
// field if mismatch in size between buffer and field.
@@ -163,6 +211,7 @@
_fields->get("buffer (interpolated)");
if (vertices->size()*fiberDim != fieldInterp.sectionSize()) {
fieldInterp.newSection(vertices, fiberDim);
+ fieldInterp.label(field.label());
fieldInterp.allocate();
} // if
logger.stagePop();
@@ -170,30 +219,33 @@
fieldInterp.zero();
fieldInterp.vectorFieldType(field.vectorFieldType());
fieldInterp.scale(field.scale());
-
- PetscVec fieldInterpVec = fieldInterp.vector();
+
+ const char* context = field.label();
+ fieldInterp.createScatter(*_pointsMesh, context);
+ PetscVec fieldInterpVec = fieldInterp.vector(context);
assert(fieldInterpVec);
- const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
- assert(!sieveMesh.isNull());
-
DM dm;
SectionReal section;
PetscErrorCode err = 0;
err = DMMeshCreate(sieveMesh->comm(), &dm);CHECK_PETSC_ERROR(err);
err = DMMeshSetMesh(dm, sieveMesh);CHECK_PETSC_ERROR(err);
- err = DMMeshInterpolationSetDof(dm, fiberDim, _interpolator);CHECK_PETSC_ERROR(err);
+ err = DMMeshInterpolationSetDof(dm, fiberDim,
+ _interpolator);CHECK_PETSC_ERROR(err);
err = SectionRealCreate(sieveMesh->comm(), §ion);CHECK_PETSC_ERROR(err);
err = SectionRealSetSection(section, field.section());CHECK_PETSC_ERROR(err);
err = SectionRealSetBundle(section, sieveMesh);CHECK_PETSC_ERROR(err);
- err = DMMeshInterpolationEvaluate(dm, section, fieldInterpVec, _interpolator);CHECK_PETSC_ERROR(err);
+ err = DMMeshInterpolationEvaluate(dm, section, fieldInterpVec,
+ _interpolator);CHECK_PETSC_ERROR(err);
err = SectionRealDestroy(§ion);CHECK_PETSC_ERROR(err);
err = DMDestroy(&dm);CHECK_PETSC_ERROR(err);
- OutputManager<topology::Mesh, topology::Field<topology::Mesh> >::appendVertexField(t, fieldInterp, mesh);
+ fieldInterp.scatterVectorToSection(context);
+
+ OutputManager<topology::Mesh, topology::Field<topology::Mesh> >::appendVertexField(t, fieldInterp, *_pointsMesh);
} // appendVertexField
Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.hh 2012-02-10 20:33:15 UTC (rev 19612)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/OutputSolnPoints.hh 2012-02-11 01:36:47 UTC (rev 19613)
@@ -73,6 +73,32 @@
const int numPoints,
const int spaceDim);
+ /** Prepare for output.
+ *
+ * @param mesh Finite-element mesh object.
+ * @param numTimeSteps Expected number of time steps.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ void open(const topology::Mesh& mesh,
+ const int numTimeSteps,
+ const char* label =0,
+ const int labelId =0);
+
+ /** Setup file for writing fields at time step.
+ *
+ * @param t Time of time step.
+ * @param mesh Finite-element mesh object.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ void openTimeStep(const PylithScalar t,
+ const topology::Mesh& mesh,
+ const char* label =0,
+ const int labelId =0);
+
/** Append finite-element vertex field to file.
*
* @param t Time associated with field.
Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Field.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Field.hh 2012-02-10 20:33:15 UTC (rev 19612)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Field.hh 2012-02-11 01:36:47 UTC (rev 19613)
@@ -169,7 +169,10 @@
*/
int sectionSize(void) const;
- /// Create sieve section.
+ /** Create sieve section.
+ *
+ * @note Don't forget to call label().
+ */
void newSection(void);
/** Create sieve section and set chart and fiber dimesion for
@@ -177,6 +180,8 @@
*
* @param points Points over which to define section.
* @param dim Fiber dimension for section.
+ *
+ * @note Don't forget to call label(), especially if reusing a field.
*/
void newSection(const ALE::Obj<label_sequence>& points,
const int fiberDim);
@@ -186,6 +191,8 @@
*
* @param points Points over which to define section.
* @param dim Fiber dimension for section.
+ *
+ * @note Don't forget to call label(), especially if reusing a field.
*/
void newSection(const int_array& points,
const int fiberDim);
@@ -195,6 +202,8 @@
* @param domain Type of points over which to define section.
* @param dim Fiber dimension for section.
* @param stratum Stratum depth (for vertices) and height (for cells).
+ *
+ * @note Don't forget to call label(), especially if reusing a field.
*/
void newSection(const DomainEnum domain,
const int fiberDim,
@@ -204,6 +213,8 @@
*
* @param sec Field defining layout.
* @param fiberDim Fiber dimension.
+ *
+ * @note Don't forget to call label(), especially if reusing a field.
*/
void newSection(const Field& src,
const int fiberDim);
@@ -214,6 +225,8 @@
* usage.
*
* @param sec Field defining layout.
+ *
+ * @note Don't forget to call label(), especially if reusing a field.
*/
void cloneSection(const Field& src);
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am 2012-02-10 20:33:15 UTC (rev 19612)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am 2012-02-11 01:36:47 UTC (rev 19613)
@@ -49,10 +49,20 @@
TestOutputSolnPoints.cc \
TestDataWriterVTKFaultMesh.cc \
TestDataWriterVTKFaultMeshCases.cc \
+ TestDataWriterPoints.cc \
+ TestDataWriterVTKPoints.cc \
+ TestDataWriterVTKPointsCases.cc \
test_meshio.cc
noinst_HEADERS = \
+ TestMeshIO.hh \
+ TestMeshIOAscii.hh \
+ TestMeshIOLagrit.hh \
+ TestOutputManager.hh \
+ TestOutputSolnSubset.hh \
+ TestOutputSolnPoints.hh \
+ TestVertexFilterVecNorm.hh \
TestCellFilterAvg.hh \
TestDataWriterMesh.hh \
TestDataWriterVTK.hh \
@@ -68,13 +78,9 @@
TestDataWriterVTKFaultMeshCases.hh \
TestDataWriterVTKBCMesh.hh \
TestDataWriterVTKBCMeshCases.hh \
- TestMeshIO.hh \
- TestMeshIOAscii.hh \
- TestMeshIOLagrit.hh \
- TestOutputManager.hh \
- TestOutputSolnSubset.hh \
- TestOutputSolnPoints.hh \
- TestVertexFilterVecNorm.hh
+ TestDataWriterPoints.hh \
+ TestDataWriterVTKPoints.hh \
+ TestDataWriterVTKPointsCases.hh
# Source files associated with testing data
@@ -131,6 +137,8 @@
data/OutputSolnPointsDataQuad4.cc \
data/OutputSolnPointsDataTet4.cc \
data/OutputSolnPointsDataHex8.cc \
+ data/DataWriterDataPoints.cc \
+ data/DataWriterVTKDataPointsTri3.cc \
data/MeshData.cc \
data/MeshData1D.cc \
data/MeshData1Din3D.cc \
@@ -199,6 +207,8 @@
data/OutputSolnPointsDataQuad4.hh \
data/OutputSolnPointsDataTet4.hh \
data/OutputSolnPointsDataHex8.hh \
+ data/DataWriterDataPoints.hh \
+ data/DataWriterVTKDataPointsTri3.hh \
data/MeshData.hh \
data/MeshData1D.hh \
data/MeshData1Din2D.hh \
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,138 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterPoints.hh" // Implementation of class methods
+
+#include "data/DataWriterDataPoints.hh" // USES DataWriterData
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/meshio/DataWriter.hh" // USES DataWriter
+#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterPoints::setUp(void)
+{ // setUp
+ _data = 0;
+ _mesh = 0;
+ _flipFault = false;
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::meshio::TestDataWriterPoints::tearDown(void)
+{ // tearDown
+ delete _data; _data = 0;
+ delete _mesh; _mesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Initialize mesh.
+void
+pylith::meshio::TestDataWriterPoints::_initialize(void)
+{ // _initialize
+ CPPUNIT_ASSERT(_data);
+
+ delete _mesh; _mesh = new topology::Mesh;
+ MeshIOAscii iohandler;
+ iohandler.filename(_data->meshFilename);
+ iohandler.read(_mesh);
+
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(_mesh->dimension());
+ _mesh->coordsys(&cs);
+
+ if (_data->faultLabel) {
+ faults::FaultCohesiveKin fault;
+ int firstFaultVertex = 0;
+ int firstLagrangeVertex = _mesh->sieveMesh()->getIntSection(_data->faultLabel)->size();
+ int firstFaultCell = _mesh->sieveMesh()->getIntSection(_data->faultLabel)->size();
+ if (fault.useLagrangeConstraints()) {
+ firstFaultCell += _mesh->sieveMesh()->getIntSection(_data->faultLabel)->size();
+ } // if
+ fault.label(_data->faultLabel);
+ fault.id(_data->faultId);
+ fault.adjustTopology(_mesh, &firstFaultVertex, &firstLagrangeVertex, &firstFaultCell, _flipFault);
+ } // if
+} // _initialize
+
+// ----------------------------------------------------------------------
+// Create vertex fields.
+void
+pylith::meshio::TestDataWriterPoints::_createVertexFields(
+ topology::Fields<MeshField>* fields) const
+{ // _createVertexFields
+ CPPUNIT_ASSERT(fields);
+ CPPUNIT_ASSERT(_mesh);
+ CPPUNIT_ASSERT(_data);
+
+ try {
+ const int nfields = _data->numVertexFields;
+
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<topology::Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const topology::Mesh::SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
+
+ // Set vertex fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->vertexFieldsInfo[i].name;
+ const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ MeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int ipt = 0;
+ for (topology::Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++ipt) {
+ const PylithScalar* values = &_data->vertexFields[i][ipt*fiberDim];
+ section->updatePoint(*v_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } catch (...) {
+ throw;
+ } // catch
+} // _createVertexFields
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.hh 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterPoints.hh
+ *
+ * @brief C++ TestDataWriterPoints object
+ *
+ * C++ unit testing for DataWriter<Mesh>.
+ */
+
+#if !defined(pylith_meshio_testdatawriterpoints_hh)
+#define pylith_meshio_testdatawriterpoints_hh
+
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterPoints;
+
+ class DataWriterDataPoints;
+ } // meshio
+} // pylith
+
+/// C++ unit testing for iDataWriter<Mesh> with interpolated solution.
+class pylith::meshio::TestDataWriterPoints
+{ // class TestDataWriterPoints
+
+ // PROTECTED METHODS //////////////////////////////////////////////////
+protected :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Initialize mesh.
+ void _initialize(void);
+
+ /** Create vertex fields.
+ *
+ * @param fields Vertex fields.
+ */
+ void
+ _createVertexFields(topology::Fields<topology::Field<topology::Mesh> >* fields) const;
+
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ DataWriterDataPoints* _data; ///< Data for testing
+ topology::Mesh* _mesh; ///< Mesh for data
+ bool _flipFault; ///< If true, flip fault orientation.
+
+}; // class TestDataWriterPoints
+
+#endif // pylith_meshio_testdatawriterpoints_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,151 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterVTKPoints.hh" // Implementation of class methods
+
+#include "data/DataWriterDataPoints.hh" // USES DataWriterDataPoints
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/meshio/OutputSolnPoints.hh" // USES OutputSolnPoints
+#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
+#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKPoints );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKPoints::setUp(void)
+{ // setUp
+ TestDataWriterPoints::setUp();
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::meshio::TestDataWriterVTKPoints::tearDown(void)
+{ // tearDown
+ TestDataWriterPoints::tearDown();
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor
+void
+pylith::meshio::TestDataWriterVTKPoints::testConstructor(void)
+{ // testConstructor
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ CPPUNIT_ASSERT(!writer._viewer);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test openTimeStep() and closeTimeStep()
+void
+pylith::meshio::TestDataWriterVTKPoints::testTimeStep(void)
+{ // testTimeStep
+ CPPUNIT_ASSERT(_mesh);
+ CPPUNIT_ASSERT(_data);
+
+ OutputSolnPoints output;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ writer.filename(_data->timestepFilename);
+ writer.timeFormat(_data->timeFormat);
+ output.writer(&writer);
+ output.setupInterpolator(_mesh, _data->points,
+ _data->numPoints, _data->spaceDim);
+
+ const PylithScalar t = _data->time;
+ const int numTimeSteps = 1;
+ if (!_data->cellsLabel) {
+ output.open(*_mesh, numTimeSteps);
+ output.openTimeStep(t, *_mesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ output.open(*_mesh, numTimeSteps, label, id);
+ output.openTimeStep(t, *_mesh, label, id);
+ } // else
+
+ output.closeTimeStep();
+ output.close();
+
+ checkFile(_data->timestepFilename, t, _data->timeFormat);
+} // testTimeStep
+
+// ----------------------------------------------------------------------
+// Test writeVertexField.
+void
+pylith::meshio::TestDataWriterVTKPoints::testWriteVertexField(void)
+{ // testWriteVertexField
+ CPPUNIT_ASSERT(_mesh);
+ CPPUNIT_ASSERT(_data);
+
+ OutputSolnPoints output;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ topology::Fields<MeshField> vertexFields(*_mesh);
+ _createVertexFields(&vertexFields);
+
+ writer.filename(_data->vertexFilename);
+ writer.timeFormat(_data->timeFormat);
+ output.writer(&writer);
+ output.setupInterpolator(_mesh, _data->points,
+ _data->numPoints, _data->spaceDim);
+
+ const int nfields = _data->numVertexFields;
+
+ const PylithScalar t = _data->time;
+ const int numTimeSteps = 1;
+ if (!_data->cellsLabel) {
+ output.open(*_mesh, numTimeSteps);
+ output.openTimeStep(t, *_mesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ output.open(*_mesh, numTimeSteps, label, id);
+ output.openTimeStep(t, *_mesh, label, id);
+ } // else
+ for (int i=0; i < nfields; ++i) {
+ MeshField& field = vertexFields.get(_data->vertexFieldsInfo[i].name);
+ field.view("FIELD");
+ output.appendVertexField(t, field, *_mesh);
+ CPPUNIT_ASSERT(writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ } // for
+ output.closeTimeStep();
+ output.close();
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->vertexFilename, t, _data->timeFormat);
+} // testWriteVertexField
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.hh 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterVTKPoints.hh
+ *
+ * @brief C++ TestDataWriterVTKPoints object
+ *
+ * C++ unit testing for DataWriterVTKPoints.
+ */
+
+#if !defined(pylith_meshio_testdatawritervtkpoints_hh)
+#define pylith_meshio_testdatawritervtkpoints_hh
+
+#include "TestDataWriterVTK.hh" // ISA TestDataWriterVTK
+#include "TestDataWriterPoints.hh" // ISA TestDataWriterPoints
+
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterVTKPoints;
+ } // meshio
+} // pylith
+
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKPoints : public TestDataWriterVTK,
+ public TestDataWriterPoints,
+ public CppUnit::TestFixture
+{ // class TestDataWriterVTKPoints
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKPoints );
+
+ CPPUNIT_TEST( testConstructor );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Test constructor
+ void testConstructor(void);
+
+ /// Test openTimeStep() and closeTimeStep()
+ void testTimeStep(void);
+
+ /// Test writeVertexField.
+ void testWriteVertexField(void);
+
+}; // class TestDataWriterVTKPoints
+
+#endif // pylith_meshio_testdatawritervtkpoints_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.cc 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterVTKPointsCases.hh" // Implementation of class methods
+
+#include "data/DataWriterVTKDataPointsTri3.hh" // USES DataWriterVTKDataPointsTri3
+//#include "data/DataWriterVTKDataPointsQuad4.hh" // USES DataWriterVTKDataPointsQuad4
+//#include "data/DataWriterVTKDataPointsTet4.hh" // USES DataWriterVTKDataPointsTet4
+//#include "data/DataWriterVTKDataPointsHex8.hh" // USES DataWriterVTKDataPointsHex8
+
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKPointsTri3 );
+//CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKPointsQuad4 );
+//CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKPointsTet4 );
+//CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKPointsHex8 );
+
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKPointsTri3::setUp(void)
+{ // setUp
+ TestDataWriterVTKPoints::setUp();
+ _data = new DataWriterVTKDataPointsTri3;
+ _flipFault = true;
+ _initialize();
+} // setUp
+
+
+#if 0
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKPointsQuad4::setUp(void)
+{ // setUp
+ TestDataWriterVTKPoints::setUp();
+ _data = new DataWriterVTKDataPointsQuad4;
+ _flipFault = false;
+ _initialize();
+} // setUp
+
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKPointsTet4::setUp(void)
+{ // setUp
+ TestDataWriterVTKPoints::setUp();
+ _data = new DataWriterVTKDataPointsTet4;
+ _flipFault = false;
+ _initialize();
+} // setUp
+
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKPointsHex8::setUp(void)
+{ // setUp
+ TestDataWriterVTKPoints::setUp();
+ _data = new DataWriterVTKDataPointsHex8;
+ _flipFault = true;
+ _initialize();
+} // setUp
+#endif
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPointsCases.hh 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,135 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterVTKPointsCases.hh
+ *
+ * @brief C++ unit testing for DataWriterVTK output interpolated to
+ * points with various mesh cell types.
+ */
+
+#if !defined(pylith_meshio_testdatawritervtkpointscases_hh)
+#define pylith_meshio_testdatawritervtkpointscases_hh
+
+#include "TestDataWriterVTKPoints.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterVTKPointsTri3;
+ //class TestDataWriterVTKPointsQuad4;
+ //class TestDataWriterVTKPointsTet4;
+ //class TestDataWriterVTKPointsHex8;
+ } // meshio
+} // pylith
+
+
+// ----------------------------------------------------------------------
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKPointsTri3 : public TestDataWriterVTKPoints
+{ // class TestDataWriterVTKPointsTri3
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKPointsTri3 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKPointsTri3
+
+
+#if 0
+// ----------------------------------------------------------------------
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKPointsQuad4 : public TestDataWriterVTKPoints
+{ // class TestDataWriterVTKPointsQuad4
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKPointsQuad4 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKPointsQuad4
+
+
+// ----------------------------------------------------------------------
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKPointsTet4 : public TestDataWriterVTKPoints
+{ // class TestDataWriterVTKPointsTet4
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKPointsTet4 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKPointsTet4
+
+
+// ----------------------------------------------------------------------
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKPointsHex8 : public TestDataWriterVTKPoints
+{ // class TestDataWriterVTKPointsHex8
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKPointsHex8 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKPointsHex8
+#endif
+
+
+#endif // pylith_meshio_testdatawritervtkpointscases_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterDataPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterDataPoints.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterDataPoints.cc 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#include "DataWriterDataPoints.hh"
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::meshio::DataWriterDataPoints::DataWriterDataPoints(void) :
+ numPoints(0),
+ spaceDim(0),
+ points(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::meshio::DataWriterDataPoints::~DataWriterDataPoints(void)
+{ // destructor
+} // destructor
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterDataPoints.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterDataPoints.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterDataPoints.hh 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawriterdatapoints_hh)
+#define pylith_meshio_datawriterdatapoints_hh
+
+// Data for testing writing interpolation of solution to points.
+
+#include "DataWriterData.hh" // ISA DataWriterData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterDataPoints;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterDataPoints : public DataWriterData
+{ // DataWriterData
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ DataWriterDataPoints(void);
+
+ /// Destructor
+ virtual
+ ~DataWriterDataPoints(void);
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public:
+
+ int numPoints; ///< Number of points for interpolation.
+ int spaceDim; ///< Spatial dimension.
+ PylithScalar* points; /// Points for interpolation.
+
+}; // DataWriterData
+
+#endif // pylith_meshio_datawriterdatapoints_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTri3.cc 2012-02-10 20:33:15 UTC (rev 19612)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTri3.cc 2012-02-11 01:36:47 UTC (rev 19613)
@@ -57,7 +57,8 @@
7.7, 8.8,
9.9, 10.0,
11.1, 12.2,
- 13.3, 14.4
+ 13.3, 14.4,
+ 15.5, 16.6,
};
const PylithScalar pylith::meshio::DataWriterVTKDataMeshTri3::_vertexField1[] = {
2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8
@@ -69,7 +70,8 @@
7.8, 8.9,
9.0, 10.1,
11.2, 12.3,
- 13.4, 14.5
+ 13.4, 14.5,
+ 15.6, 16.7,
};
const int pylith::meshio::DataWriterVTKDataMeshTri3::_numCellFields = 3;
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataPointsTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataPointsTri3.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataPointsTri3.cc 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,120 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataPointsTri3.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataPointsTri3::_meshFilename =
+ "data/tri3.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataPointsTri3::_faultLabel =
+ "fault";
+const int pylith::meshio::DataWriterVTKDataPointsTri3::_faultId = 100;
+
+const char* pylith::meshio::DataWriterVTKDataPointsTri3::_timestepFilename =
+ "tri3_points.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataPointsTri3::_vertexFilename =
+ "tri3_points_vertex.vtk";
+
+const PylithScalar pylith::meshio::DataWriterVTKDataPointsTri3::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataPointsTri3::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataPointsTri3::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataPointsTri3::_numVertices = 8;
+
+const pylith::meshio::DataWriterData::FieldStruct
+pylith::meshio::DataWriterVTKDataPointsTri3::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const PylithScalar pylith::meshio::DataWriterVTKDataPointsTri3::_vertexField0[] = {
+ 1.1, 2.2, // 0
+ 3.3, 4.4, // 1
+ 5.5, 6.6, // 2
+ 7.7, 8.8, // 3
+ 9.9, 10.0, // 4
+ 11.1, 12.2, // 5
+ 13.3, 14.4,
+ 15.5, 16.6,
+};
+const PylithScalar pylith::meshio::DataWriterVTKDataPointsTri3::_vertexField1[] = {
+ 2.1, // 0
+ 3.2, // 1
+ 4.3, // 2
+ 5.4, // 3
+ 6.5, // 4
+ 7.6, // 5
+ 8.7,
+ 9.8
+};
+const PylithScalar pylith::meshio::DataWriterVTKDataPointsTri3::_vertexField2[] = {
+ 1.2, 2.3, // 0
+ 3.4, 4.5, // 1
+ 5.6, 6.7, // 2
+ 7.8, 8.9, // 3
+ 9.0, 10.1, // 4
+ 11.2, 12.3, // 5
+ 13.4, 14.5,
+ 15.6, 16.7,
+};
+
+const int pylith::meshio::DataWriterVTKDataPointsTri3::_numPoints = 3;
+const int pylith::meshio::DataWriterVTKDataPointsTri3::_spaceDim = 2;
+const PylithScalar pylith::meshio::DataWriterVTKDataPointsTri3::_points[] = {
+ -0.3333333, 0.0,
+ 0.0000001, 0.0,
+ 0.9999999, 0.0,
+};
+
+
+pylith::meshio::DataWriterVTKDataPointsTri3::DataWriterVTKDataPointsTri3(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ numVertices = _numVertices;
+ assert(3 == numVertexFields);
+ vertexFieldsInfo = const_cast<DataWriterData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<PylithScalar*>(_vertexField0);
+ vertexFields[1] = const_cast<PylithScalar*>(_vertexField1);
+ vertexFields[2] = const_cast<PylithScalar*>(_vertexField2);
+
+ numPoints = _numPoints;
+ spaceDim = _spaceDim;
+ points = const_cast<PylithScalar*>(_points);
+} // constructor
+
+
+pylith::meshio::DataWriterVTKDataPointsTri3::~DataWriterVTKDataPointsTri3(void)
+{}
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataPointsTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataPointsTri3.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataPointsTri3.hh 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatapointstri3_hh)
+#define pylith_meshio_datawritervtkdatapointstri3_hh
+
+#include "DataWriterDataPoints.hh" // ISA DataWriterData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataPointsTri3;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataPointsTri3 : public DataWriterDataPoints
+{ // DataWriterVTKDataPointsTri3
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataPointsTri3(void);
+
+ /// Destructor
+ ~DataWriterVTKDataPointsTri3(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+
+ static const PylithScalar _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const PylithScalar _vertexField0[]; ///< Values for vertex field 0.
+ static const PylithScalar _vertexField1[]; ///< Values for vertex field 1.
+ static const PylithScalar _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Point information.
+ //@{
+ static const int _numPoints; ///< Number of points.
+ static const int _spaceDim; ///< Spatial dimension.
+ static const PylithScalar _points[]; ///< Coordinates of points.
+ //@}
+
+}; // DataWriterVTKDataPointsTri3
+
+#endif // pylith_meshio_datawritervtkdatapointstri3_hh
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/Makefile.am 2012-02-10 20:33:15 UTC (rev 19612)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/Makefile.am 2012-02-11 01:36:47 UTC (rev 19613)
@@ -186,7 +186,9 @@
tet4_fault_cell.h5 \
hex8_fault.h5 \
hex8_fault_vertex.h5 \
- hex8_fault_cell.h5
+ hex8_fault_cell.h5 \
+ tri3_points_t10.vtk \
+ tri3_points_vertex_t10.vtk
noinst_TMP =
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_points_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_points_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_points_t10.vtk 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,16 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 3 double
+-3.333333e-01 0.000000e+00 0.0
+1.000000e-07 0.000000e+00 0.0
+9.999999e-01 0.000000e+00 0.0
+CELLS 3 6
+1 0
+1 1
+1 2
+CELL_TYPES 3
+1
+1
+1
Added: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_points_vertex_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_points_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_points_vertex_t10.vtk 2012-02-11 01:36:47 UTC (rev 19613)
@@ -0,0 +1,31 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 3 double
+-3.333333e-01 0.000000e+00 0.0
+1.000000e-07 0.000000e+00 0.0
+9.999999e-01 0.000000e+00 0.0
+CELLS 3 6
+1 0
+1 1
+1 2
+CELL_TYPES 3
+1
+1
+1
+POINT_DATA 3
+VECTORS displacements double
+7.366667e+00 8.1333333e+00 0.0
+4.400000e+00 5.5000000e+00 0.0
+7.700000e+00 8.8000000e+00 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+5.400000e+00
+3.750000e+00
+5.400000e+00
+SCALARS other double 2
+LOOKUP_TABLE default
+7.133333e+00 8.233333e+00
+4.500000e+00 5.600000e+00
+7.800000e+00 8.900000e+00
More information about the CIG-COMMITS
mailing list