00001
00008 #ifndef _CSAR_GenericElement_H_
00009 #define _CSAR_GenericElement_H_
00010
00011 #include "ckvector3d.h"
00012 typedef CkVector3d CVector;
00013 typedef CkVector3d CPoint;
00014
00019 class ConcreteElement {
00020 public:
00022 virtual CPoint getNodeLocation(int i) const =0;
00023 };
00024
00028 class ConcreteElementNodeData : public ConcreteElement {
00029 public:
00031 virtual const double *getNodeData(int i) const =0;
00032 };
00033
00047 class GenericElement {
00048 protected:
00049 enum {maxSize=20};
00050 unsigned int _size;
00051 public:
00052 GenericElement(unsigned int s = 4)
00053 : _size(s)
00054 {};
00055 unsigned int size() const
00056 {
00057 return(_size);
00058 };
00059 unsigned int nedges() const
00060 {
00061 switch(_size){
00062 case 4:
00063 case 10:
00064 return (6);
00065 case 8:
00066 case 20:
00067 return (12);
00068 default:
00069 return(0);
00070 }
00071 return(0);
00072 };
00073 unsigned int nfaces() const
00074 {
00075 switch(_size){
00076 case 4:
00077 case 10:
00078 return(4);
00079 case 8:
00080 case 20:
00081 return(6);
00082 default:
00083 return(0);
00084 }
00085 return(0);
00086 };
00087 void shape_func(const CVector &natc,
00088 double []) const;
00089 void dshape_func(const CVector &natc,
00090 double [][3]) const;
00091 void jacobian(const CPoint p[],
00092 const CVector &natc,
00093 CVector J[]) const;
00094
00096 void interpolate_natural(int nValuesPerNode,
00097 const ConcreteElementNodeData &src,
00098 const CVector &nc,
00099 double *dest) const;
00100
00102 bool interpolate(int nValuesPerNode,
00103 const ConcreteElementNodeData &src,
00104 const CPoint &p,
00105 double *dest) const
00106 {
00107 CVector natc;
00108 if (!element_contains_point(p,src,natc)) return false;
00109 interpolate_natural(nValuesPerNode,src,natc,dest);
00110 return true;
00111 }
00112
00115 bool element_contains_point(const CPoint &p,
00116 const ConcreteElement &e,
00117 CVector &natc) const;
00118
00120 void shapef_jacobian_at(const CPoint &p,
00121 CVector &natc,
00122 const ConcreteElement &e,
00123 CVector &fvec,CVector fjac[]) const;
00124
00125 };
00126
00127 #endif