Commit af488332 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Make XdmfSet behave like a real std::set. Modify some writing...

ENH: Make XdmfSet behave like a real std::set.  Modify some writing functionality to make this possible.
parent 6985f1b6
......@@ -26,6 +26,7 @@ set(XdmfSources
XdmfTime
XdmfTopology
XdmfTopologyType
XdmfWriter
)
add_library(Xdmf ${XdmfSources})
......
......@@ -5,6 +5,8 @@
* Author: kleiter
*/
#include "XdmfArray.hpp"
#include "XdmfHDF5Controller.hpp"
#include "XdmfSet.hpp"
#include "XdmfSetType.hpp"
......@@ -15,8 +17,9 @@ boost::shared_ptr<XdmfSet> XdmfSet::New()
}
XdmfSet::XdmfSet() :
mSetType(XdmfSetType::NoSetType()),
mName("")
mHDF5Controller(boost::shared_ptr<XdmfHDF5Controller>()),
mName(""),
mSetType(XdmfSetType::NoSetType())
{
}
......@@ -26,14 +29,14 @@ XdmfSet::~XdmfSet()
const std::string XdmfSet::ItemTag = "Set";
std::string XdmfSet::getName() const
boost::shared_ptr<XdmfHDF5Controller> XdmfSet::getHDF5Controller()
{
return mName;
return boost::const_pointer_cast<XdmfHDF5Controller>(static_cast<const XdmfSet &>(*this).getHDF5Controller());
}
boost::shared_ptr<const XdmfSetType> XdmfSet::getSetType() const
boost::shared_ptr<const XdmfHDF5Controller> XdmfSet::getHDF5Controller() const
{
return mSetType;
return mHDF5Controller;
}
std::map<std::string, std::string> XdmfSet::getItemProperties() const
......@@ -49,6 +52,21 @@ std::string XdmfSet::getItemTag() const
return ItemTag;
}
std::string XdmfSet::getName() const
{
return mName;
}
boost::shared_ptr<const XdmfSetType> XdmfSet::getSetType() const
{
return mSetType;
}
bool XdmfSet::isInitialized() const
{
return this->size() > 0;
}
void XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
{
std::map<std::string, std::string>::const_iterator name = itemProperties.find("Name");
......@@ -60,8 +78,47 @@ void XdmfSet::populateItem(const std::map<std::string, std::string> & itemProper
{
assert(false);
}
for(std::vector<boost::shared_ptr<XdmfItem> >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter)
{
if(boost::shared_ptr<XdmfArray> array = boost::shared_dynamic_cast<XdmfArray>(*iter))
{
if(array->isInitialized())
{
for(unsigned int i=0; i<array->getSize(); ++i)
{
this->insert(array->getValueCopy<unsigned int>(i));
}
}
else
{
mHDF5Controller = array->getHDF5Controller();
}
}
}
mSetType = XdmfSetType::New(itemProperties);
XdmfDataItem::populateItem(itemProperties, childItems);
}
void XdmfSet::read()
{
if(mHDF5Controller)
{
boost::shared_ptr<XdmfArray> setValues = XdmfArray::New();
mHDF5Controller->read(setValues.get());
for(unsigned int i=0; i<setValues->getSize(); ++i)
{
this->insert(setValues->getValueCopy<unsigned int>(i));
}
}
}
void XdmfSet::release()
{
std::set<unsigned int>::clear();
}
void XdmfSet::setHDF5Controller(const boost::shared_ptr<XdmfHDF5Controller> hdf5Controller)
{
mHDF5Controller = hdf5Controller;
}
void XdmfSet::setName(const std::string & name)
......@@ -73,3 +130,12 @@ void XdmfSet::setSetType(const boost::shared_ptr<const XdmfSetType> setType)
{
mSetType = setType;
}
std::size_t XdmfSet::size() const
{
if(std::set<unsigned int>::size() != 0)
{
return std::set<unsigned int>::size();
}
return mHDF5Controller->getSize();
}
......@@ -2,10 +2,12 @@
#define XDMFSET_HPP_
// Forward Declarations
class XdmfHDF5Controller;
class XdmfSetType;
// Includes
#include "XdmfDataItem.hpp"
#include <set>
#include "XdmfItem.hpp"
/**
* @brief Holds a collection of individual nodes, cells, faces, or edges that are part of an XdmfGrid.
......@@ -15,10 +17,13 @@ class XdmfSetType;
* set are determined by their id. An XdmfSet can have XdmfAttributes attached that contain extra values
* attached to the elements in the set.
*/
class XdmfSet : public XdmfDataItem {
class XdmfSet : public XdmfItem,
public std::set<unsigned int> {
public:
// TODO: isInitialized is broken the way it is coded. Always if size == 0 it is uninitialized...
/**
* Create a new XdmfSet.
*
......@@ -28,15 +33,22 @@ public:
virtual ~XdmfSet();
LOKI_DEFINE_VISITABLE(XdmfSet, XdmfDataItem)
LOKI_DEFINE_VISITABLE(XdmfSet, XdmfItem)
static const std::string ItemTag;
/**
* Get the XdmfSetType associated with this set.
* Get the hdf5 controller attached to this set.
*
* @return XdmfSetType of this set.
* @return the hdf5 controller attached to this set.
*/
boost::shared_ptr<const XdmfSetType> getSetType() const;
boost::shared_ptr<XdmfHDF5Controller> getHDF5Controller();
/**
* Get the hdf5 controller attached to this set (const version).
*
* @return the hdf5 controller attached to this set.
*/
boost::shared_ptr<const XdmfHDF5Controller> getHDF5Controller() const;
std::map<std::string, std::string> getItemProperties() const;
......@@ -49,6 +61,35 @@ public:
*/
std::string getName() const;
/**
* Get the XdmfSetType associated with this set.
*
* @return XdmfSetType of this set.
*/
boost::shared_ptr<const XdmfSetType> getSetType() const;
/**
* Returns whether the set is initialized (contains values in memory).
*/
bool isInitialized() const;
/**
* Read data from disk into memory.
*/
void read();
/**
* Release all data held in memory. The HDF5Controller remains attached.
*/
void release();
/**
* Attach an hdf5 controller to this set.
*
* @param hdf5Controller to attach to this set.
*/
void setHDF5Controller(const boost::shared_ptr<XdmfHDF5Controller> hdf5Controller);
/**
* Set the name of the set.
*
......@@ -63,6 +104,8 @@ public:
*/
void setSetType(const boost::shared_ptr<const XdmfSetType> setType);
std::size_t size() const;
protected:
XdmfSet();
......@@ -74,6 +117,7 @@ private:
void operator=(const XdmfSet & set); // Not implemented.
std::string mName;
boost::shared_ptr<XdmfHDF5Controller> mHDF5Controller;
boost::shared_ptr<const XdmfSetType> mSetType;
};
......
// Kenneth Leiter
// Xdmf Smart Pointer Test
#include "XdmfArray.hpp"
#include "XdmfSet.hpp"
#include "XdmfWriter.hpp"
#include <iostream>
boost::shared_ptr<XdmfWriter> XdmfWriter::New(const std::string & xmlFilePath)
{
boost::shared_ptr<XdmfWriter> p(new XdmfWriter(xmlFilePath));
return p;
}
boost::shared_ptr<XdmfWriter> XdmfWriter::New(const std::string & xmlFilePath, const boost::shared_ptr<XdmfHDF5Writer> hdf5Writer)
{
boost::shared_ptr<XdmfWriter> p(new XdmfWriter(xmlFilePath, hdf5Writer));
return p;
}
XdmfWriter::XdmfWriter(const std::string & xmlFilePath) :
XdmfCoreWriter(xmlFilePath)
{
}
XdmfWriter::XdmfWriter(const std::string & xmlFilePath, boost::shared_ptr<XdmfHDF5Writer> hdf5Writer) :
XdmfCoreWriter(xmlFilePath, hdf5Writer)
{
}
XdmfWriter::~XdmfWriter()
{
}
void XdmfWriter::visit(XdmfSet & set, const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
XdmfCoreWriter::visit(dynamic_cast<XdmfItem &>(set), visitor);
boost::shared_ptr<XdmfArray> setValues = XdmfArray::New();
if(set.isInitialized())
{
setValues->reserve(set.size());
for(XdmfSet::const_iterator iter = set.begin(); iter != set.end(); ++iter)
{
setValues->pushBack(*iter);
}
}
setValues->setHDF5Controller(set.getHDF5Controller());
XdmfCoreWriter::moveToLastWrittenNode();
XdmfCoreWriter::visit(*setValues.get(), visitor);
XdmfCoreWriter::moveToParentNode();
}
#ifndef XDMFWRITER_HPP_
#define XDMFWRITER_HPP_
// Forward Declarations
class XdmfSet;
// Includes
#include "XdmfCoreWriter.hpp"
/**
* @brief Traverse the Xdmf graph and write light and heavy data stored to disk.
*
* XdmfWriter visits each node of an Xdmf graph structure and writes data to disk. Writing begins by calling the
* accept() operation on any XdmfItem and supplying this writer as the parameter. The XdmfItem as well as all children
* attached to the XdmfItem are written to disk. Heavy data is written to HDF5 format using the XdmfHDF5Writer and light
* data is written to XML.
*
* By default, the XdmfWriter writes all heavy data to a single heavy data file specified by the XdmfHDF5Writer.
* If a dataset is encountered that resides in a different heavy data file on disk, the dataset is read from disk and written
* to the new hdf5 file. If this is undesired, the XdmfWriter can be set to DistributedHeavyData mode in which the writer
* will automatically reference any hdf5 dataset even if it resides in a different file than the one currently being written to.
* written.
*/
class XdmfWriter : public XdmfCoreWriter,
public Loki::Visitor<XdmfSet> {
public:
/**
* Create a new XdmfWriter to write Xdmf data to disk. This will create its own hdf5 writer based on the xmlFileName.
* For example, if supplied "output.xmf" the created hdf5 writer would write to file "output.h5".
*
* @param xmlFilePath the path to the xml file to write to.
* @return the new XdmfWriter.
*/
static boost::shared_ptr<XdmfWriter> New(const std::string & xmlFilePath);
/**
* Create a new XdmfWriter to write Xdmf data to disk. This will utilize the supplied hdf5Writer to write any
* heavy data to disk.
*
* @param xmlFilePath the path to the xml file to write to.
* @param hdf5Writer the heavy data writer to use when writing.
* @return the new XdmfWriter.
*/
static boost::shared_ptr<XdmfWriter> New(const std::string & xmlFilePath, const boost::shared_ptr<XdmfHDF5Writer> hdf5Writer);
virtual ~XdmfWriter();
/**
* Write an XdmfSet to disk
*
* @param set an XdmfSet to write to disk.
* @param visitor a smart pointer to this visitor --- aids in grid traversal.
*/
void visit(XdmfSet & set, const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
XdmfWriter(const std::string & xmlFilePath);
XdmfWriter(const std::string & xmlFilePath, boost::shared_ptr<XdmfHDF5Writer> hdf5Writer);
private:
XdmfWriter(const XdmfWriter & writer); // Not implemented.
void operator=(const XdmfWriter & writer); // Not implemented.
};
#endif /* XDMFWRITER_HPP_ */
......@@ -25,6 +25,7 @@ set(XdmfCoreSources
XdmfArrayType
XdmfCoreItemFactory
XdmfCoreReader
XdmfCoreWriter
XdmfDataItem
XdmfHDF5Controller
XdmfHDF5Writer
......@@ -33,7 +34,6 @@ set(XdmfCoreSources
XdmfItemProperty
XdmfSystemUtils
XdmfVisitor
XdmfWriter
)
add_library(XdmfCore ${XdmfCoreSources})
......
......@@ -381,7 +381,7 @@ unsigned int XdmfArray::getCapacity() const
boost::shared_ptr<XdmfHDF5Controller> XdmfArray::getHDF5Controller()
{
return mHDF5Controller;
return boost::const_pointer_cast<XdmfHDF5Controller>(static_cast<const XdmfArray &>(*this).getHDF5Controller());
}
boost::shared_ptr<const XdmfHDF5Controller> XdmfArray::getHDF5Controller() const
......@@ -535,7 +535,7 @@ void XdmfArray::initialize(const boost::shared_ptr<const XdmfArrayType> arrayTyp
}
}
bool XdmfArray::isInitialized()
bool XdmfArray::isInitialized() const
{
return mHaveArray || mHaveArrayPointer;
}
......
......@@ -87,7 +87,7 @@ public:
void copyValues(const unsigned int startIndex, const T * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1);
/**
* Remove all values from this array
* Remove all values from this array.
*/
void clear();
......@@ -208,7 +208,7 @@ public:
/**
* Returns whether the array is initialized (contains values in memory).
*/
bool isInitialized();
bool isInitialized() const;
/**
* Copy a value to the back of this array
......
......@@ -4,20 +4,20 @@
#include <libxml/tree.h>
#include <sstream>
#include "XdmfArray.hpp"
#include "XdmfCoreWriter.hpp"
#include "XdmfItem.hpp"
#include "XdmfHDF5Controller.hpp"
#include "XdmfHDF5Writer.hpp"
#include "XdmfSystemUtils.hpp"
#include "XdmfWriter.hpp"
/**
* PIMPL
*/
class XdmfWriter::XdmfWriterImpl {
class XdmfCoreWriter::XdmfCoreWriterImpl {
public:
XdmfWriterImpl(const std::string & xmlFilePath, const boost::shared_ptr<XdmfHDF5Writer> hdf5Writer) :
XdmfCoreWriterImpl(const std::string & xmlFilePath, const boost::shared_ptr<XdmfHDF5Writer> hdf5Writer) :
mHDF5Writer(hdf5Writer),
mLightDataLimit(100),
mMode(Default),
......@@ -29,7 +29,7 @@ public:
mXMLFilePath = XdmfSystemUtils::getRealPath(xmlFilePath);
};
~XdmfWriterImpl()
~XdmfCoreWriterImpl()
{
};
......@@ -61,13 +61,7 @@ public:
std::string mXPathString;
};
boost::shared_ptr<XdmfWriter> XdmfWriter::New(const std::string & xmlFilePath)
{
boost::shared_ptr<XdmfWriter> p(new XdmfWriter(xmlFilePath));
return p;
}
XdmfWriter::XdmfWriter(const std::string & xmlFilePath)
XdmfCoreWriter::XdmfCoreWriter(const std::string & xmlFilePath)
{
std::stringstream heavyFileName;
size_t extension = xmlFilePath.rfind(".");
......@@ -80,55 +74,64 @@ XdmfWriter::XdmfWriter(const std::string & xmlFilePath)
heavyFileName << xmlFilePath << ".h5";
}
boost::shared_ptr<XdmfHDF5Writer> hdf5Writer = XdmfHDF5Writer::New(heavyFileName.str());
mImpl = new XdmfWriterImpl(xmlFilePath, hdf5Writer);
mImpl = new XdmfCoreWriterImpl(xmlFilePath, hdf5Writer);
}
XdmfWriter::XdmfWriter(const std::string & xmlFilePath, boost::shared_ptr<XdmfHDF5Writer> hdf5Writer) :
mImpl(new XdmfWriterImpl(xmlFilePath, hdf5Writer))
XdmfCoreWriter::XdmfCoreWriter(const std::string & xmlFilePath, boost::shared_ptr<XdmfHDF5Writer> hdf5Writer) :
mImpl(new XdmfCoreWriterImpl(xmlFilePath, hdf5Writer))
{
}
XdmfWriter::~XdmfWriter()
XdmfCoreWriter::~XdmfCoreWriter()
{
delete mImpl;
}
boost::shared_ptr<XdmfHDF5Writer> XdmfWriter::getHDF5Writer()
boost::shared_ptr<XdmfHDF5Writer> XdmfCoreWriter::getHDF5Writer()
{
return boost::const_pointer_cast<XdmfHDF5Writer>(static_cast<const XdmfWriter &>(*this).getHDF5Writer());
return boost::const_pointer_cast<XdmfHDF5Writer>(static_cast<const XdmfCoreWriter &>(*this).getHDF5Writer());
}
boost::shared_ptr<const XdmfHDF5Writer> XdmfWriter::getHDF5Writer() const
boost::shared_ptr<const XdmfHDF5Writer> XdmfCoreWriter::getHDF5Writer() const
{
return mImpl->mHDF5Writer;
}
std::string XdmfWriter::getFilePath() const
std::string XdmfCoreWriter::getFilePath() const
{
return mImpl->mXMLFilePath;
}
unsigned int XdmfWriter::getLightDataLimit() const
unsigned int XdmfCoreWriter::getLightDataLimit() const
{
return mImpl->mLightDataLimit;
}
XdmfWriter::Mode XdmfWriter::getMode() const
XdmfCoreWriter::Mode XdmfCoreWriter::getMode() const
{
return mImpl->mMode;
}
void XdmfWriter::setLightDataLimit(const unsigned int numValues)
void XdmfCoreWriter::moveToLastWrittenNode()
{
mImpl->mXMLCurrentNode = mImpl->mXMLCurrentNode->last;
}
void XdmfCoreWriter::moveToParentNode()
{
mImpl->mXMLCurrentNode = mImpl->mXMLCurrentNode->parent;
}
void XdmfCoreWriter::setLightDataLimit(const unsigned int numValues)
{
mImpl->mLightDataLimit = numValues;
}
void XdmfWriter::setMode(const Mode mode)
void XdmfCoreWriter::setMode(const Mode mode)
{
mImpl->mMode = mode;
}
void XdmfWriter::visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfCoreWriter::visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
if(array.getSize() > 0)
{
......@@ -166,7 +169,7 @@ void XdmfWriter::visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisito
}
}
void XdmfWriter::visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfCoreWriter::visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
if(mImpl->mXPathString.compare("") == 0)
{
......@@ -175,7 +178,6 @@ void XdmfWriter::visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor>
mImpl->mXPathCount++;
xmlNodePtr parentNode = mImpl->mXMLCurrentNode;
std::string parentXPathString = mImpl->mXPathString;
std::stringstream newXPathString;
......@@ -207,7 +209,7 @@ void XdmfWriter::visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor>
mImpl->mXPathCount = parentCount;
}
mImpl->mXMLCurrentNode = parentNode;
mImpl->mXMLCurrentNode = mImpl->mXMLCurrentNode->parent;
mImpl->mXPathString = parentXPathString;
if(mImpl->mXPathString.compare("") == 0)
......
#ifndef XDMFWRITER_HPP_
#define XDMFWRITER_HPP_
#ifndef XDMFCOREWRITER_HPP_
#define XDMFCOREWRITER_HPP_
// Forward Declarations
class XdmfArray;
......@@ -22,7 +22,7 @@ class XdmfHDF5Writer;
* will automatically reference any hdf5 dataset even if it resides in a different file than the one currently being written to.
* written.
*/
class XdmfWriter : public XdmfVisitor,
class XdmfCoreWriter : public XdmfVisitor,
public Loki::Visitor<XdmfArray> {
public:
......@@ -31,30 +31,7 @@ public:
Default, DistributedHeavyData
};
/**
* Create a new XdmfWriter to write Xdmf data to disk. This will create its own hdf5 writer based on the xmlFileName.
* For example, if supplied "output.xmf" the created hdf5 writer would write to file "output.h5".
*
* @param xmlFilePath the path to the xml file to write to.
* @return the new XdmfWriter.
*/
static boost::shared_ptr<XdmfWriter> New(const std::string & xmlFilePath);
virtual ~XdmfWriter();
/**
* Create a new XdmfWriter to write Xdmf data to disk. This will utilize the supplied hdf5Writer to write any
* heavy data to disk.
*
* @param xmlFilePath the path to the xml file to write to.
* @param hdf5Writer the heavy data writer to use when writing.
* @return the new XdmfWriter.
*/
static boost::shared_ptr<XdmfWriter> New(const std::string & xmlFilePath, const boost::shared_ptr<XdmfHDF5Writer> hdf5Writer)
{
boost::shared_ptr<XdmfWriter> p(new XdmfWriter(xmlFilePath, hdf5Writer));
return p;
}
virtual ~XdmfCoreWriter();
/**
* Get the absolute path to the XML file on disk this writer is writing to.
......@@ -111,7 +88,7 @@ public:
* @param array an XdmfArray to write to disk.
* @param visitor a smart pointer to this visitor --- aids in grid traversal.
*/
void visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisitor> visitor);
virtual void visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisitor> visitor);
/**
* Write an XdmfItem to disk
......@@ -119,25 +96,28 @@ public:
* @param item an XdmfItem to write to disk.
* @param visitor a smart pointer to this visitor --- aids in grid traversal.
*/
void visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor);
virtual void visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
XdmfWriter(const std::string & xmlFilePath);
XdmfWriter(const std::string & xmlFilePath, boost::shared_ptr<XdmfHDF5Writer> hdf5Writer);
XdmfCoreWriter(const std::string & xmlFilePath);
XdmfCoreWriter(const std::string & xmlFilePath, boost::shared_ptr<XdmfHDF5Writer> hdf5Writer);
void moveToLastWrittenNode();
void moveToParentNode();
private:
/**
* PIMPL
*/
class XdmfWriterImpl;
class XdmfCoreWriterImpl;
XdmfWriter(const XdmfWriter & writer); // Not implemented.
void operator=(const XdmfWriter & writer); // Not implemented.
XdmfCoreWriter(const XdmfCoreWriter & coreWriter); // Not implemented.
void operator=(const XdmfCoreWriter & coreWriter); // Not implemented.
XdmfWriterImpl * mImpl;
XdmfCoreWriterImpl * mImpl;
};
#endif /* XDMFWRITER_HPP_ */
#endif /* XDMFCOREWRITER_HPP_ */
......@@ -7,6 +7,24 @@
#include "XdmfTestDataGenerator.hpp"
void compare(const std::string & firstFileName, const std::string & secondFileName)
{
// Compare two files for equality
std::ifstream firstFile(firstFileName.c_str());
std::ifstream secondFile(secondFileName.c_str());
std::stringstream firstBuffer;
std::stringstream secondBuffer;
firstBuffer << firstFile.rdbuf();
secondBuffer << secondFile.rdbuf();
std::string firstContents(firstBuffer.str());
std::string secondContents(secondBuffer.str());
assert(firstContents.compare(secondContents) == 0);
}
int main(int argc, char* argv[])
{
// Test != and == operators
......@@ -44,20 +62,20 @@ int main(int argc, char* argv[])
boost::shared_ptr<XdmfWriter> writer2 = XdmfWriter::New("TestXdmfGridCollection2.xmf");
gridCollection2->accept(writer2);
// Compare two files for equality
std::ifstream firstFile("TestXdmfGridCollection1.xmf");
std::ifstream secondFile("TestXdmfGridCollection2.xmf");
compare("TestXdmfGridCollection1.xmf", "TestXdmfGridCollection2.xmf");
std::stringstream firstBuffer;
std::stringstream secondBuffer;
boost::shared_ptr<XdmfWriter> writer3 = XdmfWriter::New("TestXdmfGridCollectionHDF1.xmf");
writer3->setLightDataLimit(0);
gridCollection->accept(writer3);
firstBuffer << firstFile.rdbuf();
secondBuffer << secondFile.rdbuf();
boost::shared_ptr<XdmfGridCollection> gridCollection3 = boost::shared_dynamic_cast<XdmfGridCollection>(reader->read("TestXdmfGridCollectionHDF1.xmf"));
std::string firstContents(firstBuffer.str());
std::string secondContents(secondBuffer.str());
boost::shared_ptr<XdmfWriter> writer4 = XdmfWriter::New("TestXdmfGridCollectionHDF2.xmf");
writer4->setLightDataLimit(0);
writer4->setMode(XdmfWriter::DistributedHeavyData);
gridCollection3->accept(writer4);
assert(firstContents.compare(secondContents) == 0);
compare("TestXdmfGridCollectionHDF1.xmf", "TestXdmfGridCollectionHDF2.xmf");
return 0;
}
......@@ -4,7 +4,8 @@
// Make a new XdmfVisitor that simply counts number of values
class XdmfVisitorValueCounter : public XdmfVisitor,
public Loki::Visitor<XdmfArray> {
public Loki::Visitor<XdmfArray>,
public Loki::Visitor<XdmfSet> {
public:
......@@ -33,6 +34,11 @@ public:
mCount += array.getSize();
}
void visit(XdmfSet & set, boost::shared_ptr<Loki::BaseVisitor> visitor)
{
mCount += set.size();
}
protected:
XdmfVisitorValueCounter() :
......
......@@ -63,7 +63,7 @@ public:
int nodeIds[] = {0, 1, 2};
nodeSet->setName("Node Set");
nodeSet->setSetType(XdmfSetType::Node());
nodeSet->getArray()->copyValues(0, &nodeIds[0], 3);
nodeSet->insert(nodeIds, nodeIds + 3);
// Add time
boost::shared_ptr<XdmfTime> time = XdmfTime::New(100);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment