Commit 49cd1fb0 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Add XdmfMap which maps nodes across partition boundaries.

parent cb1fe3d8
......@@ -20,6 +20,7 @@ set(XdmfSources
XdmfGridCollection
XdmfGridCollectionType
XdmfItemFactory
XdmfMap
XdmfReader
XdmfSet
XdmfSetType
......
......@@ -30,6 +30,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfGridCollection.hpp>
#include <XdmfGridCollectionType.hpp>
#include <XdmfItemFactory.hpp>
#include <XdmfMap.hpp>
#include <XdmfReader.hpp>
#include <XdmfSet.hpp>
#include <XdmfSetType.hpp>
......@@ -69,6 +70,10 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
{
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfInformation>(information)), SWIGTYPE_p_boost__shared_ptrT_XdmfInformation_t, SWIG_POINTER_OWN);
}
else if(boost::shared_ptr<XdmfMap> map = boost::shared_dynamic_cast<XdmfMap>($1))
{
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfMap>(map)), SWIGTYPE_p_boost__shared_ptrT_XdmfMap_t, SWIG_POINTER_OWN);
}
else if(boost::shared_ptr<XdmfSet> set = boost::shared_dynamic_cast<XdmfSet>($1))
{
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfSet>(set)), SWIGTYPE_p_boost__shared_ptrT_XdmfSet_t, SWIG_POINTER_OWN);
......@@ -104,6 +109,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%shared_ptr(XdmfGridCollection)
%shared_ptr(XdmfGridCollectionType)
%shared_ptr(XdmfItemFactory)
%shared_ptr(XdmfMap)
%shared_ptr(XdmfReader)
%shared_ptr(XdmfSet)
%shared_ptr(XdmfSetType)
......@@ -121,6 +127,7 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%include XdmfGridCollection.hpp
%include XdmfGridCollectionType.hpp
%include XdmfItemFactory.hpp
%include XdmfMap.hpp
%include XdmfReader.hpp
%include XdmfSet.hpp
%include XdmfSetType.hpp
......
......@@ -117,7 +117,7 @@ void XdmfDomain::removeGridCollection(const unsigned int index)
mGridCollections.erase(mGridCollections.begin() + index);
}
void XdmfDomain::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
void XdmfDomain::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter)
{
......
......@@ -107,7 +107,7 @@ public:
*/
void removeGridCollection(const unsigned int index);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......
......@@ -8,6 +8,7 @@
#include "XdmfAttribute.hpp"
#include "XdmfGrid.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfMap.hpp"
#include "XdmfSet.hpp"
#include "XdmfTime.hpp"
#include "XdmfTopology.hpp"
......@@ -20,9 +21,10 @@ boost::shared_ptr<XdmfGrid> XdmfGrid::New()
XdmfGrid::XdmfGrid() :
mGeometry(XdmfGeometry::New()),
mMap(boost::shared_ptr<XdmfMap>()),
mName("Grid"),
mTime(boost::shared_ptr<XdmfTime>()),
mTopology(XdmfTopology::New()),
mName("Grid")
mTopology(XdmfTopology::New())
{
}
......@@ -85,6 +87,16 @@ std::string XdmfGrid::getItemTag() const
return ItemTag;
}
boost::shared_ptr<XdmfMap> XdmfGrid::getMap()
{
return boost::const_pointer_cast<XdmfMap>(static_cast<const XdmfGrid &>(*this).getMap());
}
boost::shared_ptr<const XdmfMap> XdmfGrid::getMap() const
{
return mMap;
}
std::string XdmfGrid::getName() const
{
return mName;
......@@ -182,6 +194,10 @@ void XdmfGrid::populateItem(const std::map<std::string, std::string> & itemPrope
{
mGeometry = geometry;
}
else if(boost::shared_ptr<XdmfMap> map = boost::shared_dynamic_cast<XdmfMap>(*iter))
{
mMap = map;
}
else if(boost::shared_ptr<XdmfSet> set = boost::shared_dynamic_cast<XdmfSet>(*iter))
{
this->insert(set);
......@@ -244,6 +260,11 @@ void XdmfGrid::setGeometry(const boost::shared_ptr<XdmfGeometry> geometry)
mGeometry = geometry;
}
void XdmfGrid::setMap(boost::shared_ptr<XdmfMap> map)
{
mMap = map;
}
void XdmfGrid::setName(const std::string & name)
{
mName = name;
......@@ -259,14 +280,24 @@ void XdmfGrid::setTopology(const boost::shared_ptr<XdmfTopology> topology)
mTopology = topology;
}
void XdmfGrid::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
void XdmfGrid::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
if(mTime != NULL)
{
mTime->accept(visitor);
}
mGeometry->accept(visitor);
mTopology->accept(visitor);
if(mGeometry != NULL)
{
mGeometry->accept(visitor);
}
if(mTopology != NULL)
{
mTopology->accept(visitor);
}
if(mMap != NULL)
{
mMap->accept(visitor);
}
for(std::vector<boost::shared_ptr<XdmfAttribute> >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter)
{
(*iter)->accept(visitor);
......
......@@ -4,6 +4,7 @@
// Forward Declarations
class XdmfAttribute;
class XdmfGeometry;
class XdmfMap;
class XdmfSet;
class XdmfTime;
class XdmfTopology;
......@@ -85,6 +86,20 @@ public:
virtual std::string getItemTag() const;
/**
* Get the boundary communicator map associated with this grid.
*
* @return the boundary communicator map associated with this grid.
*/
boost::shared_ptr<XdmfMap > getMap();
/**
* Get the boundary communicator map associated with this grid (const version).
*
* @return the boundary communicator map associated with this grid.
*/
boost::shared_ptr<const XdmfMap> getMap() const;
/**
* Get the name of the grid.
*
......@@ -215,6 +230,20 @@ public:
*/
void setGeometry(const boost::shared_ptr<XdmfGeometry> geometry);
/**
* Set the boundary communicator map associated with this grid.
*
* @param map a XdmfMap to associate with this grid.
*/
void setMap(boost::shared_ptr<XdmfMap> map);
/**
* Set the name of the grid.
*
* @param name of the grid to set.
*/
void setName(const std::string & name);
/**
* Set the time associated with this grid.
*
......@@ -229,14 +258,7 @@ public:
*/
void setTopology(const boost::shared_ptr<XdmfTopology> topology);
/**
* Set the name of the grid.
*
* @param name of the grid to set.
*/
void setName(const std::string & name);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......@@ -252,6 +274,7 @@ private:
std::vector<boost::shared_ptr<XdmfAttribute> > mAttributes;
boost::shared_ptr<XdmfGeometry> mGeometry;
boost::shared_ptr<XdmfMap> mMap;
std::vector<boost::shared_ptr<XdmfSet> > mSets;
boost::shared_ptr<XdmfTime> mTime;
boost::shared_ptr<XdmfTopology> mTopology;
......
......@@ -57,7 +57,7 @@ void XdmfGridCollection::setType(const boost::shared_ptr<const XdmfGridCollectio
mCollectionType = collectionType;
}
void XdmfGridCollection::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
void XdmfGridCollection::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
XdmfGrid::traverse(visitor);
XdmfDomain::traverse(visitor);
......
......@@ -54,7 +54,7 @@ public:
*/
void setType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType);
void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......
......@@ -5,6 +5,7 @@
#include "XdmfGridCollection.hpp"
#include "XdmfInformation.hpp"
#include "XdmfItemFactory.hpp"
#include "XdmfMap.hpp"
#include "XdmfSet.hpp"
#include "XdmfTime.hpp"
#include "XdmfTopology.hpp"
......@@ -60,6 +61,10 @@ boost::shared_ptr<XdmfItem> XdmfItemFactory::createItem(const std::string & item
{
newItem = XdmfInformation::New();
}
else if(itemTag.compare(XdmfMap::ItemTag) == 0)
{
newItem = XdmfMap::New();
}
else if(itemTag.compare(XdmfSet::ItemTag) == 0)
{
newItem = XdmfSet::New();
......
#include "XdmfAttribute.hpp"
#include "XdmfGridCollection.hpp"
#include "XdmfGridCollectionType.hpp"
#include "XdmfHDF5Controller.hpp"
#include "XdmfMap.hpp"
/**
* PIMPL
*/
class XdmfMap::XdmfMapImpl {
public:
XdmfMapImpl() :
mLocalNodeIdsHDF5Controller(boost::shared_ptr<XdmfHDF5Controller>()),
mRemoteLocalNodeIdsHDF5Controller(boost::shared_ptr<XdmfHDF5Controller>()),
mRemoteTaskIdsHDF5Controller(boost::shared_ptr<XdmfHDF5Controller>())
{
};
~XdmfMapImpl()
{
};
boost::shared_ptr<XdmfHDF5Controller> mLocalNodeIdsHDF5Controller;
std::map<unsigned int, std::map<unsigned int, unsigned int> > mMap; // localNodeId | remoteTaskId | remoteLocalNodeId
boost::shared_ptr<XdmfHDF5Controller> mRemoteLocalNodeIdsHDF5Controller;
boost::shared_ptr<XdmfHDF5Controller> mRemoteTaskIdsHDF5Controller;
};
boost::shared_ptr<XdmfMap> XdmfMap::New()
{
boost::shared_ptr<XdmfMap> p(new XdmfMap());
return p;
}
std::vector<boost::shared_ptr<XdmfMap> > XdmfMap::New(const std::vector<boost::shared_ptr<XdmfAttribute> > & globalNodeIds)
{
unsigned int maxGlobalNodeId = 0;
for(unsigned int i=0; i<globalNodeIds.size(); ++i)
{
const boost::shared_ptr<XdmfAttribute> currGlobalNodeIds = globalNodeIds[i];
for(unsigned int j=0; j<currGlobalNodeIds->size(); ++j)
{
unsigned int currGlobalNodeId = currGlobalNodeIds->getValueCopy<unsigned int>(j);
if(currGlobalNodeId > maxGlobalNodeId)
{
maxGlobalNodeId = currGlobalNodeId;
}
}
}
// globalNodeId | taskId | localNodeId at taskId
std::vector<std::map<unsigned int, unsigned int> > globalNodeIdMap(maxGlobalNodeId + 1, std::map<unsigned int, unsigned int>());
// Fill globalNodeIdMap
for(unsigned int i=0; i<globalNodeIds.size(); ++i)
{
const boost::shared_ptr<XdmfAttribute> currGlobalNodeIds = globalNodeIds[i];
for(unsigned int j=0; j<currGlobalNodeIds->size(); ++j)
{
unsigned int currGlobalNodeId = currGlobalNodeIds->getValueCopy<unsigned int>(j);
globalNodeIdMap[currGlobalNodeId][i] = j;
}
}
std::vector<boost::shared_ptr<XdmfMap> > toReturn;
toReturn.reserve(globalNodeIds.size());
// Fill maps for each partition
for(unsigned int i=0; i<globalNodeIds.size(); ++i)
{
boost::shared_ptr<XdmfMap> map = XdmfMap::New();
toReturn.push_back(map);
const boost::shared_ptr<XdmfAttribute> currGlobalNodeIds = globalNodeIds[i];
for(unsigned int j=0; j<currGlobalNodeIds->size(); ++j)
{
unsigned int currGlobalNodeId = currGlobalNodeIds->getValueCopy<unsigned int>(j);
if(globalNodeIdMap[currGlobalNodeId].size() > 1)
{
for(std::map<unsigned int, unsigned int>::const_iterator iter = globalNodeIdMap[currGlobalNodeId].begin(); iter != globalNodeIdMap[currGlobalNodeId].end(); ++iter)
{
if(iter->first != i)
{
map->insert(j, iter->first, iter->second);
}
}
}
}
}
return toReturn;
}
XdmfMap::XdmfMap() :
mImpl(new XdmfMapImpl())
{
}
XdmfMap::~XdmfMap()
{
delete mImpl;
}
const std::string XdmfMap::ItemTag = "Map";
std::map<std::string, std::string> XdmfMap::getItemProperties() const
{
std::map<std::string, std::string> mapProperties;
return mapProperties;
}
std::string XdmfMap::getItemTag() const
{
return ItemTag;
}
std::map<unsigned int, unsigned int> XdmfMap::getRemoteNodeIds(const unsigned int localNodeId)
{
std::map<unsigned int, std::map<unsigned int, unsigned int> >::const_iterator iter = mImpl->mMap.find(localNodeId);
if(iter != mImpl->mMap.end())
{
return iter->second;
}
// No entry, return empty map.
return std::map<unsigned int, unsigned int>();
}
void XdmfMap::insert(const unsigned int localNodeId, const unsigned int remoteTaskId, const unsigned int remoteLocalNodeId)
{
std::map<unsigned int, std::map<unsigned int, unsigned int> >::iterator iter = mImpl->mMap.find(localNodeId);
if(iter != mImpl->mMap.end())
{
iter->second[remoteTaskId] = remoteLocalNodeId;
}
else
{
std::map<unsigned int, unsigned int> newMap;
newMap[remoteTaskId] = remoteLocalNodeId;
mImpl->mMap[localNodeId] = newMap;
}
}
void XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
{
std::vector<boost::shared_ptr<XdmfArray> > arrayVector;
arrayVector.reserve(3);
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))
{
arrayVector.push_back(array);
}
}
assert(arrayVector.size() == 3);
assert(arrayVector[0]->size() == arrayVector[1]->size() && arrayVector[0]->size() == arrayVector[2]->size());
bool needToRead = false;
for(std::vector<boost::shared_ptr<XdmfArray> >::const_iterator iter = arrayVector.begin(); iter != arrayVector.end(); ++iter)
{
if((*iter)->isInitialized())
{
needToRead = true;
break;
}
}
if(needToRead)
{
for(std::vector<boost::shared_ptr<XdmfArray> >::const_iterator iter = arrayVector.begin(); iter != arrayVector.end(); ++iter)
{
(*iter)->read();
}
for(unsigned int i=0; i<arrayVector[0]->size(); ++i)
{
this->insert(arrayVector[0]->getValueCopy<unsigned int>(i), arrayVector[1]->getValueCopy<unsigned int>(i), arrayVector[2]->getValueCopy<unsigned int>(i));
}
}
else
{
mImpl->mLocalNodeIdsHDF5Controller = arrayVector[0]->getHDF5Controller();
mImpl->mRemoteTaskIdsHDF5Controller = arrayVector[1]->getHDF5Controller();
mImpl->mRemoteLocalNodeIdsHDF5Controller = arrayVector[2]->getHDF5Controller();
}
}
void XdmfMap::read()
{
if(mImpl->mLocalNodeIdsHDF5Controller != NULL && mImpl->mRemoteTaskIdsHDF5Controller != NULL && mImpl->mRemoteLocalNodeIdsHDF5Controller != NULL)
{
assert(mImpl->mLocalNodeIdsHDF5Controller->size() == mImpl->mRemoteTaskIdsHDF5Controller->size() && mImpl->mLocalNodeIdsHDF5Controller->size() == mImpl->mRemoteLocalNodeIdsHDF5Controller->size());
boost::shared_ptr<XdmfArray> globalNodeIds = XdmfArray::New();
boost::shared_ptr<XdmfArray> taskIds = XdmfArray::New();
boost::shared_ptr<XdmfArray> localNodeIds = XdmfArray::New();
mImpl->mLocalNodeIdsHDF5Controller->read(globalNodeIds.get());
mImpl->mRemoteTaskIdsHDF5Controller->read(taskIds.get());
mImpl->mRemoteLocalNodeIdsHDF5Controller->read(localNodeIds.get());
for(unsigned int i=0; i<globalNodeIds->size(); ++i)
{
std::map<unsigned int, std::map<unsigned int, unsigned int> >::iterator iter = mImpl->mMap.find(globalNodeIds->getValueCopy<unsigned int>(i));
if(iter != mImpl->mMap.end())
{
iter->second[taskIds->getValueCopy<unsigned int>(i)] = localNodeIds->getValueCopy<unsigned int>(i);
}
else
{
std::map<unsigned int, unsigned int> newMap;
newMap[taskIds->getValueCopy<unsigned int>(i)] = localNodeIds->getValueCopy<unsigned int>(i);
mImpl->mMap[globalNodeIds->getValueCopy<unsigned int>(i)] = newMap;
}
}
}
}
void XdmfMap::release()
{
}
void XdmfMap::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
boost::shared_ptr<XdmfArray> localNodeIds = XdmfArray::New();
boost::shared_ptr<XdmfArray> remoteTaskIds = XdmfArray::New();
boost::shared_ptr<XdmfArray> remoteLocalNodeIds = XdmfArray::New();
for(std::map<unsigned int, std::map<unsigned int, unsigned int> >::const_iterator iter = mImpl->mMap.begin(); iter != mImpl->mMap.end(); ++iter)
{
for(std::map<unsigned int, unsigned int>::const_iterator iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2)
{
localNodeIds->pushBack(iter->first);
remoteTaskIds->pushBack(iter2->first);
remoteLocalNodeIds->pushBack(iter2->second);
}
}
localNodeIds->setHDF5Controller(mImpl->mLocalNodeIdsHDF5Controller);
remoteTaskIds->setHDF5Controller(mImpl->mRemoteTaskIdsHDF5Controller);
remoteLocalNodeIds->setHDF5Controller(mImpl->mRemoteLocalNodeIdsHDF5Controller);
localNodeIds->accept(visitor);
remoteTaskIds->accept(visitor);
remoteLocalNodeIds->accept(visitor);
mImpl->mLocalNodeIdsHDF5Controller = localNodeIds->getHDF5Controller();
mImpl->mRemoteTaskIdsHDF5Controller = remoteTaskIds->getHDF5Controller();
mImpl->mRemoteLocalNodeIdsHDF5Controller = remoteLocalNodeIds->getHDF5Controller();
}
#ifndef XDMFMAP_HPP_
#define XDMFMAP_HPP_
// Forward Declarations
class XdmfAttribute;
class XdmfGridCollection;
// Includes
#include "XdmfItem.hpp"
/**
* @brief Boundary communicator map for partitioned spatial collections.
*
*/
class XdmfMap : public XdmfItem {
public:
/**
* Create a new XdmfMap.
*
* @return constructed XdmfMap.
*/
static boost::shared_ptr<XdmfMap> New();
static std::vector<boost::shared_ptr<XdmfMap> > New(const std::vector<boost::shared_ptr<XdmfAttribute> > & globalNodeIds);
virtual ~XdmfMap();
LOKI_DEFINE_VISITABLE(XdmfMap, XdmfItem)
static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const;
std::map<unsigned int, unsigned int> getRemoteNodeIds(const unsigned int localNodeId);
std::string getItemTag() const;
void insert(const unsigned int localNodeId, const unsigned int remoteTaskId, const unsigned int remoteLocalNodeId);
/**
* Read data from disk into memory.
*/
void read();
/**
* Release all data held in memory. The HDF5Controllers remains attached.
*/
void release();
void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
XdmfMap();
virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems);
private:
/**
* PIMPL
*/
class XdmfMapImpl;
XdmfMap(const XdmfMap & map); // Not implemented.
void operator=(const XdmfMap & map); // Not implemented.
XdmfMapImpl * mImpl;
};
#endif /* XDMFMAP_HPP_ */
......@@ -134,12 +134,12 @@ std::size_t XdmfSet::size() const
}
else if(mHDF5Controller)
{
return mHDF5Controller->getSize();
return mHDF5Controller->size();
}
return 0;
}
void XdmfSet::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
void XdmfSet::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
boost::shared_ptr<XdmfArray> setValues = XdmfArray::New();
setValues->reserve(std::set<unsigned int>::size());
......@@ -149,4 +149,5 @@ void XdmfSet::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
}
setValues->setHDF5Controller(mHDF5Controller);
setValues->accept(visitor);
mHDF5Controller = setValues->getHDF5Controller();
}
......@@ -99,7 +99,7 @@ public:
std::size_t size() const;
void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor);
XdmfSet();
......
......@@ -687,7 +687,7 @@ std::size_t XdmfArray::size() const
}
else if(mHDF5Controller)
{
return mHDF5Controller->getSize();
return mHDF5Controller->size();
}
return 0;
}
......
......@@ -36,11 +36,6 @@ std::string XdmfHDF5Controller::getFilePath() const
return mFilePath;
}
unsigned int XdmfHDF5Controller::getSize() const
{
return mSize;
}
boost::shared_ptr<const XdmfArrayType> XdmfHDF5Controller::getType() const
{
return mType;
......@@ -64,3 +59,8 @@ void XdmfHDF5Controller::read(XdmfArray * const array)
status = H5Dclose(dataset);
status = H5Fclose(hdf5Handle);
}
unsigned int XdmfHDF5Controller::size() const
{
return mSize;
}
......@@ -40,13 +40,6 @@ public:
*/
std::string getFilePath() const;
/**
* Get the size of the hdf5 data set owned by this controller.
*
* @return a int containing the size of the hdf5 data set.
*/
unsigned int getSize() const;
/**
* Get the array type of the hdf5 data set owned by this controller.
*
......@@ -61,6 +54,13 @@ public:
*/
void read(XdmfArray * const array);
/**
* Get the size of the hdf5 data set owned by this controller.
*
* @return a int containing the size of the hdf5 data set.
*/
unsigned int size() const;
protected:
XdmfHDF5Controller(const std::string & hdf5FilePath, const std::string & dataSetPath, const unsigned int size, const boost::shared_ptr<const XdmfArrayType> type);
......
......@@ -8,7 +8,7 @@ XdmfItem::~XdmfItem()
{
}
void XdmfItem::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
void XdmfItem::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
return;
}
......@@ -43,7 +43,7 @@ public:
*
* @param a visitor to pass to this XdmfItem's children.
*/
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......
......@@ -161,13 +161,15 @@ void XdmfWriter::visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisito
{
std::stringstream xmlTextValues;
if(array.getHDF5Controller() && array.getHDF5Controller()->getFilePath().compare(mImpl->mHDF5Writer->getFilePath()) != 0 && mImpl->mMode == Default)
// Take care of writing to single HDF5 file (Default behavior)
if(!array.isInitialized() && array.getHDF5Controller() && array.getHDF5Controller()->getFilePath().compare(mImpl->mHDF5Writer->getFilePath()) != 0 && mImpl->mMode == Default)
{
array.read();
}
if(array.getHDF5Controller() || array.size() > mImpl->mLightDataLimit)
{
// Write values to HDF5
mImpl->mHDF5Writer->visit(array, mImpl->mHDF5Writer);
std::string hdf5Path = array.getHDF5Controller()->getFilePath();
......@@ -185,9 +187,11 @@ void XdmfWriter::visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisito
}
else
{
// Write values to XML
xmlTextValues << array.getValuesString();
}
// Write XML (metadata) description
if(isSubclassed)
{
boost::shared_ptr<XdmfArray> arrayToWrite = XdmfArray::New();
......
......@@ -8,7 +8,7 @@ int main(int argc, char* argv[])
boost::shared_ptr<XdmfHDF5Controller> controller = XdmfHDF5Controller::New("output.h5", "/foo/data1", 10, XdmfArrayType::Int8());
assert(controller->getDataSetPath().compare("/foo/data1") == 0);
assert(controller->getFilePath().compare(XdmfSystemUtils::getRealPath("output.h5")) == 0);
assert(controller->getSize() == 10);
assert(controller->size() == 10);
assert(controller->getType() == XdmfArrayType::Int8());
return 0;
}
......@@ -3,6 +3,7 @@ set(XdmfCxxTests
TestXdmfGeometry
TestXdmfGrid
TestXdmfGridCollection
TestXdmfMap
TestXdmfReader
TestXdmfSet
TestXdmfTime
......