00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __TRIANG3_H
00036 #define __TRIANG3_H
00037
00038 #include <math.h>
00039 #include <float.h>
00040 #include <stdlib.h>
00041
00042 #include "OFELI_Config.h"
00043 #include "FEShape.h"
00044
00045 namespace OFELI {
00046
00051 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00052 struct ErrorInTriang3 {
00053 void Message(const char *file, size_t line, int code, int p1) const;
00054 };
00055 #endif
00056
00065 class Triang3 : public FEShape
00066 {
00067
00068 public :
00069
00071 Triang3();
00072
00075 Triang3(const Element *element);
00076
00079 Triang3(const Side *side);
00080
00082 ~Triang3()
00083 {
00084 #ifdef _OFELI_DEBUG
00085 std::clog << "An instance of class Triang3 is destructed.\n";
00086 std::clog << "File : " << __FILE__ << ", Line : " << __LINE__ << endl;
00087 #endif
00088 }
00089
00094 double Sh(size_t i, Point<double> s) const
00095 {
00096 #ifdef _BOUNDS_DEBUG
00097 assert(i>0);
00098 assert(i<=3);
00099 #endif
00100 switch (i) {
00101 case 1 : return (1.-s.x-s.y);
00102 case 2 : return s.x;
00103 case 3 : return s.y;
00104 }
00105 return 0;
00106 }
00107
00109 Point<double> DSh(size_t i) const
00110 {
00111 #ifdef _BOUNDS_DEBUG
00112 assert(i>0);
00113 assert(i<=3);
00114 #endif
00115 return _dsh[i-1];
00116 }
00117
00119 double getArea() { return _area=0.5*_det; }
00120
00122 Point<double> getCenter() const { return _c; }
00123
00125 Point<double> getCircumcenter() const;
00126
00128 Point<double> getRefCoord(const Point<double> &x);
00129
00131 double getMaxEdgeLength() const;
00132
00134 double getMinEdgeLength() const;
00135
00137 bool isIn(const Point<double> &x);
00138
00140 bool isStrictlyIn(const Point<double> &x);
00141
00143 double getInterpolate(const Point<double> &x, const LocalVect<double,3> &v);
00144
00152 double check() const;
00153
00154 private :
00155
00156 double _area;
00157 Point<double> _c;
00158 const Element *_el;
00159 const Side *_sd;
00160 ErrorInTriang3 _e;
00161 };
00162
00163
00164 template<class T_> struct Point;
00165 template<class T_,size_t N_> class LocalVect;
00166
00173 template<class T_>
00174 inline Point<T_> gradient(const Triang3 &fe, const class LocalVect<T_,3> &u)
00175 {
00176 return (u[0]*fe.DSh(1) + u[1]*fe.DSh(2) + u[2]*fe.DSh(3));
00177 }
00178
00179
00187 template<class T_>
00188 inline T_ interpolate(const Triang3 &fe, const LocalVect<T_,3> &u, const T_ &s)
00189 {
00190 return (u[0]*Sh(1,s) + u[1]*Sh(2,s) + u[2]*fe.Sh(3,s));
00191 }
00192
00193 }
00194
00195 #endif