00001 #ifndef CELLBASE_H
00002 #define CELLBASE_H
00003
00004 #include "SundanceDefs.h"
00005
00006 #include "TSFArray.h"
00007 #include "Point.h"
00008 #include "CellJacobian.h"
00009
00010
00011 #include "CellType.h"
00012
00013
00014 namespace Sundance
00015 {
00016
00017 using namespace TSF;
00018 using std::ostream;
00019
00020 class MeshData;
00021 class ReferenceCell;
00022 class Cell;
00023 class FacetSetBase;
00024
00025
00026
00027
00028
00029 class CellBase
00030 {
00031 public:
00032
00033
00034
00035
00036 CellBase(MeshData* meshData,
00037 int localIndex,
00038 short int )
00039 : meshData_(meshData), localIndex_(localIndex),
00040 globalIndex_(-1)
00041 {;}
00042
00043
00044
00045 CellBase(MeshData* meshData,
00046 int localIndex,
00047 int globalIndex,
00048 short int )
00049 : meshData_(meshData), localIndex_(localIndex),
00050 globalIndex_(globalIndex)
00051 {;}
00052
00053 virtual ~CellBase(){;}
00054
00055
00056 virtual bool isZeroCell() const {return false;}
00057
00058 virtual bool isMaximalCell() const {return false;}
00059
00060 bool isAffine() const ;
00061
00062 CellTopologyCode topologyCode() const ;
00063
00064 const string& typeName() const ;
00065
00066
00067 short int ownerProcID() const ;
00068
00069 int localIndex() const {return localIndex_;}
00070
00071 int globalIndex() const {return globalIndex_;}
00072
00073 void setGlobalIndex(int globalIndex);
00074
00075 virtual int dim() const = 0 ;
00076
00077 int meshDim() const ;
00078
00079 int meshID() const ;
00080
00081
00082 virtual int numNodes() const = 0 ;
00083
00084 virtual int numVertices() const = 0 ;
00085
00086 virtual void getNodes(TSFArray<int>& nodes) const = 0 ;
00087
00088
00089 virtual int node() const ;
00090
00091 virtual const TSFArray<int>& nodes() const ;
00092
00093
00094 virtual int numFacets(int d) const = 0 ;
00095
00096 virtual int numCofacets(int d) const = 0 ;
00097
00098
00099 virtual bool topologicallyEquals(const TSFArray<int>& otherNodes) const = 0 ;
00100
00101
00102 virtual const Cell& facet(int dim, int facetNumber) const = 0;
00103
00104 virtual const Cell& cofacet(int d, int cofacetNumber) const = 0;
00105 virtual void getFacetIndices(TSFArray<TSFArray<int> >& facetIndices) const = 0 ;
00106 virtual void getCofacetIndices(TSFArray<TSFArray<int> >& cofacetIndices) const =0 ;
00107
00108 virtual void addParent(int parentIndex, int myFacetIndex);
00109 virtual int numParents() const ;
00110 virtual int parentIndex(int i) const ;
00111 virtual int myFacetIndex(int i) const ;
00112
00113 virtual const FacetSetBase* facets() const ;
00114
00115 virtual const TSFArray<TSFArray<int> >& cofacetIndices() const ;
00116 virtual bool isBoundaryCell() const ;
00117
00118
00119 void setLabel(const string& newLabel) ;
00120 short int labelIndex() const ;
00121
00122 const string& label() const ;
00123
00124 virtual const ReferenceCell& refCell() const = 0;
00125
00126 virtual const Point& point(int i) const = 0 ;
00127
00128
00129
00130 void jacobian(const TSFArray<Point>& refpts,
00131 TSFArray<CellJacobian>& J) const ;
00132
00133
00134
00135
00136 void detJacobian(const TSFArray<Point>& refpts,
00137 TSFArray<double>& detJ) const ;
00138
00139
00140
00141 void constantJacobian(CellJacobian& J) const ;
00142
00143 void constantDetJacobian(double& detJ) const ;
00144
00145
00146
00147
00148 void pullBack(const TSFArray<Point>& phys,
00149 TSFArray<Point>& ref) const ;
00150 void pushFwd(const TSFArray<Point>& ref,
00151 TSFArray<Point>& phys) const ;
00152
00153
00154
00155 virtual void registerFacet(int dim, int facetNum, int facetCellIndex) = 0 ;
00156 virtual void registerCofacet(int d, int cofacetCellIndex) = 0 ;
00157
00158 ostream& print(ostream& os) const ;
00159 void textWrite(ostream& os) const ;
00160 string toString() const ;
00161
00162 virtual int byteCount() const = 0 ;
00163 virtual TSFArray<int> wastage() const {return 0;}
00164
00165 const MeshData* meshData() const {return meshData_;}
00166
00167 #ifndef NO_POOLMEM
00168 static void operator delete(void* p, size_t s);
00169 static void* operator new(size_t s);
00170 #endif
00171
00172 virtual int anchorIndex() const ;
00173 virtual int cofacetIndex() const ;
00174
00175
00176
00177 protected:
00178 bool permutedEqualityCheck(const TSFArray<int>& a1,
00179 const TSFArray<int>& a2) const ;
00180
00181
00182
00183
00184 MeshData* meshData_;
00185
00186
00187
00188 int localIndex_;
00189 int globalIndex_;
00190
00191
00192
00193
00194
00195
00196
00197
00198 static TSFArray<int> dummyRtn_;
00199 static TSFArray<TSFArray<int> > dummyRtn2_;
00200 static string dummystring_;
00201 };
00202
00203
00204
00205 }
00206 #endif
00207
00208
00209
00210
00211