00001 #ifndef INTERMEDIATECELL_H
00002 #define INTERMEDIATECELL_H
00003
00004 #include "SundanceDefs.h"
00005
00006 #include "CellBase.h"
00007 #include "Pool.h"
00008 #include "MeshData.h"
00009
00010
00011 namespace Sundance
00012 {
00013
00014 using namespace TSF;
00015 using std::string;
00016
00017 using std::ostream;
00018
00019
00020
00021
00022
00023
00024 class IntermediateCell : public CellBase
00025 {
00026 public:
00027 IntermediateCell(MeshData* meshData,
00028 int myIndex,
00029 int myDim,
00030 int parentID,
00031 int myFacetID)
00032 : CellBase(meshData, myIndex, -1),
00033 parentIndex_(1, parentID),
00034 myFacetIndex_(1, myFacetID),
00035 myDim_(myDim)
00036 {;}
00037 virtual ~IntermediateCell(){;}
00038
00039
00040 virtual int dim() const {return myDim_;}
00041
00042 virtual int numNodes() const ;
00043 virtual int numVertices() const ;
00044 virtual int numFacets(int d) const ;
00045 virtual int numCofacets(int d) const ;
00046 virtual void getNodes(TSFArray<int>& nodes) const ;
00047 virtual bool topologicallyEquals(const TSFArray<int>& otherVertices) const ;
00048 virtual const Cell& facet(int dim, int facetNumber) const ;
00049 virtual const Cell& cofacet(int d, int cofacetNumber) const ;
00050 virtual void getFacetIndices(TSFArray<TSFArray<int> >& facetIndices) const ;
00051 virtual void getCofacetIndices(TSFArray<TSFArray<int> >& cofacetIndices) const ;
00052 virtual int numParents() const {return parentIndex_.length();}
00053 virtual int parentIndex(int i) const {return parentIndex_[i];}
00054 virtual int myFacetIndex(int i) const {return myFacetIndex_[i];}
00055 virtual void addParent(int parentIndex, int myFacetIndex)
00056 {parentIndex_.append(parentIndex); myFacetIndex_.append(myFacetIndex);}
00057
00058 virtual bool isBoundaryCell() const ;
00059
00060 virtual const ReferenceCell& refCell() const ;
00061
00062 virtual const Point& point(int i) const ;
00063
00064 virtual void registerFacet(int dim, int facetNum, int facetCellIndex) ;
00065 virtual void registerCofacet(int d, int cofacetCellIndex) ;
00066
00067 virtual int byteCount() const ;
00068
00069 virtual void setAnchorIndex(int anchorIndex) {anchorIndex_=anchorIndex;}
00070 virtual void setCofacetIndex(int cofacetIndex) {myCofacetIndex_=cofacetIndex;}
00071 virtual int anchorIndex() const {return anchorIndex_;}
00072 virtual int cofacetIndex() const {return myCofacetIndex_;}
00073 #ifndef NO_POOLMEM
00074 static inline void* operator new(size_t s);
00075 static inline void operator delete(void* p, size_t s);
00076 #endif
00077
00078 protected:
00079 const Cell& parent(int i) const ;
00080
00081 TSFArray<int> parentIndex_;
00082 int anchorIndex_;
00083 int myCofacetIndex_;
00084 TSFArray<char> myFacetIndex_;
00085 char myDim_;
00086
00087
00088 #ifndef NO_POOLMEM
00089 static Pool memPool_;
00090 #endif
00091
00092
00093
00094 inline void updateNodeCache() const ;
00095 inline void updateFacetCache() const ;
00096 inline void updateCofacetCache() const ;
00097 void fillNodeCache(TSFArray<int>& nodeCache) const ;
00098 void fillFacetCache(TSFArray<TSFArray<int> >& facetCache) const ;
00099 void fillCofacetCache(TSFArray<TSFArray<int> >& cofacetCache) const ;
00100 static short int nodeCacheCellDim_;
00101 static int nodeCacheCellIndex_;
00102 static short int facetCacheCellDim_;
00103 static int facetCacheCellIndex_;
00104 static short int cofacetCacheCellDim_;
00105 static int cofacetCacheCellIndex_;
00106 static TSFArray<int> nodeCache_;
00107 static TSFArray<TSFArray<int> > facetCache_;
00108 static TSFArray<TSFArray<int> > cofacetCache_;
00109 };
00110
00111 #ifndef NO_POOLMEM
00112
00113 inline void* IntermediateCell::operator new(size_t s)
00114 {
00115 if (s != sizeof(IntermediateCell))
00116 {
00117 return ::operator new(s);
00118 }
00119 return memPool_.alloc();
00120
00121 }
00122
00123 inline void IntermediateCell::operator delete(void* p, size_t s)
00124 {
00125 if (s != sizeof(IntermediateCell)) ::operator delete(p);
00126 else memPool_.free(p);
00127
00128 }
00129
00130 #endif
00131
00132 inline void IntermediateCell::updateNodeCache() const
00133 {
00134 if (nodeCacheCellDim_ != myDim_ || nodeCacheCellIndex_ != localIndex_)
00135 {
00136 nodeCacheCellDim_ = myDim_;
00137 nodeCacheCellIndex_ = localIndex_;
00138 fillNodeCache(nodeCache_);
00139 }
00140 }
00141
00142 inline void IntermediateCell::updateFacetCache() const
00143 {
00144 if (facetCacheCellDim_ != myDim_ || facetCacheCellIndex_ != localIndex_)
00145 {
00146 facetCacheCellDim_ = myDim_;
00147 facetCacheCellIndex_ = localIndex_;
00148 fillFacetCache(facetCache_);
00149 }
00150 }
00151
00152 inline void IntermediateCell::updateCofacetCache() const
00153 {
00154 if (cofacetCacheCellDim_ != myDim_ || cofacetCacheCellIndex_ != localIndex_)
00155 {
00156 cofacetCacheCellDim_ = myDim_;
00157 cofacetCacheCellIndex_ = localIndex_;
00158 fillCofacetCache(cofacetCache_);
00159 }
00160 }
00161
00162
00163
00164
00165
00166
00167
00168 }
00169 #endif
00170
00171
00172
00173
00174