[cig-commits] r4527 - short/3D/PyLith/trunk/playpen/meshio/src
baagaard at geodynamics.org
baagaard at geodynamics.org
Thu Sep 14 09:34:43 PDT 2006
Author: baagaard
Date: 2006-09-14 09:34:41 -0700 (Thu, 14 Sep 2006)
New Revision: 4527
Added:
short/3D/PyLith/trunk/playpen/meshio/src/HDF5.cc
short/3D/PyLith/trunk/playpen/meshio/src/HDF5.hh
short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.cc
short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.hh
short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.icc
short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.cc
short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.hh
short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.icc
Modified:
short/3D/PyLith/trunk/playpen/meshio/src/Makefile.am
Log:
Removed HDF5 stuff from include. Started adding HDF5 stuff.
Added: short/3D/PyLith/trunk/playpen/meshio/src/HDF5.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/HDF5.cc 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/HDF5.cc 2006-09-14 16:34:41 UTC (rev 4527)
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "HDF5.hh" // implementation of class methods
+
+extern "C" {
+#include "hdf5.h" // USES hdf5
+}
+
+#include <stdexcept> // USES std::runtime_error
+#include <sstream> // USES std::ostringstream
+#include <assert.h> // USES assert()
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::meshio::HDF5::HDF5(const char* filename,
+ hid_t mode)
+{ // constructor
+ _file = H5Fopen(filename, mode, H5P_DEFAULT);
+ if (_file < 0) {
+ std::ostringstream msg;
+ msg << "Could not open HDF5 mesh file '" << filename << "'.";
+ throw std::runtime_error(msg.str());
+ } // if
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::meshio::HDF5::~HDF5(void)
+{ // destructor
+ H5Fclose(_file);
+} // destructor
+
+// ----------------------------------------------------------------------
+// Create group.
+hid_t
+pylith::meshio::HDF5::createGroup(const char* name)
+{ // createGroup
+ hid_t group = H5Gcreate(_file, name, 0);
+ if (group < 0) {
+ std::ostringstream msg;
+ msg << "Coule not create group '" << name << "'.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ return group;
+} // createGroup
+
+// ----------------------------------------------------------------------
+// Write scalar attribute.
+void
+pylith::meshio::HDF5::writeAttribute(hid_t parent,
+ const char* name,
+ const void* pValue,
+ hid_t datatype)
+{ // writeAttribute
+ try {
+ hid_t dataspace = H5Screate(H5S_SCALAR);
+ if (dataspace < 0)
+ throw std::runtime_error("Could not create dataspace for");
+ hid_t attribute = H5Acreate(parent, name,
+ datatype, dataspace, H5P_DEFAULT);
+ if (attribute < 0)
+ throw std::runtime_error("Could not create");
+ hid_t err = H5Awrite(attribute, datatype, pValue);
+ if (err < 0)
+ throw std::runtime_error("Could not write");
+ err = H5Aclose(attribute);
+ if (err < 0)
+ throw std::runtime_error("Could not close");
+ } catch (std::exception& err) {
+ std::ostringstream msg;
+ msg << err.what() << " attribute '" << name << "'.";
+ throw std::runtime_error(msg.str());
+ } // try/catch
+} // writeAttribute
+
+// ----------------------------------------------------------------------
+// Write string attribute.
+void
+pylith::meshio::HDF5::writeAttribute(hid_t parent,
+ const char* name,
+ const char* value)
+{ // writeAttribute
+} // writeAttribute
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/meshio/src/HDF5.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/HDF5.hh 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/HDF5.hh 2006-09-14 16:34:41 UTC (rev 4527)
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_hdf5_hh)
+#define pylith_meshio_hdf5_hh
+
+namespace pylith {
+ namespace meshio {
+ class HDF5;
+ } // meshio
+} // pylith
+
+typedef int hid_t; // HASA hid_t
+
+class pylith::meshio::HDF5
+{ // HDF5
+
+// PUBLIC METHODS -------------------------------------------------------
+public :
+
+ /** Constructor.
+ *
+ * @param filename Name of HDF5 file
+ * @param mode Mode for HDF5 file
+ */
+ HDF5(const char* filename, hid_t mode);
+
+ /// Destructor
+ ~HDF5(void);
+
+ /** Create group.
+ *
+ * Create group and leave group open for further operations.
+ *
+ * @param name Name of group (with absolute path).
+ * @returns HDF5 group
+ */
+ hid_t createGroup(const char* name);
+
+ /** Create scalar attribute.
+ *
+ * @param parent Parent of attribute.
+ * @param attrName Name of attribute.
+ * @param pValue Pointer to scalar value
+ * @param datatype Datatype of scalar.
+ */
+ void writeAttribute(hid_t parent,
+ const char* name,
+ const void* pValue,
+ hid_t datatype);
+
+ /** Create string attribute.
+ *
+ * @param parent Parent of attribute.
+ * @param attrName Name of attribute.
+ * @param value String value
+ */
+ void writeAttribute(hid_t parent,
+ const char* name,
+ const char* value);
+
+ /** Write dataset.
+ *
+ * @param parent Parent of dataset.
+ * @param name Name of dataset.
+ * @param pData Pointer to data.
+ * @param dims Dimensions of data.
+ * @param ndims Number of dimensions of data.
+ * @param datatype Type of data.
+ */
+ void writeDataset(hid_t parent,
+ const char* name,
+ const void* pData,
+ const int* dims,
+ const int ndims,
+ hid_t datatype);
+
+// PRIVATE MEMBERS ------------------------------------------------------
+private :
+
+ hid_t _file; ///< HDF5 file
+
+}; // HDF5
+
+#endif // pylith_meshio_hdf5_hh
+
+// End of file
Modified: short/3D/PyLith/trunk/playpen/meshio/src/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/Makefile.am 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/Makefile.am 2006-09-14 16:34:41 UTC (rev 4527)
@@ -13,21 +13,22 @@
bin_PROGRAMS = testascii
testascii_SOURCES = \
- HDF5.cc
+ MeshIO.cc \
+ MeshIOAscii.cc \
+ PetscMesh.cc \
+ testascii.cc
-# MeshIO.cc \
-# MeshIOAscii.cc \
+# HDF5.cc
# MeshIOHDF5.cc \
-# PetscMesh.cc \
-# testascii.cc
noinst_HEADERS = \
- HDF5.hh \
MeshIO.hh \
MeshIOAscii.hh \
- MeshIOHDF5.hh \
PetscMesh.hh
+# MeshIOHDF5.hh \
+# HDF5.hh \
+
HDF5_LIBS = -lhdf5
testascii_LDADD = $(PETSC_LIB) $(HDF5_LIBS)
Added: short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.cc 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.cc 2006-09-14 16:34:41 UTC (rev 4527)
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "MeshIO.hh" // implementation of class methods
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::meshio::MeshIO::MeshIO(void) :
+ _useIndexZero(true)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::meshio::MeshIO::~MeshIO(void)
+{ // destructor
+} // destructor
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.hh 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.hh 2006-09-14 16:34:41 UTC (rev 4527)
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_meshio_hh)
+#define pylith_meshio_meshio_hh
+
+namespace ALE {
+ template<typename T> class Obj;
+ class PetscMesh;
+}
+
+namespace pylith {
+ namespace meshio {
+ class MeshIO;
+ } // meshio
+} // pylith
+
+class pylith::meshio::MeshIO
+{ // MeshIO
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ MeshIO(void);
+
+ /// Destructor
+ virtual ~MeshIO(void);
+
+ /** Read mesh from file.
+ *
+ * @param pMesh Pointer to PETSc mesh object
+ */
+ virtual void read(ALE::Obj<ALE::PetscMesh>* pMesh) = 0;
+
+ /** Write mesh to file.
+ *
+ * @param mesh PETSc mesh object
+ */
+ virtual void write(const ALE::Obj<ALE::PetscMesh>& mesh) const = 0;
+
+// PROTECTED MEMBERS ////////////////////////////////////////////////////
+protected :
+
+ /** Get flag indicating whether indices start at 0 (True) or 1 (False).
+ *
+ * @returns True if indices start at 0, false if 1.
+ */
+ bool useIndexZero(void) const;
+
+ /** Set flag indicating whether indices start at 0 (True) or 1 (False).
+ *
+ * @param flag True if indices start at 0, false if 1.
+ */
+ void useIndexZero(const bool flag);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ bool _useIndexZero; ///< Flag indicating if indicates start at 0 (T) or 1 (F)
+
+}; // MeshIO
+
+#include "MeshIO.icc" // inline methods
+
+#endif // pylith_meshio_meshio_hh
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.icc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.icc 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.icc 2006-09-14 16:34:41 UTC (rev 4527)
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_meshio_hh)
+#error "MeshIO.icc must be included only from MeshIO.icc"
+#else
+
+// Get flag indicating whether indices start at 0 (True) or 1 (False).
+inline
+bool
+pylith::meshio::MeshIO::useIndexZero(void) const {
+ return _useIndexZero;
+}
+
+// Set flag indicating whether indices start at 0 (True) or 1 (False).
+inline
+void
+pylith::meshio::MeshIO::useIndexZero(const bool flag) {
+ _useIndexZero = flag;
+}
+
+#endif
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.cc 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.cc 2006-09-14 16:34:41 UTC (rev 4527)
@@ -0,0 +1,293 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "MeshIO.hh" // MeshIOHDF5 ISA MeshIO
+#include "MeshIOHDF5.hh" // implementation of class methods
+
+#include "PetscMesh.hh"
+extern "C" {
+#include "hdf5.h"
+}
+
+#include <stdexcept> // USES std::runtime_error
+#include <sstream> // USES std::ostringstream
+#include <assert.h> // USES assert()
+
+// ----------------------------------------------------------------------
+// Constructor
+MeshIOHDF5::MeshIOHDF5(void) :
+ _filename("")
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+MeshIOHDF5::~MeshIOHDF5(void)
+{ // destructor
+} // destructor
+
+// ----------------------------------------------------------------------
+// Read mesh from file.
+void
+MeshIOHDF5::read(ALE::Obj<ALE::PetscMesh>* pMesh)
+{ // read
+ assert(0 != pMesh);
+
+
+
+ int meshDim = 0;
+ int numDims = 0;
+ int numVertices = 0;
+ int numElements = 0;
+ int numCorners = 0;
+ double* coordinates = 0;
+ int* elements = 0;
+
+ hid_t filein = H5Fopen(_filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
+ if (filein < 0) {
+ std::ostringstream msg;
+ msg << "Could not open HDF5 mesh file '" << _filename
+ << "' for reading.\n";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ _readMeshInfo(filein, pMesh);
+ _readVertices(filein, &coordinates, &numVertices, &numDims);
+ _readElements(filein, &elements, &numElements, &numCorners);
+
+ *pMesh = ALE::PetscMesh(PETSC_COMM_WORLD, meshDim);
+ (*pMesh)->debug = true;
+ bool interpolate = false;
+
+#if 1
+ // allow mesh to have different dimension than coordinates
+ ALE::Obj<ALE::PetscMesh::sieve_type> topology = (*pMesh)->getTopology();
+ topology->setStratification(false);
+ (*pMesh)->buildTopology(numElements, elements, numVertices,
+ interpolate, numCorners);
+ topology->stratify();
+ topology->setStratification(true);
+ (*pMesh)->createVertexBundle(numElements, elements, 0, numCorners);
+ (*pMesh)->createSerialCoordinates(numDims, numElements, coordinates);
+#else
+ // require mesh to have same dimension as coordinates
+ (*pMesh)->populate(numElements, elements, numVertices, coordinates,
+ interpolate, numCorners);
+#endif
+ delete[] coordinates; coordinates = 0;
+ delete[] elements; elements = 0;
+
+ // loop over charts
+ // _readChart();
+
+ H5Fclose(filein);
+} // read
+
+// ----------------------------------------------------------------------
+// Write mesh to file.
+void
+MeshIOHDF5::write(const ALE::Obj<ALE::PetscMesh>& mesh) const
+{ // write
+ HDF5 fileout(_filename.c_str(), H5F_ACC_TRUNC);
+
+ try {
+ _writeMeshInfo(fileout, mesh);
+ _writeVertices(fileout, mesh);
+ _writeElements(fileout, mesh);
+
+ // LOOP OVER CHARTS
+ // _writeChart(fileout, mesh, nameIter->c_str());
+
+ } catch (std::exception& err) {
+ std::ostringstream msg;
+ msg
+ << "Error occurred while writing HDF5 file '" << _filename << "'.\n"
+ << err.what();
+ throw std::runtime_error(msg.str());
+ } catch (...) {
+ std::ostringstream msg;
+ msg
+ << "Unknown error occurred while writing HDF5 file '"
+ << _filename << "'";
+ throw std::runtime_error(msg.str());
+ } // try/catch
+} // write
+
+// ----------------------------------------------------------------------
+// Read general mesh information.
+void
+MeshIOHDF5::_readMeshInfo(hid_t& filein,
+ ALE::Obj<ALE::PetscMesh>* pMesh)
+{ // _readMeshInfo
+} // _readMeshInfo
+
+// ----------------------------------------------------------------------
+// Write general mesh information.
+void
+MeshIOHDF5::_writeMeshInfo(HDF5& fileout,
+ const ALE::Obj<ALE::PetscMesh>& mesh) const
+{ // _writeMeshInfo
+ hid_t meshGroup = fileout.createGroup("/mesh");
+
+ const int dimension = mesh->getDimension();
+ fileout.createAttribute(meshGroup, "dimension",
+ (void*) &dimension, H5T_NATIVE_INT);
+
+ if (H5Gclose(meshGroup) < 0)
+ throw std::runtime_error("Could not close 'mesh' group. ");
+} // _writeMeshInfo
+
+// ----------------------------------------------------------------------
+// Read mesh vertices.
+void
+MeshIOHDF5::_readVertices(hid_t& filein,
+ double** pCoordinates,
+ int* pNumVertices,
+ int* pNumDims) const
+{ // _readVertices
+ double* coordinates = 0;
+ int numDims = 0;
+ int numVertices = 0;
+
+ // ADD STUFF HERE
+
+ if (0 != pCoordinates)
+ *pCoordinates = coordinates;
+ if (0 != pNumVertices)
+ *pNumVertices = numVertices;
+ if (0 != pNumDims)
+ *pNumDims = numDims;
+} // _readVertices
+
+// ----------------------------------------------------------------------
+// Write mesh vertices.
+void
+MeshIOHDF5::_writeVertices(HDF5& fileout,
+ const ALE::Obj<ALE::PetscMesh>& mesh) const
+{ // _writeVertices
+ ALE::Obj<ALE::PetscMesh::field_type> coords_field = mesh->getCoordinates();
+ ALE::Obj<ALE::PetscMesh::bundle_type> vertexBundle = mesh->getBundle(0);
+ ALE::PetscMesh::field_type::patch_type patch;
+ const double* coordinates = coords_field->restrict(patch);
+ const int numVertices = (vertexBundle->getGlobalOffsets()) ?
+ vertexBundle->getGlobalOffsets()[mesh->commSize()] :
+ mesh->getTopology()->depthStratum(0)->size();
+ const int numDims = coords_field->getFiberDimension(patch,
+ *mesh->getTopology()->depthStratum(0)->begin());
+
+ hid_t verticesId = fileout.createGroup("/mesh/vertices");
+ int dims[2];
+ dims[0] = numVertices;
+ dims[1] = numDims;
+ fileout.writeDataset(verticesId, "coordinates", (void*) coordinates,
+ dims, 2, H5T_NATIVE_DOUBLE);
+
+ if (H5Gclose(verticesId) < 0)
+ throw std::runtime_error("Could not close 'mesh/vertices' group. ");
+} // _writeVertices
+
+// ----------------------------------------------------------------------
+// Read mesh elements.
+void
+MeshIOHDF5::_readElements(hid_t& filein,
+ int** pElements,
+ int* pNumElements,
+ int* pNumCorners) const
+{ // _readElements
+ int* elements = 0;
+ int numElements = 0;
+ int numCorners = 0;
+ int dimension = 0;
+
+ // ADD STUFF HERE
+
+ if (0 != pElements)
+ *pElements = elements;
+ if (0 != pNumElements)
+ *pNumElements = numElements;
+ if (0 != pNumCorners)
+ *pNumCorners = numCorners;
+} // _readElements
+
+// ----------------------------------------------------------------------
+// Write mesh elements.
+void
+MeshIOHDF5::_writeElements(hid_t& fileout,
+ const ALE::Obj<ALE::PetscMesh>& mesh) const
+{ // _writeElements
+ ALE::Obj<ALE::PetscMesh::sieve_type> topology = mesh->getTopology();
+ ALE::Obj<ALE::PetscMesh::sieve_type::traits::heightSequence> elements =
+ topology->heightStratum(0);
+ ALE::Obj<ALE::PetscMesh::bundle_type> vertexBundle = mesh->getBundle(0);
+ ALE::PetscMesh::bundle_type::patch_type patch;
+ std::string orderName("element");
+
+ assert(0 != topology);
+ assert(0 != elements);
+ assert(0 != vertexBundle);
+
+ int numCorners =
+ topology->nCone(*elements->begin(), topology->depth())->size();
+ const int numElements = mesh->getTopology()->heightStratum(0)->size();
+
+ int* simplices =
+ (numElements*numCorners > 0) ? new int[numElements*numCorners] : 0;
+ const int offset = (useIndexZero()) ? 0 : 1;
+ int index = 0;
+ for(ALE::PetscMesh::sieve_type::traits::heightSequence::iterator e_itor =
+ elements->begin();
+ e_itor != elements->end();
+ ++e_itor) {
+ ALE::Obj<ALE::PetscMesh::bundle_type::order_type::coneSequence> cone =
+ vertexBundle->getPatch(orderName, *e_itor);
+ assert(0 != cone);
+ for(ALE::PetscMesh::bundle_type::order_type::coneSequence::iterator c_itor =
+ cone->begin();
+ c_itor != cone->end();
+ ++c_itor)
+ simplices[index++] =
+ offset + vertexBundle->getIndex(patch, *c_itor).prefix;
+
+ hid_t elementsId = fileout.createGroup("/mesh/elements");
+ int dims[2];
+ dims[0] = numElements;
+ dims[1] = numCorners;
+ fileout.writeDataset(elementsId, "simplices", (void*) simplices,
+ dims, 2, H5T_NATIVE_INT);
+
+ if (H5Gclose(elementsId) < 0)
+ throw std::runtime_error("Could not close 'mesh/vertices' group. ");
+} // _writeElements
+
+// ----------------------------------------------------------------------
+// Read mesh charts.
+void
+MeshIOHDF5::_readChart(hid_t& filein,
+ ALE::Obj<ALE::PetscMesh>* pMesh) const
+{ // _readChart
+ std::string name = ""; // Name of chart
+ int dimension = 0; // Topology dimension associated with chart
+ int count = 0; // Number of entities in chart
+ int* indices = 0; // Indices of entities in chart
+
+} // _readChart
+
+// ----------------------------------------------------------------------
+// Write mesh chart.
+void
+MeshIOHDF5::_writeChart(hid_t& fileout,
+ const ALE::Obj<ALE::PetscMesh>& mesh,
+ const char* name) const
+{ // _writeChart
+} // _writeChart
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.hh 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.hh 2006-09-14 16:34:41 UTC (rev 4527)
@@ -0,0 +1,160 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_meshiohdf5_hh)
+#define pylith_meshio_meshiohdf5_hh
+
+#include <string> // HASA std::string
+
+namespace ALE {
+ template<typename T> class Obj;
+ class PetscMesh;
+} // ALE
+
+namespace pylith {
+ namespace meshio {
+ class MeshIO;
+ class MeshIOHDF5;
+ class HDF5; // USES HDF5
+ } // pylith
+} // meshio
+
+typedef int hid_t;
+
+class pylith::meshio::MeshIOHDF5 : public pylith::meshio::MeshIO
+{ // MeshIOHDF5
+
+// PUBLIC METHODS -------------------------------------------------------
+public :
+
+ /// Constructor
+ MeshIOHDF5(void);
+
+ /// Destructor
+ ~MeshIOHDF5(void);
+
+ /** Set filename for HDF5 file.
+ *
+ * @param filename Name of file
+ */
+ void filename(const char* name);
+
+ /** Get filename of HDF5 file.
+ *
+ * @returns Name of file
+ */
+ const char* filename(void) const;
+
+ /** Read mesh from file.
+ *
+ * @param pMesh Pointer to PETSc mesh object
+ */
+ void read(ALE::Obj<ALE::PetscMesh>* pMesh);
+
+ /** Write mesh to file.
+ *
+ * @param mesh PETSc mesh object
+ */
+ void write(const ALE::Obj<ALE::PetscMesh>& mesh) const;
+
+// PRIVATE METHODS ------------------------------------------------------
+private :
+
+ /** Read general mesh information.
+ *
+ * @param filein HDF5 file
+ * @param pMesh Pointer to mesh
+ */
+ void _readMeshInfo(hid_t& filein,
+ ALE::Obj<ALE::PetscMesh>* pMesh);
+
+ /** Write general mesh information.
+ *
+ * @param filein HDF5 file
+ * @param mesh PETSc mesh
+ */
+ void _writeMeshInfo(hid_t& fileout,
+ const ALE::Obj<ALE::PetscMesh>& mesh) const;
+
+ /** Read mesh vertices.
+ *
+ * @param filein HDF5 file
+ * @param pCoordinates Pointer to array of vertex coordinates
+ * @param pNumVertices Pointer to number of vertices
+ * @param pNumDims Pointer to number of dimensions
+ */
+ void _readVertices(hid_t& filein,
+ double** pCoordinates,
+ int* pNumVertices,
+ int* pNumDims) const;
+
+ /** Write mesh vertices.
+ *
+ * @param fileout HDF file
+ * @param mesh PETSc mesh
+ */
+ void _writeVertices(hid_t& fileout,
+ const ALE::Obj<ALE::PetscMesh>& mesh) const;
+
+ /** Read mesh elements.
+ *
+ * @param filein Input stream
+ * @param pElements Pointer to array of elements (vertices in each element)
+ * @param pNumElements Pointer to number of elements
+ * @param pNumCorners Pointer to number of corners in each element
+ */
+ void _readElements(hid_t& filein,
+ int** pElements,
+ int* pNumElements,
+ int* pNumCorners) const;
+
+ /** Write mesh elements.
+ *
+ * @param fileout HDF file
+ * @param mesh PETSc mesh
+ */
+ void _writeElements(hid_t& fileout,
+ const ALE::Obj<ALE::PetscMesh>& mesh) const;
+
+ /** Read mesh chart.
+ *
+ * @param filein HDF5 file
+ * @param pMesh Pointer to PETSc mesh
+ */
+ void _readChart(hid_t& filein,
+ ALE::Obj<ALE::PetscMesh>* pMesh) const;
+
+ /** Write mesh chart.
+ *
+ * @param fileout HDF5 file
+ * @param mesh PETSc mesh
+ * @param name Name of chart
+ */
+ void _writeChart(hid_t& fileout,
+ const ALE::Obj<ALE::PetscMesh>& mesh,
+ const char* name) const;
+
+// PRIVATE MEMBERS ------------------------------------------------------
+private :
+
+ std::string _filename; ///< Name of file
+
+}; // MeshIOHDF5
+
+#include "MeshIOHDF5.icc" // inline methods
+
+#endif // pylith_meshio_meshiohdf5_hh
+
+// version
+// $Id$
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.icc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.icc 2006-09-14 16:24:17 UTC (rev 4526)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.icc 2006-09-14 16:34:41 UTC (rev 4527)
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(meshiohdf5_hh)
+#error "MeshIOHDF5.icc must be included only from MeshIOHDF5.icc"
+#else
+
+// Set filename for HDF5 file.
+inline
+void
+MeshIOHDF5::filename(const char* name) {
+ _filename = name;
+}
+
+// Get filename of HDF5 file.
+inline
+const char*
+MeshIOHDF5::filename(void) const {
+ return _filename.c_str();
+}
+
+#endif
+
+// End of file
More information about the cig-commits
mailing list