Commit 8186bbfe authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Modify how XdmfMaps are attached to XdmfGrids by allowing

more than one map to be attached.

Add additional attribute to XdmfMap, which is the name of the map.
parent 01d89e59
......@@ -30,6 +30,7 @@
#include "XdmfTopology.hpp"
XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfAttribute, Attribute, Name)
XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfMap, Map, Name)
XDMF_CHILDREN_IMPLEMENTATION(XdmfGrid, XdmfSet, Set, Name)
XdmfGrid::XdmfGrid(const shared_ptr<XdmfGeometry> geometry,
......@@ -37,7 +38,6 @@ XdmfGrid::XdmfGrid(const shared_ptr<XdmfGeometry> geometry,
const std::string & name) :
mGeometry(geometry),
mTopology(topology),
mMap(shared_ptr<XdmfMap>()),
mName(name),
mTime(shared_ptr<XdmfTime>())
{
......@@ -69,19 +69,6 @@ XdmfGrid::getItemTag() const
return ItemTag;
}
shared_ptr<XdmfMap>
XdmfGrid::getMap()
{
return boost::const_pointer_cast<XdmfMap>
(static_cast<const XdmfGrid &>(*this).getMap());
}
shared_ptr<const XdmfMap>
XdmfGrid::getMap() const
{
return mMap;
}
std::string
XdmfGrid::getName() const
{
......@@ -135,7 +122,7 @@ XdmfGrid::populateItem(const std::map<std::string, std::string> & itemProperties
}
else if(shared_ptr<XdmfMap> map =
shared_dynamic_cast<XdmfMap>(*iter)) {
mMap = map;
this->insert(map);
}
else if(shared_ptr<XdmfSet> set =
shared_dynamic_cast<XdmfSet>(*iter)) {
......@@ -152,12 +139,6 @@ XdmfGrid::populateItem(const std::map<std::string, std::string> & itemProperties
}
}
void
XdmfGrid::setMap(shared_ptr<XdmfMap> map)
{
mMap = map;
}
void
XdmfGrid::setName(const std::string & name)
{
......@@ -183,15 +164,18 @@ XdmfGrid::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
if(mTopology) {
mTopology->accept(visitor);
}
if(mMap) {
mMap->accept(visitor);
}
for(std::vector<shared_ptr<XdmfAttribute> >::const_iterator iter =
mAttributes.begin();
iter != mAttributes.end();
++iter) {
(*iter)->accept(visitor);
}
for(std::vector<shared_ptr<XdmfMap> >::const_iterator iter =
mMaps.begin();
iter != mMaps.end();
++iter) {
(*iter)->accept(visitor);
}
for(std::vector<shared_ptr<XdmfSet> >::const_iterator iter = mSets.begin();
iter != mSets.end();
++iter) {
......
......@@ -60,6 +60,7 @@ public:
LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem);
XDMF_CHILDREN(XdmfAttribute, Attribute, Name);
XDMF_CHILDREN(XdmfSet, Set, Name);
XDMF_CHILDREN(XdmfMap, Map, Name);
static const std::string ItemTag;
/**
......@@ -73,21 +74,6 @@ public:
virtual std::string getItemTag() const;
/**
* Get the boundary communicator map associated with this grid.
*
* @return the boundary communicator map associated with this grid.
*/
shared_ptr<XdmfMap> getMap();
/**
* Get the boundary communicator map associated with this grid
* (const version).
*
* @return the boundary communicator map associated with this grid.
*/
shared_ptr<const XdmfMap> getMap() const;
/**
* Get the name of the grid.
*
......@@ -120,13 +106,6 @@ public:
using XdmfItem::insert;
/**
* Set the boundary communicator map associated with this grid.
*
* @param map a XdmfMap to associate with this grid.
*/
void setMap(shared_ptr<XdmfMap> map);
/**
* Set the name of the grid.
*
......@@ -162,7 +141,6 @@ private:
XdmfGrid(const XdmfGrid &); // Not implemented.
void operator=(const XdmfGrid &); // Not implemented.
shared_ptr<XdmfMap> mMap;
std::string mName;
shared_ptr<XdmfTime> mTime;
......
......@@ -78,7 +78,8 @@ XdmfMap::New(const std::vector<shared_ptr<XdmfAttribute> > & globalNodeIds)
return returnValue;
}
XdmfMap::XdmfMap()
XdmfMap::XdmfMap() :
mName("")
{
}
......@@ -92,6 +93,7 @@ std::map<std::string, std::string>
XdmfMap::getItemProperties() const
{
std::map<std::string, std::string> mapProperties;
mapProperties["Name"] = mName;
return mapProperties;
}
......@@ -107,6 +109,12 @@ XdmfMap::getMap() const
return mMap;
}
std::string
XdmfMap::getName() const
{
return mName;
}
XdmfMap::node_id_map
XdmfMap::getRemoteNodeIds(const task_id remoteTaskId)
{
......@@ -138,7 +146,14 @@ XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties,
const XdmfCoreReader * const reader)
{
XdmfItem::populateItem(itemProperties, childItems, reader);
std::map<std::string, std::string>::const_iterator name =
itemProperties.find("Name");
if(name != itemProperties.end()) {
mName = name->second;
}
else {
mName = "";
}
std::vector<shared_ptr<XdmfArray> > arrayVector;
arrayVector.reserve(3);
for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
......@@ -257,6 +272,12 @@ XdmfMap::setMap(std::map<task_id, node_id_map> map)
mMap = map;
}
void
XdmfMap::setName(const std::string & name)
{
mName = name;
}
void
XdmfMap::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
{
......
......@@ -97,6 +97,13 @@ public:
*/
std::map<task_id, node_id_map> getMap() const;
/**
* Get name of boundary communicator map.
*
* @return name of boundary communicator map.
*/
std::string getName() const;
/**
* Given a remote task id return a map of local node ids to remote
* node ids
......@@ -164,6 +171,13 @@ public:
*/
void setMap(std::map<task_id, node_id_map> map);
/**
* Set the name of the boundary communicator map.
*
* @param name the name of the boundary communicator map to set.
*/
void setName(const std::string & name);
void traverse(const shared_ptr<XdmfBaseVisitor> visitor);
protected:
......@@ -183,6 +197,7 @@ private:
shared_ptr<XdmfHeavyDataController> mLocalNodeIdsController;
// remoteTaskId | localNodeId | remoteLocalNodeId
std::map<task_id, node_id_map > mMap;
std::string mName;
shared_ptr<XdmfHeavyDataController> mRemoteLocalNodeIdsController;
shared_ptr<XdmfHeavyDataController> mRemoteTaskIdsController;
......
......@@ -88,8 +88,8 @@ int main(int, char **)
XdmfMap::New(globalNodeIds);
performTests(boundaryMaps);
grid0->setMap(boundaryMaps[0]);
grid1->setMap(boundaryMaps[1]);
grid0->insert(boundaryMaps[0]);
grid1->insert(boundaryMaps[1]);
// Grid Collection
shared_ptr<XdmfGridCollection> collection = XdmfGridCollection::New();
......@@ -107,8 +107,8 @@ int main(int, char **)
shared_dynamic_cast<XdmfDomain>(reader->read("TestXdmfMap1.xmf"));
boundaryMaps.clear();
boundaryMaps.push_back(domain2->getGridCollection(0)->getUnstructuredGrid(0)->getMap());
boundaryMaps.push_back(domain2->getGridCollection(0)->getUnstructuredGrid(1)->getMap());
boundaryMaps.push_back(domain2->getGridCollection(0)->getUnstructuredGrid(0)->getMap(0));
boundaryMaps.push_back(domain2->getGridCollection(0)->getUnstructuredGrid(1)->getMap(0));
performTests(boundaryMaps);
shared_ptr<XdmfWriter> writer2 = XdmfWriter::New("TestXdmfMap2.xmf");
......@@ -126,8 +126,8 @@ int main(int, char **)
shared_dynamic_cast<XdmfDomain>(reader->read("TestXdmfMapHDF1.xmf"));
boundaryMaps.clear();
boundaryMaps.push_back(domainHDF->getGridCollection(0)->getUnstructuredGrid(0)->getMap());
boundaryMaps.push_back(domainHDF->getGridCollection(0)->getUnstructuredGrid(1)->getMap());
boundaryMaps.push_back(domainHDF->getGridCollection(0)->getUnstructuredGrid(0)->getMap(0));
boundaryMaps.push_back(domainHDF->getGridCollection(0)->getUnstructuredGrid(1)->getMap(0));
performTests(boundaryMaps);
shared_ptr<XdmfWriter> writerHDF2 =
......
......@@ -516,7 +516,8 @@ XdmfPartitioner::partition(const shared_ptr<XdmfUnstructuredGrid> gridToPartitio
i<partitionedGrids->getNumberUnstructuredGrids();
++i) {
shared_ptr<XdmfMap> map = maps[i];
partitionedGrids->getUnstructuredGrid(i)->setMap(map);
map->setName("Subdomain Boundary");
partitionedGrids->getUnstructuredGrid(i)->insert(map);
if(heavyDataWriter) {
globalNodeIds[i]->release();
map->accept(heavyDataWriter);
......
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