XdmfTopology.cpp 1.57 KB
Newer Older
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
1
/*
2
 * XdmfTopology.cpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
3 4 5 6 7
 *
 *  Created on: Jan 29, 2010
 *      Author: kleiter
 */

8
#include <sstream>
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
9
#include "XdmfArray.hpp"
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
10
#include "XdmfTopology.hpp"
11
#include "XdmfTopologyType.hpp"
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
12

13
XdmfTopology::XdmfTopology() :
14 15
	mTopologyType(XdmfTopologyType::NoTopologyType()),
	mNumberElements(0)
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
16 17 18 19 20 21 22 23 24
{
	std::cout << "Created Topology " << this << std::endl;
}

XdmfTopology::~XdmfTopology()
{
	std::cout << "Deleted Topology " << this << std::endl;
}

25 26
std::string XdmfTopology::ItemTag = "Topology";

27 28
std::string XdmfTopology::getItemTag() const
{
29
	return ItemTag;
30 31
}

32 33 34
std::map<std::string, std::string> XdmfTopology::getItemProperties() const
{
	std::map<std::string, std::string> topologyProperties;
35
	mTopologyType->getProperties(topologyProperties);
36 37 38
	std::stringstream numElements;
	numElements << this->getNumberElements();
	topologyProperties["Dimensions"] = numElements.str();
39 40 41
	return topologyProperties;
}

42
unsigned int XdmfTopology::getNumberElements() const
43
{
44
	if(mTopologyType->getNodesPerElement() == 0)
45 46 47
	{
		return 0;
	}
48
	return this->getArray()->getSize() / mTopologyType->getNodesPerElement();
49 50
}

51
boost::shared_ptr<const XdmfTopologyType> XdmfTopology::getTopologyType() const
52
{
53
	return mTopologyType;
54 55
}

56 57 58 59 60 61
void XdmfTopology::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
{
	mTopologyType = XdmfTopologyType::New(itemProperties);
	XdmfDataItem::populateItem(itemProperties, childItems);
}

62
void XdmfTopology::setTopologyType(const boost::shared_ptr<const XdmfTopologyType> topologyType)
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
63
{
64
	mTopologyType = topologyType;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
65
}