[cig-commits] r6799 - in short/3D/PyLith/trunk: libsrc/meshio
unittests/libtests/meshio
brad at geodynamics.org
brad at geodynamics.org
Mon May 7 17:40:01 PDT 2007
Author: brad
Date: 2007-05-07 17:40:01 -0700 (Mon, 07 May 2007)
New Revision: 6799
Modified:
short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.cc
short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.cc
short/3D/PyLith/trunk/libsrc/meshio/PsetFileAscii.cc
short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc
Log:
Uncommented journal code in C++ meshio files. Fix was to initialize/finalize Python in C++ driver.
Modified: short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.cc 2007-05-08 00:21:25 UTC (rev 6798)
+++ short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.cc 2007-05-08 00:40:01 UTC (rev 6799)
@@ -14,7 +14,7 @@
#include "pylith/utils/array.hh" // USES double_array, int_array
-//#include "journal/info.h" // USES journal::info_t
+#include "journal/info.h" // USES journal::info_t
#include <fstream> // USES std::ifstream
#include <iomanip> // USES std::setw()
@@ -61,7 +61,7 @@
*meshDim = 3;
- //journal::info_t info("gmvfile");
+ journal::info_t info("gmvfile");
std::ifstream fin(_filename.c_str(), std::ios::in);
if (!(fin.is_open() && fin.good())) {
@@ -72,7 +72,7 @@
throw std::runtime_error(msg.str());
} // if
- //info << "Reading ASCII GMV file '" << _filename << "'." << journal::endl;
+ info << "Reading ASCII GMV file '" << _filename << "'." << journal::endl;
_readHeader(fin);
@@ -149,10 +149,10 @@
*spaceDim = 3;
- //journal::info_t info("gmvfile");
+ journal::info_t info("gmvfile");
fin >> *numVertices;
- //info << "Reading " << *numVertices << " nodes." << journal::endl;
+ info << "Reading " << *numVertices << " nodes." << journal::endl;
coordinates->resize(*numVertices * (*spaceDim));
// NOTE: Order of loops is different than what we usually have
@@ -160,7 +160,7 @@
for (int iVertex=0; iVertex < *numVertices; ++iVertex)
fin >> (*coordinates)[iVertex*(*spaceDim)+iDim];
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // readVertices
// ----------------------------------------------------------------------
@@ -174,11 +174,11 @@
assert(0 != numCells);
assert(0 != numCorners);
- //journal::info_t info("gmvfile");
+ journal::info_t info("gmvfile");
fin >> *numCells;
std::string cellString = "";
- //info << "Reading " << numCells << " cells." << journal::endl;
+ info << "Reading " << numCells << " cells." << journal::endl;
for (int iCell=0; iCell < *numCells; ++iCell) {
std::string cellStringCur;
int numCornersCur = 0;
@@ -203,7 +203,7 @@
fin >> (*cells)[iCell*(*numCorners)+iCorner];
} // for
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // readCells
// ----------------------------------------------------------------------
@@ -212,9 +212,9 @@
const int numVertices,
const int numCells)
{ // _readVariables
- //journal::info_t info("gmvfile");
+ journal::info_t info("gmvfile");
- //info << "Reading variables..." << journal::endl;
+ info << "Reading variables..." << journal::endl;
std::string varName;
fin >> varName;
@@ -235,7 +235,7 @@
fin >> varName;
} // while
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readVariables
// ----------------------------------------------------------------------
@@ -244,9 +244,9 @@
const int numVertices,
const int numCells)
{ // _readFlags
- //journal::info_t info("gmvfile");
+ journal::info_t info("gmvfile");
- //info << "Reading flags..." << journal::endl;
+ info << "Reading flags..." << journal::endl;
std::string varName;
fin >> varName;
@@ -270,7 +270,7 @@
fin >> varName;
} // while
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readFlags
// ----------------------------------------------------------------------
@@ -282,8 +282,8 @@
{ // _readMaterials
assert(0 != materialIds);
- //journal::info_t info("gmvfile");
- //info << "Reading materials..." << journal::endl;
+ journal::info_t info("gmvfile");
+ info << "Reading materials..." << journal::endl;
int numMaterials = 0;
int dataType = 0;
@@ -303,7 +303,7 @@
fin >> materials[iVertex];
} // else
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readMaterials
Modified: short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc 2007-05-08 00:21:25 UTC (rev 6798)
+++ short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc 2007-05-08 00:40:01 UTC (rev 6799)
@@ -16,7 +16,7 @@
#include "pylith/utils/array.hh" // USES double_array, int_array
-//#include "journal/info.h" // USES journal::info_t
+#include "journal/info.h" // USES journal::info_t
#include <fstream> // USES std::ifstream
#include <iomanip> // USES std::setw()
@@ -65,7 +65,7 @@
*meshDim = 3;
- //journal::info_t info("gmvfile");
+ journal::info_t info("gmvfile");
std::ifstream fin(_filename.c_str(), std::ios::in | std::ios::binary);
if (!(fin.is_open() && fin.good())) {
@@ -76,7 +76,7 @@
throw std::runtime_error(msg.str());
} // if
- //info << "Reading binary GMV file '" << _filename << "'." << journal::endl;
+ info << "Reading binary GMV file '" << _filename << "'." << journal::endl;
_readHeader(fin);
@@ -152,13 +152,13 @@
*spaceDim = 3;
- //journal::info_t info("gmvfile");
+ journal::info_t info("gmvfile");
fin.read((char*) numVertices, sizeof(int));
if (_flipEndian)
BinaryIO::swapByteOrder((char*) numVertices, 1, sizeof(int));
assert(*numVertices > 0);
- //info << "Reading " << *numVertices << " nodes." << journal::endl;
+ info << "Reading " << *numVertices << " nodes." << journal::endl;
const int size = (*numVertices) * (*spaceDim);
float_array buffer(size);
@@ -173,7 +173,7 @@
for (int iVertex=0; iVertex < *numVertices; ++iVertex)
(*coordinates)[iVertex*(*spaceDim)+iDim] = buffer[i++];
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readNodes
// ----------------------------------------------------------------------
@@ -187,12 +187,12 @@
assert(0 != numCells);
assert(0 != numCorners);
- //journal::info_t info("gmvfile");
+ journal::info_t info("gmvfile");
fin.read((char*) numCells, sizeof(int));
if (_flipEndian)
BinaryIO::swapByteOrder((char*) numCells, 1, sizeof(int));
- //info << "Reading " << *numCells << " cells." << journal::endl;
+ info << "Reading " << *numCells << " cells." << journal::endl;
std::string cellString = "";
for (int iCell=0; iCell < *numCells; ++iCell) {
const int stringLen = 8;
@@ -224,7 +224,7 @@
if (_flipEndian)
BinaryIO::swapByteOrder((char*) &(*cells)[0],
(*numCells)*(*numCorners), sizeof(int));
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // readCells
// ----------------------------------------------------------------------
@@ -233,8 +233,8 @@
const int numVertices,
const int numCells)
{ // _readVariables
- //journal::info_t info("gmvfile");
- //info << "Reading variables..." << journal::endl;
+ journal::info_t info("gmvfile");
+ info << "Reading variables..." << journal::endl;
const int varNameLen = 8;
std::string varName = BinaryIO::readString(fin, varNameLen);
@@ -251,7 +251,7 @@
varName = BinaryIO::readString(fin, varNameLen);
} // while
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readVariables
// ----------------------------------------------------------------------
@@ -260,8 +260,8 @@
const int numVertices,
const int numCells)
{ // _readFlags
- //journal::info_t info("gmvfile");
- //info << "Reading flags..." << journal::endl;
+ journal::info_t info("gmvfile");
+ info << "Reading flags..." << journal::endl;
const int varNameLen = 8;
std::string varName = BinaryIO::readString(fin, varNameLen);
@@ -284,7 +284,7 @@
varName = BinaryIO::readString(fin, varNameLen);
} // while
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readFlags
// ----------------------------------------------------------------------
@@ -296,8 +296,8 @@
{ // _readMaterials
assert(0 != materialIds);
- //journal::info_t info("gmvfile");
- //info << "Reading materials..." << journal::endl;
+ journal::info_t info("gmvfile");
+ info << "Reading materials..." << journal::endl;
int numMaterials = 0;
fin.read((char*) &numMaterials, sizeof(int));
@@ -320,7 +320,7 @@
fin.read((char*) &buffer[0], sizeof(int)*numVertices);
} // else
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readMaterials
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.cc 2007-05-08 00:21:25 UTC (rev 6798)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.cc 2007-05-08 00:40:01 UTC (rev 6799)
@@ -16,7 +16,7 @@
#include "pylith/utils/array.hh" // USES double_array, int_array, string_vector
-//#include "journal/info.h" // USES journal::info_t
+#include "journal/info.h" // USES journal::info_t
#include <netcdfcpp.h> // USES netcdf
@@ -115,13 +115,13 @@
assert(0 != numVertices);
assert(0 != numDims);
- //journal::info_t info("meshiocubit");
+ journal::info_t info("meshiocubit");
NcDim* num_nodes = ncfile.get_dim("num_nodes");
if (0 == num_nodes)
throw std::runtime_error("Could not get dimension 'num_nodes'.");
*numVertices = num_nodes->size();
- //info << "Reading " << *numVertices << " vertices." << journal::endl;
+ info << "Reading " << *numVertices << " vertices." << journal::endl;
NcVar* coord = ncfile.get_var("coord");
if (0 == coord)
@@ -165,7 +165,7 @@
assert(0 != numCells);
assert(0 != numCorners);
- //journal::info_t info("meshiocubit");
+ journal::info_t info("meshiocubit");
NcDim* num_elem = ncfile.get_dim("num_elem");
if (0 == num_elem)
@@ -176,8 +176,8 @@
throw std::runtime_error("Could not get dimension 'num_el_blk'.");
const int numMaterials = num_el_blk->size();
- //info << "Reading " << numCells << " cells in " << numMaterials
- // << " blocks." << journal::endl;
+ info << "Reading " << numCells << " cells in " << numMaterials
+ << " blocks." << journal::endl;
NcVar* eb_prop1 = ncfile.get_var("eb_prop1");
if (0 == eb_prop1)
@@ -239,13 +239,13 @@
void
pylith::meshio::MeshIOCubit::_readGroups(NcFile& ncfile)
{ // _readGroups
- //journal::info_t info("meshiocubit");
+ journal::info_t info("meshiocubit");
NcDim* num_node_sets = ncfile.get_dim("num_node_sets");
if (0 == num_node_sets)
throw std::runtime_error("Could not get dimension 'num_node_sets'.");
const int numGroups = num_node_sets->size();
- //info << "Found " << numGroups << " node sets." << journal::endl;
+ info << "Found " << numGroups << " node sets." << journal::endl;
NcVar* ns_prop1 = ncfile.get_var("ns_prop1");
if (0 == ns_prop1)
@@ -264,8 +264,8 @@
if (0 == node_ns)
throw std::runtime_error("Could not get node set.");
const int size = node_ns->num_vals();
- //info << "Reading node set " << ids[iGroup] << " with "
- //<< size << " nodes." << journal::endl;
+ info << "Reading node set " << ids[iGroup] << " with "
+ << size << " nodes." << journal::endl;
points.resize(size);
long* counts = node_ns->edges();
Modified: short/3D/PyLith/trunk/libsrc/meshio/PsetFileAscii.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/PsetFileAscii.cc 2007-05-08 00:21:25 UTC (rev 6798)
+++ short/3D/PyLith/trunk/libsrc/meshio/PsetFileAscii.cc 2007-05-08 00:40:01 UTC (rev 6799)
@@ -14,7 +14,7 @@
#include "pylith/utils/array.hh" // USES double_array, int_array
-//#include "journal/info.h" // USES journal::info_t
+#include "journal/info.h" // USES journal::info_t
#include <fstream> // USES std::ifstream
#include <iomanip> // USES std::setw()
@@ -45,7 +45,7 @@
{ // read
assert(0 != groups);
- //journal::info_t info("psetfile");
+ journal::info_t info("psetfile");
std::ifstream fin(_filename.c_str(), std::ios::in);
if (!(fin.is_open() && fin.good())) {
@@ -56,7 +56,7 @@
throw std::runtime_error(msg.str());
} // if
- //info << "Reading ASCII Pset file '" << _filename << "'." << journal::endl;
+ info << "Reading ASCII Pset file '" << _filename << "'." << journal::endl;
_readHeader(fin);
@@ -66,7 +66,7 @@
groups->resize(numGroups);
// Read groups
- //info << "Reading " << numGroups << " point sets from file." << journal::endl;
+ info << "Reading " << numGroups << " point sets from file." << journal::endl;
for (int iGroup=0; iGroup < numGroups; ++iGroup)
_readPset(fin, &(*groups)[iGroup]);
} // read
@@ -76,7 +76,7 @@
void
pylith::meshio::PsetFileAscii::write(const std::vector<Pset>& groups)
{ // write
- //journal::info_t info("psetfile");
+ journal::info_t info("psetfile");
std::ofstream fout(_filename.c_str(), std::ios::out);
if (!(fout.is_open() && fout.good())) {
@@ -87,7 +87,7 @@
throw std::runtime_error(msg.str());
} // if
- //info << "Writing ASCII Pset file '" << _filename << "'." << journal::endl;
+ info << "Writing ASCII Pset file '" << _filename << "'." << journal::endl;
_writeHeader(fout);
@@ -96,7 +96,7 @@
fout << std::setw(4) << numGroups << std::endl;
// Write groups
- //info << "Writing " << numGroups << " point sets to file." << journal::endl;
+ info << "Writing " << numGroups << " point sets to file." << journal::endl;
for (int iGroup=0; iGroup < numGroups; ++iGroup)
_writePset(fout, groups[iGroup]);
} // write
@@ -132,18 +132,18 @@
{ // _readPset
assert(0 != group);
- //journal::info_t info("psetfile");
+ journal::info_t info("psetfile");
int size = 0;
fin >> group->id >> group->name >> size;
- //info << "Reading point set '" << group->name << "' with " << size
- // << " points." << journal::endl;
+ info << "Reading point set '" << group->name << "' with " << size
+ << " points." << journal::endl;
group->points.resize(size);
for (int i=0; i < size; ++i)
fin >> group->points[i];
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readPset
// ----------------------------------------------------------------------
@@ -151,11 +151,11 @@
pylith::meshio::PsetFileAscii::_writePset(std::ofstream& fout,
const Pset& group)
{ // _writePset
- //journal::info_t info("psetfile");
+ journal::info_t info("psetfile");
const int size = group.points.size();
- //info << "Writing point set '" << group.name << "' with " << size
- // << " points." << journal::endl;
+ info << "Writing point set '" << group.name << "' with " << size
+ << " points." << journal::endl;
fout << group.id << " " << group.name << " " << size << std::endl;
@@ -168,7 +168,7 @@
} // if
} // for
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _writePset
Modified: short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.cc 2007-05-08 00:21:25 UTC (rev 6798)
+++ short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.cc 2007-05-08 00:40:01 UTC (rev 6799)
@@ -16,7 +16,7 @@
#include "pylith/utils/array.hh" // USES double_array, int_array
-//#include "journal/info.h" // USES journal::info_t
+#include "journal/info.h" // USES journal::info_t
#include <fstream> // USES std::ifstream
#include <iomanip> // USES std::setw()
@@ -49,7 +49,7 @@
{ // read
assert(0 != groups);
- //journal::info_t info("psetfile");
+ journal::info_t info("psetfile");
std::ifstream fin(_filename.c_str(), std::ios::in);
if (!(fin.is_open() && fin.good())) {
@@ -60,7 +60,7 @@
throw std::runtime_error(msg.str());
} // if
- //info << "Reading binary Pset file '" << _filename << "'." << journal::endl;
+ info << "Reading binary Pset file '" << _filename << "'." << journal::endl;
_readHeader(fin);
@@ -73,7 +73,7 @@
groups->resize(numGroups);
// Read groups
- //info << "Reading " << numGroups << " point sets from file." << journal::endl;
+ info << "Reading " << numGroups << " point sets from file." << journal::endl;
for (int iGroup=0; iGroup < numGroups; ++iGroup)
_readPset(fin, &(*groups)[iGroup]);
} // read
@@ -83,7 +83,7 @@
void
pylith::meshio::PsetFileBinary::write(const std::vector<Pset>& groups)
{ // write
- //journal::info_t info("psetfile");
+ journal::info_t info("psetfile");
std::ofstream fout(_filename.c_str(), std::ios::out);
if (!(fout.is_open() && fout.good())) {
@@ -94,7 +94,7 @@
throw std::runtime_error(msg.str());
} // if
- //info << "Writing binary Pset file '" << _filename << "'." << journal::endl;
+ info << "Writing binary Pset file '" << _filename << "'." << journal::endl;
_writeHeader(fout);
@@ -105,7 +105,7 @@
fout.write((char*) &numGroups, sizeof(numGroups));
// Write groups
- //info << "Writing " << numGroups << " point sets to file." << journal::endl;
+ info << "Writing " << numGroups << " point sets to file." << journal::endl;
for (int iGroup=0; iGroup < numGroups; ++iGroup)
_writePset(fout, groups[iGroup]);
} // write
@@ -140,7 +140,7 @@
{ // _readPset
assert(0 != group);
- //journal::info_t info("psetfile");
+ journal::info_t info("psetfile");
int id = 0;
fin.read((char*) &id, sizeof(int));
@@ -153,15 +153,15 @@
BinaryIO::swapByteOrder((char*) &size, 1, sizeof(size));
assert(size >= 0);
- //info << "Reading point set '" << group->name << "' with " << size
- // << " points." << journal::endl;
+ info << "Reading point set '" << group->name << "' with " << size
+ << " points." << journal::endl;
group->points.resize(size);
fin.read((char*) &group->points[0], size*sizeof(int));
if (_flipEndian)
BinaryIO::swapByteOrder((char*) &group->points[0], size, sizeof(int));
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _readPset
// ----------------------------------------------------------------------
@@ -169,10 +169,10 @@
pylith::meshio::PsetFileBinary::_writePset(std::ofstream& fout,
const Pset& group)
{ // _writePset
- //journal::info_t info("psetfile");
+ journal::info_t info("psetfile");
const int size = group.points.size();
- //info << "Writing point set '" << group.name << "' with " << size
- // << " points." << journal::endl;
+ info << "Writing point set '" << group.name << "' with " << size
+ << " points." << journal::endl;
int id = group.id;
if (_flipEndian)
@@ -191,7 +191,7 @@
BinaryIO::swapByteOrder((char*) &pointsIO[0], size, sizeof(int));
fout.write((char*) &pointsIO[0], size*sizeof(int));
- //info << "Done." << journal::endl;
+ info << "Done." << journal::endl;
} // _writePset
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am 2007-05-08 00:21:25 UTC (rev 6798)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am 2007-05-08 00:40:01 UTC (rev 6799)
@@ -54,10 +54,11 @@
data/MeshDataCubitHex.hh \
data/MeshDataCubitTet.hh
-testmeshio_LDFLAGS = $(PETSC_LIB)
-#$(PYTHON_BLDLIBRARY)
+testmeshio_LDFLAGS = $(PETSC_LIB) $(PYTHON_BLDLIBRARY)
-AM_CPPFLAGS = $(PETSC_SIEVE_FLAGS) $(PETSC_INCLUDE)
+AM_CPPFLAGS = \
+ $(PETSC_SIEVE_FLAGS) $(PETSC_INCLUDE) \
+ -I$(PYTHON_INCDIR) $(PYTHON_EGG_CPPFLAGS)
testmeshio_LDADD = \
-lcppunit -ldl \
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc 2007-05-08 00:21:25 UTC (rev 6798)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc 2007-05-08 00:40:01 UTC (rev 6799)
@@ -10,8 +10,11 @@
// ----------------------------------------------------------------------
//
-#include "petsc.h"
+#include <portinfo>
+#include <petsc.h>
+#include <Python.h>
+
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/BriefTestProgressListener.h>
@@ -23,6 +26,8 @@
#include <stdlib.h> // USES abort()
+#include "journal/info.h"
+
int
main(int argc,
char* argv[])
@@ -34,6 +39,12 @@
PetscErrorCode err = PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
CHKERRQ(err);
+ // Initialize Python
+ Py_Initialize();
+
+ journal::info_t info("meshiocubit");
+ //info.activate();
+
// Create event manager and test controller
CppUnit::TestResult controller;
@@ -53,6 +64,9 @@
CppUnit::TextOutputter outputter(&result, std::cerr);
outputter.write();
+ // Finalize Python
+ Py_Finalize();
+
// Finalize PETSc
err = PetscFinalize();
CHKERRQ(err);
More information about the cig-commits
mailing list