XdmfTopology.hpp 4.32 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
// Includes
12
#include "XdmfItem.hpp"
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
13

14 15 16 17
class XdmfTopologyType {

public:

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

22 23 24 25 26 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
	// Supported Xdmf Topology Types
	static XdmfTopologyType NoTopologyType();
	static XdmfTopologyType Polyvertex();
	static XdmfTopologyType Polyline();
	static XdmfTopologyType Polygon(const int&);
	static XdmfTopologyType Triangle();
	static XdmfTopologyType Quadrilateral();
	static XdmfTopologyType Tetrahedron();
	static XdmfTopologyType Pyramid();
	static XdmfTopologyType Wedge();
	static XdmfTopologyType Hexahedron();
	static XdmfTopologyType Edge_3();
	static XdmfTopologyType Triangle_6();
	static XdmfTopologyType Quadrilateral_8();
	static XdmfTopologyType Tetrahedron_10();
	static XdmfTopologyType Pyramid_13();
	static XdmfTopologyType Wedge_15();
	static XdmfTopologyType Hexahedron_20();
	static XdmfTopologyType Mixed();
	static XdmfTopologyType TwoDSMesh();
	static XdmfTopologyType TwoDRectMesh();
	static XdmfTopologyType TwoDCoRectMesh();
	static XdmfTopologyType ThreeDSMesh();
	static XdmfTopologyType ThreeDRectMesh();
	static XdmfTopologyType ThreeDCoRectMesh();

	/**
	 * Get the number of nodes per element associated with this topology type.
	 *
	 * @return an int containing number of nodes per element.
	 */
	int getNodesPerElement() const;

	/**
	 * Get the name of this topology type
	 *
	 * @return a string containing the name.
	 */
	std::string getName() const;

	/**
	 * Get the cell type associated with this topology type
	 *
	 * @return a CellType containing the cell type.
	 */
	CellType getCellType() const;
68

69
	/*
70
	 * Compare two XdmfTopology types for equality.
71 72 73 74
	 *
	 * @param an XdmfTopologyType to compare equality to.
	 * @return true iff the XdmfTopologyTypes are equal.
	 */
75 76
	bool operator==(const XdmfTopologyType& top) const
	{
77
		return mNodesPerElement == top.mNodesPerElement && mName.compare(top.mName) == 0 && mCellType == top.mCellType;
78 79
	}

80
	/**
81
	 * Compare two XdmfTopology types for inequality
82 83 84 85
	 *
	 * @param XdmfTopologyType to compare inequality to.
	 * @return true iff the XdmfTopologyTypes are not equal.
	 */
86 87
	bool operator!=(const XdmfTopologyType& top) const
	{
88
		return !this->operator ==(top);
89 90
	}

91 92 93
	XdmfTopologyType(const XdmfTopologyType&);
	XdmfTopologyType& operator=(const XdmfTopologyType&);

94 95
protected:

96 97
	/**
	 * Protected constructor for XdmfTopologyType.  The constructor is protected because all topology types supported
98
	 * by Xdmf should be accessed through more specific static methods that construct XdmfTopologyType - i.e. XdmfTopologyType::Tetrahedron()
99 100
	 */
	XdmfTopologyType(const int& nodesPerElement, const std::string& name, const CellType& cellType) :
101 102 103
		mNodesPerElement(nodesPerElement),
		mName(name),
		mCellType(cellType)
104 105 106 107
	{};

private:

108 109 110
	int mNodesPerElement;
	std::string mName;
	CellType mCellType;
111 112
};

113
class XdmfTopology : public XdmfItem {
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
114 115 116 117 118

public:

	XdmfNewMacro(XdmfTopology);

119 120 121 122 123
	/**
	 * Get the XdmfTopologyType associated with this Topology.
	 *
	 * @return XdmfTopologyType.
	 */
124
	XdmfTopologyType getTopologyType() const;
125 126 127 128 129 130

	/**
	 * Set the XdmfTopologyType associated with this Topology.
	 *
	 * @param XdmfTopologyType to set.
	 */
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
	void setTopologyType(const XdmfTopologyType& topType);

	/**
	 * Get the number of elements this Topology contains.
	 *
	 * @return int of number elements in the Topology.
	 */
	int getNumberElements() const;

	/**
	 * Set the number of elements this Topology contains.
	 *
	 * @param int of number elements to set.
	 */
	void setNumberElements(int&);
146 147 148 149 150 151

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

154 155 156 157 158
	/**
	 * Get the number of nodes per element for this Topology.
	 *
	 * @return int of number of nodes per element.
	 */
159
	int getNodesPerElement() const;
160 161 162 163

	/**
	 *
	 */
164
	virtual const std::string printSelf() const;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
165

166 167
	virtual void write(boost::shared_ptr<XdmfVisitor> visitor) const;

Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
168 169 170 171 172 173 174
protected:

	XdmfTopology();
	virtual ~XdmfTopology();

private:

175 176
	XdmfTopology(const XdmfTopology&);  // Not implemented.
	void operator=(const XdmfTopology&);  // Not implemented.
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
177

178 179
	XdmfTopologyType mTopologyType;
	int mNumberElements;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
180 181 182
};

#endif /* XDMFTOPOLOGY_HPP_ */