00001
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
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef CLIPPER_DERIVS
00046 #define CLIPPER_DERIVS
00047
00048
00049 #include "coords.h"
00050
00051
00052 namespace clipper
00053 {
00054 template<class T> class Grad_orth;
00055 template<class T> class Grad_frac;
00056 template<class T> class Grad_map;
00057 template<class T> class Curv_orth;
00058 template<class T> class Curv_frac;
00059 template<class T> class Curv_map;
00060
00061
00063 template<class T> class Grad_orth : public Vec3<T>
00064 {
00065 public:
00066 Grad_orth() {}
00067 explicit Grad_orth( const Vec3<T>& v ) :
00068 Vec3<T>( v ) {}
00069 Grad_orth( const T& dx, const T& dy, const T& dz ) :
00070 Vec3<T>( dx, dy, dz ) {}
00071 const T& dx() const { return (*this)[0]; }
00072 const T& dy() const { return (*this)[1]; }
00073 const T& dz() const { return (*this)[2]; }
00074
00075 Grad_frac<T> grad_frac( const Cell& cell ) const;
00076 String format() const;
00077 };
00078
00079
00081 template<class T> class Grad_frac : public Vec3<T>
00082 {
00083 public:
00084 Grad_frac() {}
00085 explicit Grad_frac( const Vec3<T>& v ) :
00086 Vec3<T>( v ) {}
00087 Grad_frac( const T& du, const T& dv, const T& dw ) :
00088 Vec3<T>( du, dv, dw ) {}
00089 const T& du() const { return (*this)[0]; }
00090 const T& dv() const { return (*this)[1]; }
00091 const T& dw() const { return (*this)[2]; }
00092
00093 Grad_orth<T> grad_orth( const Cell& cell ) const;
00095 Grad_map<T> grad_map( const Grid& g ) const;
00096 String format() const;
00097 };
00098
00099
00101 template<class T> class Grad_map : public Vec3<T>
00102 {
00103 public:
00104 Grad_map() {}
00105 explicit Grad_map( const Vec3<T>& v ) :
00106 Vec3<T>( v ) {}
00107 Grad_map( const T& du, const T& dv, const T& dw ) :
00108 Vec3<T>( du, dv, dw ) {}
00109 const T& du() const { return (*this)[0]; }
00110 const T& dv() const { return (*this)[1]; }
00111 const T& dw() const { return (*this)[2]; }
00112
00113 Grad_frac<T> grad_frac( const Grid& g ) const;
00114 String format() const;
00115 };
00116
00117
00119 template<class T> class Curv_orth : public Mat33<T>
00120 {
00121 public:
00122 Curv_orth() {}
00123 explicit Curv_orth( const Mat33<T>& m ) :
00124 Mat33<T>( m ) {}
00125
00126 Curv_frac<T> curv_frac( const Cell& cell ) const;
00127 };
00128
00129
00131 template<class T> class Curv_frac : public Mat33<T>
00132 {
00133 public:
00134 Curv_frac() {}
00135 explicit Curv_frac( const Mat33<T>& m ) :
00136 Mat33<T>( m ) {}
00137
00138 Curv_orth<T> curv_orth( const Cell& cell ) const;
00140 Curv_map<T> curv_map( const Grid& g ) const;
00141 };
00142
00143
00145 template<class T> class Curv_map : public Mat33<T>
00146 {
00147 public:
00148 Curv_map() {}
00149 explicit Curv_map( const Mat33<T>& m ) :
00150 Mat33<T>( m ) {}
00151
00152 Curv_frac<T> curv_frac( const Grid& g ) const;
00153 };
00154
00155
00156
00157
00158
00163 template<class T> String Grad_orth<T>::format() const
00164 { return "d/dx,d/dy,d/dz = ("+String(dx())+","+String(dy())+","+String(dz())+")"; }
00165
00167 template<class T> inline Grad_frac<T> Grad_orth<T>::grad_frac( const Cell& cell ) const
00168 { return Grad_frac<T>( (*this) * Mat33<T>( cell.matrix_orth() ) ); }
00169
00170
00172 template<class T> String Grad_frac<T>::format() const
00173 { return "d/du,d/dv,d/dw = ("+String(du())+","+String(dv())+","+String(dw())+")"; }
00174
00176 template<class T> inline Grad_orth<T> Grad_frac<T>::grad_orth( const Cell& cell ) const
00177 { return Grad_orth<T>( (*this) * Mat33<T>( cell.matrix_frac() ) ); }
00178
00180 template<class T> inline Grad_map<T> Grad_frac<T>::grad_map( const Grid& g ) const
00181 { return Grad_map<T>( du()/g.nu(), dv()/g.nv(), dw()/g.nw() ); }
00182
00183
00185 template<class T> String Grad_map<T>::format() const
00186 { return "d/du,d/dv,d/dw = ("+String(du())+","+String(dv())+","+String(dw())+")"; }
00187
00189 template<class T> inline Grad_frac<T> Grad_map<T>::grad_frac( const Grid& g ) const
00190 { return Grad_frac<T>( du()*g.nu(), dv()*g.nv(), dw()*g.nw() ); }
00191
00192
00194 template<class T> Curv_frac<T> Curv_orth<T>::curv_frac( const Cell& cell ) const
00195 {
00196 Mat33<T> m( cell.matrix_orth() );
00197 return Curv_frac<T>( m.transpose() * (*this) * m );
00198 }
00199
00200
00202 template<class T> Curv_orth<T> Curv_frac<T>::curv_orth( const Cell& cell ) const
00203 {
00204 Mat33<T> m( cell.matrix_frac() );
00205 return Curv_orth<T>( m.transpose() * (*this) * m );
00206 }
00207
00209 template<class T> Curv_map<T> Curv_frac<T>::curv_map( const Grid& g ) const
00210 {
00211 Curv_map<T> c;
00212 c(0,0) = (*this)(0,0) / T(g.nu()*g.nu());
00213 c(0,1) = (*this)(0,1) / T(g.nu()*g.nv());
00214 c(0,2) = (*this)(0,2) / T(g.nu()*g.nw());
00215 c(1,0) = (*this)(1,0) / T(g.nv()*g.nu());
00216 c(1,1) = (*this)(1,1) / T(g.nv()*g.nv());
00217 c(1,2) = (*this)(1,2) / T(g.nv()*g.nw());
00218 c(2,0) = (*this)(2,0) / T(g.nw()*g.nu());
00219 c(2,1) = (*this)(2,1) / T(g.nw()*g.nv());
00220 c(2,2) = (*this)(2,2) / T(g.nw()*g.nw());
00221 return c;
00222 }
00223
00224
00226 template<class T> Curv_frac<T> Curv_map<T>::curv_frac( const Grid& g ) const
00227 {
00228 Curv_frac<T> c;
00229 c(0,0) = (*this)(0,0) * T(g.nu()*g.nu());
00230 c(0,1) = (*this)(0,1) * T(g.nu()*g.nv());
00231 c(0,2) = (*this)(0,2) * T(g.nu()*g.nw());
00232 c(1,0) = (*this)(1,0) * T(g.nv()*g.nu());
00233 c(1,1) = (*this)(1,1) * T(g.nv()*g.nv());
00234 c(1,2) = (*this)(1,2) * T(g.nv()*g.nw());
00235 c(2,0) = (*this)(2,0) * T(g.nw()*g.nu());
00236 c(2,1) = (*this)(2,1) * T(g.nw()*g.nv());
00237 c(2,2) = (*this)(2,2) * T(g.nw()*g.nw());
00238 return c;
00239 }
00240
00241
00242 }
00243
00244 #endif