Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

GenericCell.h

Go to the documentation of this file.
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg.
00002 // Licensed under the GNU GPL Version 2.
00003 
00004 #ifndef __GENERIC_CELL_H
00005 #define __GENERIC_CELL_H
00006 
00007 #include <dolfin/constants.h>
00008 #include <dolfin/Cell.h>
00009 #include <dolfin/NodeIterator.h>
00010 #include <dolfin/CellIterator.h>
00011 #include <dolfin/EdgeIterator.h>
00012 #include <dolfin/FaceIterator.h>
00013 #include <dolfin/Array.h>
00014 
00015 namespace dolfin {
00016 
00017   class Point;
00018   class Node;
00019   class Cell;
00020   class Mesh;
00021   class CellRefData;
00022   
00023   class GenericCell {
00024   public:
00025          
00026     GenericCell();
00027     virtual ~GenericCell();
00028 
00029     int id() const;
00030     virtual Cell::Type type() const = 0;
00031 
00032     virtual int noNodes() const = 0;
00033     virtual int noEdges() const = 0;
00034     virtual int noFaces() const = 0;
00035     virtual int noBoundaries() const = 0;
00036     
00037     int noCellNeighbors() const;
00038     int noNodeNeighbors() const;
00039     int noChildren() const;
00040 
00041     Node& node(int i) const;
00042     Edge& edge(int i) const;
00043     Face& face(int i) const;
00044     Cell& neighbor(int i) const;
00045     Cell* parent() const;
00046     Cell* child(int i) const;
00047     Point& coord(int i) const;
00048     Point midpoint() const;
00049     int   nodeID(int i) const;
00050     virtual real volume() const = 0;
00051     virtual real diameter() const = 0;
00052 
00053     void mark();
00054 
00055     // Friends
00056     friend class Cell;
00057     friend class MeshRefinement;
00058     friend class Triangle;
00059     friend class Tetrahedron;
00060     friend class MeshInit;
00061     friend class NodeIterator::CellNodeIterator;
00062     friend class CellIterator::CellCellIterator;
00063     friend class EdgeIterator::CellEdgeIterator;
00064     friend class FaceIterator::CellFaceIterator;
00065     
00066   private:
00067 
00068     // Specify global cell number
00069     int setID(int id, Mesh& mesh);
00070     
00071     // Set mesh pointer
00072     void setMesh(Mesh& mesh);
00073 
00074     // Set parent cell
00075     void setParent(Cell& parent);
00076 
00077     // Remove parent cell
00078     void removeParent();
00079 
00080     // Set number of children
00081     void initChildren(int n);
00082 
00083     // Set child cell
00084     void addChild(Cell& child);
00085 
00086     // Remove child cell
00087     void removeChild(Cell& child);
00088 
00089     // Check if given cell is a neighbor
00090     bool neighbor(GenericCell& cell) const;
00091 
00092     // Check if given node is contained in the cell
00093     bool haveNode(Node& node) const;
00094 
00095     // Check if given edge is contained in the cell
00096     bool haveEdge(Edge& edge) const;
00097 
00098     // Create edges for the cell
00099     virtual void createEdges() = 0;
00100 
00101     // Create faces for the cell
00102     virtual void createFaces() = 0;
00103 
00104     // Create a given edge
00105     void createEdge(Node& n0, Node& n1);
00106 
00107     // Create a given face
00108     void createFace(Edge& e0, Edge& e1, Edge& e2);
00109 
00110     // Find node with given coordinates (null if not found)
00111     Node* findNode(const Point& p) const;
00112 
00113     // Find edge within cell (null if not found)
00114     Edge* findEdge(Node& n0, Node& n1);
00115 
00116     // Find face within cell (null if not found)
00117     Face* findFace(Edge& e0, Edge& e1, Edge& e2);
00118     Face* findFace(Edge& e0, Edge& e1);
00119 
00120     // Initialize marker (if not already done)
00121     void initMarker();
00122 
00123     // Return cell marker
00124     Cell::Marker& marker();
00125 
00126     // Return cell status
00127     Cell::Status& status();
00128 
00129     //--- Cell data ---
00130 
00131     // The mesh containing this cell
00132     Mesh* mesh;
00133 
00134     // Global cell number
00135     int _id;
00136 
00137     // Connectivity
00138     Array<Node*> cn;
00139     Array<Cell*> cc;
00140     Array<Edge*> ce;
00141     Array<Face*> cf;
00142 
00143     // Parent-child info
00144     Cell* _parent;
00145     Array<Cell*> children;
00146 
00147     // Mesh refinement data
00148     CellRefData* rd;
00149     
00150   };
00151 
00152 }
00153 
00154 #endif


Documentation automatically generated with Doxygen on 10 Sep 2004.