[cig-commits] r14671 - in short/3D/PyLith/branches/pylith-swig: libsrc/meshio unittests/libtests/meshio
brad at geodynamics.org
brad at geodynamics.org
Sun Apr 12 15:14:04 PDT 2009
Author: brad
Date: 2009-04-12 15:14:02 -0700 (Sun, 12 Apr 2009)
New Revision: 14671
Modified:
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilter.cc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilter.hh
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilterAvg.cc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilterAvg.hh
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriter.cc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriter.hh
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.cc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.hh
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.icc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputManager.cc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputManager.hh
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputSolnSubset.cc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputSolnSubset.hh
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilter.cc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilter.hh
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilterVecNorm.cc
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilterVecNorm.hh
short/3D/PyLith/branches/pylith-swig/libsrc/meshio/meshiofwd.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestCellFilterAvg.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMesh.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMesh.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestOutputManager.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestVertexFilterVecNorm.cc
Log:
Changed to using both mesh_type and field_type template arguments in output objects.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilter.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilter.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilter.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -16,24 +16,24 @@
// ----------------------------------------------------------------------
// Constructor
-template<typename mesh_type>
-pylith::meshio::CellFilter<mesh_type>::CellFilter(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilter<mesh_type, field_type>::CellFilter(void) :
_quadrature(0)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-template<typename mesh_type>
-pylith::meshio::CellFilter<mesh_type>::~CellFilter(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilter<mesh_type, field_type>::~CellFilter(void)
{ // destructor
delete _quadrature; _quadrature = 0;
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-template<typename mesh_type>
-pylith::meshio::CellFilter<mesh_type>::CellFilter(const CellFilter& f) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilter<mesh_type, field_type>::CellFilter(const CellFilter& f) :
_quadrature(0)
{ // copy constructor
if (0 != f._quadrature)
@@ -42,9 +42,9 @@
// ----------------------------------------------------------------------
// Set quadrature associated with cells.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::CellFilter<mesh_type>::quadrature(const feassemble::Quadrature<mesh_type>* q)
+pylith::meshio::CellFilter<mesh_type, field_type>::quadrature(const feassemble::Quadrature<mesh_type>* q)
{ // quadrature
delete _quadrature;
_quadrature = (0 != q) ? new feassemble::Quadrature<mesh_type>(*q) : 0;
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilter.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilter.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilter.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -27,7 +27,7 @@
#include "pylith/feassemble/feassemblefwd.hh" // HOLDSA Quadrature<Mesh>
// CellFilter -----------------------------------------------------------
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
class pylith::meshio::CellFilter
{ // CellFilter
@@ -35,9 +35,9 @@
protected:
// Convenience typedefs
- typedef typename mesh_type::RealSection RealSection;
typedef typename mesh_type::SieveMesh SieveMesh;
typedef typename SieveMesh::label_sequence label_sequence;
+ typedef typename field_type::Mesh::RealSection RealSection;
typedef typename RealSection::chart_type chart_type;
// PUBLIC METHODS ///////////////////////////////////////////////////////
@@ -71,8 +71,8 @@
* @returns Averaged field.
*/
virtual
- const topology::Field<mesh_type>&
- filter(const topology::Field<mesh_type>& fieldIn,
+ const field_type&
+ filter(const field_type& fieldIn,
const char* label =0,
const int labelId =0) = 0;
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilterAvg.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilterAvg.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilterAvg.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -16,55 +16,58 @@
// ----------------------------------------------------------------------
// Constructor
-template<typename mesh_type>
-pylith::meshio::CellFilterAvg<mesh_type>::CellFilterAvg(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilterAvg<mesh_type, field_type>::CellFilterAvg(void) :
_fieldAvg(0)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-template<typename mesh_type>
-pylith::meshio::CellFilterAvg<mesh_type>::~CellFilterAvg(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilterAvg<mesh_type, field_type>::~CellFilterAvg(void)
{ // destructor
delete _fieldAvg; _fieldAvg = 0;
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-template<typename mesh_type>
-pylith::meshio::CellFilterAvg<mesh_type>::CellFilterAvg(const CellFilterAvg& f) :
- CellFilter<mesh_type>(f),
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilterAvg<mesh_type, field_type>::CellFilterAvg(
+ const CellFilterAvg& f) :
+ CellFilter<mesh_type, field_type>(f),
_fieldAvg(0)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Create copy of filter.
-template<typename mesh_type>
-pylith::meshio::CellFilter<mesh_type>*
-pylith::meshio::CellFilterAvg<mesh_type>::clone(void) const
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilter<mesh_type, field_type>*
+pylith::meshio::CellFilterAvg<mesh_type, field_type>::clone(void) const
{ // clone
- return new CellFilterAvg<mesh_type>(*this);
+ return new CellFilterAvg<mesh_type,field_type>(*this);
} // clone
// ----------------------------------------------------------------------
// Filter field.
-template<typename mesh_type>
-const pylith::topology::Field<mesh_type>&
-pylith::meshio::CellFilterAvg<mesh_type>::filter(
- const topology::Field<mesh_type>& fieldIn,
- const char* label,
- const int labelId)
+template<typename mesh_type, typename field_type>
+const field_type&
+pylith::meshio::CellFilterAvg<mesh_type,field_type>::filter(
+ const field_type& fieldIn,
+ const char* label,
+ const int labelId)
{ // filter
- typedef typename mesh_type::RealSection RealSection;
typedef typename mesh_type::SieveMesh SieveMesh;
typedef typename SieveMesh::label_sequence label_sequence;
+ typedef typename field_type::Mesh::RealSection RealSection;
- assert(0 != CellFilter<mesh_type>::_quadrature);
+ const feassemble::Quadrature<mesh_type>* quadrature =
+ CellFilter<mesh_type, field_type>::_quadrature;
+ assert(0 != quadrature);
- const int numQuadPts = CellFilter<mesh_type>::_quadrature->numQuadPts();
- const double_array& wts = CellFilter<mesh_type>::_quadrature->quadWts();
+ const int numQuadPts = quadrature->numQuadPts();
+ const double_array& wts = quadrature->quadWts();
const ALE::Obj<SieveMesh>& sieveMesh = fieldIn.mesh().sieveMesh();
assert(!sieveMesh.isNull());
@@ -84,7 +87,7 @@
// Allocate field if necessary
if (0 == _fieldAvg) {
- _fieldAvg = new topology::Field<mesh_type>(fieldIn.mesh());
+ _fieldAvg = new field_type(fieldIn.mesh());
assert(0 != _fieldAvg);
_fieldAvg->newSection(sectionIn->getChart(), fiberDim);
_fieldAvg->allocate();
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilterAvg.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilterAvg.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/CellFilterAvg.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -24,8 +24,8 @@
#include "CellFilter.hh" // ISA CellFilter
// CellFilter -----------------------------------------------------------
-template<typename mesh_type>
-class pylith::meshio::CellFilterAvg : public CellFilter<mesh_type>
+template<typename mesh_type, typename field_type>
+class pylith::meshio::CellFilterAvg : public CellFilter<mesh_type, field_type>
{ // CellFilterAvg
// PUBLIC METHODS ///////////////////////////////////////////////////////
@@ -41,7 +41,7 @@
*
* @returns Copy of filter.
*/
- CellFilter<mesh_type>* clone(void) const;
+ CellFilter<mesh_type,field_type>* clone(void) const;
/** Filter field over cells.
*
@@ -51,8 +51,8 @@
*
* @returns Averaged field.
*/
- const topology::Field<mesh_type>&
- filter(const topology::Field<mesh_type>& fieldIn,
+ const field_type&
+ filter(const field_type& fieldIn,
const char* label =0,
const int labelId =0);
@@ -75,7 +75,7 @@
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- topology::Field<mesh_type>* _fieldAvg; ///< Averaged cell field
+ field_type* _fieldAvg; ///< Averaged cell field
}; // CellFilterAvg
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriter.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriter.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriter.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -14,24 +14,24 @@
// ----------------------------------------------------------------------
// Constructor
-template<typename mesh_type>
-pylith::meshio::DataWriter<mesh_type>::DataWriter(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriter<mesh_type, field_type>::DataWriter(void) :
_numTimeSteps(0)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-template<typename mesh_type>
-pylith::meshio::DataWriter<mesh_type>::~DataWriter(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriter<mesh_type, field_type>::~DataWriter(void)
{ // destructor
} // destructor
// ----------------------------------------------------------------------
// Prepare for writing files.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriter<mesh_type>::open(const mesh_type& mesh,
+pylith::meshio::DataWriter<mesh_type, field_type>::open(const mesh_type& mesh,
const int numTimeSteps,
const char* label,
const int labelId)
@@ -41,17 +41,17 @@
// ----------------------------------------------------------------------
// Close output files.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriter<mesh_type>::close(void)
+pylith::meshio::DataWriter<mesh_type, field_type>::close(void)
{ // close
} // close
// ----------------------------------------------------------------------
// Prepare file for data at a new time step.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriter<mesh_type>::openTimeStep(const double t,
+pylith::meshio::DataWriter<mesh_type, field_type>::openTimeStep(const double t,
const mesh_type& mesh,
const char* label,
const int labelId)
@@ -60,16 +60,16 @@
// ----------------------------------------------------------------------
// Cleanup after writing data for a time step.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriter<mesh_type>::closeTimeStep(void)
+pylith::meshio::DataWriter<mesh_type, field_type>::closeTimeStep(void)
{ // closeTimeStep
} // closeTimeStep
// ----------------------------------------------------------------------
// Copy constructor.
-template<typename mesh_type>
-pylith::meshio::DataWriter<mesh_type>::DataWriter(const DataWriter& w)
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriter<mesh_type, field_type>::DataWriter(const DataWriter& w)
{ // copy constructor
} // copy constructor
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriter.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriter.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriter.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -25,7 +25,7 @@
#include "pylith/topology/topologyfwd.hh" // USES Field
// DataWriter -----------------------------------------------------------
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
class pylith::meshio::DataWriter
{ // DataWriter
@@ -89,7 +89,7 @@
*/
virtual
void writeVertexField(const double t,
- const topology::Field<mesh_type>& field) = 0;
+ const field_type& field) = 0;
/** Write field over cells to file.
*
@@ -101,7 +101,7 @@
*/
virtual
void writeCellField(const double t,
- const topology::Field<mesh_type>& field,
+ const field_type& field,
const char* label =0,
const int labelId =0) = 0;
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -20,8 +20,8 @@
// ----------------------------------------------------------------------
// Constructor
-template<typename mesh_type>
-pylith::meshio::DataWriterVTK<mesh_type>::DataWriterVTK(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::DataWriterVTK(void) :
_timeConstant(1.0),
_filename("output.vtk"),
_timeFormat("%f"),
@@ -33,8 +33,8 @@
// ----------------------------------------------------------------------
// Destructor
-template<typename mesh_type>
-pylith::meshio::DataWriterVTK<mesh_type>::~DataWriterVTK(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::~DataWriterVTK(void)
{ // destructor
if (0 != _viewer)
PetscViewerDestroy(_viewer);
@@ -43,9 +43,9 @@
// ----------------------------------------------------------------------
// Copy constructor.
-template<typename mesh_type>
-pylith::meshio::DataWriterVTK<mesh_type>::DataWriterVTK(const DataWriterVTK<mesh_type>& w) :
- DataWriter<mesh_type>(w),
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::DataWriterVTK(const DataWriterVTK<mesh_type, field_type>& w) :
+ DataWriter<mesh_type, field_type>(w),
_timeConstant(w._timeConstant),
_filename(w._filename),
_timeFormat(w._timeFormat),
@@ -57,9 +57,9 @@
// ----------------------------------------------------------------------
// Set value used to normalize time stamp in name of VTK file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK<mesh_type>::timeConstant(const double value)
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::timeConstant(const double value)
{ // timeConstant
if (value <= 0.0) {
std::ostringstream msg;
@@ -72,9 +72,9 @@
// ----------------------------------------------------------------------
// Prepare file for data at a new time step.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK<mesh_type>::openTimeStep(const double t,
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::openTimeStep(const double t,
const mesh_type& mesh,
const char* label,
const int labelId)
@@ -136,9 +136,9 @@
// ----------------------------------------------------------------------
/// Cleanup after writing data for a time step.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK<mesh_type>::closeTimeStep(void)
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::closeTimeStep(void)
{ // closeTimeStep
PetscViewerDestroy(_viewer); _viewer = 0;
_wroteVertexHeader = false;
@@ -147,14 +147,14 @@
// ----------------------------------------------------------------------
// Write field over vertices to file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK<mesh_type>::writeVertexField(
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::writeVertexField(
const double t,
- const topology::Field<mesh_type>& field)
+ const field_type& field)
{ // writeVertexField
- typedef typename mesh_type::SieveMesh SieveMesh;
- typedef typename mesh_type::RealSection RealSection;
+ typedef typename field_type::Mesh::SieveMesh SieveMesh;
+ typedef typename field_type::Mesh::RealSection RealSection;
try {
const ALE::Obj<SieveMesh>& sieveMesh = field.mesh().sieveMesh();
@@ -209,16 +209,16 @@
// ----------------------------------------------------------------------
// Write field over cells to file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK<mesh_type>::writeCellField(
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::writeCellField(
const double t,
- const topology::Field<mesh_type>& field,
+ const field_type& field,
const char* label,
const int labelId)
{ // writeCellField
- typedef typename mesh_type::SieveMesh SieveMesh;
- typedef typename mesh_type::RealSection RealSection;
+ typedef typename field_type::Mesh::SieveMesh SieveMesh;
+ typedef typename field_type::Mesh::RealSection RealSection;
try {
const ALE::Obj<SieveMesh>& sieveMesh = field.mesh().sieveMesh();
@@ -278,13 +278,14 @@
// ----------------------------------------------------------------------
// Generate filename for VTK file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
std::string
-pylith::meshio::DataWriterVTK<mesh_type>::_vtkFilename(const double t) const
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::_vtkFilename(const double t) const
{ // _vtkFilename
std::ostringstream filename;
const int indexExt = _filename.find(".vtk");
- if (DataWriter<mesh_type>::_numTimeSteps > 0) {
+ const int numTimeSteps = DataWriter<mesh_type, field_type>::_numTimeSteps;
+ if (numTimeSteps > 0) {
// If data with multiple time steps, then add time stamp to filename
char sbuffer[256];
sprintf(sbuffer, _timeFormat.c_str(), t/_timeConstant);
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -23,10 +23,13 @@
#include "DataWriter.hh" // ISA DataWriter
// DataWriterVTK --------------------------------------------------------
-template<typename mesh_type>
-class pylith::meshio::DataWriterVTK : public DataWriter<mesh_type>
+template<typename mesh_type, typename field_type>
+class pylith::meshio::DataWriterVTK : public DataWriter<mesh_type,field_type>
{ // DataWriterVTK
- friend class TestDataWriterVTK; // unit testing
+ friend class TestDataWriterVTKMesh; // unit testing
+ friend class TestDataWriterVTKSubMesh; // unit testing
+ friend class TestDataWriterVTKBCMesh; // unit testing
+ friend class TestDataWriterVTKFaultMesh; // unit testing
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
@@ -41,7 +44,7 @@
*
* @returns Copy of this.
*/
- DataWriter<mesh_type>* clone(void) const;
+ DataWriter<mesh_type, field_type>* clone(void) const;
/** Set filename for VTK file.
*
@@ -86,7 +89,7 @@
* @param field Field over vertices.
*/
void writeVertexField(const double t,
- const topology::Field<mesh_type>& field);
+ const field_type& field);
/** Write field over cells to file.
*
@@ -97,7 +100,7 @@
* @param labelId Value of label defining which cells to include.
*/
void writeCellField(const double t,
- const topology::Field<mesh_type>& field,
+ const field_type& field,
const char* label =0,
const int labelId =0);
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.icc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.icc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/DataWriterVTK.icc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -15,26 +15,26 @@
#else
// Make copy of this object.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
inline
-pylith::meshio::DataWriter<mesh_type>*
-pylith::meshio::DataWriterVTK<mesh_type>::clone(void) const {
+pylith::meshio::DataWriter<mesh_type, field_type>*
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::clone(void) const {
return new DataWriterVTK(*this);
}
// Set filename for VTK file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
inline
void
-pylith::meshio::DataWriterVTK<mesh_type>::filename(const char* filename) {
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::filename(const char* filename) {
_filename = filename;
}
// Set time format for time stamp in name of VTK file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
inline
void
-pylith::meshio::DataWriterVTK<mesh_type>::timeFormat(const char* format) {
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::timeFormat(const char* format) {
_timeFormat = format;
}
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputManager.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputManager.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputManager.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -20,8 +20,8 @@
// ----------------------------------------------------------------------
// Constructor
-template<typename mesh_type>
-pylith::meshio::OutputManager<mesh_type>::OutputManager(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::OutputManager<mesh_type, field_type>::OutputManager(void) :
_coordsys(0),
_writer(0),
_vertexFilter(0),
@@ -31,8 +31,8 @@
// ----------------------------------------------------------------------
// Destructor
-template<typename mesh_type>
-pylith::meshio::OutputManager<mesh_type>::~OutputManager(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::OutputManager<mesh_type, field_type>::~OutputManager(void)
{ // destructor
_writer = 0; // :TODO: Use shared pointer
_vertexFilter = 0; // :TODO: Use shared pointer
@@ -42,9 +42,9 @@
// ----------------------------------------------------------------------
// Set coordinate system in output. The vertex fields in the output
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::coordsys(
+pylith::meshio::OutputManager<mesh_type, field_type>::coordsys(
const spatialdata::geocoords::CoordSys* cs)
{ // coordsys
delete _coordsys; _coordsys = (0 != cs) ? cs->clone() : 0;
@@ -52,42 +52,43 @@
// ----------------------------------------------------------------------
// Set writer to write data to file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::writer(
- DataWriter<mesh_type>* const datawriter)
+pylith::meshio::OutputManager<mesh_type, field_type>::writer(
+ DataWriter<mesh_type, field_type>* const datawriter)
{ // writer
_writer = datawriter; // :TODO: Use shared pointer
} // writer
// ----------------------------------------------------------------------
// Set filter for vertex data.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::vertexFilter(
- VertexFilter<mesh_type>* const filter)
+pylith::meshio::OutputManager<mesh_type, field_type>::vertexFilter(
+ VertexFilter<field_type>* const filter)
{ // vertexFilter
_vertexFilter = filter; // :TODO: Use shared pointer
} // vertexFilter
// ----------------------------------------------------------------------
// Set filter for cell data.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::cellFilter(
- CellFilter<mesh_type>* const filter)
+pylith::meshio::OutputManager<mesh_type, field_type>::cellFilter(
+ CellFilter<mesh_type, field_type>* const filter)
{ // cellFilter
_cellFilter = filter; // :TODO: Use shared pointer
} // cellFilter
// ----------------------------------------------------------------------
// Prepare for output.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::open(const mesh_type& mesh,
- const int numTimeSteps,
- const char* label,
- const int labelId)
+pylith::meshio::OutputManager<mesh_type, field_type>::open(
+ const mesh_type& mesh,
+ const int numTimeSteps,
+ const char* label,
+ const int labelId)
{ // open
assert(0 != _writer);
@@ -96,9 +97,9 @@
// ----------------------------------------------------------------------
/// Close output files.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::close(void)
+pylith::meshio::OutputManager<mesh_type, field_type>::close(void)
{ // close
assert(0 != _writer);
_writer->close();
@@ -106,9 +107,10 @@
// ----------------------------------------------------------------------
// Setup file for writing fields at time step.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::openTimeStep(const double t,
+pylith::meshio::OutputManager<mesh_type, field_type>::openTimeStep(
+ const double t,
const mesh_type& mesh,
const char* label,
const int labelId)
@@ -119,9 +121,9 @@
// ----------------------------------------------------------------------
// End writing fields at time step.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::closeTimeStep(void)
+pylith::meshio::OutputManager<mesh_type, field_type>::closeTimeStep(void)
{ // closeTimeStep
assert(0 != _writer);
_writer->closeTimeStep();
@@ -129,13 +131,13 @@
// ----------------------------------------------------------------------
// Append finite-element vertex field to file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::appendVertexField(
- const double t,
- const topology::Field<mesh_type>& field)
+pylith::meshio::OutputManager<mesh_type, field_type>::appendVertexField(
+ const double t,
+ const field_type& field)
{ // appendVertexField
- const topology::Field<mesh_type>& fieldFiltered =
+ const field_type& fieldFiltered =
(0 == _vertexFilter) ? field : _vertexFilter->filter(field);
_writer->writeVertexField(t, fieldFiltered);
@@ -143,15 +145,15 @@
// ----------------------------------------------------------------------
// Append finite-element cell field to file.
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager<mesh_type>::appendCellField(
- const double t,
- const topology::Field<mesh_type>& field,
- const char* label,
- const int labelId)
+pylith::meshio::OutputManager<mesh_type, field_type>::appendCellField(
+ const double t,
+ const field_type& field,
+ const char* label,
+ const int labelId)
{ // appendCellField
- const topology::Field<mesh_type>& fieldFiltered =
+ const field_type& fieldFiltered =
(0 == _cellFilter) ? field : _cellFilter->filter(field, label, labelId);
_writer->writeCellField(t, fieldFiltered, label, labelId);
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputManager.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputManager.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputManager.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -26,7 +26,7 @@
#include "spatialdata/geocoords/geocoordsfwd.hh" // USES CoordSys
// OutputManager --------------------------------------------------------
-template<typename mesh_type>
+template<typename mesh_type, typename field_type>
class pylith::meshio::OutputManager
{ // OutputManager
friend class TestOutputManager; // unit testing
@@ -52,19 +52,19 @@
*
* @param datawriter Writer for data.
*/
- void writer(DataWriter<mesh_type>* const datawriter);
+ void writer(DataWriter<mesh_type, field_type>* const datawriter);
/** Set filter for vertex data.
*
* @param filter Filter to apply to vertex data before writing.
*/
- void vertexFilter(VertexFilter<mesh_type>* const filter);
+ void vertexFilter(VertexFilter<field_type>* const filter);
/** Set filter for cell data.
*
* @param filter Filter to apply to cell data before writing.
*/
- void cellFilter(CellFilter<mesh_type>* const filter);
+ void cellFilter(CellFilter<mesh_type, field_type>* const filter);
/** Prepare for output.
*
@@ -104,7 +104,7 @@
* @param field Vertex field.
*/
void appendVertexField(const double t,
- const topology::Field<mesh_type>& field);
+ const field_type& field);
/** Append finite-element cell field to file.
*
@@ -115,7 +115,7 @@
* @param labelId Value of label defining which cells to include.
*/
void appendCellField(const double t,
- const topology::Field<mesh_type>& field,
+ const field_type& field,
const char* label =0,
const int labelId =0);
@@ -131,9 +131,9 @@
/// Coordinate system for output.
spatialdata::geocoords::CoordSys* _coordsys;
- DataWriter<mesh_type>* _writer; ///< Writer for data.
- VertexFilter<mesh_type>* _vertexFilter; ///< Filter applied to vertex data.
- CellFilter<mesh_type>* _cellFilter; ///< Filter applied to cell data.
+ DataWriter<mesh_type, field_type>* _writer; ///< Writer for data.
+ VertexFilter<field_type>* _vertexFilter; ///< Filter applied to vertex data.
+ CellFilter<mesh_type, field_type>* _cellFilter; ///< Filter applied to cell data.
}; // OutputManager
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputSolnSubset.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputSolnSubset.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputSolnSubset.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -65,14 +65,5 @@
return *_submesh;
} // subdomainMesh
-// ----------------------------------------------------------------------
-// Append finite-element vertex field to file.
-void
-pylith::meshio::OutputSolnSubset::appendVertexField(const double t,
- const topology::Field<topology::Mesh>& field)
-{ // appendVertexField
- // How do we call DataWriter<SubMesh>::appendVertexField() with a Field<Mesh>?
-} // appendVertexField
-
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputSolnSubset.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputSolnSubset.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/OutputSolnSubset.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -24,12 +24,15 @@
#include "meshiofwd.hh" // forward declarations
#include "pylith/topology/SubMesh.hh" // ISA OutputManager<SubMesh>
+#include "pylith/topology/Mesh.hh" // ISA OutputManager<Field<Mesh>>
+#include "pylith/topology/Field.hh" // ISA OutputManager<Field<Mesh>>
#include "OutputManager.hh" // ISA OutputManager
#include <string> // HASA std::string
// OutputSolnSubset -----------------------------------------------------
-class pylith::meshio::OutputSolnSubset : public OutputManager<topology::SubMesh>
+class pylith::meshio::OutputSolnSubset :
+ public OutputManager<topology::SubMesh, topology::Field<topology::Mesh> >
{ // OutputSolnSubset
friend class TestOutputSolnSubset; // unit testing
@@ -60,15 +63,6 @@
*/
const topology::SubMesh& subdomainMesh(const topology::Mesh& mesh);
- /** Append finite-element vertex field to file.
- *
- * @param t Time associated with field.
- * @param field Vertex field.
- */
- void appendVertexField(const double t,
- const topology::Field<topology::Mesh>& field);
-
-
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilter.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilter.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilter.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -14,30 +14,30 @@
// ----------------------------------------------------------------------
// Constructor
-template<typename mesh_type>
-pylith::meshio::VertexFilter<mesh_type>::VertexFilter(void)
+template<typename field_type>
+pylith::meshio::VertexFilter<field_type>::VertexFilter(void)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-template<typename mesh_type>
-pylith::meshio::VertexFilter<mesh_type>::~VertexFilter(void)
+template<typename field_type>
+pylith::meshio::VertexFilter<field_type>::~VertexFilter(void)
{ // destructor
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-template<typename mesh_type>
-pylith::meshio::VertexFilter<mesh_type>::VertexFilter(const VertexFilter& f)
+template<typename field_type>
+pylith::meshio::VertexFilter<field_type>::VertexFilter(const VertexFilter& f)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// operator=.
-template<typename mesh_type>
-const pylith::meshio::VertexFilter<mesh_type>&
-pylith::meshio::VertexFilter<mesh_type>::operator=(const VertexFilter& f)
+template<typename field_type>
+const pylith::meshio::VertexFilter<field_type>&
+pylith::meshio::VertexFilter<field_type>::operator=(const VertexFilter& f)
{ // operator=
} // operator=
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilter.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilter.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilter.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -26,7 +26,7 @@
#include "pylith/topology/topologyfwd.hh" // USES Field
// VertexFilter ---------------------------------------------------------
-template<typename mesh_type>
+template<typename field_type>
class pylith::meshio::VertexFilter
{ // VertexFilter
@@ -51,8 +51,8 @@
* @param fieldIn Field to filter.
*/
virtual
- const topology::Field<mesh_type>&
- filter(const topology::Field<mesh_type>& fieldIn) = 0;
+ const field_type&
+ filter(const field_type& fieldIn) = 0;
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilterVecNorm.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilterVecNorm.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilterVecNorm.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -16,47 +16,47 @@
// ----------------------------------------------------------------------
// Constructor
-template<typename mesh_type>
-pylith::meshio::VertexFilterVecNorm<mesh_type>::VertexFilterVecNorm(void) :
+template<typename field_type>
+pylith::meshio::VertexFilterVecNorm<field_type>::VertexFilterVecNorm(void) :
_fieldVecNorm(0)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-template<typename mesh_type>
-pylith::meshio::VertexFilterVecNorm<mesh_type>::~VertexFilterVecNorm(void)
+template<typename field_type>
+pylith::meshio::VertexFilterVecNorm<field_type>::~VertexFilterVecNorm(void)
{ // destructor
delete _fieldVecNorm; _fieldVecNorm = 0;
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-template<typename mesh_type>
-pylith::meshio::VertexFilterVecNorm<mesh_type>::VertexFilterVecNorm(const VertexFilterVecNorm& f) :
- VertexFilter<mesh_type>(f),
+template<typename field_type>
+pylith::meshio::VertexFilterVecNorm<field_type>::VertexFilterVecNorm(const VertexFilterVecNorm& f) :
+ VertexFilter<field_type>(f),
_fieldVecNorm(0)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Create copy of filter.
-template<typename mesh_type>
-pylith::meshio::VertexFilter<mesh_type>*
-pylith::meshio::VertexFilterVecNorm<mesh_type>::clone(void) const
+template<typename field_type>
+pylith::meshio::VertexFilter<field_type>*
+pylith::meshio::VertexFilterVecNorm<field_type>::clone(void) const
{ // clone
return new VertexFilterVecNorm(*this);
} // clone
// ----------------------------------------------------------------------
// Filter field.
-template<typename mesh_type>
-const pylith::topology::Field<mesh_type>&
-pylith::meshio::VertexFilterVecNorm<mesh_type>::filter(
- const topology::Field<mesh_type>& fieldIn)
+template<typename field_type>
+const field_type&
+pylith::meshio::VertexFilterVecNorm<field_type>::filter(
+ const field_type& fieldIn)
{ // filter
- typedef typename mesh_type::RealSection RealSection;
- typedef typename mesh_type::SieveMesh SieveMesh;
+ typedef typename field_type::Mesh::RealSection RealSection;
+ typedef typename field_type::Mesh::SieveMesh SieveMesh;
typedef typename SieveMesh::label_sequence label_sequence;
const ALE::Obj<SieveMesh>& sieveMesh = fieldIn.mesh().sieveMesh();
@@ -73,7 +73,7 @@
// Allocation field if necessary
if (0 == _fieldVecNorm) {
- _fieldVecNorm = new topology::Field<mesh_type>(fieldIn.mesh());
+ _fieldVecNorm = new field_type(fieldIn.mesh());
_fieldVecNorm->newSection(sectionIn->getChart(), fiberDimNorm);
_fieldVecNorm->allocate();
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilterVecNorm.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilterVecNorm.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/VertexFilterVecNorm.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -24,8 +24,8 @@
#include "VertexFilter.hh" // ISA VertexFilter
// VertexFilterVecNorm --------------------------------------------------
-template<typename mesh_type>
-class pylith::meshio::VertexFilterVecNorm : public VertexFilter<mesh_type>
+template<typename field_type>
+class pylith::meshio::VertexFilterVecNorm : public VertexFilter<field_type>
{ // VertexFilterVecNorm
// PUBLIC METHODS ///////////////////////////////////////////////////////
@@ -41,14 +41,14 @@
*
* @returns Copy of filter.
*/
- VertexFilter<mesh_type>* clone(void) const;
+ VertexFilter<field_type>* clone(void) const;
/** Filter vertex field.
*
* @param fieldIn Field to filter.
*/
- const topology::Field<mesh_type>&
- filter(const topology::Field<mesh_type>& fieldIn);
+ const field_type&
+ filter(const field_type& fieldIn);
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -69,7 +69,7 @@
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- topology::Field<mesh_type>* _fieldVecNorm; ///< Filtered vertex field
+ field_type* _fieldVecNorm; ///< Filtered vertex field
}; // VertexFilterVecNorm
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/meshio/meshiofwd.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/meshio/meshiofwd.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/meshio/meshiofwd.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -38,13 +38,13 @@
class PsetFileAscii;
class PsetFileBinary;
- template<typename mesh_type> class OutputManager;
- template<typename mesh_type> class DataWriter;
- template<typename mesh_type> class DataWriterVTK;
- template<typename mesh_type> class CellFilter;
- template<typename mesh_type> class CellFilterAvg;
- template<typename mesh_type> class VertexFilter;
- template<typename mesh_type> class VertexFilterVecNorm;
+ template<typename mesh_type, typename field_type> class OutputManager;
+ template<typename mesh_type, typename field_type> class DataWriter;
+ template<typename mesh_type, typename field_type> class DataWriterVTK;
+ template<typename mesh_type, typename field_type> class CellFilter;
+ template<typename mesh_type, typename field_type> class CellFilterAvg;
+ template<typename field_type> class VertexFilter;
+ template<typename field_type> class VertexFilterVecNorm;
class OutputSolnSubset;
class UCDFaultFile;
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestCellFilterAvg.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestCellFilterAvg.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestCellFilterAvg.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -24,11 +24,14 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestCellFilterAvg );
// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestCellFilterAvg::testConstructor(void)
{ // testConstructor
- CellFilterAvg<topology::Mesh> filter;
+ CellFilterAvg<topology::Mesh, MeshField> filter;
} // testConstructor
// ----------------------------------------------------------------------
@@ -85,7 +88,7 @@
iohandler.read(&mesh);
// Set cell field
- topology::Field<topology::Mesh> field(mesh);
+ MeshField field(mesh);
field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
field.allocate();
field.vectorFieldType(fieldType);
@@ -116,7 +119,7 @@
quadWts, numQuadPts,
spaceDim);
- CellFilterAvg<topology::Mesh> filter;
+ CellFilterAvg<topology::Mesh, MeshField> filter;
filter.quadrature(&quadrature);
const topology::Field<topology::Mesh>& fieldF = filter.filter(field);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -16,24 +16,14 @@
#include "data/DataWriterVTKData.hh" // USES DataWriterVTKData
-#include "pylith/topology/Mesh.hh" // USES Mesh
-#include "pylith/topology/Field.hh" // USES Field
-#include "pylith/topology/Fields.hh" // USES Fields
-#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
-
#include <string.h> // USES strcmp()
// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTK );
-
-// ----------------------------------------------------------------------
// Setup testing data.
void
pylith::meshio::TestDataWriterVTK::setUp(void)
{ // setUp
- _mesh = 0;
_data = 0;
- _flipFault = false;
} // setUp
// ----------------------------------------------------------------------
@@ -41,316 +31,10 @@
void
pylith::meshio::TestDataWriterVTK::tearDown(void)
{ // tearDown
- delete _mesh; _mesh = 0;
delete _data; _data = 0;
} // tearDown
// ----------------------------------------------------------------------
-// Test constructor
-void
-pylith::meshio::TestDataWriterVTK::testConstructor(void)
-{ // testConstructor
- DataWriterVTK<topology::Mesh> writer;
-
- CPPUNIT_ASSERT(0 == writer._viewer);
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-} // testConstructor
-
-// ----------------------------------------------------------------------
-// Test filename()
-void
-pylith::meshio::TestDataWriterVTK::testFilename(void)
-{ // testDebug
- DataWriterVTK<topology::Mesh> writer;
-
- const char* filename = "data.vtk";
- writer.filename(filename);
- CPPUNIT_ASSERT_EQUAL(std::string(filename), writer._filename);
-} // testFilename
-
-// ----------------------------------------------------------------------
-// Test timeFormat()
-void
-pylith::meshio::TestDataWriterVTK::testTimeFormat(void)
-{ // testTimeFormat
- DataWriterVTK<topology::Mesh> writer;
-
- const char* format = "%4.1f";
- writer.timeFormat(format);
- CPPUNIT_ASSERT_EQUAL(std::string(format), writer._timeFormat);
-} // testInterpolate
-
-// ----------------------------------------------------------------------
-// Test timeConstant()
-void
-pylith::meshio::TestDataWriterVTK::testTimeConstant(void)
-{ // testTimeConstant
- DataWriterVTK<topology::Mesh> writer;
-
- const double value = 4.5;
- writer.timeConstant(value);
- CPPUNIT_ASSERT_EQUAL(value, writer._timeConstant);
-} // testInterpolate
-
-// ----------------------------------------------------------------------
-// Test openTimeStep() and closeTimeStep()
-void
-pylith::meshio::TestDataWriterVTK::testTimeStep(void)
-{ // testTimeStep
- CPPUNIT_ASSERT(0 != _mesh);
- CPPUNIT_ASSERT(0 != _data);
-
- DataWriterVTK<topology::Mesh> writer;
-
- writer.filename(_data->timestepFilename);
- writer.timeFormat(_data->timeFormat);
-
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- const double t = _data->time;
- const int numTimeSteps = 1;
- if (0 == _data->cellsLabel) {
- writer.open(*_mesh, numTimeSteps);
- writer.openTimeStep(t, *_mesh);
- } else {
- const char* label = _data->cellsLabel;
- const int id = _data->labelId;
- writer.open(*_mesh, numTimeSteps, label, id);
- writer.openTimeStep(t, *_mesh, label, id);
- } // else
-
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- writer.closeTimeStep();
- writer.close();
-
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- checkFile(_data->timestepFilename, t, _data->timeFormat);
-} // testTimeStep
-
-// ----------------------------------------------------------------------
-// Test writeVertexField.
-void
-pylith::meshio::TestDataWriterVTK::testWriteVertexField(void)
-{ // testWriteVertexField
- CPPUNIT_ASSERT(0 != _mesh);
- CPPUNIT_ASSERT(0 != _data);
-
- DataWriterVTK<topology::Mesh> writer;
-
- topology::Fields<topology::Field<topology::Mesh> > vertexFields(*_mesh);
- _createVertexFields(&vertexFields);
-
- writer.filename(_data->vertexFilename);
- writer.timeFormat(_data->timeFormat);
-
- const int nfields = _data->numVertexFields;
-
- const double t = _data->time;
- const int numTimeSteps = 1;
- if (0 == _data->cellsLabel) {
- writer.open(*_mesh, numTimeSteps);
- writer.openTimeStep(t, *_mesh);
- } else {
- const char* label = _data->cellsLabel;
- const int id = _data->labelId;
- writer.open(*_mesh, numTimeSteps, label, id);
- writer.openTimeStep(t, *_mesh, label, id);
- } // else
- for (int i=0; i < nfields; ++i) {
- const topology::Field<topology::Mesh>& field =
- vertexFields.get(_data->vertexFieldsInfo[i].name);
- writer.writeVertexField(t, field);
- CPPUNIT_ASSERT(writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
- } // for
- writer.closeTimeStep();
- writer.close();
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- checkFile(_data->vertexFilename, t, _data->timeFormat);
-} // testWriteVertexField
-
-// ----------------------------------------------------------------------
-// Test writeCellField.
-void
-pylith::meshio::TestDataWriterVTK::testWriteCellField(void)
-{ // testWriteCellField
- CPPUNIT_ASSERT(0 != _mesh);
- CPPUNIT_ASSERT(0 != _data);
-
- DataWriterVTK<topology::Mesh> writer;
-
- topology::Fields<topology::Field<topology::Mesh> > cellFields(*_mesh);
- _createCellFields(&cellFields);
-
- writer.filename(_data->cellFilename);
- writer.timeFormat(_data->timeFormat);
-
- const int nfields = _data->numCellFields;
-
- const double t = _data->time;
- const int numTimeSteps = 1;
- if (0 == _data->cellsLabel) {
- writer.open(*_mesh, numTimeSteps);
- writer.openTimeStep(t, *_mesh);
- for (int i=0; i < nfields; ++i) {
- const topology::Field<topology::Mesh>& field =
- cellFields.get(_data->cellFieldsInfo[i].name);
- writer.writeCellField(t, field);
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(writer._wroteCellHeader);
- } // for
- } else {
- const char* label = _data->cellsLabel;
- const int id = _data->labelId;
- writer.open(*_mesh, numTimeSteps, label, id);
- writer.openTimeStep(t, *_mesh, label, id);
- for (int i=0; i < nfields; ++i) {
- const topology::Field<topology::Mesh>& field =
- cellFields.get(_data->cellFieldsInfo[i].name);
- writer.writeCellField(t, field, label, id);
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(writer._wroteCellHeader);
- } // for
- } // else
- writer.closeTimeStep();
- writer.close();
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- checkFile(_data->cellFilename, t, _data->timeFormat);
-} // testWriteCellField
-
-// ----------------------------------------------------------------------
-// Test _vtkFilename.
-void pylith::meshio::TestDataWriterVTK::testVtkFilename(void)
-{ // testVtkFilename
- DataWriterVTK<topology::Mesh> writer;
-
- // Append info to filename if number of time steps is 0.
- writer._numTimeSteps = 0;
- writer._filename = "output.vtk";
- CPPUNIT_ASSERT_EQUAL(std::string("output_info.vtk"), writer._vtkFilename(0.0));
-
- // Use default normalization of 1.0, remove period from time stamp.
- writer._numTimeSteps = 100;
- writer._filename = "output.vtk";
- writer.timeFormat("%05.2f");
- CPPUNIT_ASSERT_EQUAL(std::string("output_t0230.vtk"),
- writer._vtkFilename(2.3));
-
- // Use normalization of 20.0, remove period from time stamp.
- writer._numTimeSteps = 100;
- writer._filename = "output.vtk";
- writer.timeFormat("%05.2f");
- writer.timeConstant(20.0);
- CPPUNIT_ASSERT_EQUAL(std::string("output_t0250.vtk"),
- writer._vtkFilename(50.0));
-} // testVtkFilename
-
-// ----------------------------------------------------------------------
-// Create vertex fields.
-void
-pylith::meshio::TestDataWriterVTK::_createVertexFields(
- topology::Fields<topology::Field<topology::Mesh> >* fields) const
-{ // _createVertexFields
- CPPUNIT_ASSERT(0 != fields);
- CPPUNIT_ASSERT(0 != _mesh);
- CPPUNIT_ASSERT(0 != _data);
-
- try {
- const int nfields = _data->numVertexFields;
-
- const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
- CPPUNIT_ASSERT(!sieveMesh.isNull());
- const ALE::Obj<topology::Mesh::SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
- CPPUNIT_ASSERT(!vertices.isNull());
- const topology::Mesh::SieveMesh::label_sequence::iterator verticesEnd =
- vertices->end();
-
- // Set vertex fields
- for (int i=0; i < nfields; ++i) {
- const char* name = _data->vertexFieldsInfo[i].name;
- const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
- fields->add(name, name);
- topology::Field<topology::Mesh>& field = fields->get(name);
- field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
- field.allocate();
- field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
-
- const ALE::Obj<topology::Mesh::RealSection>& section = field.section();
- CPPUNIT_ASSERT(!section.isNull());
- int ipt = 0;
- for (topology::Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter, ++ipt) {
- const double* values = &_data->vertexFields[i][ipt*fiberDim];
- section->updatePoint(*v_iter, values);
- } // for
- CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
- } // for
- } catch (const ALE::Exception& err) {
- throw std::runtime_error(err.msg());
- } // catch
-} // _createVertexFields
-
-// ----------------------------------------------------------------------
-// Create cell fields.
-void
-pylith::meshio::TestDataWriterVTK::_createCellFields(
- topology::Fields<topology::Field<topology::Mesh> >* fields) const
-{ // _createCellFields
- CPPUNIT_ASSERT(0 != fields);
- CPPUNIT_ASSERT(0 != _mesh);
- CPPUNIT_ASSERT(0 != _data);
-
- try {
- const int nfields = _data->numCellFields;
-
- const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
- CPPUNIT_ASSERT(!sieveMesh.isNull());
- const ALE::Obj<topology::Mesh::SieveMesh::label_sequence>& cells =
- (0 == _data->cellsLabel) ?
- sieveMesh->depthStratum(1) :
- sieveMesh->getLabelStratum(_data->cellsLabel, _data->labelId);
- const topology::Mesh::SieveMesh::label_sequence::iterator cellsEnd =
- cells->end();
-
- // Set cell fields
- for (int i=0; i < nfields; ++i) {
- const char* name = _data->cellFieldsInfo[i].name;
- const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
- fields->add(name, name);
- topology::Field<topology::Mesh>& field = fields->get(name);
- field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
- field.allocate();
- field.vectorFieldType(_data->cellFieldsInfo[i].field_type);
-
- const ALE::Obj<topology::Mesh::RealSection>& section = field.section();
- CPPUNIT_ASSERT(!section.isNull());
- int icell = 0;
- for (topology::Mesh::SieveMesh::label_sequence::iterator c_iter=cells->begin();
- c_iter != cellsEnd;
- ++c_iter, ++icell) {
- const double* values = &_data->cellFields[i][icell*fiberDim];
- section->updatePoint(*c_iter, values);
- } // for
- CPPUNIT_ASSERT_EQUAL(_data->numCells, icell);
- } // for
- } catch (const ALE::Exception& err) {
- throw std::runtime_error(err.msg());
- } // catch
-} // _createCellFields
-
-// ----------------------------------------------------------------------
// Check VTK file against archived file.
void
pylith::meshio::TestDataWriterVTK::checkFile(const char* filenameRoot,
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTK.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -21,8 +21,6 @@
#if !defined(pylith_meshio_testdatawritervtk_hh)
#define pylith_meshio_testdatawritervtk_hh
-#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field
-
#include <cppunit/extensions/HelperMacros.h>
/// Namespace for pylith package
@@ -38,17 +36,6 @@
class pylith::meshio::TestDataWriterVTK : public CppUnit::TestFixture
{ // class TestDataWriterVTK
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDataWriterVTK );
-
- CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST( testFilename );
- CPPUNIT_TEST( testTimeFormat );
- CPPUNIT_TEST( testTimeConstant );
- CPPUNIT_TEST( testVtkFilename );
-
- CPPUNIT_TEST_SUITE_END();
-
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
@@ -58,30 +45,6 @@
/// Tear down testing data.
void tearDown(void);
- /// Test constructor
- void testConstructor(void);
-
- /// Test filename()
- void testFilename(void);
-
- /// Test timeFormat()
- void testTimeFormat(void);
-
- /// Test timeConstant()
- void testTimeConstant(void);
-
- /// Test openTimeStep() and closeTimeStep()
- void testTimeStep(void);
-
- /// Test writeVertexField.
- void testWriteVertexField(void);
-
- /// Test writeCellField.
- void testWriteCellField(void);
-
- /// Test vtkFilename.
- void testVtkFilename(void);
-
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
@@ -100,26 +63,7 @@
protected :
DataWriterVTKData* _data; ///< Data for testing
- topology::Mesh* _mesh; ///< Mesh for data
- bool _flipFault; ///< If true, flip fault orientation.
- // PRIVATE MEMBERS ////////////////////////////////////////////////////
-private :
-
- /** Create vertex fields.
- *
- * @param fields Vertex fields.
- */
- void
- _createVertexFields(topology::Fields<topology::Field<topology::Mesh> >* fields) const;
-
- /** Create cell fields.
- *
- * @param fields Cell fields.
- */
- void
- _createCellFields(topology::Fields<topology::Field<topology::Mesh> >* fields) const;
-
}; // class TestDataWriterVTK
#endif // pylith_meshio_testdatawritervtk_hh
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMesh.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMesh.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -16,10 +16,246 @@
#include "data/DataWriterVTKData.hh" // USES DataWriterVTKData
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKMesh );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKMesh::setUp(void)
+{ // setUp
+ TestDataWriterVTK::setUp();
+ _mesh = 0;
+ _flipFault = false;
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::meshio::TestDataWriterVTKMesh::tearDown(void)
+{ // tearDown
+ TestDataWriterVTK::tearDown();
+ delete _mesh; _mesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor
+void
+pylith::meshio::TestDataWriterVTKMesh::testConstructor(void)
+{ // testConstructor
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ CPPUNIT_ASSERT(0 == writer._viewer);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test filename()
+void
+pylith::meshio::TestDataWriterVTKMesh::testFilename(void)
+{ // testDebug
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ const char* filename = "data.vtk";
+ writer.filename(filename);
+ CPPUNIT_ASSERT_EQUAL(std::string(filename), writer._filename);
+} // testFilename
+
+// ----------------------------------------------------------------------
+// Test timeFormat()
+void
+pylith::meshio::TestDataWriterVTKMesh::testTimeFormat(void)
+{ // testTimeFormat
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ const char* format = "%4.1f";
+ writer.timeFormat(format);
+ CPPUNIT_ASSERT_EQUAL(std::string(format), writer._timeFormat);
+} // testInterpolate
+
+// ----------------------------------------------------------------------
+// Test timeConstant()
+void
+pylith::meshio::TestDataWriterVTKMesh::testTimeConstant(void)
+{ // testTimeConstant
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ const double value = 4.5;
+ writer.timeConstant(value);
+ CPPUNIT_ASSERT_EQUAL(value, writer._timeConstant);
+} // testInterpolate
+
+// ----------------------------------------------------------------------
+// Test openTimeStep() and closeTimeStep()
+void
+pylith::meshio::TestDataWriterVTKMesh::testTimeStep(void)
+{ // testTimeStep
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ writer.filename(_data->timestepFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_mesh, numTimeSteps);
+ writer.openTimeStep(t, *_mesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_mesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_mesh, label, id);
+ } // else
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ writer.closeTimeStep();
+ writer.close();
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->timestepFilename, t, _data->timeFormat);
+} // testTimeStep
+
+// ----------------------------------------------------------------------
+// Test writeVertexField.
+void
+pylith::meshio::TestDataWriterVTKMesh::testWriteVertexField(void)
+{ // testWriteVertexField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ topology::Fields<MeshField> vertexFields(*_mesh);
+ _createVertexFields(&vertexFields);
+
+ writer.filename(_data->vertexFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numVertexFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_mesh, numTimeSteps);
+ writer.openTimeStep(t, *_mesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_mesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_mesh, label, id);
+ } // else
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = vertexFields.get(_data->vertexFieldsInfo[i].name);
+ writer.writeVertexField(t, field);
+ CPPUNIT_ASSERT(writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ } // for
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->vertexFilename, t, _data->timeFormat);
+} // testWriteVertexField
+
+// ----------------------------------------------------------------------
+// Test writeCellField.
+void
+pylith::meshio::TestDataWriterVTKMesh::testWriteCellField(void)
+{ // testWriteCellField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ topology::Fields<MeshField> cellFields(*_mesh);
+ _createCellFields(&cellFields);
+
+ writer.filename(_data->cellFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numCellFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_mesh, numTimeSteps);
+ writer.openTimeStep(t, *_mesh);
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_mesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_mesh, label, id);
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field, label, id);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } // else
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->cellFilename, t, _data->timeFormat);
+} // testWriteCellField
+
+// ----------------------------------------------------------------------
+// Test _vtkFilename.
+void pylith::meshio::TestDataWriterVTKMesh::testVtkFilename(void)
+{ // testVtkFilename
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ // Append info to filename if number of time steps is 0.
+ writer._numTimeSteps = 0;
+ writer._filename = "output.vtk";
+ CPPUNIT_ASSERT_EQUAL(std::string("output_info.vtk"), writer._vtkFilename(0.0));
+
+ // Use default normalization of 1.0, remove period from time stamp.
+ writer._numTimeSteps = 100;
+ writer._filename = "output.vtk";
+ writer.timeFormat("%05.2f");
+ CPPUNIT_ASSERT_EQUAL(std::string("output_t0230.vtk"),
+ writer._vtkFilename(2.3));
+
+ // Use normalization of 20.0, remove period from time stamp.
+ writer._numTimeSteps = 100;
+ writer._filename = "output.vtk";
+ writer.timeFormat("%05.2f");
+ writer.timeConstant(20.0);
+ CPPUNIT_ASSERT_EQUAL(std::string("output_t0250.vtk"),
+ writer._vtkFilename(50.0));
+} // testVtkFilename
+
+// ----------------------------------------------------------------------
// Initialize mesh.
void
pylith::meshio::TestDataWriterVTKMesh::_initialize(void)
@@ -39,5 +275,100 @@
} // if
} // _initialize
+// ----------------------------------------------------------------------
+// Create vertex fields.
+void
+pylith::meshio::TestDataWriterVTKMesh::_createVertexFields(
+ topology::Fields<MeshField>* fields) const
+{ // _createVertexFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+ try {
+ const int nfields = _data->numVertexFields;
+
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<topology::Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const topology::Mesh::SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
+
+ // Set vertex fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->vertexFieldsInfo[i].name;
+ const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ MeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int ipt = 0;
+ for (topology::Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++ipt) {
+ const double* values = &_data->vertexFields[i][ipt*fiberDim];
+ section->updatePoint(*v_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createVertexFields
+
+// ----------------------------------------------------------------------
+// Create cell fields.
+void
+pylith::meshio::TestDataWriterVTKMesh::_createCellFields(
+ topology::Fields<MeshField>* fields) const
+{ // _createCellFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ try {
+ const int nfields = _data->numCellFields;
+
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<topology::Mesh::SieveMesh::label_sequence>& cells =
+ (0 == _data->cellsLabel) ?
+ sieveMesh->depthStratum(1) :
+ sieveMesh->getLabelStratum(_data->cellsLabel, _data->labelId);
+ const topology::Mesh::SieveMesh::label_sequence::iterator cellsEnd =
+ cells->end();
+
+ // Set cell fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->cellFieldsInfo[i].name;
+ const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ MeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->cellFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int icell = 0;
+ for (topology::Mesh::SieveMesh::label_sequence::iterator c_iter=cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter, ++icell) {
+ const double* values = &_data->cellFields[i][icell*fiberDim];
+ section->updatePoint(*c_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numCells, icell);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createCellFields
+
+
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMesh.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMesh.hh 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMesh.hh 2009-04-12 22:14:02 UTC (rev 14671)
@@ -21,8 +21,11 @@
#if !defined(pylith_meshio_testdatawritervtkmesh_hh)
#define pylith_meshio_testdatawritervtkmesh_hh
-#include "TestDataWriterVTK.hh"
+#include "TestDataWriterVTK.hh" // ISA TestDataWriterVTK
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field
+
+
/// Namespace for pylith package
namespace pylith {
namespace meshio {
@@ -34,12 +37,79 @@
class pylith::meshio::TestDataWriterVTKMesh : public TestDataWriterVTK
{ // class TestDataWriterVTKMesh
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKMesh );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testFilename );
+ CPPUNIT_TEST( testTimeFormat );
+ CPPUNIT_TEST( testTimeConstant );
+ CPPUNIT_TEST( testVtkFilename );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Test constructor
+ void testConstructor(void);
+
+ /// Test filename()
+ void testFilename(void);
+
+ /// Test timeFormat()
+ void testTimeFormat(void);
+
+ /// Test timeConstant()
+ void testTimeConstant(void);
+
+ /// Test openTimeStep() and closeTimeStep()
+ void testTimeStep(void);
+
+ /// Test writeVertexField.
+ void testWriteVertexField(void);
+
+ /// Test writeCellField.
+ void testWriteCellField(void);
+
+ /// Test vtkFilename.
+ void testVtkFilename(void);
+
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
/// Initialize mesh.
void _initialize(void);
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ topology::Mesh* _mesh; ///< Mesh for data
+ bool _flipFault; ///< If true, flip fault orientation.
+
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ /** Create vertex fields.
+ *
+ * @param fields Vertex fields.
+ */
+ void
+ _createVertexFields(topology::Fields<topology::Field<topology::Mesh> >* fields) const;
+
+ /** Create cell fields.
+ *
+ * @param fields Cell fields.
+ */
+ void
+ _createCellFields(topology::Fields<topology::Field<topology::Mesh> >* fields) const;
+
}; // class TestDataWriterVTKMesh
#endif // pylith_meshio_testdatawritervtkmesh_hh
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestOutputManager.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestOutputManager.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestOutputManager.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -15,11 +15,11 @@
#include "TestOutputManager.hh" // Implementation of class methods
#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
#include "pylith/meshio/OutputManager.hh"
#include "TestDataWriterVTK.hh" // USES TestDataWriterVTK::checkFile()
-#include "pylith/topology/Field.hh" // USES Field
#include "pylith/meshio/CellFilterAvg.hh" // USES CellFilterAvg
#include "pylith/meshio/VertexFilterVecNorm.hh" // USES VertexFilterVecNorm
#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
@@ -37,13 +37,14 @@
// ----------------------------------------------------------------------
typedef pylith::topology::Mesh::SieveMesh SieveMesh;
typedef pylith::topology::Mesh::RealSection RealSection;
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestOutputManager::testConstructor(void)
{ // testConstructor
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
} // testConstructor
// ----------------------------------------------------------------------
@@ -51,7 +52,7 @@
void
pylith::meshio::TestOutputManager::testCoordsys(void)
{ // testCoordsys
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
CPPUNIT_ASSERT(0 == manager._coordsys);
@@ -65,11 +66,11 @@
void
pylith::meshio::TestOutputManager::testWriter(void)
{ // testWriter
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
CPPUNIT_ASSERT(0 == manager._writer);
- DataWriterVTK<topology::Mesh> writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
manager.writer(&writer);
CPPUNIT_ASSERT(0 != manager._writer);
} // testWriter
@@ -79,12 +80,12 @@
void
pylith::meshio::TestOutputManager::testVertexFilter(void)
{ // testVertexFilter
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
CPPUNIT_ASSERT(0 == manager._vertexFilter);
CPPUNIT_ASSERT(0 == manager._cellFilter);
- VertexFilterVecNorm<topology::Mesh> filter;
+ VertexFilterVecNorm<MeshField> filter;
manager.vertexFilter(&filter);
CPPUNIT_ASSERT(0 != manager._vertexFilter);
CPPUNIT_ASSERT(0 == manager._cellFilter);
@@ -95,12 +96,12 @@
void
pylith::meshio::TestOutputManager::testCellFilter(void)
{ // testCellFilter
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
CPPUNIT_ASSERT(0 == manager._vertexFilter);
CPPUNIT_ASSERT(0 == manager._cellFilter);
- CellFilterAvg<topology::Mesh> filter;
+ CellFilterAvg<topology::Mesh, MeshField> filter;
manager.cellFilter(&filter);
CPPUNIT_ASSERT(0 != manager._cellFilter);
CPPUNIT_ASSERT(0 == manager._vertexFilter);
@@ -111,7 +112,7 @@
void
pylith::meshio::TestOutputManager::testOpenClose(void)
{ // testOpenClose
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
topology::Mesh mesh;
MeshIOAscii iohandler;
@@ -123,7 +124,7 @@
// TODO Replace DataVTKWriter with writer that has nontrivial
// open()/close().
- DataWriterVTK<topology::Mesh> writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
manager.writer(&writer);
manager.open(mesh, numTimeSteps);
@@ -135,7 +136,7 @@
void
pylith::meshio::TestOutputManager::testOpenCloseTimeStep(void)
{ // testOpenCloseTimeStep
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
topology::Mesh mesh;
MeshIOAscii iohandler;
@@ -148,7 +149,7 @@
const char* filenameRoot = "output.vtk";
const char* timeFormat = "%3.1f";
- DataWriterVTK<topology::Mesh> writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
writer.filename(filenameRoot);
writer.timeFormat(timeFormat);
manager.writer(&writer);
@@ -192,7 +193,7 @@
CPPUNIT_ASSERT(!vertices.isNull());
const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- topology::Field<topology::Mesh> field(mesh);
+ MeshField field(mesh);
field.newSection(vertices, fiberDim);
field.allocate();
field.label(label);
@@ -216,11 +217,11 @@
const char* filenameRootF = "output_vertex_filter.vtk";
const char* timeFormat = "%3.1f";
- DataWriterVTK<topology::Mesh> writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
writer.filename(filenameRoot);
writer.timeFormat(timeFormat);
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
manager.writer(&writer);
manager.open(mesh, numTimeSteps);
manager.openTimeStep(t, mesh);
@@ -230,7 +231,7 @@
TestDataWriterVTK::checkFile(filenameRoot, t, timeFormat);
- VertexFilterVecNorm<topology::Mesh> filter;
+ VertexFilterVecNorm<MeshField> filter;
manager.vertexFilter(&filter);
writer.filename(filenameRootF);
manager.writer(&writer);
@@ -274,7 +275,7 @@
CPPUNIT_ASSERT(!cells.isNull());
const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
- topology::Field<topology::Mesh> field(mesh);
+ MeshField field(mesh);
field.newSection(cells, fiberDim);
field.allocate();
field.label(label);
@@ -298,11 +299,11 @@
const char* filenameRootF = "output_cell_filter.vtk";
const char* timeFormat = "%3.1f";
- DataWriterVTK<topology::Mesh> writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
writer.filename(filenameRoot);
writer.timeFormat(timeFormat);
- OutputManager<topology::Mesh> manager;
+ OutputManager<topology::Mesh, MeshField> manager;
manager.writer(&writer);
manager.open(mesh, numTimeSteps);
manager.openTimeStep(t, mesh);
@@ -341,7 +342,7 @@
quadWts, numQuadPts,
spaceDim);
- CellFilterAvg<topology::Mesh> filter;
+ CellFilterAvg<topology::Mesh, MeshField> filter;
filter.quadrature(&quadrature);
manager.cellFilter(&filter);
writer.filename(filenameRootF);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestVertexFilterVecNorm.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestVertexFilterVecNorm.cc 2009-04-12 04:22:52 UTC (rev 14670)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestVertexFilterVecNorm.cc 2009-04-12 22:14:02 UTC (rev 14671)
@@ -24,11 +24,14 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestVertexFilterVecNorm );
// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestVertexFilterVecNorm::testConstructor(void)
{ // testConstructor
- VertexFilterVecNorm<topology::Mesh> filter;
+ VertexFilterVecNorm<MeshField> filter;
} // testConstructor
// ----------------------------------------------------------------------
@@ -67,7 +70,7 @@
iohandler.read(&mesh);
// Set vertex field
- topology::Field<topology::Mesh> field(mesh);
+ MeshField field(mesh);
field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
field.allocate();
field.vectorFieldType(fieldType);
@@ -91,8 +94,8 @@
section->updatePoint(*v_iter, values);
} // for
- VertexFilterVecNorm<topology::Mesh> filter;
- const topology::Field<topology::Mesh>& fieldF = filter.filter(field);
+ VertexFilterVecNorm<MeshField> filter;
+ const MeshField& fieldF = filter.filter(field);
const ALE::Obj<RealSection>& sectionF = fieldF.section();
CPPUNIT_ASSERT(!sectionF.isNull());
More information about the CIG-COMMITS
mailing list