Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

CellBase.h

Go to the documentation of this file.
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 /* #include "InvCellJacobian.h" */
00010 /* #include "InvCellHessian.h" */
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   /** \ingroup LowLevelGeometry
00026       Base class for cell implementations.
00027   */
00028 
00029   class CellBase
00030     {
00031     public:
00032       /** Construct with a pointer to the low-level mesh data structure
00033        * and a local index. This will be used to create IntermediateCells,
00034        * for which the global index is not known until the processor
00035        * synchronization step */
00036       CellBase(MeshData* meshData,
00037                int localIndex,
00038                short int /*labelInd*/)
00039         : meshData_(meshData), localIndex_(localIndex),
00040         globalIndex_(-1)
00041         {;}
00042       /** Construct with a pointer to the low-level mesh data structure,
00043        *  a local index, and a global index. This will be used to create
00044        *  maximal and zero cells whose global index is known at creation */
00045       CellBase(MeshData* meshData,
00046                int localIndex,
00047                int globalIndex,
00048                short int /*labelInd*/)
00049         : meshData_(meshData), localIndex_(localIndex),
00050         globalIndex_(globalIndex)
00051         {;}
00052       /** dtor */
00053       virtual ~CellBase(){;}
00054 
00055       /** identify self as zero cell or not */
00056       virtual bool isZeroCell() const {return false;}
00057       /** identify self as maximal cell or not */
00058       virtual bool isMaximalCell() const {return false;}
00059       /** identify self as affine cell or not */
00060       bool isAffine() const ;
00061       /** return a code describing my topology type */
00062       CellTopologyCode topologyCode() const ;
00063       /** typeid */
00064       const string& typeName() const ;
00065 
00066       /** return the rank of the processor that owns me */
00067       short int ownerProcID() const ;
00068       /** return my local index on the current processor */
00069       int localIndex() const {return localIndex_;}
00070       /** return my global index */
00071       int globalIndex() const {return globalIndex_;}
00072       /** set my global index */
00073       void setGlobalIndex(int globalIndex);
00074       /** return my dimension */
00075       virtual int dim() const = 0 ;
00076       /** return the dimension of the mesh in which I live */
00077       int meshDim() const ;
00078       /** return the ID number of the mesh in which I live */
00079       int meshID() const ;
00080 
00081       /** return the number of nodes defining this cell */
00082       virtual int numNodes() const = 0 ;
00083       /** return the number of vertices */
00084       virtual int numVertices() const = 0 ;
00085       /** get a list of the cell's node numbers */
00086       virtual void getNodes(TSFArray<int>& nodes) const = 0 ;
00087 
00088       /** return my node number (ZeroCell only) */
00089       virtual int node() const ;
00090       /** return a list of my node numbers (MaximalCell only) */
00091       virtual const TSFArray<int>& nodes() const ;
00092 
00093       /** return the number of d-facets */
00094       virtual int numFacets(int d) const = 0 ;
00095       /** return the number of d-cofacets */
00096       virtual int numCofacets(int d) const = 0 ;
00097 
00098       /** determine if my node list is identical to the given node list */
00099       virtual bool topologicallyEquals(const TSFArray<int>& otherNodes) const = 0 ;
00100 
00101       /** return the facetNumber-th facet of dimension dim */
00102       virtual const Cell& facet(int dim, int facetNumber) const = 0;
00103       /** return the cofacetNumber-th cofacet of dimension d */
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       //  virtual const TSFArray<TSFArray<int> >& facets() const ;
00113       virtual const FacetSetBase* facets() const ;
00114       // implemented for zeroCell only
00115       virtual const TSFArray<TSFArray<int> >& cofacetIndices() const ;
00116       virtual bool isBoundaryCell() const ;
00117 
00118       // labeling methods
00119       void setLabel(const string& newLabel) ;
00120       short int labelIndex() const ;//{return labelIndex_;}
00121       //    {return meshData_->labelIndices_[dim()][localIndex_];}
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       // mapping methods
00129 
00130       void jacobian(const TSFArray<Point>& refpts,
00131                     TSFArray<CellJacobian>& J) const ;
00132      /*  void invJacobian(const TSFArray<Point>& refpts, */
00133 /*                        TSFArray<InvCellJacobian>& invJ) const ; */
00134 /*       void invHessian(const TSFArray<Point>& refpts, */
00135 /*                       TSFArray<InvCellHessian>& invH) const ; */
00136       void detJacobian(const TSFArray<Point>& refpts,
00137                        TSFArray<double>& detJ) const ;
00138 
00139       // constant-Jacobian methods, for efficiency on affine cells.
00140       // No Hessian is needed since affine cells have zero hessian.
00141       void constantJacobian(CellJacobian& J) const ;
00142 /*       void constantInvJacobian(InvCellJacobian& invJ) const ; */
00143       void constantDetJacobian(double& detJ) const ;
00144 
00145       // mapping between physical and reference coordinates.
00146       // pullback means phys -> ref.
00147       // pushfwd means ref -> phys.
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       //virtual void setAnchorIndex(int anchorIndex);
00175       //  virtual void setCofacetIndex(int cofacetIndex);
00176 
00177     protected:
00178       bool permutedEqualityCheck(const TSFArray<int>& a1,
00179                                  const TSFArray<int>& a2) const ;
00180 
00181       // The mesh in which this cell lives.
00182       // This is an externally managed pointer, so don't delete it in
00183       // any methods of this class.
00184       MeshData* meshData_;
00185 
00186       // This cell's index in the mesh's local table of cells.
00187       // Cells are tabulated by (dimension, index).
00188       int localIndex_;   // index local to this processor
00189       int globalIndex_;  // index global across all processors
00190 
00191       // labeling: store an index into the mesh's table of labels.
00192       //  char labelIndex_;
00193 
00194       // ID number of the processor that owns this cell.
00195       // char ownerProcID_;
00196 
00197       // dummy -Wall return value for method nodes();
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 

Contact:
Kevin Long (krlong@ca.sandia.gov)


Documentation generated by