00001 #ifndef CELLJACOBIAN_H
00002 #define CELLJACOBIAN_H
00003
00004 #include "SundanceDefs.h"
00005 #include "TSFError.h"
00006 #include <string>
00007
00008
00009 namespace Sundance
00010 {
00011
00012 using namespace TSF;
00013 using std::string;
00014
00015 using std::ostream;
00016
00017
00018
00019
00020
00021
00022 class CellJacobian
00023 {
00024 public:
00025
00026 inline CellJacobian();
00027
00028 inline CellJacobian(const double& Jxu);
00029
00030 inline CellJacobian(const double& Jxu, const double& Jxv,
00031 const double& Jyu, const double& Jyv);
00032
00033 inline CellJacobian(const double& Jxu, const double& Jxv, const double& Jxw,
00034 const double& Jyu, const double& Jyv, const double& Jyw,
00035 const double& Jzu, const double& Jzv, const double& Jzw);
00036
00037 inline CellJacobian(const CellJacobian& other);
00038
00039 inline CellJacobian& operator=(const CellJacobian& other);
00040
00041
00042 inline const double& operator()(int phys, int ref) const ;
00043
00044 inline int dim() const {return dim_;}
00045
00046
00047 static bool unitTest() ;
00048 private:
00049 inline void boundsCheck(int i, int j) const ;
00050 double J_[9];
00051 int dim_;
00052 };
00053
00054 ostream& operator<<(ostream& os, CellJacobian& J);
00055
00056 inline CellJacobian::CellJacobian()
00057 : dim_(0)
00058 {
00059 ;
00060 }
00061
00062 inline CellJacobian::CellJacobian(const double& Jxu)
00063 : dim_(1)
00064 {
00065 J_[0] = Jxu;
00066 }
00067
00068
00069 inline CellJacobian::CellJacobian(const double& Jxu, const double& Jxv,
00070 const double& Jyu, const double& Jyv)
00071 : dim_(2)
00072 {
00073 J_[0] = Jxu;
00074 J_[1] = Jxv;
00075 J_[2] = Jyu;
00076 J_[3] = Jyv;
00077 }
00078
00079
00080
00081 inline CellJacobian::CellJacobian(const double& Jxu, const double& Jxv,
00082 const double& Jxw,
00083 const double& Jyu, const double& Jyv,
00084 const double& Jyw,
00085 const double& Jzu, const double& Jzv,
00086 const double& Jzw)
00087 : dim_(3)
00088 {
00089 J_[0] = Jxu;
00090 J_[1] = Jxv;
00091 J_[2] = Jxw;
00092 J_[3] = Jyu;
00093 J_[4] = Jyv;
00094 J_[5] = Jyw;
00095 J_[6] = Jzu;
00096 J_[7] = Jzv;
00097 J_[8] = Jzw;
00098 }
00099
00100 inline CellJacobian::CellJacobian(const CellJacobian& other)
00101 : dim_(other.dim_)
00102 {
00103 int n = dim_*dim_;
00104 for (int i=0; i<n; i++) J_[i] = other.J_[i];
00105 }
00106
00107 inline CellJacobian& CellJacobian::operator=(const CellJacobian& other)
00108 {
00109 if (this == &other) return *this;
00110
00111 dim_ = other.dim_;
00112
00113 int n = dim_*dim_;
00114 for (int i=0; i<n; i++) J_[i] = other.J_[i];
00115
00116 return *this;
00117 }
00118
00119 inline void CellJacobian::boundsCheck(int phys, int ref) const
00120 {
00121 if (phys >= dim_ || ref >= dim_) TSFError::raise("CellJacobian bounds error");
00122 }
00123
00124 inline const double& CellJacobian::operator()(int phys, int ref) const
00125 {
00126 #ifndef NOBOUNDSCHECK
00127 boundsCheck(phys, ref);
00128 #endif
00129 return J_[ref + dim_*phys];
00130 }
00131
00132
00133
00134
00135
00136
00137
00138 }
00139 #endif