// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == crystal growth group == // == == // == Stiftung caesar == // == Ludwig-Erhard-Allee 2 == // == 53175 Bonn == // == germany == // == == // ============================================================================ // == == // == http://www.caesar.de/cg/AMDiS == // == == // ============================================================================ /** \file Triangle.h */ #ifndef AMDIS_TRIANGLE_H #define AMDIS_TRIANGLE_H #include "Element.h" namespace AMDiS { /** \ingroup Triangulation * \brief * A Triangle is a 2-dimensional Element. * * A Triangle and its refinements: * * */ class Triangle : public Element { public: /// calls base class contructor. Triangle(Mesh* aMesh) : Element(aMesh) {} ~Triangle() {} /// implements Element::clone inline Element *clone() { return new Triangle(mesh); } /// implements Element::getVertexOfEdge inline int getVertexOfEdge(int i, int j) const { return vertexOfEdge[i][j]; } /// implements Element::getVertexOfPosition int getVertexOfPosition(GeoIndex position, int positionIndex, int vertexIndex) const; /// implements Element::getGeo inline int getGeo(GeoIndex i) const { switch (i) { case VERTEX: case PARTS: case NEIGH: return 3; break; case EDGE: return 3; case FACE: return 0; case CENTER: return 1; break; case DIMEN: return 2; break; case BOUNDARY: return 6; break; case PROJECTION: return 3; break; default: ERROR_EXIT("invalid geo-index\n"); return 0; } } /// implements Element::hasSide bool hasSide(Element* sideElem) const; /// implements Element::sortFaceIndices const FixVec& sortFaceIndices(int face, FixVec *vec) const; /// implements Element::isLine. Returns false because this element is a Triangle inline bool isLine() const { return false; } /// implements Element::isTriangle. Returns true because this element is a Triangle inline bool isTriangle() const { return true; } /** \brief * implements Element::isTetrahedron. Returns false because this element is a * Triangle */ inline bool isTetrahedron() const { return false; } /// implements Element::getSideOfChild() virtual int getSideOfChild(int child, int side, int) const { FUNCNAME("Triangle::getSideOfChild()"); TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n"); TEST_EXIT_DBG(side >= 0 && side <= 2)("side must be between 0 and 2\n"); return sideOfChild[child][side]; } /// implements Element::getVertexOfParent() virtual int getVertexOfParent(int child, int side, int = 0) const { FUNCNAME("Triangle::getVertexOfParent()"); TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n"); TEST_EXIT_DBG(side >= 0 && side <= 2)("side must be between 0 and 2\n"); return vertexOfParent[child][side]; } virtual int getPositionOfVertex(int side, int vertex) const { static int positionOfVertex[3][3] = {{-1,0,1},{1,-1,0},{0,1,-1}}; return positionOfVertex[side][vertex]; } inline int getEdgeOfFace(int face, int edge) const { TEST_EXIT_DBG(face == 0)("face must be zero at triangle\n"); TEST_EXIT_DBG(edge >= 0 && edge < 3)("invalid edge\n"); return edge; } std::string getTypeName() const { return "Triangle"; } protected: /** \brief * vertexOfEdge[i][j] is the local number of the j-th vertex of the i-th * edge of this element. */ static const int vertexOfEdge[3][2]; static const int sideOfChild[2][3]; static const int vertexOfParent[2][3]; }; } #endif // AMDIS_TRIANGLE_H