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 namespace Foam
00030 {
00031
00032
00033
00034
00035 template <class Cmpt>
00036 inline SphericalTensor<Cmpt>::SphericalTensor()
00037 {}
00038
00039
00040
00041 template <class Cmpt>
00042 inline SphericalTensor<Cmpt>::SphericalTensor
00043 (
00044 const VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>& vs
00045 )
00046 :
00047 VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(vs)
00048 {}
00049
00050
00051
00052 template <class Cmpt>
00053 inline SphericalTensor<Cmpt>::SphericalTensor(const Cmpt& stii)
00054 {
00055 this->v_[II] = stii;
00056 }
00057
00058
00059
00060 template <class Cmpt>
00061 inline SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
00062 :
00063 VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(is)
00064 {}
00065
00066
00067
00068
00069 template <class Cmpt>
00070 inline const Cmpt& SphericalTensor<Cmpt>::ii() const
00071 {
00072 return this->v_[II];
00073 }
00074
00075
00076 template <class Cmpt>
00077 inline Cmpt& SphericalTensor<Cmpt>::ii()
00078 {
00079 return this->v_[II];
00080 }
00081
00082
00083
00084
00085 template <class Cmpt>
00086 inline Tensor<Cmpt>
00087 operator+(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00088 {
00089 return Tensor<Cmpt>
00090 (
00091 st1.ii() + t2.xx(), t2.xy(), t2.xz(),
00092 t2.yx(), st1.ii() + t2.yy(), t2.yz(),
00093 t2.zx(), t2.zy(), st1.ii() + t2.zz()
00094 );
00095 }
00096
00097
00098 template <class Cmpt>
00099 inline Tensor<Cmpt>
00100 operator+(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
00101 {
00102 return Tensor<Cmpt>
00103 (
00104 t1.xx() + st2.ii(), t1.xy(), t1.xz(),
00105 t1.yx(), t1.yy() + st2.ii(), t1.yz(),
00106 t1.zx(), t1.zy(), t1.zz() + st2.ii()
00107 );
00108 }
00109
00110
00111 template <class Cmpt>
00112 inline Tensor<Cmpt>
00113 operator-(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00114 {
00115 return Tensor<Cmpt>
00116 (
00117 st1.ii() - t2.xx(), -t2.xy(), -t2.xz(),
00118 -t2.yx(), st1.ii() - t2.yy(), -t2.yz(),
00119 -t2.zx(), -t2.zy(), st1.ii() - t2.zz()
00120 );
00121 }
00122
00123
00124 template <class Cmpt>
00125 inline Tensor<Cmpt>
00126 operator-(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
00127 {
00128 return Tensor<Cmpt>
00129 (
00130 t1.xx() - st2.ii(), t1.xy(), t1.xz(),
00131 t1.yx(), t1.yy() - st2.ii(), t1.yz(),
00132 t1.zx(), t1.zy(), t1.zz() - st2.ii()
00133 );
00134 }
00135
00136
00137
00138 template <class Cmpt>
00139 inline SphericalTensor<Cmpt>
00140 operator&(const SphericalTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& st2)
00141 {
00142 return SphericalTensor<Cmpt>(st1.ii()*st2.ii());
00143 }
00144
00145
00146
00147 template <class Cmpt>
00148 inline Tensor<Cmpt>
00149 operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00150 {
00151 return Tensor<Cmpt>
00152 (
00153 st1.ii()*t2.xx(),
00154 st1.ii()*t2.xy(),
00155 st1.ii()*t2.xz(),
00156
00157 st1.ii()*t2.yx(),
00158 st1.ii()*t2.yy(),
00159 st1.ii()*t2.yz(),
00160
00161 st1.ii()*t2.zx(),
00162 st1.ii()*t2.zy(),
00163 st1.ii()*t2.zz()
00164 );
00165 }
00166
00167
00168
00169 template <class Cmpt>
00170 inline Tensor<Cmpt>
00171 operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
00172 {
00173 return Tensor<Cmpt>
00174 (
00175 t1.xx()*st2.ii(),
00176 t1.xy()*st2.ii(),
00177 t1.xz()*st2.ii(),
00178
00179 t1.yx()*st2.ii(),
00180 t1.yy()*st2.ii(),
00181 t1.yz()*st2.ii(),
00182
00183 t1.zx()*st2.ii(),
00184 t1.zy()*st2.ii(),
00185 t1.zz()*st2.ii()
00186 );
00187 }
00188
00189
00190
00191 template <class Cmpt>
00192 inline Vector<Cmpt>
00193 operator&(const SphericalTensor<Cmpt>& st, const Vector<Cmpt>& v)
00194 {
00195 return Vector<Cmpt>
00196 (
00197 st.ii()*v.x(),
00198 st.ii()*v.y(),
00199 st.ii()*v.z()
00200 );
00201 }
00202
00203
00204
00205 template <class Cmpt>
00206 inline Vector<Cmpt>
00207 operator&(const Vector<Cmpt>& v, const SphericalTensor<Cmpt>& st)
00208 {
00209 return Vector<Cmpt>
00210 (
00211 v.x()*st.ii(),
00212 v.y()*st.ii(),
00213 v.z()*st.ii()
00214 );
00215 }
00216
00217
00218
00219 template <class Cmpt>
00220 inline SphericalTensor<Cmpt>
00221 operator/(const scalar s, const SphericalTensor<Cmpt>& st)
00222 {
00223 return SphericalTensor<Cmpt>(s/st.ii());
00224 }
00225
00226
00227
00228 template <class Cmpt>
00229 inline scalar tr(const SphericalTensor<Cmpt>& st)
00230 {
00231 return 3*st.ii();
00232 }
00233
00234
00235
00236 template <class Cmpt>
00237 inline scalar det(const SphericalTensor<Cmpt>& st)
00238 {
00239 return st.ii()*st.ii()*st.ii();
00240 }
00241
00242
00243
00244 template <class Cmpt>
00245 inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st)
00246 {
00247 return SphericalTensor<Cmpt>(1.0/st.ii());
00248 }
00249
00250
00251
00252 template <class Cmpt>
00253 inline Tensor<Cmpt> dev(const Tensor<Cmpt>& t)
00254 {
00255 return t - SphericalTensor<Cmpt>::oneThirdI*tr(t);
00256 }
00257
00258
00259
00260 template <class Cmpt>
00261 inline Tensor<Cmpt> dev2(const Tensor<Cmpt>& t)
00262 {
00263 return t - SphericalTensor<Cmpt>::twoThirdsI*tr(t);
00264 }
00265
00266
00267 template<class Cmpt>
00268 class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt> >
00269 {
00270 public:
00271
00272 typedef Tensor<Cmpt> type;
00273 };
00274
00275 template<class Cmpt>
00276 class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt> >
00277 {
00278 public:
00279
00280 typedef Tensor<Cmpt> type;
00281 };
00282
00283
00284 template<class Cmpt>
00285 class outerProduct<SphericalTensor<Cmpt>, Cmpt>
00286 {
00287 public:
00288
00289 typedef SphericalTensor<Cmpt> type;
00290 };
00291
00292 template<class Cmpt>
00293 class outerProduct<Cmpt, SphericalTensor<Cmpt> >
00294 {
00295 public:
00296
00297 typedef SphericalTensor<Cmpt> type;
00298 };
00299
00300
00301 template<class Cmpt>
00302 class innerProduct<SphericalTensor<Cmpt>, SphericalTensor<Cmpt> >
00303 {
00304 public:
00305
00306 typedef SphericalTensor<Cmpt> type;
00307 };
00308
00309 template<class Cmpt>
00310 class innerProduct<SphericalTensor<Cmpt>, Tensor<Cmpt> >
00311 {
00312 public:
00313
00314 typedef Tensor<Cmpt> type;
00315 };
00316
00317 template<class Cmpt>
00318 class innerProduct<Tensor<Cmpt>, SphericalTensor<Cmpt> >
00319 {
00320 public:
00321
00322 typedef Tensor<Cmpt> type;
00323 };
00324
00325 template<class Cmpt>
00326 class innerProduct<SphericalTensor<Cmpt>, Vector<Cmpt> >
00327 {
00328 public:
00329
00330 typedef Vector<Cmpt> type;
00331 };
00332
00333 template<class Cmpt>
00334 class innerProduct<Vector<Cmpt>, SphericalTensor<Cmpt> >
00335 {
00336 public:
00337
00338 typedef Vector<Cmpt> type;
00339 };
00340
00341
00342
00343
00344 }
00345
00346