TestXdmfVisitor.cpp 1.21 KB
Newer Older
1
#include "XdmfAttribute.hpp"
2
#include "XdmfDataItem.hpp"
3 4
#include "XdmfGeometry.hpp"
#include "XdmfGrid.hpp"
5 6 7 8 9
#include "XdmfTopology.hpp"
#include "XdmfVisitor.hpp"

int main(int argc, char* argv[])
{
10 11
	boost::shared_ptr<XdmfVisitor> visitor3 = XdmfVisitor::New();
	boost::shared_ptr<XdmfGrid> grid = XdmfGrid::New();
12

13
	grid->setName("test");
14 15 16 17 18 19 20 21 22

	// Set Geometry
	int points[] = { 0, 0, 1, 1, 0, 1, 3, 0, 2, 0, 1, 1, 1, 1, 1, 3, 2, 2,
			0, 0, -1, 1, 0, -1, 3, 0, -2, 0, 1, -1, 1, 1, -1, 3, 2, -2};
	grid->getGeometry()->setGeometryType(XdmfGeometryType::XYZ());
	grid->getGeometry()->getData()->setData(points);
	grid->getGeometry()->getData()->setNumberValues(36);

	// Set Topology
23
	grid->getTopology()->setTopologyType(XdmfTopologyType::Hexahedron());
24 25 26 27 28
	grid->getTopology()->setNumberElements(2);
	int connectivity[] = { 0, 1, 7, 6, 3, 4, 10, 9, 1, 2, 8, 7, 4, 5, 11, 10};
	grid->getTopology()->getData()->setNumberValues(16);
	grid->getTopology()->getData()->setData(connectivity);

29 30 31 32
	boost::shared_ptr<XdmfAttribute> attr = XdmfAttribute::New();
	attr->setName("Attr1");
	attr->setAttributeType(XdmfAttributeType::Scalar());
	grid->insert(attr);
33 34 35
	grid->write(visitor3);
	std::cout << visitor3->printSelf() << std::endl;

36 37
	return 0;
}