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 Tensor<Cmpt>::Tensor()
00037 {}
00038
00039
00040
00041 template <class Cmpt>
00042 inline Tensor<Cmpt>::Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>& vs)
00043 :
00044 VectorSpace<Tensor<Cmpt>, Cmpt, 9>(vs)
00045 {}
00046
00047
00048
00049 template <class Cmpt>
00050 inline Tensor<Cmpt>::Tensor(const SphericalTensor<Cmpt>& st)
00051 {
00052 this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
00053 this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0;
00054 this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii();
00055 }
00056
00057
00058
00059 template <class Cmpt>
00060 inline Tensor<Cmpt>::Tensor(const SymmTensor<Cmpt>& st)
00061 {
00062 this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
00063 this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz();
00064 this->v_[ZX] = st.xz(); this->v_[ZY] = st.yz(); this->v_[ZZ] = st.zz();
00065 }
00066
00067
00068
00069 template <class Cmpt>
00070 inline Tensor<Cmpt>::Tensor
00071 (
00072 const Cmpt txx, const Cmpt txy, const Cmpt txz,
00073 const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
00074 const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
00075 )
00076 {
00077 this->v_[XX] = txx; this->v_[XY] = txy; this->v_[XZ] = txz;
00078 this->v_[YX] = tyx; this->v_[YY] = tyy; this->v_[YZ] = tyz;
00079 this->v_[ZX] = tzx; this->v_[ZY] = tzy; this->v_[ZZ] = tzz;
00080 }
00081
00082
00083
00084 template <class Cmpt>
00085 inline Tensor<Cmpt>::Tensor(Istream& is)
00086 :
00087 VectorSpace<Tensor<Cmpt>, Cmpt, 9>(is)
00088 {}
00089
00090
00091
00092
00093 template <class Cmpt>
00094 inline const Vector<Cmpt>& Tensor<Cmpt>::x() const
00095 {
00096 return reinterpret_cast<const Vector<Cmpt>&>(this->v_[XX]);
00097 }
00098
00099 template <class Cmpt>
00100 inline const Vector<Cmpt>& Tensor<Cmpt>::y() const
00101 {
00102 return reinterpret_cast<const Vector<Cmpt>&>(this->v_[YX]);
00103 }
00104
00105 template <class Cmpt>
00106 inline const Vector<Cmpt>& Tensor<Cmpt>::z() const
00107 {
00108 return reinterpret_cast<const Vector<Cmpt>&>(this->v_[ZX]);
00109 }
00110
00111
00112 template <class Cmpt>
00113 inline Vector<Cmpt>& Tensor<Cmpt>::x()
00114 {
00115 return reinterpret_cast<Vector<Cmpt>&>(this->v_[XX]);
00116 }
00117
00118 template <class Cmpt>
00119 inline Vector<Cmpt>& Tensor<Cmpt>::y()
00120 {
00121 return reinterpret_cast<Vector<Cmpt>&>(this->v_[YX]);
00122 }
00123
00124 template <class Cmpt>
00125 inline Vector<Cmpt>& Tensor<Cmpt>::z()
00126 {
00127 return reinterpret_cast<Vector<Cmpt>&>(this->v_[ZX]);
00128 }
00129
00130
00131 template <class Cmpt>
00132 inline const Cmpt& Tensor<Cmpt>::xx() const
00133 {
00134 return this->v_[XX];
00135 }
00136
00137 template <class Cmpt>
00138 inline const Cmpt& Tensor<Cmpt>::xy() const
00139 {
00140 return this->v_[XY];
00141 }
00142
00143 template <class Cmpt>
00144 inline const Cmpt& Tensor<Cmpt>::xz() const
00145 {
00146 return this->v_[XZ];
00147 }
00148
00149
00150 template <class Cmpt>
00151 inline const Cmpt& Tensor<Cmpt>::yx() const
00152 {
00153 return this->v_[YX];
00154 }
00155
00156 template <class Cmpt>
00157 inline const Cmpt& Tensor<Cmpt>::yy() const
00158 {
00159 return this->v_[YY];
00160 }
00161
00162 template <class Cmpt>
00163 inline const Cmpt& Tensor<Cmpt>::yz() const
00164 {
00165 return this->v_[YZ];
00166 }
00167
00168
00169 template <class Cmpt>
00170 inline const Cmpt& Tensor<Cmpt>::zx() const
00171 {
00172 return this->v_[ZX];
00173 }
00174
00175 template <class Cmpt>
00176 inline const Cmpt& Tensor<Cmpt>::zy() const
00177 {
00178 return this->v_[ZY];
00179 }
00180
00181 template <class Cmpt>
00182 inline const Cmpt& Tensor<Cmpt>::zz() const
00183 {
00184 return this->v_[ZZ];
00185 }
00186
00187
00188 template <class Cmpt>
00189 inline Cmpt& Tensor<Cmpt>::xx()
00190 {
00191 return this->v_[XX];
00192 }
00193
00194 template <class Cmpt>
00195 inline Cmpt& Tensor<Cmpt>::xy()
00196 {
00197 return this->v_[XY];
00198 }
00199
00200 template <class Cmpt>
00201 inline Cmpt& Tensor<Cmpt>::xz()
00202 {
00203 return this->v_[XZ];
00204 }
00205
00206
00207 template <class Cmpt>
00208 inline Cmpt& Tensor<Cmpt>::yx()
00209 {
00210 return this->v_[YX];
00211 }
00212
00213 template <class Cmpt>
00214 inline Cmpt& Tensor<Cmpt>::yy()
00215 {
00216 return this->v_[YY];
00217 }
00218
00219 template <class Cmpt>
00220 inline Cmpt& Tensor<Cmpt>::yz()
00221 {
00222 return this->v_[YZ];
00223 }
00224
00225
00226 template <class Cmpt>
00227 inline Cmpt& Tensor<Cmpt>::zx()
00228 {
00229 return this->v_[ZX];
00230 }
00231
00232 template <class Cmpt>
00233 inline Cmpt& Tensor<Cmpt>::zy()
00234 {
00235 return this->v_[ZY];
00236 }
00237
00238 template <class Cmpt>
00239 inline Cmpt& Tensor<Cmpt>::zz()
00240 {
00241 return this->v_[ZZ];
00242 }
00243
00244
00245
00246 template <class Cmpt>
00247 inline Tensor<Cmpt> Tensor<Cmpt>::T() const
00248 {
00249 return Tensor<Cmpt>
00250 (
00251 xx(), yx(), zx(),
00252 xy(), yy(), zy(),
00253 xz(), yz(), zz()
00254 );
00255 }
00256
00257
00258
00259
00260 template <class Cmpt>
00261 inline void Tensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st)
00262 {
00263 this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
00264 this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0;
00265 this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii();
00266 }
00267
00268
00269 template <class Cmpt>
00270 inline void Tensor<Cmpt>::operator=(const SymmTensor<Cmpt>& st)
00271 {
00272 this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
00273 this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz();
00274 this->v_[ZX] = st.xz(); this->v_[ZY] = st.yz(); this->v_[ZZ] = st.zz();
00275 }
00276
00277
00278
00279
00280
00281 template <class Cmpt>
00282 inline Vector<Cmpt> operator*(const Tensor<Cmpt>& t)
00283 {
00284 return Vector<Cmpt>(t.yz(), -t.xz(), t.xy());
00285 }
00286
00287
00288
00289 template <class Cmpt>
00290 inline Tensor<Cmpt> operator*(const Vector<Cmpt>& v)
00291 {
00292 return Tensor<Cmpt>
00293 (
00294 0, -v.z(), v.y(),
00295 v.z(), 0, -v.x(),
00296 -v.y(), v.x(), 0
00297 );
00298 }
00299
00300
00301
00302 template <class Cmpt>
00303 inline typename innerProduct<Tensor<Cmpt>, Tensor<Cmpt> >::type
00304 operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
00305 {
00306 return Tensor<Cmpt>
00307 (
00308 t1.xx()*t2.xx() + t1.xy()*t2.yx() + t1.xz()*t2.zx(),
00309 t1.xx()*t2.xy() + t1.xy()*t2.yy() + t1.xz()*t2.zy(),
00310 t1.xx()*t2.xz() + t1.xy()*t2.yz() + t1.xz()*t2.zz(),
00311
00312 t1.yx()*t2.xx() + t1.yy()*t2.yx() + t1.yz()*t2.zx(),
00313 t1.yx()*t2.xy() + t1.yy()*t2.yy() + t1.yz()*t2.zy(),
00314 t1.yx()*t2.xz() + t1.yy()*t2.yz() + t1.yz()*t2.zz(),
00315
00316 t1.zx()*t2.xx() + t1.zy()*t2.yx() + t1.zz()*t2.zx(),
00317 t1.zx()*t2.xy() + t1.zy()*t2.yy() + t1.zz()*t2.zy(),
00318 t1.zx()*t2.xz() + t1.zy()*t2.yz() + t1.zz()*t2.zz()
00319 );
00320 }
00321
00322
00323
00324 template <class Cmpt>
00325 inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt> >::type
00326 operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
00327 {
00328 return Vector<Cmpt>
00329 (
00330 t.xx()*v.x() + t.xy()*v.y() + t.xz()*v.z(),
00331 t.yx()*v.x() + t.yy()*v.y() + t.yz()*v.z(),
00332 t.zx()*v.x() + t.zy()*v.y() + t.zz()*v.z()
00333 );
00334 }
00335
00336
00337
00338 template <class Cmpt>
00339 inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt> >::type
00340 operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
00341 {
00342 return Vector<Cmpt>
00343 (
00344 v.x()*t.xx() + v.y()*t.yx() + v.z()*t.zx(),
00345 v.x()*t.xy() + v.y()*t.yy() + v.z()*t.zy(),
00346 v.x()*t.xz() + v.y()*t.yz() + v.z()*t.zz()
00347 );
00348 }
00349
00350
00351
00352 template <class Cmpt>
00353 inline typename outerProduct<Vector<Cmpt>, Vector<Cmpt> >::type
00354 operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
00355 {
00356 return Tensor<Cmpt>
00357 (
00358 v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
00359 v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
00360 v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
00361 );
00362 }
00363
00364
00365
00366
00367
00368 template <class Cmpt>
00369 inline Cmpt tr(const Tensor<Cmpt>& t)
00370 {
00371 return t.xx() + t.yy() + t.zz();
00372 }
00373
00374
00375
00376 template <class Cmpt>
00377 inline SphericalTensor<Cmpt> sph(const Tensor<Cmpt>& t)
00378 {
00379 return (1.0/3.0)*tr(t);
00380 }
00381
00382
00383
00384 template <class Cmpt>
00385 inline SymmTensor<Cmpt> symm(const Tensor<Cmpt>& t)
00386 {
00387 return SymmTensor<Cmpt>
00388 (
00389 t.xx(), 0.5*(t.xy() + t.yx()), 0.5*(t.xz() + t.zx()),
00390 t.yy(), 0.5*(t.yz() + t.zy()),
00391 t.zz()
00392 );
00393 }
00394
00395
00396
00397 template <class Cmpt>
00398 inline SymmTensor<Cmpt> twoSymm(const Tensor<Cmpt>& t)
00399 {
00400 return SymmTensor<Cmpt>
00401 (
00402 2*t.xx(), (t.xy() + t.yx()), (t.xz() + t.zx()),
00403 2*t.yy(), (t.yz() + t.zy()),
00404 2*t.zz()
00405 );
00406 }
00407
00408
00409
00410 template <class Cmpt>
00411 inline Tensor<Cmpt> skew(const Tensor<Cmpt>& t)
00412 {
00413 return Tensor<Cmpt>
00414 (
00415 0.0, 0.5*(t.xy() - t.yx()), 0.5*(t.xz() - t.zx()),
00416 0.5*(t.yx() - t.xy()), 0.0, 0.5*(t.yz() - t.zy()),
00417 0.5*(t.zx() - t.xz()), 0.5*(t.zy() - t.yz()), 0.0
00418 );
00419 }
00420
00421
00422
00423 template <class Cmpt>
00424 inline const Tensor<Cmpt>& skew(const SymmTensor<Cmpt>& st)
00425 {
00426 return Tensor<Cmpt>::zero;
00427 }
00428
00429
00430
00431 template <class Cmpt>
00432 inline Tensor<Cmpt> dev(const Tensor<Cmpt>& t)
00433 {
00434 return t - SphericalTensor<Cmpt>::oneThirdI*tr(t);
00435 }
00436
00437
00438
00439 template <class Cmpt>
00440 inline Tensor<Cmpt> dev2(const Tensor<Cmpt>& t)
00441 {
00442 return t - SphericalTensor<Cmpt>::twoThirdsI*tr(t);
00443 }
00444
00445
00446
00447 template <class Cmpt>
00448 inline Cmpt det(const Tensor<Cmpt>& t)
00449 {
00450 return
00451 (
00452 t.xx()*t.yy()*t.zz() + t.xy()*t.yz()*t.zx()
00453 + t.xz()*t.yx()*t.zy() - t.xx()*t.yz()*t.zy()
00454 - t.xy()*t.yx()*t.zz() - t.xz()*t.yy()*t.zx()
00455 );
00456 }
00457
00458
00459
00460 template <class Cmpt>
00461 inline Tensor<Cmpt> cofactors(const Tensor<Cmpt>& t)
00462 {
00463 return Tensor<Cmpt>
00464 (
00465 t.yy()*t.zz() - t.zy()*t.yz(),
00466 t.zx()*t.yz() - t.yx()*t.zz(),
00467 t.yx()*t.zy() - t.yy()*t.zx(),
00468
00469 t.xz()*t.zy() - t.xy()*t.zz(),
00470 t.xx()*t.zz() - t.xz()*t.zx(),
00471 t.xy()*t.zx() - t.xx()*t.zy(),
00472
00473 t.xy()*t.yz() - t.xz()*t.yy(),
00474 t.yx()*t.xz() - t.xx()*t.yz(),
00475 t.xx()*t.yy() - t.yx()*t.xy()
00476 );
00477 }
00478
00479
00480
00481 template <class Cmpt>
00482 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t, const Cmpt dett)
00483 {
00484 return Tensor<Cmpt>
00485 (
00486 t.yy()*t.zz() - t.zy()*t.yz(),
00487 t.xz()*t.zy() - t.xy()*t.zz(),
00488 t.xy()*t.yz() - t.xz()*t.yy(),
00489
00490 t.zx()*t.yz() - t.yx()*t.zz(),
00491 t.xx()*t.zz() - t.xz()*t.zx(),
00492 t.yx()*t.xz() - t.xx()*t.yz(),
00493
00494 t.yx()*t.zy() - t.yy()*t.zx(),
00495 t.xy()*t.zx() - t.xx()*t.zy(),
00496 t.xx()*t.yy() - t.yx()*t.xy()
00497 )/dett;
00498 }
00499
00500
00501
00502 template <class Cmpt>
00503 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t)
00504 {
00505 return inv(t, det(t));
00506 }
00507
00508
00509
00510 template <class Cmpt>
00511 inline Cmpt invariantI(const Tensor<Cmpt>& t)
00512 {
00513 return tr(t);
00514 }
00515
00516
00517
00518 template <class Cmpt>
00519 inline Cmpt invariantII(const Tensor<Cmpt>& t)
00520 {
00521 return
00522 (
00523 0.5*sqr(tr(t))
00524 - 0.5*
00525 (
00526 t.xx()*t.xx() + t.xy()*t.xy() + t.xz()*t.xz()
00527 + t.yx()*t.yx() + t.yy()*t.yy() + t.yz()*t.yz()
00528 + t.zx()*t.zx() + t.zy()*t.zy() + t.zz()*t.zz()
00529 )
00530 );
00531 }
00532
00533
00534
00535 template <class Cmpt>
00536 inline Cmpt invariantIII(const Tensor<Cmpt>& t)
00537 {
00538 return det(t);
00539 }
00540
00541
00542
00543
00544 template <class Cmpt>
00545 inline Tensor<Cmpt>
00546 operator+(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00547 {
00548 return Tensor<Cmpt>
00549 (
00550 st1.ii() + t2.xx(), t2.xy(), t2.xz(),
00551 t2.yx(), st1.ii() + t2.yy(), t2.yz(),
00552 t2.zx(), t2.zy(), st1.ii() + t2.zz()
00553 );
00554 }
00555
00556
00557 template <class Cmpt>
00558 inline Tensor<Cmpt>
00559 operator+(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
00560 {
00561 return Tensor<Cmpt>
00562 (
00563 t1.xx() + st2.ii(), t1.xy(), t1.xz(),
00564 t1.yx(), t1.yy() + st2.ii(), t1.yz(),
00565 t1.zx(), t1.zy(), t1.zz() + st2.ii()
00566 );
00567 }
00568
00569
00570 template <class Cmpt>
00571 inline Tensor<Cmpt>
00572 operator-(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00573 {
00574 return Tensor<Cmpt>
00575 (
00576 st1.ii() - t2.xx(), -t2.xy(), -t2.xz(),
00577 -t2.yx(), st1.ii() - t2.yy(), -t2.yz(),
00578 -t2.zx(), -t2.zy(), st1.ii() - t2.zz()
00579 );
00580 }
00581
00582
00583 template <class Cmpt>
00584 inline Tensor<Cmpt>
00585 operator-(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
00586 {
00587 return Tensor<Cmpt>
00588 (
00589 t1.xx() - st2.ii(), t1.xy(), t1.xz(),
00590 t1.yx(), t1.yy() - st2.ii(), t1.yz(),
00591 t1.zx(), t1.zy(), t1.zz() - st2.ii()
00592 );
00593 }
00594
00595
00596
00597 template <class Cmpt>
00598 inline Tensor<Cmpt>
00599 operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00600 {
00601 return Tensor<Cmpt>
00602 (
00603 st1.ii()*t2.xx(),
00604 st1.ii()*t2.xy(),
00605 st1.ii()*t2.xz(),
00606
00607 st1.ii()*t2.yx(),
00608 st1.ii()*t2.yy(),
00609 st1.ii()*t2.yz(),
00610
00611 st1.ii()*t2.zx(),
00612 st1.ii()*t2.zy(),
00613 st1.ii()*t2.zz()
00614 );
00615 }
00616
00617
00618
00619 template <class Cmpt>
00620 inline Tensor<Cmpt>
00621 operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
00622 {
00623 return Tensor<Cmpt>
00624 (
00625 t1.xx()*st2.ii(),
00626 t1.xy()*st2.ii(),
00627 t1.xz()*st2.ii(),
00628
00629 t1.yx()*st2.ii(),
00630 t1.yy()*st2.ii(),
00631 t1.yz()*st2.ii(),
00632
00633 t1.zx()*st2.ii(),
00634 t1.zy()*st2.ii(),
00635 t1.zz()*st2.ii()
00636 );
00637 }
00638
00639
00640
00641 template <class Cmpt>
00642 inline Cmpt
00643 operator&&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00644 {
00645 return(st1.ii()*t2.xx() + st1.ii()*t2.yy() + st1.ii()*t2.zz());
00646 }
00647
00648
00649
00650 template <class Cmpt>
00651 inline Cmpt
00652 operator&&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
00653 {
00654 return(t1.xx()*st2.ii() + t1.yy()*st2.ii() + t1.zz()*st2.ii());
00655 }
00656
00657
00658 template<class Cmpt>
00659 class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt> >
00660 {
00661 public:
00662
00663 typedef Tensor<Cmpt> type;
00664 };
00665
00666 template<class Cmpt>
00667 class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt> >
00668 {
00669 public:
00670
00671 typedef Tensor<Cmpt> type;
00672 };
00673
00674
00675 template<class Cmpt>
00676 class innerProduct<SphericalTensor<Cmpt>, Tensor<Cmpt> >
00677 {
00678 public:
00679
00680 typedef Tensor<Cmpt> type;
00681 };
00682
00683 template<class Cmpt>
00684 class innerProduct<Tensor<Cmpt>, SphericalTensor<Cmpt> >
00685 {
00686 public:
00687
00688 typedef Tensor<Cmpt> type;
00689 };
00690
00691
00692
00693
00694 template <class Cmpt>
00695 inline Tensor<Cmpt>
00696 operator+(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00697 {
00698 return Tensor<Cmpt>
00699 (
00700 st1.xx() + t2.xx(), st1.xy() + t2.xy(), st1.xz() + t2.xz(),
00701 st1.xy() + t2.yx(), st1.yy() + t2.yy(), st1.yz() + t2.yz(),
00702 st1.xz() + t2.zx(), st1.yz() + t2.zy(), st1.zz() + t2.zz()
00703 );
00704 }
00705
00706
00707 template <class Cmpt>
00708 inline Tensor<Cmpt>
00709 operator+(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
00710 {
00711 return Tensor<Cmpt>
00712 (
00713 t1.xx() + st2.xx(), t1.xy() + st2.xy(), t1.xz() + st2.xz(),
00714 t1.yx() + st2.xy(), t1.yy() + st2.yy(), t1.yz() + st2.yy(),
00715 t1.zx() + st2.xz(), t1.zy() + st2.yz(), t1.zz() + st2.zz()
00716 );
00717 }
00718
00719
00720 template <class Cmpt>
00721 inline Tensor<Cmpt>
00722 operator-(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00723 {
00724 return Tensor<Cmpt>
00725 (
00726 st1.xx() - t2.xx(), st1.xy() - t2.xy(), st1.xz() - t2.xz(),
00727 st1.xy() - t2.yx(), st1.yy() - t2.yy(), st1.yz() - t2.yz(),
00728 st1.xz() - t2.zx(), st1.yz() - t2.zy(), st1.zz() - t2.zz()
00729 );
00730 }
00731
00732
00733 template <class Cmpt>
00734 inline Tensor<Cmpt>
00735 operator-(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
00736 {
00737 return Tensor<Cmpt>
00738 (
00739 t1.xx() - st2.xx(), t1.xy() - st2.xy(), t1.xz() - st2.xz(),
00740 t1.yx() - st2.xy(), t1.yy() - st2.yy(), t1.yz() - st2.yy(),
00741 t1.zx() - st2.xz(), t1.zy() - st2.yz(), t1.zz() - st2.zz()
00742 );
00743 }
00744
00745
00746
00747 template <class Cmpt>
00748 inline Tensor<Cmpt>
00749 operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00750 {
00751 return Tensor<Cmpt>
00752 (
00753 st1.xx()*t2.xx() + st1.xy()*t2.yx() + st1.xz()*t2.zx(),
00754 st1.xx()*t2.xy() + st1.xy()*t2.yy() + st1.xz()*t2.zy(),
00755 st1.xx()*t2.xz() + st1.xy()*t2.yz() + st1.xz()*t2.zz(),
00756
00757 st1.xy()*t2.xx() + st1.yy()*t2.yx() + st1.yz()*t2.zx(),
00758 st1.xy()*t2.xy() + st1.yy()*t2.yy() + st1.yz()*t2.zy(),
00759 st1.xy()*t2.xz() + st1.yy()*t2.yz() + st1.yz()*t2.zz(),
00760
00761 st1.xz()*t2.xx() + st1.yz()*t2.yx() + st1.zz()*t2.zx(),
00762 st1.xz()*t2.xy() + st1.yz()*t2.yy() + st1.zz()*t2.zy(),
00763 st1.xz()*t2.xz() + st1.yz()*t2.yz() + st1.zz()*t2.zz()
00764 );
00765 }
00766
00767
00768
00769 template <class Cmpt>
00770 inline Tensor<Cmpt>
00771 operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
00772 {
00773 return Tensor<Cmpt>
00774 (
00775 t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz(),
00776 t1.xx()*st2.xy() + t1.xy()*st2.yy() + t1.xz()*st2.yz(),
00777 t1.xx()*st2.xz() + t1.xy()*st2.yz() + t1.xz()*st2.zz(),
00778
00779 t1.yx()*st2.xx() + t1.yy()*st2.xy() + t1.yz()*st2.xz(),
00780 t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz(),
00781 t1.yx()*st2.xz() + t1.yy()*st2.yz() + t1.yz()*st2.zz(),
00782
00783 t1.zx()*st2.xx() + t1.zy()*st2.xy() + t1.zz()*st2.xz(),
00784 t1.zx()*st2.xy() + t1.zy()*st2.yy() + t1.zz()*st2.yz(),
00785 t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
00786 );
00787 }
00788
00789
00790
00791 template <class Cmpt>
00792 inline Cmpt
00793 operator&&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
00794 {
00795 return
00796 (
00797 st1.xx()*t2.xx() + st1.xy()*t2.yx() + st1.xz()*t2.zx() +
00798 st1.xx()*t2.xy() + st1.xy()*t2.yy() + st1.xz()*t2.zy() +
00799 st1.xx()*t2.xz() + st1.xy()*t2.yz() + st1.xz()*t2.zz() +
00800
00801 st1.xy()*t2.xx() + st1.yy()*t2.yx() + st1.yz()*t2.zx() +
00802 st1.xy()*t2.xy() + st1.yy()*t2.yy() + st1.yz()*t2.zy() +
00803 st1.xy()*t2.xz() + st1.yy()*t2.yz() + st1.yz()*t2.zz() +
00804
00805 st1.xz()*t2.xx() + st1.yz()*t2.yx() + st1.zz()*t2.zx() +
00806 st1.xz()*t2.xy() + st1.yz()*t2.yy() + st1.zz()*t2.zy() +
00807 st1.xz()*t2.xz() + st1.yz()*t2.yz() + st1.zz()*t2.zz()
00808 );
00809 }
00810
00811
00812
00813 template <class Cmpt>
00814 inline Cmpt
00815 operator&&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
00816 {
00817 return
00818 (
00819 t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz() +
00820 t1.xx()*st2.xy() + t1.xy()*st2.yy() + t1.xz()*st2.yz() +
00821 t1.xx()*st2.xz() + t1.xy()*st2.yz() + t1.xz()*st2.zz() +
00822
00823 t1.yx()*st2.xx() + t1.yy()*st2.xy() + t1.yz()*st2.xz() +
00824 t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz() +
00825 t1.yx()*st2.xz() + t1.yy()*st2.yz() + t1.yz()*st2.zz() +
00826
00827 t1.zx()*st2.xx() + t1.zy()*st2.xy() + t1.zz()*st2.xz() +
00828 t1.zx()*st2.xy() + t1.zy()*st2.yy() + t1.zz()*st2.yz() +
00829 t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
00830 );
00831 }
00832
00833
00834 template<class Cmpt>
00835 class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt> >
00836 {
00837 public:
00838
00839 typedef Tensor<Cmpt> type;
00840 };
00841
00842 template<class Cmpt>
00843 class typeOfSum<Tensor<Cmpt>, SymmTensor<Cmpt> >
00844 {
00845 public:
00846
00847 typedef Tensor<Cmpt> type;
00848 };
00849
00850
00851 template<class Cmpt>
00852 class innerProduct<SymmTensor<Cmpt>, Tensor<Cmpt> >
00853 {
00854 public:
00855
00856 typedef Tensor<Cmpt> type;
00857 };
00858
00859 template<class Cmpt>
00860 class innerProduct<Tensor<Cmpt>, SymmTensor<Cmpt> >
00861 {
00862 public:
00863
00864 typedef Tensor<Cmpt> type;
00865 };
00866
00867
00868
00869
00870 }
00871
00872
Copyright © 2000-2007 OpenCFD Ltd