00001
00029 #ifndef SEGMENT
00030 #define SEGMENT
00031
00032 #include "AuxDefs.h"
00033 #include "ElementGeometry.h"
00034
00035 #include <cmath>
00036 #include <iostream>
00037 #include <cassert>
00038
00060 template<size_t SPD>
00061 class Segment:public AbstractGeom<SPD>
00062 {
00063 public:
00064 Segment (const std::vector<double> globalCoordVec, const std::vector<GlobalNodalIndex>& connectivity)
00065 :AbstractGeom<SPD> (globalCoordVec, connectivity) {
00066 assert (connectivity.size () == 2);
00067 }
00068
00069
00070 inline virtual ~Segment(){}
00071
00072 Segment(const Segment<SPD> & that) : AbstractGeom<SPD> (that) {
00073 }
00074
00075 virtual Segment<SPD>* clone() const {
00076 return new Segment<SPD>(*this);
00077 }
00078
00079 inline const size_t getNumVertices() const { return 2; }
00080
00081 inline const std::string getPolytopeName() const { return "SEGMENT"; }
00082
00083 inline const size_t getParametricDimension() const { return 1; }
00084
00085 inline const size_t getEmbeddingDimension() const { return SPD; }
00086
00089 void map(const double * X, double *Y) const;
00093 void dMap(const double * X, double *DY, double &Jac) const;
00094 inline size_t getNumFaces() const { return 2; }
00095
00097 ElementGeometry * getFaceGeometry(size_t e) const
00098 { std::cerr << "Segment<SPD>::getFaceGeometry. "
00099 "Not implemented!\n\n"; return 0; }
00100
00101 const double getInRadius(void) const{
00102 double l;
00103 l = 0.0;
00104 for(size_t i=0; i<SPD; i++) {
00105 l += (AbstractGeom<SPD>::getCoordinate(1,i) - AbstractGeom<SPD>::getCoordinate(0,i))*
00106 (AbstractGeom<SPD>::getCoordinate(1,i) - AbstractGeom<SPD>::getCoordinate(0,i)) ;
00107 }
00108
00109 return(0.5*sqrt(l));
00110 };
00111
00112 const double getOutRadius(void) const{
00113 return(getInRadius());
00114 };
00115
00116 virtual void computeNormal (size_t e, std::vector<double>& vNormal) const {
00117 std::cerr << "Segment::computeNormal not implemented yet" << std::endl;
00118 abort ();
00119 }
00120
00121
00122
00123 };
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 template<size_t SPD>
00134 void Segment<SPD>::map(const double * X, double *Y) const
00135 {
00136 for(size_t i=0; i<SPD; i++)
00137 Y[i] = X[0]*AbstractGeom<SPD>::getCoordinate(0,i) + (1-X[0])*AbstractGeom<SPD>::getCoordinate(1,i);
00138
00139 return;
00140 }
00141
00142
00143
00144
00145 template<size_t SPD>
00146 void Segment<SPD>::dMap(const double * X, double *DY, double &Jac) const
00147 {
00148 for(size_t i=0; i<SPD; i++)
00149 DY[i] = AbstractGeom<SPD>::getCoordinate(0,i) - AbstractGeom<SPD>::getCoordinate(1,i);
00150
00151 double g11=0;
00152
00153 for(size_t i=0; i<SPD; i++)
00154 g11 += DY[i]*DY[i];
00155
00156 Jac=sqrt(g11);
00157
00158 return;
00159 }
00160
00161
00162 #endif