![]() |
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 00004 // A couple of comments: 00005 // 00006 // - Enums don't need to be called "refined_regular", just "regular" is enough? 00007 // - Move data to GenericCell? Cell should only contain the GenericCell pointer? 00008 // - Maybe more methods should be private? 00009 00010 #ifndef __CELL_H 00011 #define __CELL_H 00012 00013 #include <dolfin/dolfin_log.h> 00014 #include <dolfin/Array.h> 00015 #include <dolfin/CellIterator.h> 00016 #include <dolfin/NodeIterator.h> 00017 #include <dolfin/EdgeIterator.h> 00018 #include <dolfin/FaceIterator.h> 00019 00020 namespace dolfin 00021 { 00022 00023 class Point; 00024 class Node; 00025 class Edge; 00026 class Triangle; 00027 class Tetrahedron; 00028 class Mesh; 00029 class MeshInit; 00030 class CellRefData; 00031 00032 class Cell 00033 { 00034 public: 00035 00036 enum Type { triangle, tetrahedron, none }; 00037 00039 Cell(); 00040 00042 Cell(Node& n0, Node& n1, Node& n2); 00043 00045 Cell(Node& n0, Node& n1, Node& n2, Node& n3); 00046 00048 ~Cell(); 00049 00051 void clear(); 00052 00054 00056 int id() const; 00057 00059 Type type() const; 00060 00062 int noNodes() const; 00063 00065 int noEdges() const; 00066 00068 int noFaces() const; 00069 00071 int noBoundaries() const; 00072 00074 int noCellNeighbors() const; 00075 00077 int noNodeNeighbors() const; 00078 00080 int noChildren() const; 00081 00083 Node& node(int i) const; 00084 00086 Edge& edge(int i) const; 00087 00089 Face& face(int i) const; 00090 00092 Cell& neighbor(int i) const; 00093 00095 Cell* parent() const; 00096 00098 Cell* child(int i) const; 00099 00101 Point& coord(int i) const; 00102 00104 Point midpoint() const; 00105 00106 // Return id for node number i 00107 int nodeID(int i) const; 00108 00109 // Compute and return volume / area 00110 real volume() const; 00111 00112 // Compute and return diameter 00113 real diameter() const; 00114 00116 bool operator==(const Cell& cell) const; 00117 00119 bool operator!=(const Cell& cell) const; 00120 00122 00124 void mark(); 00125 00127 00129 friend LogStream& operator<<(LogStream& stream, const Cell& cell); 00130 00131 // Friends 00132 friend class Mesh; 00133 friend class MeshData; 00134 friend class MeshInit; 00135 friend class MeshRefinement; 00136 friend class MeshRefinementData; 00137 friend class TriMeshRefinement; 00138 friend class TetMeshRefinement; 00139 friend class GenericCell; 00140 friend class CellRefData; 00141 friend class NodeIterator::CellNodeIterator; 00142 friend class CellIterator::CellCellIterator; 00143 friend class EdgeIterator::CellEdgeIterator; 00144 friend class FaceIterator::CellFaceIterator; 00145 00146 private: 00147 00148 enum Marker { marked_for_reg_ref, // Marked for regular refinement 00149 marked_for_irr_ref_1, // Marked for irregular refinement by rule 1 00150 marked_for_irr_ref_2, // Marked for irregular refinement by rule 2 00151 marked_for_irr_ref_3, // Marked for irregular refinement by rule 3 00152 marked_for_irr_ref_4, // Marked for irregular refinement by rule 4 00153 marked_for_no_ref, // Marked for no refinement 00154 marked_for_coarsening, // Marked for coarsening 00155 marked_according_to_ref }; // Marked according to refinement 00156 00157 enum Status { ref_reg, // Refined regularly 00158 ref_irr, // Refined irregularly 00159 unref }; // Unrefined 00160 00161 // Specify global cell number 00162 int setID(int id, Mesh& mesh); 00163 00164 // Set the mesh pointer 00165 void setMesh(Mesh& mesh); 00166 00167 // Set parent cell 00168 void setParent(Cell& parent); 00169 00170 // Remove parent cell 00171 void removeParent(); 00172 00173 // Set number of children 00174 void initChildren(int n); 00175 00176 // Set child cell 00177 void addChild(Cell& child); 00178 00179 // Remove child cell 00180 void removeChild(Cell& child); 00181 00182 // Clear data and create a new triangle 00183 void set(Node& n0, Node& n1, Node& n2); 00184 00185 // Clear data and create a new tetrahedron 00186 void set(Node& n0, Node& n1, Node& n2, Node& n3); 00187 00188 // Check if given cell is a neighbor 00189 bool neighbor(Cell& cell) const; 00190 00191 // Check if given node is contained in the cell 00192 bool haveNode(Node& node) const; 00193 00194 // Check if given edge is contained in the cell 00195 bool haveEdge(Edge& edge) const; 00196 00197 // Create edges for the cell 00198 void createEdges(); 00199 00200 // Create faces for the cell 00201 void createFaces(); 00202 00203 // Create a given edge 00204 void createEdge(Node& n0, Node& n1); 00205 00206 // Create a given face 00207 void createFace(Edge& e0, Edge& e1, Edge& e2); 00208 00209 // Find node with given coordinates (null if not found) 00210 Node* findNode(const Point& p) const; 00211 00212 // Find edge within cell (null if not found) 00213 Edge* findEdge(Node& n0, Node& n1); 00214 00215 // Find face within cell (null if not found) 00216 Face* findFace(Edge& e0, Edge& e1, Edge& e2); 00217 Face* findFace(Edge& e0, Edge& e1); 00218 00219 // Return cell marker 00220 Marker& marker(); 00221 00222 // Return cell status 00223 Status& status(); 00224 00225 //--- Cell data --- 00226 00227 // The cell 00228 GenericCell* c; 00229 00230 }; 00231 00232 } 00233 00234 #endif
Documentation automatically generated with Doxygen on 10 Sep 2004.