Commit 891463d8 authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

Merge branch 'master' of /data/Repository/Xdmf2

parents 354c9ad4 8df57166
......@@ -267,9 +267,9 @@ struct DefaultCatchAll
// Apply the Acyclic Visitor
if (Visitor<T,R>* p = dynamic_cast<Visitor<T,R>*>(guest.get()))
{
return p->visit(visited, guest);
p->visit(visited, guest);
}
return R();
return;
}
};
......@@ -288,9 +288,9 @@ struct DefaultCatchAll
// Apply the Acyclic Visitor
if (Visitor<T,R,true>* p = dynamic_cast<Visitor<T,R,true>*>(guest.get()))
{
return p->visit(visited, guest);
p->visit(visited, guest);
}
return R();
return;
}
};
......@@ -303,18 +303,18 @@ struct DefaultCatchAll
#define LOKI_DEFINE_VISITABLE_BASE() \
virtual ReturnType accept(const shared_ptr<Loki::BaseVisitor> guest) \
{ return acceptImpl(*this, guest); }
{ acceptImpl(*this, guest); }
#define LOKI_DEFINE_VISITABLE(my_class, my_base) \
virtual ReturnType accept(const shared_ptr<Loki::BaseVisitor> guest) \
{ \
if (Loki::Visitor<my_class,ReturnType>* p = dynamic_cast<Loki::Visitor<my_class,ReturnType>*>(guest.get())) \
{ \
return p->visit(*this, guest); \
p->visit(*this, guest); \
} \
else \
{ \
return my_base::accept(guest); \
my_base::accept(guest); \
} \
}
......
......@@ -1031,6 +1031,13 @@ XdmfPartitioner::unpartition(const shared_ptr<XdmfGridCollection> gridToUnPartit
for(unsigned int k=0; k<set->getNumberAttributes(); ++k) {
const shared_ptr<XdmfAttribute> attribute = set->getAttribute(k);
bool releaseAttribute = false;
if(!attribute->isInitialized()) {
attribute->read();
releaseAttribute = true;
}
const shared_ptr<const XdmfAttributeCenter> attributeCenter =
attribute->getCenter();
const shared_ptr<const XdmfAttributeType> attributeType =
......@@ -1054,6 +1061,10 @@ XdmfPartitioner::unpartition(const shared_ptr<XdmfGridCollection> gridToUnPartit
attribute->getSize());
}
if(releaseAttribute) {
attribute->release();
}
}
}
......@@ -1078,9 +1089,11 @@ XdmfPartitioner::unpartition(const shared_ptr<XdmfGridCollection> gridToUnPartit
#include "XdmfDomain.hpp"
#include "XdmfGraph.hpp"
#include "XdmfGridCollection.hpp"
#include "XdmfGridCollectionType.hpp"
#include "XdmfHDF5Writer.hpp"
#include "XdmfPartitioner.hpp"
#include "XdmfReader.hpp"
#include "XdmfUnstructuredGrid.hpp"
#include "XdmfWriter.hpp"
namespace {
......@@ -1270,15 +1283,46 @@ XdmfPartitioner::unpartition(const shared_ptr<XdmfGridCollection> gridToUnPartit
heavyFileName << meshName << ".h5";
shared_ptr<XdmfHDF5Writer> heavyDataWriter =
XdmfHDF5Writer::New(heavyFileName.str());
heavyDataWriter->setReleaseData(true);
shared_ptr<XdmfDomain> newDomain = XdmfDomain::New();
shared_ptr<XdmfPartitioner> partitioner = XdmfPartitioner::New();
if(unpartition) {
shared_ptr<XdmfUnstructuredGrid> toWrite =
partitioner->unpartition(domain->getGridCollection(0));
newDomain->insert(toWrite);
shared_ptr<XdmfGridCollection> gridCollection =
domain->getGridCollection(0);
const shared_ptr<const XdmfGridCollectionType> collectionType =
gridCollection->getType();
if(collectionType == XdmfGridCollectionType::Spatial()) {
shared_ptr<XdmfUnstructuredGrid> toWrite =
partitioner->unpartition(gridCollection);
newDomain->insert(toWrite);
}
else if(collectionType == XdmfGridCollectionType::Temporal()) {
const unsigned int numberTimesteps =
gridCollection->getNumberGridCollections();
if(numberTimesteps == 0) {
std::cout << "No grid collections to unpartition" << std::endl;
return 1;
}
shared_ptr<XdmfGridCollection> newCollection =
XdmfGridCollection::New();
newCollection->setType(XdmfGridCollectionType::Temporal());
for(unsigned int i=0; i<numberTimesteps; ++i) {
const shared_ptr<XdmfGridCollection> spatialCollection =
gridCollection->getGridCollection(i);
const shared_ptr<XdmfTime> time = spatialCollection->getTime();
assert(spatialCollection->getType() ==
XdmfGridCollectionType::Spatial());
const shared_ptr<XdmfUnstructuredGrid> toWrite =
partitioner->unpartition(spatialCollection);
toWrite->accept(heavyDataWriter);
toWrite->setTime(time);
newCollection->insert(toWrite);
}
newDomain->insert(newCollection);
}
}
else {
if(domain->getNumberGraphs() == 0) {
......
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