00001 #ifndef __TETRA4_HPP__
00002 #define __TETRA4_HPP__
00003
00004 #include "elem/Simplex.hpp"
00005 #include "tools/ElementConList.hpp"
00006
00007 #include <vector>
00008 #include <string>
00009
00010 #include <boost/array.hpp>
00011
00012 namespace DAPTA {
00013
00015
00018 template <typename V>
00019 class Tetra4 {
00020 public:
00021 typedef V VertexType;
00022 typedef V* VertexHandle;
00023 typedef Tetra4<V> ElementType;
00024 typedef Tetra4<V>* ElementHandle;
00025 typedef CohElem<Tetra4<V> > CohElementType;
00026 typedef CohElementType* CohElementHandle;
00027 typedef Simplex<V,3> FaceElementType;
00028 typedef FaceElementType* FaceElementHandle;
00029 typedef Simplex<V,2> EdgeElementType;
00030 typedef EdgeElementType* EdgeElementHandle;
00031 typedef ElementConList ElementConListType;
00032 typedef ElementConListType* ElementConListHandle;
00033
00034 static const int num_vertices = 4;
00035 static const int num_adjacents = 4;
00036 static const int num_edges = 6;
00037
00038 static const std::string deck_keyword;
00039
00040 Tetra4(VertexHandle v1, VertexHandle v2, VertexHandle v3, VertexHandle v4);
00041 Tetra4(boost::array<VertexHandle, num_vertices> nodes);
00042 Tetra4() : globalID(0) {;}
00043 ~Tetra4() {;}
00044
00045 int FindVertex(VertexHandle v);
00046 ElementHandle AdjElement(VertexHandle v) { return AdjElement(FindVertex(v)); }
00047 ElementHandle AdjElement(int i) { return adjacents.at(i); }
00048
00049 bool IsBoundaryEdge(VertexHandle v1, VertexHandle v2);
00050 bool IsBoundaryEdge(int v1, int v2);
00051 bool IsBoundaryFace(VertexHandle v) { return IsBoundaryFace(FindVertex(v)); }
00052 bool IsBoundaryFace(int i) { return (adjacents.at(i) == NULL); }
00053
00054 ElementHandle NextTetOnEdge(int &v1, int &v2, int &f);
00055 int FaceToVertex(VertexHandle v1, VertexHandle v2, VertexHandle v3);
00056 int FaceToVertex(int v1, int v2, int v3);
00057 int FaceToVertex(boost::array<VertexHandle, (num_adjacents-1)> vs);
00058 void BreakConnection(int f) { adjacents.at(f)=NULL; }
00059 void MakeConnection(VertexHandle f, ElementHandle t) { MakeConnection(FindVertex(f), t); }
00060 void MakeConnection(int f, ElementHandle t) { adjacents.at(f)=t; }
00061
00062 FaceElementType GetFace(int ind);
00063 int GetFaceIndex(FaceElementType face);
00064 EdgeElementType GetEdge(int ind);
00065 int GetEdgeIndex(EdgeElementType edge);
00066 std::vector<EdgeElementType> GetEdges(int f);
00067 std::vector<EdgeElementType> GetAllEdges();
00068 ElementHandle NextOnEdge(int ind);
00069 ElementHandle PrevOnEdge(int ind);
00070 ElementHandle NextOnEdge(EdgeElementType edge);
00071 ElementHandle PrevOnEdge(EdgeElementType edge);
00072 CohElementHandle NextCohOnEdge(int ind);
00073 CohElementHandle PrevCohOnEdge(int ind);
00074
00075 VertexHandle GetCentre();
00076
00077 boost::array<VertexHandle,num_vertices> vertices;
00078 boost::array<ElementHandle,num_adjacents> adjacents;
00079 boost::array<CohElementHandle,num_adjacents> coh_adjacents;
00080 boost::array<ElementConListHandle,num_edges> con_lists;
00081
00082 int globalID;
00083
00084
00085
00086
00087 private:
00088 };
00089
00090 template <typename V>
00091 const std::string Tetra4<V>::deck_keyword = "TETRA4";
00092
00093 }
00094
00095 #include "Tetra4.cpp"
00096
00097 #endif