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

ReferenceCell.h

Go to the documentation of this file.
00001 #ifndef REFERENCECELL_H
00002 #define REFERENCECELL_H
00003 
00004 #include "SundanceDefs.h"
00005 
00006 #include "Pool.h"
00007 #include "TSFSmartPtr.h"
00008 #include "ReferenceCellBase.h"
00009 
00010 
00011 namespace Sundance
00012 {
00013 
00014   using namespace TSF;
00015   using std::string;
00016 
00017   using std::ostream;
00018 
00019   class Cell;
00020 
00021   class FacetSetBase;
00022 
00023 
00024   /**  \ingroup LowLevelGeometry
00025    *
00026    * A ReferenceCell contains the data and
00027    * methods that are common to all cells of a given geometry
00028    * type. The ReferenceCell class itself is a handle to a
00029    * ReferenceCellBase, from which geometry-specific subtypes are
00030    * derived.  ReferenceCell provides several types of service:
00031    * mapping between physical and reference coordinates, and
00032    * identification of facets
00033    */
00034 
00035   class ReferenceCell
00036     {
00037     public:
00038       /** empty ctor, for use in containers */
00039       ReferenceCell() : ptr_(0) {;}
00040       /** construct with a pointer to a derived type */
00041       ReferenceCell(ReferenceCellBase* ptr) : ptr_(ptr) {;}
00042 
00043 
00044       /** \name introspection */
00045       //@{
00046       /** get a name for this tpye of cell */
00047       const string& typeName() const {return ptr_->typeName();}
00048       /** get a topology identifier */
00049       CellTopologyCode topologyCode() const {return ptr_->topologyCode();}
00050 
00051       /** identify affine cells. Affine cells have constant Jacobians so
00052        * we can do simpler calculations in that case. */
00053       bool isAffine() const {return ptr_->isAffine();}
00054 
00055       /** get cell dimension */
00056       int dim() const {return ptr_->dim();}
00057       /** number of nodes */
00058       int numNodes() const {return ptr_->numNodes();}
00059       /** number of vertices (vertices are nodes which correspond to zero-cells) */
00060       int numVertices() const {return ptr_->numVertices();}
00061       /** number of facets of dimension d */
00062       int numFacets(int d) const {return ptr_->numFacets(d);}
00063 
00064       //@}
00065 
00066       /** \name faceting methods */
00067       //@{
00068 
00069       /** facetNodePtrs() returns a list of pointers to nodes for the facets
00070        * of dimension facetDim. They are organized as
00071        * facetNodes[facetNumber][nodeNumber]. The pointers are indices into
00072        * a cell's local array of nodes. */
00073       const TSFArray<TSFArray<int> >& facetNodePtrs(int facetDim) const
00074         {return ptr_->facetNodePtrs(facetDim);}
00075 
00076       /** facetFacetPtrs() returns a list of pointers to the facets of
00077        * the facet-num-th facet of dimension d. */
00078       const TSFArray<TSFArray<int> >& facetFacetPtrs(int d, int facetNum) const
00079         {return ptr_->facetFacetPtrs(d, facetNum);}
00080 
00081       /** return the reference cell for the given facet. */
00082       const ReferenceCell& facetReferenceCell(int facetDim,
00083                                               int facetNumber) const
00084         {return ptr_->facetReferenceCell(facetDim, facetNumber);}
00085 
00086       /** create a facet set */
00087       FacetSetBase* newFacetSet() const
00088         {return ptr_->newFacetSet();}
00089       //@}
00090 
00091       /**\name mappings and jacobians */
00092       //@{
00093       /** Jacobian computation, general maximal-dimension non-affine case. */
00094       void jacobian(const Cell& cell,
00095                     const TSFArray<Point>& refpts,
00096                     TSFArray<CellJacobian>& J) const ;
00097 
00098       /** Jacobian computation on embedded cells */
00099       void detJacobian(const Cell& cell,
00100                        const TSFArray<Point>& refpts,
00101                        TSFArray<double>& detJ) const ;
00102 
00103       /** constant-Jacobian, maximal-dimension computation,
00104        * for efficiency on affine cells. */
00105       void constantJacobian(const Cell& cell,
00106                             CellJacobian& J) const ;
00107 
00108       /** constant-Jacobian, embedded cell computation,
00109        * for efficiency on affine cells. */
00110       void constantDetJacobian(const Cell& cell,
00111                                double& detJ) const ;
00112 
00113       /** push forward (ref --> phys) */
00114       void pushFwd(const Cell& cell,
00115                    const TSFArray<Point>& ref,
00116                    TSFArray<Point>& phys) const ;
00117       //@}
00118 
00119       /** \name compute diameter of cell */
00120       double diameter(const Cell& cell) const ;
00121 
00122       /** \name compute outward normal of cell */
00123       Point normal(const Cell& cell) const ;
00124 
00125       /** \name memory management */
00126       //@{
00127       /** pooled new */
00128       static void* operator new(size_t s);
00129       /** pooled delete */
00130       static void operator delete(void* p);
00131       //@}
00132     private:
00133       TSFSmartPtr<ReferenceCellBase> ptr_;
00134       // memory pool
00135       static Pool memPool_;
00136     };
00137 
00138   inline void* ReferenceCell::operator new(size_t s)
00139     {
00140       if (s != sizeof(ReferenceCell))
00141         {
00142           return ::operator new(s);
00143         }
00144       return memPool_.alloc();
00145     }
00146 
00147   inline void ReferenceCell::operator delete(void* p)
00148     {
00149       memPool_.free(p);
00150     }
00151 }
00152 #endif
00153 
00154 

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


Documentation generated by