[cig-commits] r17247 - in short/3D/PyLith/trunk/unittests/libtests/meshio: . data

brad at geodynamics.org brad at geodynamics.org
Sat Oct 9 13:23:53 PDT 2010


Author: brad
Date: 2010-10-09 13:23:53 -0700 (Sat, 09 Oct 2010)
New Revision: 17247

Added:
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.hh
   short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterHDF5DataMeshHex8.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterHDF5DataMeshHex8.hh
Modified:
   short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
Log:
Added first HDF5 C++ mesh unit test.

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am	2010-10-09 19:45:47 UTC (rev 17246)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am	2010-10-09 20:23:53 UTC (rev 17247)
@@ -61,6 +61,7 @@
 	TestDataWriterVTKSubMeshHex8.cc \
 	TestDataWriterHDF5.cc \
 	TestDataWriterHDF5Mesh.cc \
+	TestDataWriterHDF5MeshHex8.cc \
 	TestOutputManager.cc \
 	TestOutputSolnSubset.cc \
 	TestDataWriterVTKFaultMesh.cc \
@@ -107,6 +108,7 @@
 	TestDataWriterVTKBCMeshHex8.hh \
 	TestDataWriterHDF5.hh \
 	TestDataWriterHDF5Mesh.hh \
+	TestDataWriterHDF5MeshHex8.hh \
 	TestMeshIO.hh \
 	TestMeshIOAscii.hh \
 	TestMeshIOLagrit.hh \
@@ -141,6 +143,7 @@
 	data/DataWriterVTKDataBCMeshQuad4.cc \
 	data/DataWriterVTKDataBCMeshTet4.cc \
 	data/DataWriterVTKDataBCMeshHex8.cc \
+	data/DataWriterHDF5DataMeshHex8.cc \
 	data/MeshData.cc \
 	data/MeshData1D.cc \
 	data/MeshData1Din3D.cc \
@@ -181,6 +184,7 @@
 	data/DataWriterVTKDataBCMeshQuad4.hh \
 	data/DataWriterVTKDataBCMeshTet4.hh \
 	data/DataWriterVTKDataBCMeshHex8.hh \
