XdmfTopology.hpp 3.98 KB
Newer Older
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
1 2 3 4 5 6 7 8 9 10
/*
 * XdmfTopology.hpp
 *
 *  Created on: Jan 25, 2010
 *      Author: kleiter
 */

#ifndef XDMFTOPOLOGY_HPP_
#define XDMFTOPOLOGY_HPP_

11
#include "XdmfItem.hpp"
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
12

13 14 15 16
class XdmfTopologyType {

public:

17 18 19 20 21
	enum CellType {
		NoCellType, Linear, Quadratic, Arbitrary, Structured
	};

	const int nodesPerElement;
22
	const std::string name;
23
	const CellType cellType;
24 25

	// Supported Xdmf Topology Type
26
	// TODO: How do we deal with Polygon datatypes and others that can have variable nodesPerElement?
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
	static const XdmfTopologyType NoTopology;
	static const XdmfTopologyType Polyvertex;
	static const XdmfTopologyType Polyline;
	static const XdmfTopologyType Polygon;
	static const XdmfTopologyType Triangle;
	static const XdmfTopologyType Quadrilateral;
	static const XdmfTopologyType Tetrahedron;
	static const XdmfTopologyType Pyramid;
	static const XdmfTopologyType Wedge;
	static const XdmfTopologyType Hexahedron;
	static const XdmfTopologyType Edge_3;
	static const XdmfTopologyType Triangle_6;
	static const XdmfTopologyType Quadrilateral_8;
	static const XdmfTopologyType Tetrahedron_10;
	static const XdmfTopologyType Pyramid_13;
	static const XdmfTopologyType Wedge_15;
	static const XdmfTopologyType Hexahedron_20;
	static const XdmfTopologyType Mixed;
	static const XdmfTopologyType TwoDSMesh;
	static const XdmfTopologyType TwoDRectMesh;
	static const XdmfTopologyType TwoDCoRectMesh;
	static const XdmfTopologyType ThreeDSMesh;
	static const XdmfTopologyType ThreeDRectMesh;
	static const XdmfTopologyType ThreeDCoRectMesh;

52 53 54 55 56 57 58
	/*
	 * Compare two XdmfTopology types for equality. Each topology type has a single static instance meaning that
	 * equality can be determined by determining if they have the same pointer value.
	 *
	 * @param an XdmfTopologyType to compare equality to.
	 * @return true iff the XdmfTopologyTypes are equal.
	 */
59 60 61 62 63
	bool operator==(const XdmfTopologyType& top) const
	{
		return (this == &top) ? true : false;
	}

64 65 66 67 68 69 70
	/**
	 * Compare two XdmfTopology types for inequality. Each topology type has a single static instance meaning that
	 * equality can be determined by determining if they have the same pointer value.
	 *
	 * @param XdmfTopologyType to compare inequality to.
	 * @return true iff the XdmfTopologyTypes are not equal.
	 */
71 72 73 74 75 76 77
	bool operator!=(const XdmfTopologyType& top) const
	{
		return (this != &top) ? true : false;
	}

protected:

78 79 80 81 82 83 84 85
	/**
	 * Protected constructor for XdmfTopologyType.  The constructor is protected because all topology types supported
	 * by Xdmf should be accessed through static public instances of XdmfTopologyType - i.e. XdmfTopologyType::Tetrahedron.
	 */
	XdmfTopologyType(const int& nodesPerElement, const std::string& name, const CellType& cellType) :
		nodesPerElement(nodesPerElement),
		name(name),
		cellType(cellType)
86 87 88 89 90 91 92 93 94
	{};

private:

	//XdmfTopologyType(const XdmfTopologyType&);  // Not implemented.
	//void operator=(const XdmfTopologyType&);  // Not implemented.

};

95
class XdmfTopology : public XdmfItem {
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
96 97 98 99 100

public:

	XdmfNewMacro(XdmfTopology);

101 102
	virtual void write(boost::shared_ptr<XdmfVisitor>) const;

103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
	/**
	 * Get the XdmfTopologyType associated with this Topology.
	 *
	 * @return XdmfTopologyType.
	 */
	const XdmfTopologyType& getTopologyType() const;

	/**
	 * Set the XdmfTopologyType associated with this Topology.
	 *
	 * @param XdmfTopologyType to set.
	 */
	void setTopologyType(const XdmfTopologyType&);

	/**
	 * Get the name of the TopologyType associated with this Topology.
	 *
	 * @return std::string containing name of the TopologyType.
	 */
122 123
	const std::string getTopologyTypeAsString() const;

124 125 126 127 128 129 130 131 132 133
	/**
	 * Get the number of nodes per element for this Topology.
	 *
	 * @return int of number of nodes per element.
	 */
	const int getNodesPerElement() const;

	/**
	 *
	 */
134
	virtual const std::string printSelf() const;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
135 136 137 138 139 140 141 142 143 144 145

protected:

	XdmfTopology();
	virtual ~XdmfTopology();

private:

  XdmfTopology(const XdmfTopology&);  // Not implemented.
  void operator=(const XdmfTopology&);  // Not implemented.

146
  const XdmfTopologyType * mTopologyType;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
147 148 149
};

#endif /* XDMFTOPOLOGY_HPP_ */