[cig-commits] r4542 - in short/3D/PyLith/trunk: . libsrc
libsrc/meshio playpen/meshio/src pylith/meshio
baagaard at geodynamics.org
baagaard at geodynamics.org
Thu Sep 14 18:45:20 PDT 2006
Author: baagaard
Date: 2006-09-14 18:45:20 -0700 (Thu, 14 Sep 2006)
New Revision: 4542
Added:
short/3D/PyLith/trunk/libsrc/meshio/
short/3D/PyLith/trunk/libsrc/meshio/HDF5.cc
short/3D/PyLith/trunk/libsrc/meshio/HDF5.hh
short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.icc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.icc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOHDF5.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOHDF5.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIOHDF5.icc
short/3D/PyLith/trunk/libsrc/meshio/README.txt
Removed:
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/MeshIOAscii.cc
short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.hh
short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.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
short/3D/PyLith/trunk/playpen/meshio/src/PetscMesh.cc
short/3D/PyLith/trunk/playpen/meshio/src/PetscMesh.hh
short/3D/PyLith/trunk/playpen/meshio/src/meshio.txt
short/3D/PyLith/trunk/playpen/meshio/src/testascii.cc
Modified:
short/3D/PyLith/trunk/configure.ac
short/3D/PyLith/trunk/libsrc/Makefile.am
short/3D/PyLith/trunk/pylith/meshio/MeshIOAscii.py
Log:
Moved playpen/meshio stuff to libsrc/meshio. Added spatialdata and proj4 tests to configure.
Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/configure.ac 2006-09-15 01:45:20 UTC (rev 4542)
@@ -85,6 +85,31 @@
])
fi
+# PROJ4
+AC_CHECK_LIB(proj, pj_init_plus, [
+ AC_CHECK_HEADER([proj_api.h], [], [
+ AC_MSG_ERROR([Proj4 header not found; try CPPFLAGS="-I<Proj4 include dir>"])
+ ])
+],[
+ AC_MSG_ERROR([Proj4 library not found; try LDFLAGS="-L<Proj4 lib dir>"])
+])
+
+# SPATIALDATA
+AC_LANG(C++)
+AC_CHECK_HEADER([spatialdata/spatialdb/SpatialDB.hh], [], [
+ AC_MSG_ERROR([SpatialDB header not found; try CPPFLAGS="-I<Spatialdata include dir>"])
+])
+AC_MSG_CHECKING([for spatialdb::SimpleDB in -lspatialdata])
+AC_REQUIRE_CPP
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <spatialdata/spatialdb/SpatialDB.hh>]
+ [#include <spatialdata/spatialdb/SimpleDB.hh>]],
+ [[spatialdata::spatialdb::SimpleDB db;]])],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+ AC_MSG_ERROR([Spatialdata library not found; try LDFLAGS="-L<Spatialdata lib dir>"])
+])
+
# DOXYGEN
AM_CONDITIONAL([ENABLE_DOCUMENTATION], [test "$enable_documentation" = yes])
if test "$enable_documentation" = "yes" ; then
@@ -101,10 +126,13 @@
AC_CONFIG_FILES([Makefile
pylith/Makefile
libsrc/Makefile
- libsrc/materials/Makefile
+ libsrc/meshio/Makefile
modulesrc/Makefile
modulesrc/meshio/Makefile
doc/Makefile])
+
+# libsrc/materials/Makefile
+
AC_OUTPUT
dnl end of configure.ac
Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am 2006-09-15 01:45:20 UTC (rev 4542)
@@ -11,8 +11,10 @@
#
SUBDIRS = \
- materials
+ meshio
+# materials
+
# version
# $Id$
Copied: short/3D/PyLith/trunk/libsrc/meshio/HDF5.cc (from rev 4537, short/3D/PyLith/trunk/playpen/meshio/src/HDF5.cc)
Copied: short/3D/PyLith/trunk/libsrc/meshio/HDF5.hh (from rev 4537, short/3D/PyLith/trunk/playpen/meshio/src/HDF5.hh)
Added: short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/Makefile.am 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/libsrc/meshio/Makefile.am 2006-09-15 01:45:20 UTC (rev 4542)
@@ -0,0 +1,40 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+subpackage = meshio
+include $(top_srcdir)/subpackage.am
+
+lib_LTLIBRARIES = libpylithmeshio.la
+
+libpylithmeshio_la_SOURCES = \
+ MeshIO.cc \
+ MeshIOAscii.cc
+
+subpkginclude_HEADERS = \
+ MeshIO.hh \
+ MeshIO.icc \
+ MeshIOAscii.hh \
+ MeshIOAscii.icc
+
+noinst_HEADERS =
+
+INCLUDES += $(PETSC_INCLUDE)
+
+# export
+clean-local: clean-subpkgincludeHEADERS
+BUILT_SOURCES = export-subpkgincludeHEADERS
+CLEANFILES = export-subpkgincludeHEADERS
+
+# version
+# $Id$
+
+# End of file
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc (from rev 4538, short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.cc)
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh (from rev 4538, short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.hh)
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.icc (from rev 4538, short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.icc)
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.cc (from rev 4538, short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.cc)
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.hh (from rev 4538, short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.hh)
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.icc (from rev 4538, short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.icc)
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIOHDF5.cc (from rev 4537, short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.cc)
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIOHDF5.hh (from rev 4537, short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.hh)
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshIOHDF5.icc (from rev 4537, short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.icc)
Copied: short/3D/PyLith/trunk/libsrc/meshio/README.txt (from rev 4537, short/3D/PyLith/trunk/playpen/meshio/src/meshio.txt)
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/HDF5.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/HDF5.cc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/HDF5.cc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,96 +0,0 @@
-// -*- 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
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/HDF5.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/HDF5.hh 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/HDF5.hh 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,96 +0,0 @@
-// -*- 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
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.cc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.cc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,28 +0,0 @@
-// -*- 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
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.hh 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.hh 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,74 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_meshio_hh)
-#define pylith_meshio_meshio_hh
-
-#include <Mesh.hh> // PETSc Mesh
-
-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::Mesh>& pMesh, const bool interpolate) = 0;
-
- /** Write mesh to file.
- *
- * @param mesh PETSc mesh object
- */
- virtual void write(const ALE::Obj<ALE::Mesh>& 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
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.icc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.icc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIO.icc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,33 +0,0 @@
-// -*- 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
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.cc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.cc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,439 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include "MeshIO.hh" // MeshIOAscii ISA MeshIO
-#include "MeshIOAscii.hh" // implementation of class methods
-
-#include <fstream> // USES std::ifstream, std::ofstream
-#include <stdexcept> // USES std::runtime_error
-#include <sstream> // USES std::ostringstream
-#include <assert.h> // USES assert()
-#include <iomanip> // USES setw(), setiosflags(), resetiosflags()
-
-// ----------------------------------------------------------------------
-// Constructor
-pylith::meshio::MeshIOAscii::MeshIOAscii(void) :
- _filename("")
-{ // constructor
-} // constructor
-
-// ----------------------------------------------------------------------
-// Destructor
-pylith::meshio::MeshIOAscii::~MeshIOAscii(void)
-{ // destructor
-} // destructor
-
-// ----------------------------------------------------------------------
-// Unpickle mesh
-void
-pylith::meshio::MeshIOAscii::read(Obj<Mesh>& mesh,
- const bool interpolate)
-{ // read
- int meshDim = 0;
- int numDims = 0;
- int numVertices = 0;
- int numCells = 0;
- int numCorners = 0;
- double* coordinates = 0;
- int* cells = 0;
-
- std::ifstream filein(_filename.c_str());
- if (!filein.is_open() || !filein.good()) {
- std::ostringstream msg;
- msg << "Could not open mesh file '" << _filename
- << "' for reading.\n";
- throw std::runtime_error(msg.str());
- } // if
-
- std::string token;
- const int maxIgnore = 1024;
- filein >> token;
- if (0 != strcasecmp(token.c_str(), "mesh")) {
- std::ostringstream msg;
- msg << "Expected 'mesh' token but encountered '" << token << "'\n";
- throw std::runtime_error(msg.str());
- }
-
- bool readDim = false;
- bool readCells = false;
- bool readVertices = false;
- bool builtTopology = false;
-
- filein.ignore(maxIgnore, '{');
- filein >> token;
- while (filein.good() && token != "}") {
- if (0 == strcasecmp(token.c_str(), "dimension")) {
- filein.ignore(maxIgnore, '=');
- filein >> meshDim;
- readDim = true;
- } else if (0 == strcasecmp(token.c_str(), "use-index-zero")) {
- filein.ignore(maxIgnore, '=');
- std::string flag = "";
- filein >> flag;
- if (0 == strcasecmp(flag.c_str(), "true"))
- useIndexZero(true);
- else
- useIndexZero(false);
- } else if (0 == strcasecmp(token.c_str(), "vertices")) {
- filein.ignore(maxIgnore, '{');
- _readVertices(filein, &coordinates, &numVertices, &numDims);
- readVertices = true;
- } else if (0 == strcasecmp(token.c_str(), "cells")) {
- filein.ignore(maxIgnore, '{');
- _readCells(filein, &cells, &numCells, &numCorners);
- readCells = true;
- } else if (0 == strcasecmp(token.c_str(), "group")) {
- if (!builtTopology)
- throw std::runtime_error("Both 'vertices' and 'cells' must "
- "precede any groups in mesh file.");
- filein.ignore(maxIgnore, '{');
- _readGroup(filein, mesh);
- } else {
- std::ostringstream msg;
- msg << "Could not parse '" << token << "' into a mesh setting.";
- throw std::runtime_error(msg.str());
- } // else
-
- if (readDim && readCells && readVertices && !builtTopology) {
- // Can now build topology
- mesh = Mesh(PETSC_COMM_WORLD, meshDim);
- mesh->debug = true;
-
- // allow mesh to have different dimension than coordinates
- Obj<sieve_type> sieve = new sieve_type(mesh->comm(), mesh->debug);
- Obj<topology_type> topology = new topology_type(mesh->comm(), mesh->debug);
-
- ALE::New::SieveBuilder<sieve_type>::buildTopology(sieve, meshDim, numCells, cells, numVertices, interpolate, numCorners);
- sieve->stratify();
- topology->setPatch(0, sieve);
- topology->stratify();
- mesh->setTopologyNew(topology);
- ALE::New::SieveBuilder<sieve_type>::buildCoordinates(mesh->getSection("coordinates"), meshDim, coordinates);
- delete[] coordinates; coordinates = NULL;
- delete[] cells; cells = NULL;
- builtTopology = true;
- } // if
-
- filein >> token;
- } // while
- filein.close();
-} // read
-
-// ----------------------------------------------------------------------
-// Write mesh to file.
-void
-pylith::meshio::MeshIOAscii::write(const Obj<Mesh>& mesh) const
-{ // write
- std::ofstream fileout(_filename.c_str());
- if (!fileout.is_open() || !fileout.good()) {
- std::ostringstream msg;
- msg << "Could not open mesh file '" << _filename
- << "' for writing.\n";
- throw std::runtime_error(msg.str());
- } // if
-
- const int dimension = mesh->getDimension();
-
- fileout
- << "mesh = {\n"
- << " dimension = " << dimension << "\n"
- << " use-index-zero = " << (useIndexZero() ? "true" : "false") << "\n";
-
- _writeVertices(fileout, mesh);
- _writeCells(fileout, mesh);
-
- // LOOP OVER GROUPS
- // _writeGroup(fileout, mesh, nameIter->c_str());
-
- fileout << "}\n";
- fileout.close();
-} // write
-
-// ----------------------------------------------------------------------
-// Read mesh vertices.
-void
-pylith::meshio::MeshIOAscii::_readVertices(std::istream& filein,
- double** pCoordinates,
- int* pNumVertices,
- int* pNumDims) const
-{ // _readVertices
- double* coordinates = 0;
- int numDims = 0;
- int numVertices = 0;
-
- std::string token;
- const int maxIgnore = 1024;
- filein >> token;
- while (filein.good() && token != "}") {
- if (0 == strcasecmp(token.c_str(), "dimension")) {
- filein.ignore(maxIgnore, '=');
- filein >> numDims;
- } else if (0 == strcasecmp(token.c_str(), "count")) {
- filein.ignore(maxIgnore, '=');
- filein >> numVertices;
- } else if (0 == strcasecmp(token.c_str(), "coordinates")) {
- const int size = numVertices*numDims;
- if (0 == size) {
- std::ostringstream msg;
- msg << "Tokens 'dimension' and 'count' must precede 'coordinates'.";
- throw std::runtime_error(msg.str());
- } // if
-
- filein.ignore(maxIgnore, '{');
- delete[] coordinates; coordinates = new double[size];
- assert(0 != coordinates);
- for (int i=0; i < size; ++i)
- filein >> coordinates[i];
- filein.ignore(maxIgnore, '}');
- } else {
- std::ostringstream msg;
- msg << "Could not parse '" << token << "' into a vertices setting.";
- throw std::runtime_error(msg.str());
- } // else
- filein >> token;
- } // while
- if (!filein.good())
- throw std::runtime_error("I/O error while parsing vertices settings.");
-
- if (0 != pCoordinates)
- *pCoordinates = coordinates;
- if (0 != pNumVertices)
- *pNumVertices = numVertices;
- if (0 != pNumDims)
- *pNumDims = numDims;
-} // _readVertices
-
-// ----------------------------------------------------------------------
-// Write mesh vertices.
-void
-pylith::meshio::MeshIOAscii::_writeVertices(std::ostream& fileout,
- const Obj<Mesh>& mesh) const
-{ // _writeVertices
- const Obj<Mesh::section_type>& coords_field = mesh->getSection("coordinates");
- const Obj<Mesh::topology_type>& topology = mesh->getTopologyNew();
- const Mesh::section_type::patch_type patch = 0;
- const Obj<Mesh::topology_type::label_sequence>& vertices = topology->depthStratum(patch, 0);
- const int embedDim = coords_field->getFiberDimension(patch, *vertices->begin());
-
- fileout
- << " vertices = {\n"
- << " dimension = " << embedDim << "\n"
- << " count = " << vertices->size() << "\n"
- << " coordinates = {\n"
- << std::resetiosflags(std::ios::fixed)
- << std::setiosflags(std::ios::scientific)
- << std::setprecision(6);
- for(Mesh::topology_type::label_sequence::iterator v_iter = vertices->begin(); v_iter != vertices->end(); ++v_iter) {
- const Mesh::section_type::value_type *coordinates = coords_field->restrict(patch, *v_iter);
-
- fileout << " ";
- for(int d = 0; d < embedDim; ++d) {
- fileout << std::setw(18) << coordinates[d];
- }
- fileout << "\n";
- } // for
- fileout
- << " }\n"
- << " }\n";
-} // _writeVertices
-
-// ----------------------------------------------------------------------
-// Read mesh cells.
-void
-pylith::meshio::MeshIOAscii::_readCells(std::istream& filein,
- int** pCells,
- int* pNumCells,
- int* pNumCorners) const
-{ // _readCells
- int* cells = 0;
- int numCells = 0;
- int numCorners = 0;
- int dimension = 0;
-
- std::string token;
- const int maxIgnore = 1024;
- filein >> token;
- while (filein.good() && token != "}") {
- if (0 == strcasecmp(token.c_str(), "num-corners")) {
- filein.ignore(maxIgnore, '=');
- filein >> numCorners;
- } else if (0 == strcasecmp(token.c_str(), "count")) {
- filein.ignore(maxIgnore, '=');
- filein >> numCells;
- } else if (0 == strcasecmp(token.c_str(), "simplices")) {
- const int size = numCells*numCorners;
- if (0 == size) {
- std::ostringstream msg;
- msg << "Tokens 'num-corners' and 'count' must precede 'cells'.";
- throw std::runtime_error(msg.str());
- } // if
-
- filein.ignore(maxIgnore, '{');
- delete[] cells; cells = new int[size];
- assert(0 != cells);
- for (int i=0; i < size; ++i)
- filein >> cells[i];
- if (!useIndexZero()) {
- // if files begins with index 1, then decrement to index 0
- // for compatibility with Sieve
- for (int i=0; i < size; ++i)
- --cells[i];
- } // if
-
- filein.ignore(maxIgnore, '}');
- } else {
- std::ostringstream msg;
- msg << "Could not parse '" << token << "' into an cells setting.";
- throw std::runtime_error(msg.str());
- } // else
- filein >> token;
- } // while
- if (!filein.good())
- throw std::runtime_error("I/O error while parsing cells settings.");
-
- if (0 != pCells)
- *pCells = cells;
- if (0 != pNumCells)
- *pNumCells = numCells;
- if (0 != pNumCorners)
- *pNumCorners = numCorners;
-} // _readCells
-
-// ----------------------------------------------------------------------
-// Write mesh cells.
-void
-pylith::meshio::MeshIOAscii::_writeCells(std::ostream& fileout,
- const Obj<Mesh>& mesh) const
-{ // _writeCells
- const Obj<topology_type>& topology = mesh->getTopologyNew();
- const topology_type::patch_type patch = 0;
- const Obj<sieve_type>& sieve = topology->getPatch(patch);
- const Obj<Mesh::topology_type::label_sequence>& cells = topology->heightStratum(patch, 0);
- const Obj<Mesh::numbering_type>& vNumbering = mesh->getLocalNumbering(0);
- const int numCorners = sieve->nCone(*cells->begin(), topology->depth())->size();
-
- fileout
- << " cells = {\n"
- << " count = " << cells->size() << "\n"
- << " num-corners = " << numCorners << "\n"
- << " simplices = {\n";
-
- const int offset = (useIndexZero()) ? 0 : 1;
- for(Mesh::topology_type::label_sequence::iterator e_iter = cells->begin(); e_iter != cells->end(); ++e_iter) {
- fileout << " ";
- const Obj<sieve_type::traits::coneSequence>& cone = sieve->cone(*e_iter);
-
- for(sieve_type::traits::coneSequence::iterator c_iter = cone->begin(); c_iter != cone->end(); ++c_iter) {
- fileout << std::setw(8) << vNumbering->getIndex(*c_iter) + offset;
- }
- fileout << "\n";
- } // for
- fileout
- << " }\n"
- << " }\n";
-} // _writeCells
-
-// ----------------------------------------------------------------------
-// Read mesh group.
-void
-pylith::meshio::MeshIOAscii::_readGroup(std::istream& filein,
- const Obj<Mesh>& mesh) const
-{ // _readGroup
- std::string name = ""; // Name of group
- int dimension = 0; // Topology dimension associated with group
- int count = 0; // Number of entities in group
- int* indices = 0; // Indices of entities in group
-
- std::string token;
- const int maxIgnore = 1024;
- filein >> token;
- while (filein.good() && token != "}") {
- if (0 == strcasecmp(token.c_str(), "name")) {
- filein.ignore(maxIgnore, '=');
- filein >> name;
- } else if (0 == strcasecmp(token.c_str(), "dimension")) {
- filein.ignore(maxIgnore, '=');
- filein >> dimension;
- } else if (0 == strcasecmp(token.c_str(), "count")) {
- filein.ignore(maxIgnore, '=');
- filein >> count;
- } else if (0 == strcasecmp(token.c_str(), "indices")) {
- if (0 == count) {
- std::ostringstream msg;
- msg << "Tokens 'count' must precede 'indices'.";
- throw std::runtime_error(msg.str());
- } // if
-
- filein.ignore(maxIgnore, '{');
- delete[] indices; indices = new int[count];
- assert(0 != indices);
- for (int i = 0; i < count; ++i)
- filein >> indices[i];
- filein.ignore(maxIgnore, '}');
- } else {
- std::ostringstream msg;
- msg << "Could not parse '" << token << "' into a group setting.";
- throw std::runtime_error(msg.str());
- } // else
- filein >> token;
- } // while
- if (!filein.good())
- throw std::runtime_error("I/O error while parsing group settings.");
-
-#if 0
- assert(!mesh.isNull());
- Obj<Mesh::field_type> groupField = mesh->getField(name);
- const int meshDim = mesh->getDimension();
- Obj<std::list<Mesh::point_type> > patchPoints =
- std::list<Mesh::point_type>();
- Mesh::field_type::patch_type patch;
-
- patchPoints->clear();
- if (meshDim == dimension) {
- for (int i=0; i < count; ++i)
- patchPoints->push_back(Mesh::point_type(0, indices[i]));
- groupField->setPatch(patchPoints, patch);
- } else if (0 == dimension) {
- } // if
- groupField->setFiberDimensionByHeight(patch, 0, 1);
- groupField->orderPatches();
- const double zero = 0;
- for (int i=0; i < count; ++i)
- groupField->update(patch, Mesh::point_type(0, i), &zero);
-#endif
-} // _readGroup
-
-// ----------------------------------------------------------------------
-// Write mesh group.
-void
-pylith::meshio::MeshIOAscii::_writeGroup(std::ostream& fileout,
- const Obj<Mesh>& mesh,
- const char* name) const
-{ // _writeGroup
- //_writeGroup(fileout, mesh);
- // ADD STUFF HERE
- int count = 0; // TEMPORARY
- int dimension = 0; // TEMPORARY
-
- fileout
- << " group = {\n"
- << " name = " << name << "\n"
- << " dimension = " << dimension << "\n"
- << " count = " << count << "\n"
- << " indices = {\n";
-
- fileout
- << " }\n"
- << " }\n";
-} // _writeGroup
-
-// End of file
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.hh 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.hh 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,145 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_meshioascii_hh)
-#define pylith_meshio_meshioascii_hh
-
-#include <iosfwd> // USES std::istream, std::ostream
-#include <string> // HASA std::string
-#include <MeshIO.hh>
-
-using ALE::Obj;
-
-namespace pylith {
- namespace meshio {
- class MeshIOAscii;
- } // meshio
-} // pylith
-
-class pylith::meshio::MeshIOAscii : public pylith::meshio::MeshIO
-{ // MeshIOAscii
-// PUBLIC TYPEDEFS -------------------------------------------------------
-public :
- typedef ALE::Mesh Mesh;
- typedef ALE::Mesh::sieve_type sieve_type;
- typedef ALE::Mesh::topology_type topology_type;
-// PUBLIC METHODS -------------------------------------------------------
-public :
-
- /// Constructor
- MeshIOAscii(void);
-
- /// Destructor
- ~MeshIOAscii(void);
-
- /** Set filename for ASCII file.
- *
- * @param filename Name of file
- */
- void filename(const char* name);
-
- /** Get filename of ASCII file.
- *
- * @returns Name of file
- */
- const char* filename(void) const;
-
- /** Read mesh from file.
- *
- * @param pMesh Pointer to PETSc mesh object
- * @param interpolate Flag indicating whether to build intermediate topology
- */
- void read(Obj<Mesh>& mesh,
- const bool interpolate =false);
-
- /** Write mesh to file.
- *
- * @param mesh PETSc mesh object
- */
- void write(const Obj<Mesh>& mesh) const;
-
-// PRIVATE METHODS ------------------------------------------------------
-private :
-
- /** Read mesh vertices.
- *
- * @param filein Input stream
- * @param pCoordinates Pointer to array of vertex coordinates
- * @param pNumVertices Pointer to number of vertices
- * @param pNumDims Pointer to number of dimensions
- */
- void _readVertices(std::istream& filein,
- double** pCoordinates,
- int* pNumVertices,
- int* pNumDims) const;
-
- /** Write mesh vertices.
- *
- * @param fileout Output stream
- * @param mesh PETSc mesh
- */
- void _writeVertices(std::ostream& fileout,
- const Obj<Mesh>& mesh) const;
-
- /** Read mesh cells.
- *
- * @param filein Input stream
- * @param pCells Pointer to array of cells (vertices in each element)
- * @param pNumCells Pointer to number of cells
- * @param pNumCorners Pointer to number of corners in each element
- */
- void _readCells(std::istream& filein,
- int** pCells,
- int* pNumCells,
- int* pNumCorners) const;
-
- /** Write mesh cells.
- *
- * @param fileout Output stream
- * @param mesh PETSc mesh
- */
- void _writeCells(std::ostream& fileout,
- const Obj<Mesh>& mesh) const;
-
- /** Read mesh group.
- *
- * @param filein Output stream
- * @param pMesh Pointer to PETSc mesh
- */
- void _readGroup(std::istream& filein,
- const Obj<Mesh>& pMesh) const;
-
- /** Write mesh group.
- *
- * @param fileout Output stream
- * @param mesh PETSc mesh
- * @param name Name of group
- */
- void _writeGroup(std::ostream& fileout,
- const Obj<Mesh>& mesh,
- const char* name) const;
-
-// PRIVATE MEMBERS ------------------------------------------------------
-private :
-
- std::string _filename; ///< Name of file
-
-}; // MeshIOAscii
-
-#include "MeshIOAscii.icc" // inline methods
-
-#endif // pylith_meshio_meshioascii_hh
-
-// version
-// $Id$
-
-// End of file
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.icc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.icc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOAscii.icc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,33 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_meshioascii_hh)
-#error "MeshIOAscii.icc must be included only from MeshIOAscii.icc"
-#else
-
-// Set filename for ASCII file.
-inline
-void
-pylith::meshio::MeshIOAscii::filename(const char* name) {
- _filename = name;
-}
-
-// Get filename of ASCII file.
-inline
-const char*
-pylith::meshio::MeshIOAscii::filename(void) const {
- return _filename.c_str();
-}
-
-#endif
-
-// End of file
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.cc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.cc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,293 +0,0 @@
-// -*- 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
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.hh 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.hh 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,160 +0,0 @@
-// -*- 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
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.icc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.icc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/MeshIOHDF5.icc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,33 +0,0 @@
-// -*- 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
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/PetscMesh.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/PetscMesh.cc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/PetscMesh.cc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,416 +0,0 @@
-#include "PetscMesh.hh"
-
-ALE::PetscMesh::PetscMesh(MPI_Comm comm,
- int dimension,
- int debug) : debug(debug), dim(dimension) {
- this->setComm(comm);
- this->topology = sieve_type(comm, debug);
- this->coordinates = field_type(comm, debug);
- this->boundary = field_type(comm, debug);
- this->boundaries = foliation_type(comm, debug);
- this->distributed = false;
- this->coordinates->setTopology(this->topology);
- this->boundary->setTopology(this->topology);
- this->boundaries->setTopology(this->topology);
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::getBundle"
-ALE::Obj<ALE::PetscMesh::bundle_type>
-ALE::PetscMesh::getBundle(const int dim) {
- ALE_LOG_EVENT_BEGIN;
- if (this->bundles.find(dim) == this->bundles.end()) {
- Obj<bundle_type> bundle = bundle_type(this->comm(), debug);
-
- // Need to globalize indices (that is what we might use the value ints for)
- std::cout << "Creating new bundle for dim " << dim << std::endl;
- bundle->setTopology(this->topology);
- bundle->setPatch(this->topology->leaves(), bundle_type::patch_type());
- bundle->setFiberDimensionByDepth(bundle_type::patch_type(), dim, 1);
- bundle->orderPatches();
- if (this->distributed) {
- bundle->createGlobalOrder();
- }
- // "element" reorder is in vertexBundle by default, and intermediate bundles could be handled by a cell tuple
- this->bundles[dim] = bundle;
- } else {
- if (this->distributed && this->bundles[dim]->getGlobalOffsets() == NULL) {
- this->bundles[dim]->createGlobalOrder();
- }
- }
- ALE_LOG_EVENT_END;
- return this->bundles[dim];
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::getField"
-ALE::Obj<ALE::PetscMesh::field_type>
-ALE::PetscMesh::getField(const std::string& name) {
- if (this->fields.find(name) == this->fields.end()) {
- Obj<field_type> field = field_type(this->comm(), debug);
-
- std::cout << "Creating new field " << name << std::endl;
- field->setTopology(this->topology);
- this->fields[name] = field;
- }
- return this->fields[name];
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::hasField"
-bool
-ALE::PetscMesh::hasField(const std::string& name) {
- return(this->fields.find(name) != this->fields.end());
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::getFields"
-ALE::Obj<std::set<std::string> >
-ALE::PetscMesh::getFields() {
- Obj<std::set<std::string> > names = std::set<std::string>();
-
- for(FieldContainer::iterator f_iter = this->fields.begin(); f_iter != this->fields.end(); ++f_iter) {
- names->insert(f_iter->first);
- }
- return names;
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::buildHexFaces"
-// For a hex, there are 2d faces
-void
-ALE::PetscMesh::buildHexFaces(int dim, std::map<int, int*> *curSimplex, PointArray *boundary, point_type& simplex) {
- PointArray *faces = NULL;
-
- if (debug > 1) {std::cout << " Building hex faces for boundary of " << simplex << " (size " << boundary->size() << "), dim " << dim << std::endl;}
- if (dim > 3) {
- throw ALE::Exception("Cannot do hexes of dimension greater than three");
- } else if (dim > 2) {
- int nodes[24] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 5, 4,
- 1, 2, 6, 5, 2, 3, 7, 6, 3, 0, 4, 7};
- faces = new PointArray();
-
- for(int b = 0; b < 6; b++) {
- PointArray faceBoundary = PointArray();
- point_type face;
-
- for(int c = 0; c < 4; c++) {
- faceBoundary.push_back((*boundary)[nodes[b*4+c]]);
- }
- if (debug > 1) {std::cout << " boundary point " << (*boundary)[b] << std::endl;}
- this->buildHexFaces(dim-1, curSimplex, &faceBoundary, face);
- faces->push_back(face);
- }
- } else if (dim > 1) {
- int boundarySize = (int) boundary->size();
- faces = new PointArray();
-
- for(int b = 0; b < boundarySize; b++) {
- PointArray faceBoundary = PointArray();
- point_type face;
-
- for(int c = 0; c < 2; c++) {
- faceBoundary.push_back((*boundary)[(b+c)%boundarySize]);
- }
- if (debug > 1) {std::cout << " boundary point " << (*boundary)[b] << std::endl;}
- this->buildHexFaces(dim-1, curSimplex, &faceBoundary, face);
- faces->push_back(face);
- }
- } else {
- if (debug > 1) {std::cout << " Just set faces to boundary in 1d" << std::endl;}
- faces = boundary;
- }
- if (debug > 1) {
- for(PointArray::iterator f_itor = faces->begin(); f_itor != faces->end(); ++f_itor) {
- std::cout << " face point " << *f_itor << std::endl;
- }
- }
- // We always create the toplevel, so we could short circuit somehow
- // Should not have to loop here since the meet of just 2 boundary elements is an element
- PointArray::iterator f_itor = faces->begin();
- point_type start = *f_itor;
- f_itor++;
- point_type next = *f_itor;
- Obj<sieve_type::supportSet> preElement = this->topology->nJoin(start, next, 1);
-
- if (preElement->size() > 0) {
- simplex = *preElement->begin();
- if (debug > 1) {std::cout << " Found old simplex " << simplex << std::endl;}
- } else {
- int color = 0;
-
- simplex = point_type(0, (*(*curSimplex)[dim])++);
- for(PointArray::iterator f_itor = faces->begin(); f_itor != faces->end(); ++f_itor) {
- this->topology->addArrow(*f_itor, simplex, color++);
- }
- if (debug > 1) {std::cout << " Added simplex " << simplex << " dim " << dim << std::endl;}
- }
- if (dim > 1) {
- delete faces;
- }
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::buildFaces"
-void
-ALE::PetscMesh::buildFaces(int dim, std::map<int, int*> *curSimplex, PointArray *boundary, point_type& simplex) {
- PointArray *faces = NULL;
-
- if (debug > 1) {std::cout << " Building faces for boundary of " << simplex << " (size " << boundary->size() << "), dim " << dim << std::endl;}
- if (dim > 1) {
- faces = new PointArray();
-
- // Use the cone construction
- for(PointArray::iterator b_itor = boundary->begin(); b_itor != boundary->end(); ++b_itor) {
- PointArray faceBoundary = PointArray();
- point_type face;
-
- for(PointArray::iterator i_itor = boundary->begin(); i_itor != boundary->end(); ++i_itor) {
- if (i_itor != b_itor) {
- faceBoundary.push_back(*i_itor);
- }
- }
- if (debug > 1) {std::cout << " boundary point " << *b_itor << std::endl;}
- this->buildFaces(dim-1, curSimplex, &faceBoundary, face);
- faces->push_back(face);
- }
- } else {
- if (debug > 1) {std::cout << " Just set faces to boundary in 1d" << std::endl;}
- faces = boundary;
- }
- if (debug > 1) {
- for(PointArray::iterator f_itor = faces->begin(); f_itor != faces->end(); ++f_itor) {
- std::cout << " face point " << *f_itor << std::endl;
- }
- }
- // We always create the toplevel, so we could short circuit somehow
- // Should not have to loop here since the meet of just 2 boundary elements is an element
- PointArray::iterator f_itor = faces->begin();
- point_type start = *f_itor;
- f_itor++;
- point_type next = *f_itor;
- Obj<sieve_type::supportSet> preElement = this->topology->nJoin(start, next, 1);
-
- if (preElement->size() > 0) {
- simplex = *preElement->begin();
- if (debug > 1) {std::cout << " Found old simplex " << simplex << std::endl;}
- } else {
- int color = 0;
-
- simplex = point_type(0, (*(*curSimplex)[dim])++);
- for(PointArray::iterator f_itor = faces->begin(); f_itor != faces->end(); ++f_itor) {
- this->topology->addArrow(*f_itor, simplex, color++);
- }
- if (debug > 1) {std::cout << " Added simplex " << simplex << " dim " << dim << std::endl;}
- }
- if (dim > 1) {
- delete faces;
- }
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::buildTopology"
-// Build a topology from a connectivity description
-// (0, 0) ... (0, numSimplices-1): dim-dimensional simplices
-// (0, numSimplices) ... (0, numVertices): vertices
-// The other simplices are numbered as they are requested
-void
-ALE::PetscMesh::buildTopology(int numSimplices,
- int simplices[],
- int numVertices,
- bool interpolate,
- int corners) {
- ALE_LOG_EVENT_BEGIN;
- if (this->commRank() != 0) {
- ALE_LOG_EVENT_END;
- return;
- }
- // Create a map from dimension to the current element number for that dimension
- std::map<int,int*> curElement = std::map<int,int*>();
- int curSimplex = 0;
- int curVertex = numSimplices;
- int newElement = numSimplices+numVertices;
- PointArray boundary = PointArray();
-
- if (corners < 0) corners = this->dim+1;
- curElement[0] = &curVertex;
- curElement[this->dim] = &curSimplex;
- for(int d = 1; d < this->dim; d++) {
- curElement[d] = &newElement;
- }
- for(int s = 0; s < numSimplices; s++) {
- point_type simplex(0, s);
-
- // Build the simplex
- if (interpolate) {
- boundary.clear();
- for(int b = 0; b < corners; b++) {
- point_type vertex(0, simplices[s*corners+b]+numSimplices);
-
- if (debug > 1) {std::cout << "Adding boundary node " << vertex << std::endl;}
- boundary.push_back(vertex);
- }
- if (debug) {std::cout << "simplex " << s << " boundary size " << boundary.size() << std::endl;}
-
- if (corners != this->dim+1) {
- this->buildHexFaces(this->dim, &curElement, &boundary, simplex);
- } else {
- this->buildFaces(this->dim, &curElement, &boundary, simplex);
- }
- } else {
- for(int b = 0; b < corners; b++) {
- point_type p(0, simplices[s*corners+b]+numSimplices);
-
- this->topology->addArrow(p, simplex, b);
- }
- }
- }
- ALE_LOG_EVENT_END;
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::createVertBnd"
-void
-ALE::PetscMesh::createVertexBundle(int numSimplices,
- int simplices[],
- int elementOffset,
- int corners) {
- ALE_LOG_STAGE_BEGIN;
- Obj<bundle_type> vertexBundle = this->getBundle(0);
- Obj<sieve_type::traits::heightSequence> elements = this->topology->heightStratum(0);
- std::string orderName("element");
- int vertexOffset;
-
- ALE_LOG_EVENT_BEGIN;
- if (elementOffset) {
- vertexOffset = 0;
- } else {
- vertexOffset = numSimplices;
- }
- if (corners < 0) corners = this->dim+1;
- for(sieve_type::traits::heightSequence::iterator e_iter = elements->begin(); e_iter != elements->end(); ++e_iter) {
- // setFiberDimensionByDepth() does not work here since we only want it to apply to the patch cone
- // What we really need is the depthStratum relative to the patch
- Obj<PointArray> patch = PointArray();
-
- for(int b = 0; b < corners; b++) {
- patch->push_back(point_type(0, simplices[((*e_iter).index - elementOffset)*corners+b]+vertexOffset));
- }
- vertexBundle->setPatch(orderName, patch, *e_iter);
- for(PointArray::iterator p_iter = patch->begin(); p_iter != patch->end(); ++p_iter) {
- vertexBundle->setFiberDimension(orderName, *e_iter, *p_iter, 1);
- }
- }
- if (elements->size() == 0) {
- vertexBundle->setPatch(orderName, elements, bundle_type::patch_type());
- }
- ALE_LOG_EVENT_END;
- vertexBundle->orderPatches(orderName);
- ALE_LOG_STAGE_END;
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::createSerCoords"
-void
-ALE::PetscMesh::createSerialCoordinates(int embedDim, int numSimplices, double coords[]) {
- ALE_LOG_EVENT_BEGIN;
- patch_type patch;
-
- this->coordinates->setTopology(this->topology);
- this->coordinates->setPatch(this->topology->leaves(), patch);
- this->coordinates->setFiberDimensionByDepth(patch, 0, embedDim);
- this->coordinates->orderPatches();
- Obj<sieve_type::traits::depthSequence> vertices = this->topology->depthStratum(0);
- for(sieve_type::traits::depthSequence::iterator v_itor = vertices->begin(); v_itor != vertices->end(); v_itor++) {
- this->coordinates->update(patch, *v_itor, &coords[((*v_itor).index - numSimplices)*embedDim]);
- }
- Obj<bundle_type> vertexBundle = this->getBundle(0);
- Obj<sieve_type::traits::heightSequence> elements = this->topology->heightStratum(0);
- std::string orderName("element");
-
- for(sieve_type::traits::heightSequence::iterator e_iter = elements->begin(); e_iter != elements->end(); e_iter++) {
- // setFiberDimensionByDepth() does not work here since we only want it to apply to the patch cone
- // What we really need is the depthStratum relative to the patch
- Obj<bundle_type::order_type::coneSequence> cone = vertexBundle->getPatch(orderName, *e_iter);
-
- this->coordinates->setPatch(orderName, cone, *e_iter);
- for(bundle_type::order_type::coneSequence::iterator c_iter = cone->begin(); c_iter != cone->end(); ++c_iter) {
- this->coordinates->setFiberDimension(orderName, *e_iter, *c_iter, embedDim);
- }
- }
- if (elements->size() == 0) {
- this->coordinates->setPatch(orderName, elements, field_type::patch_type());
- }
- this->coordinates->orderPatches(orderName);
- ALE_LOG_EVENT_END;
-}
-
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::parVertReOrd"
-// This is not right, we should not have to copy everything to the new order first
-void
-ALE::PetscMesh::createParallelVertexReorder(Obj<bundle_type> serialVertexBundle) {
- ALE_LOG_EVENT_BEGIN;
- Obj<bundle_type> vertexBundle = this->getBundle(0);
- std::string orderName("element");
-
- if (!this->commRank()) {
- Obj<bundle_type::order_type::baseSequence> patches = serialVertexBundle->getPatches(orderName);
-
- for(bundle_type::order_type::baseSequence::iterator e_iter = patches->begin(); e_iter != patches->end(); ++e_iter) {
- Obj<bundle_type::order_type::coneSequence> patch = serialVertexBundle->getPatch(orderName, *e_iter);
-
- vertexBundle->setPatch(orderName, patch, *e_iter);
- for(bundle_type::order_type::coneSequence::iterator p_iter = patch->begin(); p_iter != patch->end(); ++p_iter) {
- vertexBundle->setFiberDimension(orderName, *e_iter, *p_iter, 1);
- }
- }
- } else {
- Obj<sieve_type::traits::heightSequence> elements = this->topology->heightStratum(0);
- Obj<bundle_type::order_type> reorder = vertexBundle->__getOrder(orderName);
-
- for(sieve_type::traits::heightSequence::iterator e_iter = elements->begin(); e_iter != elements->end(); e_iter++) {
- reorder->addBasePoint(*e_iter);
- }
- }
- vertexBundle->orderPatches(orderName);
- vertexBundle->partitionOrder(orderName);
- ALE_LOG_EVENT_END;
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::populate"
-// Create a serial mesh
-void
-ALE::PetscMesh::populate(int numSimplices,
- int simplices[],
- int numVertices,
- double coords[],
- bool interpolate,
- int corners) {
- this->topology->setStratification(false);
- this->buildTopology(numSimplices, simplices, numVertices, interpolate, corners);
- this->topology->stratify();
- this->topology->setStratification(true);
- this->createVertexBundle(numSimplices, simplices, 0, corners);
- this->createSerialCoordinates(this->dim, numSimplices, coords);
-}
-
-#undef __FUNCT__
-#define __FUNCT__ "Mesh::populateBd"
-void
-ALE::PetscMesh::populateBd(int numSimplices,
- int simplices[],
- int numVertices,
- double coords[],
- bool interpolate,
- int corners) {
- this->topology->setStratification(false);
- this->buildTopology(numSimplices, simplices, numVertices, interpolate, corners);
- this->topology->stratify();
- this->topology->setStratification(true);
- this->createVertexBundle(numSimplices, simplices, 0, corners);
- this->createSerialCoordinates(this->dim+1, numSimplices, coords);
-}
-
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/PetscMesh.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/PetscMesh.hh 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/PetscMesh.hh 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,125 +0,0 @@
-#ifndef included_ALE_Mesh_hh
-#define included_ALE_Mesh_hh
-
-#ifndef included_ALE_CoSifter_hh
-#include <CoSifter.hh>
-#endif
-#ifndef included_ALE_ParDelta_hh
-#include <ParDelta.hh>
-#endif
-#ifndef included_ALE_Partitioner_hh
-#include <Partitioner.hh>
-#endif
-
-#include <petscvec.h>
-
-namespace ALE {
- class PetscMesh;
-} // namespace ALE
-
-class ALE::PetscMesh {
-public:
- typedef ALE::Point point_type;
- typedef std::vector<point_type> PointArray;
- typedef ALE::Sieve<point_type,int,int> sieve_type;
- typedef point_type patch_type;
- typedef CoSifter<sieve_type, patch_type, point_type, int> bundle_type;
- typedef CoSifter<sieve_type, patch_type, point_type, double> field_type;
- typedef CoSifter<sieve_type, ALE::pair<patch_type,int>, point_type, double> foliation_type;
- typedef std::map<std::string, Obj<field_type> > FieldContainer;
- typedef std::map<int, Obj<bundle_type> > BundleContainer;
- int debug;
-
-private:
- Obj<sieve_type> topology;
- Obj<field_type> coordinates;
- Obj<field_type> boundary;
- Obj<foliation_type> boundaries;
- FieldContainer fields;
- BundleContainer bundles;
- MPI_Comm _comm;
- int _commRank;
- int _commSize;
- int dim;
-
- //FIX:
-public:
- bool distributed;
-
-public:
-
- PetscMesh(MPI_Comm comm,
- int dimension,
- int debug = 0);
-
- MPI_Comm comm() const {return this->_comm;};
- void setComm(MPI_Comm comm) {
- this->_comm = comm;
- MPI_Comm_rank(comm, &this->_commRank);
- MPI_Comm_size(comm, &this->_commSize);
- };
- int commRank() const {return this->_commRank;};
- int commSize() const {return this->_commSize;};
- Obj<sieve_type> getTopology() const {return this->topology;};
- void setTopology(const Obj<sieve_type>& topology) {this->topology = topology;};
- int getDimension() const {return this->dim;};
- void setDimension(int dim) {this->dim = dim;};
- Obj<field_type> getCoordinates() const {return this->coordinates;};
- void setCoordinates(const Obj<field_type>& coordinates) {this->coordinates = coordinates;};
- Obj<field_type> getBoundary() const {return this->boundary;};
- void setBoundary(const Obj<field_type>& boundary) {this->boundary = boundary;};
- Obj<foliation_type> getBoundaries() const {return this->boundaries;};
-
- Obj<bundle_type> getBundle(const int dim);
-
- Obj<field_type> getField(const std::string& name);
-
- bool hasField(const std::string& name);
-
- Obj<std::set<std::string> > getFields();
-
- void buildHexFaces(int dim,
- std::map<int, int*> *curSimplex,
- PointArray *boundary,
- point_type& simplex);
-
- void buildFaces(int dim,
- std::map<int, int*> *curSimplex,
- PointArray *boundary,
- point_type& simplex);
-
- void buildTopology(int numSimplices,
- int simplices[],
- int numVertices,
- bool interpolate = true,
- int corners = -1);
-
- void createVertexBundle(int numSimplices,
- int simplices[],
- int elementOffset = 0,
- int corners = -1);
-
- void createSerialCoordinates(int embedDim,
- int numSimplices,
- double coords[]);
-
- void createParallelVertexReorder(Obj<bundle_type> serialVertexBundle);
-
- void populate(int numSimplices,
- int simplices[],
- int numVertices,
- double coords[],
- bool interpolate = true,
- int corners = -1);
-
- void populateBd(int numSimplices,
- int simplices[],
- int numVertices,
- double coords[],
- bool interpolate = true,
- int corners = -1);
-
-
-}; // PetscMesh
-
-#endif
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/meshio.txt
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/meshio.txt 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/meshio.txt 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,24 +0,0 @@
-Abstract
-
- public
-
- read(ALE::PetscMesh*)
- write(const ALE::PetscMesh&)
-
- protected, pure virtual
-
- _open(filename)
- _readMeshInfo(dimension)
- _writeMeshInfo(dimension)
- _readVertices(coordinates, numVertices, numDims)
- _writeVertices(coordinates, numVertices, numDims)
- _readElements(elements, numElements, numCorners)
- _writeElements(elements, numElements, numCorners)
- _readGroup()
- _writeGroup()
- _close()
-
- protected
-
- _addGroup(name, dimension, entries, numEntries)
- _getGroup(name, dimension, entries, numEntries)
Deleted: short/3D/PyLith/trunk/playpen/meshio/src/testascii.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/meshio/src/testascii.cc 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/playpen/meshio/src/testascii.cc 2006-09-15 01:45:20 UTC (rev 4542)
@@ -1,54 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include "MeshIO.hh"
-#include "MeshIOAscii.hh"
-
-#include <iostream> // USES std::cerr
-
-// ----------------------------------------------------------------------
-int
-main(int argc,
- char** argv)
-{ // main
- PetscErrorCode err;
-
- PetscInitialize(&argc, &argv, 0, 0);
-
- if (argc < 3) {
- std::cerr << "usage: testascii MESHIN MESHOUT [options]" << std::endl;
- return -1;
- } // if
-
- try {
- ALE::Obj<ALE::Mesh> mesh;
-
- pylith::meshio::MeshIOAscii iohandler;
- iohandler.filename(argv[1]);
- iohandler.read(mesh);
-
- iohandler.filename(argv[2]);
- iohandler.write(mesh);
- } catch(const ALE::Exception& err) {
- int rank;
- MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
- std::cout << "[" << rank << "]: " << err << std::endl;
- }
- err = PetscFinalize(); CHKERRQ(err);
-
- return err;
-} // main
-
-// version
-// $Id$
-
-// End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/MeshIOAscii.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIOAscii.py 2006-09-15 01:30:37 UTC (rev 4541)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIOAscii.py 2006-09-15 01:45:20 UTC (rev 4542)
@@ -18,7 +18,7 @@
from MeshIO import MeshIO
# MeshIOAscii class
-class MeshIOAscii(Component):
+class MeshIOAscii(MeshIO):
"""
Python object for reading/writing finite-element mesh from simple
ASCII file.
@@ -26,9 +26,9 @@
# PUBLIC METHODS /////////////////////////////////////////////////////
- def __init__(self, name="meshio"):
+ def __init__(self, name="meshioascii"):
"""Constructor."""
- MeshIO.__init__(self, name, facility="meshio")
+ MeshIO.__init__(self, name)
import pylith.meshio.meshio as bindings
self.cppHandler = bindings.MeshIOAscii()
return
More information about the cig-commits
mailing list