+	data/DataWriterHDF5DataMeshHex8.hh \
 	data/MeshData.hh \
 	data/MeshData1D.hh \
 	data/MeshData1Din2D.hh \

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.cc	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.cc	2010-10-09 20:23:53 UTC (rev 17247)
@@ -0,0 +1,41 @@
+// -*- 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 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterHDF5MeshHex8.hh" // Implementation of class methods
+
+#include "data/DataWriterHDF5DataMeshHex8.hh" // USES DataWriterHDF5DataMeshHex8
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterHDF5MeshHex8 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterHDF5MeshHex8::setUp(void)
+{ // setUp
+  TestDataWriterHDF5Mesh::setUp();
+  _data = new DataWriterHDF5DataMeshHex8;
+  _flipFault = true;
+
+  _initialize();
+} // setUp
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.hh	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.hh	2010-10-09 20:23:53 UTC (rev 17247)
@@ -0,0 +1,63 @@
+// -*- 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 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterHDF5MeshHex8.hh
+ *
+ * @brief C++ TestDataWriterHDF5MeshHex8 object
+ *
+ * C++ unit testing for DataWriterHDF5MeshHex8.
+ */
+
+#if !defined(pylith_meshio_testdatawriterhdf5meshhex8_hh)
+#define pylith_meshio_testdatawriterhdf5meshhex8_hh
+
+#include "TestDataWriterHDF5Mesh.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace meshio {
+    class TestDataWriterHDF5MeshHex8;
+  } // meshio
+} // pylith
+
+/// C++ unit testing for DataWriterHDF5
+class pylith::meshio::TestDataWriterHDF5MeshHex8 : public TestDataWriterHDF5Mesh
+{ // class TestDataWriterHDF5MeshHex8
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestDataWriterHDF5MeshHex8 );
+
+  CPPUNIT_TEST( testTimeStep );
+  CPPUNIT_TEST( testWriteVertexField );
+  CPPUNIT_TEST( testWriteCellField );
+
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Setup testing data.
+  void setUp(void);
+
+}; // class TestDataWriterHDF5MeshHex8
+
+#endif // pylith_meshio_testdatawriterhdf5meshhex8_hh
+
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterHDF5DataMeshHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterHDF5DataMeshHex8.cc	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterHDF5DataMeshHex8.cc	2010-10-09 20:23:53 UTC (rev 17247)
@@ -0,0 +1,160 @@
+// -*- 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 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#include "DataWriterHDF5DataMeshHex8.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterHDF5DataMeshHex8::_meshFilename = 
+  "data/hex8.mesh";
+
+const char* pylith::meshio::DataWriterHDF5DataMeshHex8::_faultLabel = 
+  "fault";
+const int pylith::meshio::DataWriterHDF5DataMeshHex8::_faultId = 100;
+
+const char* pylith::meshio::DataWriterHDF5DataMeshHex8::_timestepFilename = 
+  "hex8.h5";
+
+const char* pylith::meshio::DataWriterHDF5DataMeshHex8::_vertexFilename = 
+  "hex8_vertex.h5";
+
+const char* pylith::meshio::DataWriterHDF5DataMeshHex8::_cellFilename = 
+  "hex8_cell.h5";
+
+const double pylith::meshio::DataWriterHDF5DataMeshHex8::_time = 1.0;
+
+const char* pylith::meshio::DataWriterHDF5DataMeshHex8::_timeFormat = 
+  "%3.1f";
+
+const int pylith::meshio::DataWriterHDF5DataMeshHex8::_numVertexFields = 3;
+const int pylith::meshio::DataWriterHDF5DataMeshHex8::_numVertices = 20;
+
+const pylith::meshio::DataWriterData::FieldStruct
+pylith::meshio::DataWriterHDF5DataMeshHex8::_vertexFields[] = {
+  { "displacements", topology::FieldBase::VECTOR, 3 },
+  { "pressure", topology::FieldBase::SCALAR, 1 },
+  { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterHDF5DataMeshHex8::_vertexField0[] = {
+  1.1, 2.2, 3.3,
+  4.4, 5.5, 6.6,
+  7.7, 8.8, 9.9,
+  10.1, 11.2, 12.3,
+  1.2, 2.3, 3.4,
+  4.5, 5.6, 6.7,
+  7.8, 8.9, 9.0,
+  10.2, 11.3, 12.4,
+  1.3, 2.4, 3.5,
+  4.6, 5.7, 6.8,
+  7.9, 8.0, 9.1,
+  10.2, 11.3, 12.4,
+  13.5, 14.6, 15.7,
+  16.8, 17.9, 18.1,
+  19.2, 20.3, 21.4,
+  22.5, 23.6, 24.7,
+  25.8, 26.9, 27.1,
+  28.8, 29.9, 30.1,
+  31.8, 32.9, 33.1,
+  34.8, 35.9, 36.1,
+};
+const double pylith::meshio::DataWriterHDF5DataMeshHex8::_vertexField1[] = {
+  2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8,
+  10.0, 12.1, 11.1, 13.1, 14.1, 15.1, 16.1, 17.1,
+  18.1, 19.1, 20.1, 21.2
+};
+const double pylith::meshio::DataWriterHDF5DataMeshHex8::_vertexField2[] = {
+  1.2, 2.3,
+  3.4, 4.5,
+  5.6, 6.7,
+  7.8, 8.9,
+  1.3, 2.4,
+  3.5, 4.6,
+  5.7, 6.8,
+  7.9, 8.0,
+  1.3, 2.4,
+  3.5, 4.6,
+  5.7, 6.8,
+  8.0, 1.4,
+  2.5, 3.6,
+  4.8, 1.5,
+  2.6, 3.7,
+  4.8, 5.9,
+  6.1, 7.2,
+  7.1, 8.2,
+  8.1, 9.2,
+  9.1, 10.1
+};
+
+const int pylith::meshio::DataWriterHDF5DataMeshHex8::_numCellFields = 3;
+const int pylith::meshio::DataWriterHDF5DataMeshHex8::_numCells = 3;
+
+const pylith::meshio::DataWriterData::FieldStruct
+pylith::meshio::DataWriterHDF5DataMeshHex8::_cellFields[] = {
+  { "traction", topology::FieldBase::VECTOR, 3 },
+  { "pressure", topology::FieldBase::SCALAR, 1 },
+  { "other", topology::FieldBase::TENSOR, 6 },
+};
+const double pylith::meshio::DataWriterHDF5DataMeshHex8::_cellField0[] = {
+  1.1, 2.2, 3.3,
+  4.4, 5.5, 6.6,
+  7.7, 8.8, 9.9
+};
+const double pylith::meshio::DataWriterHDF5DataMeshHex8::_cellField1[] = {
+  2.1, 3.2, 4.3
+};
+const double pylith::meshio::DataWriterHDF5DataMeshHex8::_cellField2[] = {
+  1.2, 2.3, 3.4, 4.5, 5.6, 6.7,
+  1.1, 2.2, 3.3, 4.4, 5.5, 6.6,
+  1.3, 2.4, 3.5, 4.6, 5.7, 6.8
+};
+
+pylith::meshio::DataWriterHDF5DataMeshHex8::DataWriterHDF5DataMeshHex8(void)
+{ // constructor
+  meshFilename = const_cast<char*>(_meshFilename);
+  faultLabel = const_cast<char*>(_faultLabel);
+  faultId = _faultId;
+
+  timestepFilename = const_cast<char*>(_timestepFilename);
+  vertexFilename = const_cast<char*>(_vertexFilename);
+  cellFilename = const_cast<char*>(_cellFilename);
+
+  time = _time;
+  timeFormat = const_cast<char*>(_timeFormat);
+  
+  numVertexFields = _numVertexFields;
+  numVertices = _numVertices;
+  assert(3 == numVertexFields);
+  vertexFieldsInfo = const_cast<DataWriterData::FieldStruct*>(_vertexFields);
+  vertexFields[0] = const_cast<double*>(_vertexField0);
+  vertexFields[1] = const_cast<double*>(_vertexField1);
+  vertexFields[2] = const_cast<double*>(_vertexField2);
+
+  numCellFields = _numCellFields;
+  numCells = _numCells;
+  assert(3 == numCellFields);
+  cellFieldsInfo = const_cast<DataWriterData::FieldStruct*>(_cellFields);
+  cellFields[0] = const_cast<double*>(_cellField0);
+  cellFields[1] = const_cast<double*>(_cellField1);
+  cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterHDF5DataMeshHex8::~DataWriterHDF5DataMeshHex8(void)
+{}
+
+
+// End of file

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterHDF5DataMeshHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterHDF5DataMeshHex8.hh	                        (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterHDF5DataMeshHex8.hh	2010-10-09 20:23:53 UTC (rev 17247)
@@ -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 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawriterhdf5datameshhex8_hh)
+#define pylith_meshio_datawriterhdf5datameshhex8_hh
+
+#include "DataWriterData.hh" // ISA DataWriterData
+
+namespace pylith {
+  namespace meshio {
+     class DataWriterHDF5DataMeshHex8;
+  } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterHDF5DataMeshHex8 : public DataWriterData
+{ // DataWriterHDF5DataMeshHex8
+
+public: 
+
+  /// Constructor
+  DataWriterHDF5DataMeshHex8(void);
+
+  /// Destructor
+  ~DataWriterHDF5DataMeshHex8(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 HDF5 file without fields.
+  static const char* _vertexFilename; ///< Name of HDF5 file for vertex fields.
+  static const char* _cellFilename; ///< Name of HDF5 file for cell fields.
+
+  static const double _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 double _vertexField0[]; ///< Values for vertex field 0.
+  static const double _vertexField1[]; ///< Values for vertex field 1.
+  static const double _vertexField2[]; ///< Values for vertex field 2.
+  //@}
+
+  /// @name Cell field information.
+  //@{
+  static const int _numCellFields; ///< Number of cell fields.
+  static const int _numCells; ///< Number of cells.
+  static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+  static const double _cellField0[]; ///< Values for cell field 0.
+  static const double _cellField1[]; ///< Values for cell field 1.
+  static const double _cellField2[]; ///< Values for cell field 2.
+  //@}
+
+}; // DataWriterHDF5DataMeshHex8
+
+#endif // pylith_meshio_datawriterhdf5datameshhex8_hh
+
+// End of file



More information about the CIG-COMMITS mailing list