TensorI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "SymmTensor.H"
27 #include "DiagTensor.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Cmpt>
33 {}
34 
35 
36 template<class Cmpt>
38 :
40 {}
41 
42 
43 template<class Cmpt>
44 template<class Cmpt2>
46 (
47  const MatrixSpace<Tensor<Cmpt2>, Cmpt2, 3, 3>& vs
48 )
49 :
50  Tensor::msType(vs)
51 {}
52 
53 
54 template<class Cmpt>
55 template<class Cmpt2>
57 (
58  const VectorSpace<Tensor<Cmpt2>, Cmpt2, 9>& vs
59 )
60 :
61  Tensor::msType(vs)
62 {}
63 
64 
65 template<class Cmpt>
67 {
68  this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
69  this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0;
70  this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii();
71 }
72 
73 
74 template<class Cmpt>
76 {
77  this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
78  this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz();
79  this->v_[ZX] = st.xz(); this->v_[ZY] = st.yz(); this->v_[ZZ] = st.zz();
80 }
81 
82 
83 template<class Cmpt>
85 {
86  this->v_[XX] = st.xx(); this->v_[XY] = 0; this->v_[XZ] = 0;
87  this->v_[YX] = 0; this->v_[YY] = st.yy(); this->v_[YZ] = 0;
88  this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.zz();
89 }
90 
91 
92 template<class Cmpt>
94 {
95  this->v_[XX] = tr.x().x();
96  this->v_[XY] = tr.x().y();
97  this->v_[XZ] = tr.x().z();
98 
99  this->v_[YX] = tr.y().x();
100  this->v_[YY] = tr.y().y();
101  this->v_[YZ] = tr.y().z();
102 
103  this->v_[ZX] = tr.z().x();
104  this->v_[ZY] = tr.z().y();
105  this->v_[ZZ] = tr.z().z();
106 }
107 
108 
109 template<class Cmpt>
111 (
112  const Vector<Cmpt>& x,
113  const Vector<Cmpt>& y,
114  const Vector<Cmpt>& z
115 )
116 {
117  this->v_[XX] = x.x(); this->v_[XY] = x.y(); this->v_[XZ] = x.z();
118  this->v_[YX] = y.x(); this->v_[YY] = y.y(); this->v_[YZ] = y.z();
119  this->v_[ZX] = z.x(); this->v_[ZY] = z.y(); this->v_[ZZ] = z.z();
120 }
121 
122 
123 template<class Cmpt>
125 (
126  const Cmpt txx, const Cmpt txy, const Cmpt txz,
127  const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
128  const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
129 )
130 {
131  this->v_[XX] = txx; this->v_[XY] = txy; this->v_[XZ] = txz;
132  this->v_[YX] = tyx; this->v_[YY] = tyy; this->v_[YZ] = tyz;
133  this->v_[ZX] = tzx; this->v_[ZY] = tzy; this->v_[ZZ] = tzz;
134 }
135 
136 
137 template<class Cmpt>
138 template
139 <
140  template<class, Foam::direction, Foam::direction> class Block2,
141  Foam::direction BRowStart,
142  Foam::direction BColStart
143 >
145 (
146  const Block2<Tensor<Cmpt>, BRowStart, BColStart>& block
147 )
148 :
150 {}
151 
152 
153 template<class Cmpt>
155 :
156  Tensor::msType(is)
157 {}
158 
159 
160 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
161 
162 template<class Cmpt>
163 inline const Cmpt& Foam::Tensor<Cmpt>::xx() const
164 {
165  return this->v_[XX];
166 }
167 
168 
169 template<class Cmpt>
170 inline const Cmpt& Foam::Tensor<Cmpt>::xy() const
171 {
172  return this->v_[XY];
173 }
174 
175 
176 template<class Cmpt>
177 inline const Cmpt& Foam::Tensor<Cmpt>::xz() const
178 {
179  return this->v_[XZ];
180 }
181 
182 
183 template<class Cmpt>
184 inline const Cmpt& Foam::Tensor<Cmpt>::yx() const
185 {
186  return this->v_[YX];
187 }
188 
189 
190 template<class Cmpt>
191 inline const Cmpt& Foam::Tensor<Cmpt>::yy() const
192 {
193  return this->v_[YY];
194 }
195 
196 
197 template<class Cmpt>
198 inline const Cmpt& Foam::Tensor<Cmpt>::yz() const
199 {
200  return this->v_[YZ];
201 }
202 
203 
204 template<class Cmpt>
205 inline const Cmpt& Foam::Tensor<Cmpt>::zx() const
206 {
207  return this->v_[ZX];
208 }
209 
210 
211 template<class Cmpt>
212 inline const Cmpt& Foam::Tensor<Cmpt>::zy() const
213 {
214  return this->v_[ZY];
215 }
216 
217 
218 template<class Cmpt>
219 inline const Cmpt& Foam::Tensor<Cmpt>::zz() const
220 {
221  return this->v_[ZZ];
222 }
223 
224 
225 template<class Cmpt>
227 {
228  return this->v_[XX];
229 }
230 
231 
232 template<class Cmpt>
234 {
235  return this->v_[XY];
236 }
237 
238 
239 template<class Cmpt>
241 {
242  return this->v_[XZ];
243 }
244 
245 
246 template<class Cmpt>
248 {
249  return this->v_[YX];
250 }
251 
252 
253 template<class Cmpt>
255 {
256  return this->v_[YY];
257 }
258 
259 
260 template<class Cmpt>
262 {
263  return this->v_[YZ];
264 }
265 
266 
267 template<class Cmpt>
269 {
270  return this->v_[ZX];
271 }
272 
273 
274 template<class Cmpt>
276 {
277  return this->v_[ZY];
278 }
279 
280 
281 template<class Cmpt>
283 {
284  return this->v_[ZZ];
285 }
286 
287 
288 template<class Cmpt>
290 {
291  return Vector<Cmpt>(this->v_[XX], this->v_[XY], this->v_[XZ]);
292 }
293 
294 
295 template<class Cmpt>
297 {
298  return Vector<Cmpt>(this->v_[YX], this->v_[YY], this->v_[YZ]);
299 }
300 
301 
302 template<class Cmpt>
304 {
305  return Vector<Cmpt>(this->v_[ZX], this->v_[ZY], this->v_[ZZ]);
306 }
307 
308 
309 template<class Cmpt>
311 (
312  const direction cmpt
313 ) const
314 {
315  switch (cmpt)
316  {
317  case 0:
318  return x();
319  break;
320  case 1:
321  return y();
322  break;
323  case 2:
324  return z();
325  break;
326  }
327 }
328 
329 
330 template<class Cmpt>
332 {
333  return Tensor<Cmpt>
334  (
335  xx(), yx(), zx(),
336  xy(), yy(), zy(),
337  xz(), yz(), zz()
338  );
339 }
340 
341 
342 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
343 
344 template<class Cmpt>
345 inline void Foam::Tensor<Cmpt>::operator&=(const Tensor<Cmpt>& t)
346 {
347  *this =
348  (
350  (
351  this->xx()*t.xx() + this->xy()*t.yx() + this->xz()*t.zx(),
352  this->xx()*t.xy() + this->xy()*t.yy() + this->xz()*t.zy(),
353  this->xx()*t.xz() + this->xy()*t.yz() + this->xz()*t.zz(),
354 
355  this->yx()*t.xx() + this->yy()*t.yx() + this->yz()*t.zx(),
356  this->yx()*t.xy() + this->yy()*t.yy() + this->yz()*t.zy(),
357  this->yx()*t.xz() + this->yy()*t.yz() + this->yz()*t.zz(),
358 
359  this->zx()*t.xx() + this->zy()*t.yx() + this->zz()*t.zx(),
360  this->zx()*t.xy() + this->zy()*t.yy() + this->zz()*t.zy(),
361  this->zx()*t.xz() + this->zy()*t.yz() + this->zz()*t.zz()
362  )
363  );
364 }
365 
366 
367 template<class Cmpt>
368 template<class Cmpt2>
369 inline void Foam::Tensor<Cmpt>::operator=
370 (
371  const VectorSpace<Tensor<Cmpt2>, Cmpt2, 9>& vs
372 )
373 {
374  VectorSpace<Tensor<Cmpt>, Cmpt, 9>::operator=(vs);
375 }
376 
377 
378 template<class Cmpt>
380 {
381  this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
382  this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0;
383  this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii();
384 }
385 
386 
387 template<class Cmpt>
389 {
390  this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
391  this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz();
392  this->v_[ZX] = st.xz(); this->v_[ZY] = st.yz(); this->v_[ZZ] = st.zz();
393 }
394 
395 
396 template<class Cmpt>
398 {
399  this->v_[XX] = tr.x().x();
400  this->v_[XY] = tr.x().y();
401  this->v_[XZ] = tr.x().z();
402 
403  this->v_[YX] = tr.y().x();
404  this->v_[YY] = tr.y().y();
405  this->v_[YZ] = tr.y().z();
406 
407  this->v_[ZX] = tr.z().x();
408  this->v_[ZY] = tr.z().y();
409  this->v_[ZZ] = tr.z().z();
410 }
411 
412 
413 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
414 
415 namespace Foam
416 {
417 
418 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
419 
420 template<class Cmpt>
422 {
423  return Vector<Cmpt>(t.yz(), -t.xz(), t.xy());
424 }
425 
426 
427 template<class Cmpt>
429 {
430  return Tensor<Cmpt>
431  (
432  0, -v.z(), v.y(),
433  v.z(), 0, -v.x(),
434  -v.y(), v.x(), 0
435  );
436 }
437 
438 
439 template<class Cmpt>
441 operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
442 {
443  return Tensor<Cmpt>
444  (
445  t1.xx()*t2.xx() + t1.xy()*t2.yx() + t1.xz()*t2.zx(),
446  t1.xx()*t2.xy() + t1.xy()*t2.yy() + t1.xz()*t2.zy(),
447  t1.xx()*t2.xz() + t1.xy()*t2.yz() + t1.xz()*t2.zz(),
448 
449  t1.yx()*t2.xx() + t1.yy()*t2.yx() + t1.yz()*t2.zx(),
450  t1.yx()*t2.xy() + t1.yy()*t2.yy() + t1.yz()*t2.zy(),
451  t1.yx()*t2.xz() + t1.yy()*t2.yz() + t1.yz()*t2.zz(),
452 
453  t1.zx()*t2.xx() + t1.zy()*t2.yx() + t1.zz()*t2.zx(),
454  t1.zx()*t2.xy() + t1.zy()*t2.yy() + t1.zz()*t2.zy(),
455  t1.zx()*t2.xz() + t1.zy()*t2.yz() + t1.zz()*t2.zz()
456  );
457 }
458 
459 
460 template<class Cmpt>
461 inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
463 {
464  return Vector<Cmpt>
465  (
466  t.xx()*v.x() + t.xy()*v.y() + t.xz()*v.z(),
467  t.yx()*v.x() + t.yy()*v.y() + t.yz()*v.z(),
468  t.zx()*v.x() + t.zy()*v.y() + t.zz()*v.z()
469  );
470 }
471 
472 
473 template<class Cmpt>
476 {
477  return Vector<Cmpt>
478  (
479  v.x()*t.xx() + v.y()*t.yx() + v.z()*t.zx(),
480  v.x()*t.xy() + v.y()*t.yy() + v.z()*t.zy(),
481  v.x()*t.xz() + v.y()*t.yz() + v.z()*t.zz()
482  );
483 }
484 
485 
486 template<class Cmpt>
488 operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
489 {
490  return Tensor<Cmpt>
491  (
492  v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
493  v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
494  v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
495  );
496 }
497 
498 
499 template<class Cmpt>
500 inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
502 {
503  return inv(t) & v;
504 }
505 
506 
507 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
508 
509 //- Return the trace of a tensor
510 template<class Cmpt>
511 inline Cmpt tr(const Tensor<Cmpt>& t)
512 {
513  return t.xx() + t.yy() + t.zz();
514 }
515 
516 
517 //- Return the spherical part of a tensor
518 template<class Cmpt>
520 {
521  return (1.0/3.0)*tr(t);
522 }
523 
524 
525 //- Return the symmetric part of a tensor
526 template<class Cmpt>
528 {
529  return SymmTensor<Cmpt>
530  (
531  t.xx(), 0.5*(t.xy() + t.yx()), 0.5*(t.xz() + t.zx()),
532  t.yy(), 0.5*(t.yz() + t.zy()),
533  t.zz()
534  );
535 }
536 
537 
538 //- Return twice the symmetric part of a tensor
539 template<class Cmpt>
541 {
542  return SymmTensor<Cmpt>
543  (
544  2*t.xx(), (t.xy() + t.yx()), (t.xz() + t.zx()),
545  2*t.yy(), (t.yz() + t.zy()),
546  2*t.zz()
547  );
548 }
549 
550 
551 //- Return the skew-symmetric part of a tensor
552 template<class Cmpt>
554 {
555  return Tensor<Cmpt>
556  (
557  0.0, 0.5*(t.xy() - t.yx()), 0.5*(t.xz() - t.zx()),
558  0.5*(t.yx() - t.xy()), 0.0, 0.5*(t.yz() - t.zy()),
559  0.5*(t.zx() - t.xz()), 0.5*(t.zy() - t.yz()), 0.0
560  );
561 }
562 
563 
564 //- Return the skew-symmetric part of a symmetric tensor
565 template<class Cmpt>
566 inline const Tensor<Cmpt>& skew(const SymmTensor<Cmpt>& st)
567 {
568  return Tensor<Cmpt>::zero;
569 }
570 
571 
572 //- Return the deviatoric part of a tensor
573 template<class Cmpt>
574 inline Tensor<Cmpt> dev(const Tensor<Cmpt>& t)
575 {
576  return t - SphericalTensor<Cmpt>::oneThirdI*tr(t);
577 }
578 
579 
580 //- Return the deviatoric part of a tensor
581 template<class Cmpt>
583 {
585 }
586 
587 
588 //- Return the determinant of a tensor
589 template<class Cmpt>
590 inline Cmpt det(const Tensor<Cmpt>& t)
591 {
592  return
593  (
594  t.xx()*t.yy()*t.zz() + t.xy()*t.yz()*t.zx()
595  + t.xz()*t.yx()*t.zy() - t.xx()*t.yz()*t.zy()
596  - t.xy()*t.yx()*t.zz() - t.xz()*t.yy()*t.zx()
597  );
598 }
599 
600 
601 //- Return the cofactor tensor of a tensor
602 template<class Cmpt>
603 inline Tensor<Cmpt> cof(const Tensor<Cmpt>& t)
604 {
605  return Tensor<Cmpt>
606  (
607  t.yy()*t.zz() - t.zy()*t.yz(),
608  t.zx()*t.yz() - t.yx()*t.zz(),
609  t.yx()*t.zy() - t.yy()*t.zx(),
610 
611  t.xz()*t.zy() - t.xy()*t.zz(),
612  t.xx()*t.zz() - t.xz()*t.zx(),
613  t.xy()*t.zx() - t.xx()*t.zy(),
614 
615  t.xy()*t.yz() - t.xz()*t.yy(),
616  t.yx()*t.xz() - t.xx()*t.yz(),
617  t.xx()*t.yy() - t.yx()*t.xy()
618  );
619 }
620 
621 
622 //- Return the inverse of a tensor given the determinant
623 template<class Cmpt>
624 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t, const Cmpt dett)
625 {
626  return Tensor<Cmpt>
627  (
628  t.yy()*t.zz() - t.zy()*t.yz(),
629  t.xz()*t.zy() - t.xy()*t.zz(),
630  t.xy()*t.yz() - t.xz()*t.yy(),
631 
632  t.zx()*t.yz() - t.yx()*t.zz(),
633  t.xx()*t.zz() - t.xz()*t.zx(),
634  t.yx()*t.xz() - t.xx()*t.yz(),
635 
636  t.yx()*t.zy() - t.yy()*t.zx(),
637  t.xy()*t.zx() - t.xx()*t.zy(),
638  t.xx()*t.yy() - t.yx()*t.xy()
639  )/dett;
640 }
641 
642 
643 //- Return the inverse of a tensor
644 template<class Cmpt>
645 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t)
646 {
647  return inv(t, det(t));
648 }
649 
650 
651 template<class Cmpt>
653 {
654  return Foam::inv(*this);
655 }
656 
657 
658 //- Return the 1st invariant of a tensor
659 template<class Cmpt>
660 inline Cmpt invariantI(const Tensor<Cmpt>& t)
661 {
662  return tr(t);
663 }
664 
665 
666 //- Return the 2nd invariant of a tensor
667 template<class Cmpt>
668 inline Cmpt invariantII(const Tensor<Cmpt>& t)
669 {
670  return
671  (
672  t.xx()*t.yy() + t.yy()*t.zz() + t.xx()*t.zz()
673  - t.xy()*t.yx() - t.yz()*t.zy() - t.xz()*t.zx()
674  );
675 }
676 
677 
678 //- Return the 3rd invariant of a tensor
679 template<class Cmpt>
680 inline Cmpt invariantIII(const Tensor<Cmpt>& t)
681 {
682  return det(t);
683 }
684 
685 
686 // * * * * * * * * * Mixed Tensor SphericalTensor Operators * * * * * * * * //
687 
688 template<class Cmpt>
689 inline Tensor<Cmpt>
691 {
692  return Tensor<Cmpt>
693  (
694  st1.ii() + t2.xx(), t2.xy(), t2.xz(),
695  t2.yx(), st1.ii() + t2.yy(), t2.yz(),
696  t2.zx(), t2.zy(), st1.ii() + t2.zz()
697  );
698 }
699 
700 
701 template<class Cmpt>
702 inline Tensor<Cmpt>
704 {
705  return Tensor<Cmpt>
706  (
707  t1.xx() + st2.ii(), t1.xy(), t1.xz(),
708  t1.yx(), t1.yy() + st2.ii(), t1.yz(),
709  t1.zx(), t1.zy(), t1.zz() + st2.ii()
710  );
711 }
712 
713 
714 template<class Cmpt>
715 inline Tensor<Cmpt>
717 {
718  return Tensor<Cmpt>
719  (
720  st1.ii() - t2.xx(), -t2.xy(), -t2.xz(),
721  -t2.yx(), st1.ii() - t2.yy(), -t2.yz(),
722  -t2.zx(), -t2.zy(), st1.ii() - t2.zz()
723  );
724 }
725 
726 
727 template<class Cmpt>
728 inline Tensor<Cmpt>
730 {
731  return Tensor<Cmpt>
732  (
733  t1.xx() - st2.ii(), t1.xy(), t1.xz(),
734  t1.yx(), t1.yy() - st2.ii(), t1.yz(),
735  t1.zx(), t1.zy(), t1.zz() - st2.ii()
736  );
737 }
738 
739 
740 //- Inner-product between a spherical tensor and a tensor
741 template<class Cmpt>
742 inline Tensor<Cmpt>
744 {
745  return Tensor<Cmpt>
746  (
747  st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
748  st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
749  st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
750  );
751 }
752 
753 
754 //- Inner-product between a tensor and a spherical tensor
755 template<class Cmpt>
756 inline Tensor<Cmpt>
758 {
759  return Tensor<Cmpt>
760  (
761  t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
762  t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
763  t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
764  );
765 }
766 
767 
768 //- Double-dot-product between a spherical tensor and a tensor
769 template<class Cmpt>
770 inline Cmpt
772 {
773  return(st1.ii()*t2.xx() + st1.ii()*t2.yy() + st1.ii()*t2.zz());
774 }
775 
776 
777 //- Double-dot-product between a tensor and a spherical tensor
778 template<class Cmpt>
779 inline Cmpt
781 {
782  return(t1.xx()*st2.ii() + t1.yy()*st2.ii() + t1.zz()*st2.ii());
783 }
784 
785 
786 template<class Cmpt>
787 class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt>>
788 {
789 public:
790 
792 };
793 
794 
795 template<class Cmpt>
796 class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt>>
797 {
798 public:
799 
801 };
802 
803 
804 template<class Cmpt>
806 {
807 public:
808 
810 };
811 
812 
813 template<class Cmpt>
815 {
816 public:
817 
819 };
820 
821 
822 // * * * * * * * * * * Mixed Tensor SymmTensor Operators * * * * * * * * * * //
823 
824 template<class Cmpt>
825 inline Tensor<Cmpt>
827 {
828  return Tensor<Cmpt>
829  (
830  st1.xx() + t2.xx(), st1.xy() + t2.xy(), st1.xz() + t2.xz(),
831  st1.xy() + t2.yx(), st1.yy() + t2.yy(), st1.yz() + t2.yz(),
832  st1.xz() + t2.zx(), st1.yz() + t2.zy(), st1.zz() + t2.zz()
833  );
834 }
835 
836 
837 template<class Cmpt>
838 inline Tensor<Cmpt>
840 {
841  return Tensor<Cmpt>
842  (
843  t1.xx() + st2.xx(), t1.xy() + st2.xy(), t1.xz() + st2.xz(),
844  t1.yx() + st2.xy(), t1.yy() + st2.yy(), t1.yz() + st2.yz(),
845  t1.zx() + st2.xz(), t1.zy() + st2.yz(), t1.zz() + st2.zz()
846  );
847 }
848 
849 
850 template<class Cmpt>
851 inline Tensor<Cmpt>
853 {
854  return Tensor<Cmpt>
855  (
856  st1.xx() - t2.xx(), st1.xy() - t2.xy(), st1.xz() - t2.xz(),
857  st1.xy() - t2.yx(), st1.yy() - t2.yy(), st1.yz() - t2.yz(),
858  st1.xz() - t2.zx(), st1.yz() - t2.zy(), st1.zz() - t2.zz()
859  );
860 }
861 
862 
863 template<class Cmpt>
864 inline Tensor<Cmpt>
866 {
867  return Tensor<Cmpt>
868  (
869  t1.xx() - st2.xx(), t1.xy() - st2.xy(), t1.xz() - st2.xz(),
870  t1.yx() - st2.xy(), t1.yy() - st2.yy(), t1.yz() - st2.yz(),
871  t1.zx() - st2.xz(), t1.zy() - st2.yz(), t1.zz() - st2.zz()
872  );
873 }
874 
875 
876 //- Inner-product between a symmetric tensor and a tensor
877 template<class Cmpt>
878 inline Tensor<Cmpt>
880 {
881  return Tensor<Cmpt>
882  (
883  st1.xx()*t2.xx() + st1.xy()*t2.yx() + st1.xz()*t2.zx(),
884  st1.xx()*t2.xy() + st1.xy()*t2.yy() + st1.xz()*t2.zy(),
885  st1.xx()*t2.xz() + st1.xy()*t2.yz() + st1.xz()*t2.zz(),
886 
887  st1.xy()*t2.xx() + st1.yy()*t2.yx() + st1.yz()*t2.zx(),
888  st1.xy()*t2.xy() + st1.yy()*t2.yy() + st1.yz()*t2.zy(),
889  st1.xy()*t2.xz() + st1.yy()*t2.yz() + st1.yz()*t2.zz(),
890 
891  st1.xz()*t2.xx() + st1.yz()*t2.yx() + st1.zz()*t2.zx(),
892  st1.xz()*t2.xy() + st1.yz()*t2.yy() + st1.zz()*t2.zy(),
893  st1.xz()*t2.xz() + st1.yz()*t2.yz() + st1.zz()*t2.zz()
894  );
895 }
896 
897 
898 //- Inner-product between a tensor and a symmetric tensor
899 template<class Cmpt>
900 inline Tensor<Cmpt>
902 {
903  return Tensor<Cmpt>
904  (
905  t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz(),
906  t1.xx()*st2.xy() + t1.xy()*st2.yy() + t1.xz()*st2.yz(),
907  t1.xx()*st2.xz() + t1.xy()*st2.yz() + t1.xz()*st2.zz(),
908 
909  t1.yx()*st2.xx() + t1.yy()*st2.xy() + t1.yz()*st2.xz(),
910  t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz(),
911  t1.yx()*st2.xz() + t1.yy()*st2.yz() + t1.yz()*st2.zz(),
912 
913  t1.zx()*st2.xx() + t1.zy()*st2.xy() + t1.zz()*st2.xz(),
914  t1.zx()*st2.xy() + t1.zy()*st2.yy() + t1.zz()*st2.yz(),
915  t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
916  );
917 }
918 
919 
920 //- Double-dot-product between a symmetric tensor and a tensor
921 template<class Cmpt>
922 inline Cmpt
924 {
925  return
926  (
927  st1.xx()*t2.xx() + st1.xy()*t2.xy() + st1.xz()*t2.xz() +
928  st1.xy()*t2.yx() + st1.yy()*t2.yy() + st1.yz()*t2.yz() +
929  st1.xz()*t2.zx() + st1.yz()*t2.zy() + st1.zz()*t2.zz()
930  );
931 }
932 
933 
934 //- Double-dot-product between a tensor and a symmetric tensor
935 template<class Cmpt>
936 inline Cmpt
938 {
939  return
940  (
941  t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz() +
942  t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz() +
943  t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
944  );
945 }
946 
947 
948 template<class Cmpt>
949 class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt>>
950 {
951 public:
952 
954 };
955 
956 
957 template<class Cmpt>
958 class typeOfSum<Tensor<Cmpt>, SymmTensor<Cmpt>>
959 {
960 public:
961 
963 };
964 
965 
966 template<class Cmpt>
967 class innerProduct<SymmTensor<Cmpt>, Tensor<Cmpt>>
968 {
969 public:
970 
972 };
973 
974 
975 template<class Cmpt>
976 class innerProduct<Tensor<Cmpt>, SymmTensor<Cmpt>>
977 {
978 public:
979 
981 };
982 
983 
984 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
985 
986 } // End namespace Foam
987 
988 // ************************************************************************* //
const Cmpt & yz() const
Definition: SymmTensorI.H:111
innerProduct< Vector< Cmpt >, Tensor< Cmpt > >::type operator/(const Vector< Cmpt > &v, const Tensor< Cmpt > &t)
Definition: TensorI.H:501
const Cmpt & yx() const
Definition: TensorI.H:184
Cmpt tr(const Tensor< Cmpt > &t)
Return the trace of a tensor.
Definition: TensorI.H:511
const Cmpt & xx() const
Definition: DiagTensorI.H:78
const Cmpt & yy() const
Definition: DiagTensorI.H:84
const Cmpt & zy() const
Definition: TensorI.H:212
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components...
Definition: SymmTensor.H:53
Cmpt invariantIII(const Tensor< Cmpt > &t)
Return the 3rd invariant of a tensor.
Definition: TensorI.H:680
const Cmpt & xz() const
Definition: TensorI.H:177
void operator &=(const Tensor< Cmpt > &)
Inner-product with a Tensor.
const Cmpt & xx() const
Definition: SymmTensorI.H:87
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Tensor< Cmpt > T() const
Return transpose.
Definition: TensorI.H:331
Vector< Cmpt > x() const
Definition: TensorI.H:289
Tensor< Cmpt > operator &(const Tensor< Cmpt > &t1, const SymmTensor< Cmpt > &st2)
Inner-product between a tensor and a symmetric tensor.
Definition: TensorI.H:901
const Cmpt & yy() const
Definition: TensorI.H:191
const Cmpt & xx() const
Definition: TensorI.H:163
const Cmpt & yz() const
Definition: TensorI.H:198
const Cmpt & zz() const
Definition: DiagTensorI.H:90
Templated vector space.
Definition: VectorSpace.H:53
Tensor< Cmpt > dev(const Tensor< Cmpt > &t)
Return the deviatoric part of a tensor.
Definition: TensorI.H:574
Vector< Cmpt > y() const
Definition: TensorI.H:296
const Cmpt & z() const
Definition: VectorI.H:87
Templated matrix space.
Definition: MatrixSpace.H:55
const Cmpt & yy() const
Definition: SymmTensorI.H:105
Tensor()
Construct null.
Definition: TensorI.H:32
const Cmpt & y() const
Definition: VectorI.H:81
SphericalTensor< Cmpt > sph(const Tensor< Cmpt > &t)
Return the spherical part of a tensor.
Definition: TensorI.H:519
Cmpt det(const Tensor< Cmpt > &t)
Return the determinant of a tensor.
Definition: TensorI.H:590
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component, element access using th ii() member function and the inner-product (dot-product) and outer-product operators.
Vector< Cmpt > z() const
Definition: TensorI.H:303
scalar y
SymmTensor< Cmpt > symm(const Tensor< Cmpt > &t)
Return the symmetric part of a tensor.
Definition: TensorI.H:527
const Cmpt & xz() const
Definition: SymmTensorI.H:99
const Cmpt & zz() const
Definition: SymmTensorI.H:117
void operator=(const VectorSpace< Tensor< Cmpt2 >, Cmpt2, 9 > &)
Assign to an equivalent vector space.
Definition: TensorI.H:370
const Cmpt & ii() const
SymmTensor< Cmpt > twoSymm(const Tensor< Cmpt > &t)
Return twice the symmetric part of a tensor.
Definition: TensorI.H:540
Templated 3D DiagTensor derived from VectorSpace.
Definition: DiagTensor.H:53
static const zero Zero
Definition: zero.H:97
const Cmpt & x() const
Definition: VectorI.H:75
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:63
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
Definition: Vector.H:57
Cmpt operator &&(const Tensor< Cmpt > &t1, const SymmTensor< Cmpt > &st2)
Double-dot-product between a tensor and a symmetric tensor.
Definition: TensorI.H:937
Tensor< Cmpt > cof(const Tensor< Cmpt > &t)
Return the cofactor tensor of a tensor.
Definition: TensorI.H:603
outerProduct< Vector< Cmpt >, Vector< Cmpt > >::type operator*(const Vector< Cmpt > &v1, const Vector< Cmpt > &v2)
Definition: TensorI.H:488
const Cmpt & zx() const
Definition: TensorI.H:205
Cmpt invariantII(const Tensor< Cmpt > &t)
Return the 2nd invariant of a tensor.
Definition: TensorI.H:668
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
Tensor< Cmpt > operator+(const Tensor< Cmpt > &t1, const SymmTensor< Cmpt > &st2)
Definition: TensorI.H:839
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
Vector< Cmpt > vectorComponent(const direction) const
Definition: TensorI.H:311
const Cmpt & xy() const
Definition: SymmTensorI.H:93
Tensor< Cmpt > inv(const Tensor< Cmpt > &t)
Return the inverse of a tensor.
Definition: TensorI.H:645
Templated 3D tensor derived from MatrixSpace adding construction from 9 components, element access using xx(), xy() etc. member functions and the inner-product (dot-product) and outer-product of two Vectors (tensor-product) operators.
Definition: complexI.H:215
const Cmpt & xy() const
Definition: TensorI.H:170
const Tensor< Cmpt > & skew(const SymmTensor< Cmpt > &st)
Return the skew-symmetric part of a symmetric tensor.
Definition: TensorI.H:566
const Cmpt & zz() const
Definition: TensorI.H:219
Tensor< Cmpt > operator-(const Tensor< Cmpt > &t1, const SymmTensor< Cmpt > &st2)
Definition: TensorI.H:865
Tensor< Cmpt > dev2(const Tensor< Cmpt > &t)
Return the deviatoric part of a tensor.
Definition: TensorI.H:582
Cmpt invariantI(const Tensor< Cmpt > &t)
Return the 1st invariant of a tensor.
Definition: TensorI.H:660
Namespace for OpenFOAM.