vtf-logo

SimplexJac.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_SimplexJac_h__)
00009 #define __geom_SimplexJac_h__
00010 
00011 #if defined(DEBUG_geom) && !defined(DEBUG_SimplexJac)
00012 #define DEBUG_SimplexJac
00013 #endif
00014 
00015 #include "geometry.h"
00016 
00017 #include "../../../ads/tensor/SquareMatrix.h"
00018 
00019 BEGIN_NAMESPACE_GEOM
00020 
00022 
00129 template<int N, typename T = double>
00130 class SimplexJac {
00131 public:
00132 
00133   //
00134   // public typedefs
00135   //
00136 
00138   typedef T Number;
00139 
00141   typedef ads::FixedArray<N,Number> Vertex;
00142 
00144   typedef Simplex<N,Vertex,Number> Simplex;
00145 
00147   typedef ads::SquareMatrix<N,Number> Matrix;
00148 
00149 private:
00150 
00151   //
00152   // Member data.
00153   //
00154 
00155   // The Jacobian matrix that maps the identity simplex to this 
00156   // simplex (after the first vertex has been translated to the origin.)
00157   Matrix _matrix;
00158 
00159   // The determinant of _matrix.
00160   Number _determinant;
00161 
00162   // The gradient of the determinant of the Jacobian matrix.
00163   Vertex _gradientDeterminant;
00164 
00165   //
00166   // Static member data.
00167   //
00168 
00169   // The Jacobian matrix that maps the identity simplex to the reference 
00170   // simplex.  In 2-D, it maps the identity triangle:
00171   // (0,0), (1,0), (1/2,sqrt(3)/2)
00172   // to the reference triangle:
00173   // (0,0), (1,0), (0,1).
00174   // In 3-D it maps the identity tetrahedron:
00175   // (0,0,0), (1,0,0), (1/2,sqrt(3)/2,0), (1/2,sqrt(3)/6,sqrt(2)/sqrt(3))
00176   // to the reference tetrahedron:
00177   // (0,0,0), (1,0,0), (0,1,0), (0,0,1).
00178   static Matrix _identityToReference;
00179 
00180   // The gradient of the Jacobian matrix.
00181   static ads::FixedArray<N,Matrix> _gradientMatrix;
00182 
00183   // The determinant of _identityToReference;
00184   static Number _determinantIdentityToReference;
00185 
00186   // N!
00187   static Number _nFactorial;
00188 
00189 public:
00190 
00191   //--------------------------------------------------------------------------
00194 
00196   SimplexJac() :
00197     _matrix(),
00198     _determinant(),
00199     _gradientDeterminant()
00200   {}
00201 
00203   SimplexJac(const SimplexJac& other) :
00204     _matrix(other._matrix),
00205     _determinant(other._determinant),
00206     _gradientDeterminant(other._gradientDeterminant)
00207   {}
00208 
00209 
00211   SimplexJac(const Simplex& s) {
00212     set(s);
00213   }
00214 
00216   SimplexJac& 
00217   operator=(const SimplexJac& other) {
00218     if (&other != this) {
00219       _matrix = other._matrix;
00220       _determinant = other._determinant;
00221       _gradientDeterminant = other._gradientDeterminant;
00222     }
00223     return *this;
00224   }
00225   
00227   ~SimplexJac()
00228   {}
00229 
00231   //--------------------------------------------------------------------------
00234 
00236   const Matrix&
00237   getMatrix() const {
00238     return _matrix;
00239   }
00240 
00242   const ads::FixedArray<N,Matrix>&
00243   getGradientMatrix() const {
00244     return _gradientMatrix;
00245   }
00246 
00248   Number
00249   getDeterminant() const {
00250     return _determinant;
00251   }
00252 
00254   const Vertex&
00255   getGradientDeterminant() const {
00256     return _gradientDeterminant;
00257   }
00258 
00260   Number
00261   computeContent() const {
00262     return _determinant / _nFactorial / _determinantIdentityToReference;
00263   }
00264 
00266   void
00267   computeGradientContent(Vertex* grad) const {
00268     *grad = _gradientDeterminant;
00269     *grad /= (_nFactorial * _determinantIdentityToReference);
00270   }
00271 
00273   Vertex
00274   computeGradientContent() const {
00275     Vertex grad;
00276     computeGradientContent(&grad);
00277     return grad;
00278   }
00279 
00281   //--------------------------------------------------------------------------
00284 
00286   void
00287   setFunction(const Simplex& s);
00288 
00290   void
00291   set(const Simplex& s);
00292 
00293   // CONTINUE: These kind of functions do not know the orientation of the 
00294   // simplex.  A 3-2 mesh could become tangled and still have high quality.
00296 
00300   void
00301   setFunction(const geom::Simplex<N,ads::FixedArray<N+1,Number>,Number>& s);
00302 
00304 
00307   void
00308   set(const geom::Simplex<N,ads::FixedArray<N+1,Number>,Number>& s);
00309 
00311 
00312 };
00313 
00314 END_NAMESPACE_GEOM
00315 
00316 #define __geom_SimplexJac_ipp__
00317 #include "SimplexJac.ipp"
00318 #undef __geom_SimplexJac_ipp__
00319 
00320 #endif

Generated on Fri Aug 24 12:55:58 2007 for Computational Geometry Package by  doxygen 1.4.7