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-2022 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 :
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>
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>
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] = dt.xx(); this->v_[XY] = 0; this->v_[XZ] = 0;
391  this->v_[YX] = 0; this->v_[YY] = dt.yy(); this->v_[YZ] = 0;
392  this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = dt.zz();
393 }
394 
395 
396 template<class Cmpt>
398 {
399  this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
400  this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz();
401  this->v_[ZX] = st.xz(); this->v_[ZY] = st.yz(); this->v_[ZZ] = st.zz();
402 }
403 
404 
405 template<class Cmpt>
407 {
408  this->v_[XX] = tr.x().x();
409  this->v_[XY] = tr.x().y();
410  this->v_[XZ] = tr.x().z();
411 
412  this->v_[YX] = tr.y().x();
413  this->v_[YY] = tr.y().y();
414  this->v_[YZ] = tr.y().z();
415 
416  this->v_[ZX] = tr.z().x();
417  this->v_[ZY] = tr.z().y();
418  this->v_[ZZ] = tr.z().z();
419 }
420 
421 
422 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
423 
424 namespace Foam
425 {
426 
427 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
428 
429 template<class Cmpt>
431 {
432  return Vector<Cmpt>(t.yz(), -t.xz(), t.xy());
433 }
434 
435 
436 template<class Cmpt>
438 {
439  return Tensor<Cmpt>
440  (
441  0, -v.z(), v.y(),
442  v.z(), 0, -v.x(),
443  -v.y(), v.x(), 0
444  );
445 }
446 
447 
448 template<class Cmpt>
449 inline typename innerProduct<Tensor<Cmpt>, Tensor<Cmpt>>::type
450 operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
451 {
452  return Tensor<Cmpt>
453  (
454  t1.xx()*t2.xx() + t1.xy()*t2.yx() + t1.xz()*t2.zx(),
455  t1.xx()*t2.xy() + t1.xy()*t2.yy() + t1.xz()*t2.zy(),
456  t1.xx()*t2.xz() + t1.xy()*t2.yz() + t1.xz()*t2.zz(),
457 
458  t1.yx()*t2.xx() + t1.yy()*t2.yx() + t1.yz()*t2.zx(),
459  t1.yx()*t2.xy() + t1.yy()*t2.yy() + t1.yz()*t2.zy(),
460  t1.yx()*t2.xz() + t1.yy()*t2.yz() + t1.yz()*t2.zz(),
461 
462  t1.zx()*t2.xx() + t1.zy()*t2.yx() + t1.zz()*t2.zx(),
463  t1.zx()*t2.xy() + t1.zy()*t2.yy() + t1.zz()*t2.zy(),
464  t1.zx()*t2.xz() + t1.zy()*t2.yz() + t1.zz()*t2.zz()
465  );
466 }
467 
468 
469 template<class Cmpt>
470 inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
472 {
473  return Vector<Cmpt>
474  (
475  t.xx()*v.x() + t.xy()*v.y() + t.xz()*v.z(),
476  t.yx()*v.x() + t.yy()*v.y() + t.yz()*v.z(),
477  t.zx()*v.x() + t.zy()*v.y() + t.zz()*v.z()
478  );
479 }
480 
481 
482 template<class Cmpt>
483 inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
485 {
486  return Vector<Cmpt>
487  (
488  v.x()*t.xx() + v.y()*t.yx() + v.z()*t.zx(),
489  v.x()*t.xy() + v.y()*t.yy() + v.z()*t.zy(),
490  v.x()*t.xz() + v.y()*t.yz() + v.z()*t.zz()
491  );
492 }
493 
494 
495 template<class Cmpt>
496 inline typename outerProduct<Vector<Cmpt>, Vector<Cmpt>>::type
497 operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
498 {
499  return Tensor<Cmpt>
500  (
501  v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
502  v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
503  v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
504  );
505 }
506 
507 
508 template<class Cmpt>
509 inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
511 {
512  return inv(t) & v;
513 }
514 
515 
516 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
517 
518 //- Return the trace of a tensor
519 template<class Cmpt>
520 inline Cmpt tr(const Tensor<Cmpt>& t)
521 {
522  return t.xx() + t.yy() + t.zz();
523 }
524 
525 
526 //- Return the spherical part of a tensor
527 template<class Cmpt>
529 {
530  return (1.0/3.0)*tr(t);
531 }
532 
533 
534 //- Return the symmetric part of a tensor
535 template<class Cmpt>
537 {
538  return SymmTensor<Cmpt>
539  (
540  t.xx(), 0.5*(t.xy() + t.yx()), 0.5*(t.xz() + t.zx()),
541  t.yy(), 0.5*(t.yz() + t.zy()),
542  t.zz()
543  );
544 }
545 
546 
547 //- Return twice the symmetric part of a tensor
548 template<class Cmpt>
550 {
551  return SymmTensor<Cmpt>
552  (
553  2*t.xx(), (t.xy() + t.yx()), (t.xz() + t.zx()),
554  2*t.yy(), (t.yz() + t.zy()),
555  2*t.zz()
556  );
557 }
558 
559 
560 //- Return the skew-symmetric part of a tensor
561 template<class Cmpt>
563 {
564  return Tensor<Cmpt>
565  (
566  0.0, 0.5*(t.xy() - t.yx()), 0.5*(t.xz() - t.zx()),
567  0.5*(t.yx() - t.xy()), 0.0, 0.5*(t.yz() - t.zy()),
568  0.5*(t.zx() - t.xz()), 0.5*(t.zy() - t.yz()), 0.0
569  );
570 }
571 
572 
573 //- Return the skew-symmetric part of a symmetric tensor
574 template<class Cmpt>
575 inline const Tensor<Cmpt>& skew(const SymmTensor<Cmpt>& st)
576 {
577  return Tensor<Cmpt>::zero;
578 }
579 
580 
581 //- Return the deviatoric part of a tensor
582 template<class Cmpt>
583 inline Tensor<Cmpt> dev(const Tensor<Cmpt>& t)
584 {
585  return t - SphericalTensor<Cmpt>::oneThirdI*tr(t);
586 }
587 
588 
589 //- Return the deviatoric part of a tensor
590 template<class Cmpt>
592 {
594 }
595 
596 
597 //- Return the determinant of a tensor
598 template<class Cmpt>
599 inline Cmpt det(const Tensor<Cmpt>& t)
600 {
601  return
602  (
603  t.xx()*t.yy()*t.zz() + t.xy()*t.yz()*t.zx()
604  + t.xz()*t.yx()*t.zy() - t.xx()*t.yz()*t.zy()
605  - t.xy()*t.yx()*t.zz() - t.xz()*t.yy()*t.zx()
606  );
607 }
608 
609 
610 //- Return the cofactor tensor of a tensor
611 template<class Cmpt>
612 inline Tensor<Cmpt> cof(const Tensor<Cmpt>& t)
613 {
614  return Tensor<Cmpt>
615  (
616  t.yy()*t.zz() - t.zy()*t.yz(),
617  t.zx()*t.yz() - t.yx()*t.zz(),
618  t.yx()*t.zy() - t.yy()*t.zx(),
619 
620  t.xz()*t.zy() - t.xy()*t.zz(),
621  t.xx()*t.zz() - t.xz()*t.zx(),
622  t.xy()*t.zx() - t.xx()*t.zy(),
623 
624  t.xy()*t.yz() - t.xz()*t.yy(),
625  t.yx()*t.xz() - t.xx()*t.yz(),
626  t.xx()*t.yy() - t.yx()*t.xy()
627  );
628 }
629 
630 
631 //- Return the inverse of a tensor given the determinant
632 template<class Cmpt>
633 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t, const Cmpt dett)
634 {
635  return Tensor<Cmpt>
636  (
637  t.yy()*t.zz() - t.zy()*t.yz(),
638  t.xz()*t.zy() - t.xy()*t.zz(),
639  t.xy()*t.yz() - t.xz()*t.yy(),
640 
641  t.zx()*t.yz() - t.yx()*t.zz(),
642  t.xx()*t.zz() - t.xz()*t.zx(),
643  t.yx()*t.xz() - t.xx()*t.yz(),
644 
645  t.yx()*t.zy() - t.yy()*t.zx(),
646  t.xy()*t.zx() - t.xx()*t.zy(),
647  t.xx()*t.yy() - t.yx()*t.xy()
648  )/dett;
649 }
650 
651 
652 //- Return the inverse of a tensor
653 template<class Cmpt>
654 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t)
655 {
656  return inv(t, det(t));
657 }
658 
659 
660 template<class Cmpt>
662 {
663  return Foam::inv(*this);
664 }
665 
666 
667 //- Return the 1st invariant of a tensor
668 template<class Cmpt>
669 inline Cmpt invariantI(const Tensor<Cmpt>& t)
670 {
671  return tr(t);
672 }
673 
674 
675 //- Return the 2nd invariant of a tensor
676 template<class Cmpt>
677 inline Cmpt invariantII(const Tensor<Cmpt>& t)
678 {
679  return
680  (
681  t.xx()*t.yy() + t.yy()*t.zz() + t.xx()*t.zz()
682  - t.xy()*t.yx() - t.yz()*t.zy() - t.xz()*t.zx()
683  );
684 }
685 
686 
687 //- Return the 3rd invariant of a tensor
688 template<class Cmpt>
689 inline Cmpt invariantIII(const Tensor<Cmpt>& t)
690 {
691  return det(t);
692 }
693 
694 
695 // * * * * * * * * * Mixed Tensor SphericalTensor Operators * * * * * * * * //
696 
697 template<class Cmpt>
698 inline Tensor<Cmpt>
700 {
701  return Tensor<Cmpt>
702  (
703  st1.ii() + t2.xx(), t2.xy(), t2.xz(),
704  t2.yx(), st1.ii() + t2.yy(), t2.yz(),
705  t2.zx(), t2.zy(), st1.ii() + t2.zz()
706  );
707 }
708 
709 
710 template<class Cmpt>
711 inline Tensor<Cmpt>
713 {
714  return Tensor<Cmpt>
715  (
716  t1.xx() + st2.ii(), t1.xy(), t1.xz(),
717  t1.yx(), t1.yy() + st2.ii(), t1.yz(),
718  t1.zx(), t1.zy(), t1.zz() + st2.ii()
719  );
720 }
721 
722 
723 template<class Cmpt>
724 inline Tensor<Cmpt>
726 {
727  return Tensor<Cmpt>
728  (
729  st1.ii() - t2.xx(), -t2.xy(), -t2.xz(),
730  -t2.yx(), st1.ii() - t2.yy(), -t2.yz(),
731  -t2.zx(), -t2.zy(), st1.ii() - t2.zz()
732  );
733 }
734 
735 
736 template<class Cmpt>
737 inline Tensor<Cmpt>
739 {
740  return Tensor<Cmpt>
741  (
742  t1.xx() - st2.ii(), t1.xy(), t1.xz(),
743  t1.yx(), t1.yy() - st2.ii(), t1.yz(),
744  t1.zx(), t1.zy(), t1.zz() - st2.ii()
745  );
746 }
747 
748 
749 //- Inner-product between a spherical tensor and a tensor
750 template<class Cmpt>
751 inline Tensor<Cmpt>
753 {
754  return Tensor<Cmpt>
755  (
756  st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
757  st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
758  st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
759  );
760 }
761 
762 
763 //- Inner-product between a tensor and a spherical tensor
764 template<class Cmpt>
765 inline Tensor<Cmpt>
767 {
768  return Tensor<Cmpt>
769  (
770  t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
771  t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
772  t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
773  );
774 }
775 
776 
777 //- Double-dot-product between a spherical tensor and a tensor
778 template<class Cmpt>
779 inline Cmpt
781 {
782  return(st1.ii()*t2.xx() + st1.ii()*t2.yy() + st1.ii()*t2.zz());
783 }
784 
785 
786 //- Double-dot-product between a tensor and a spherical tensor
787 template<class Cmpt>
788 inline Cmpt
790 {
791  return(t1.xx()*st2.ii() + t1.yy()*st2.ii() + t1.zz()*st2.ii());
792 }
793 
794 
795 template<class Cmpt>
796 class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt>>
797 {
798 public:
799 
801 };
802 
803 
804 template<class Cmpt>
805 class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt>>
806 {
807 public:
808 
810 };
811 
812 
813 template<class Cmpt>
815 {
816 public:
817 
819 };
820 
821 
822 template<class Cmpt>
824 {
825 public:
826 
828 };
829 
830 
831 // * * * * * * * * * * Mixed Tensor SymmTensor Operators * * * * * * * * * * //
832 
833 template<class Cmpt>
834 inline Tensor<Cmpt>
836 {
837  return Tensor<Cmpt>
838  (
839  st1.xx() + t2.xx(), st1.xy() + t2.xy(), st1.xz() + t2.xz(),
840  st1.xy() + t2.yx(), st1.yy() + t2.yy(), st1.yz() + t2.yz(),
841  st1.xz() + t2.zx(), st1.yz() + t2.zy(), st1.zz() + t2.zz()
842  );
843 }
844 
845 
846 template<class Cmpt>
847 inline Tensor<Cmpt>
849 {
850  return Tensor<Cmpt>
851  (
852  t1.xx() + st2.xx(), t1.xy() + st2.xy(), t1.xz() + st2.xz(),
853  t1.yx() + st2.xy(), t1.yy() + st2.yy(), t1.yz() + st2.yz(),
854  t1.zx() + st2.xz(), t1.zy() + st2.yz(), t1.zz() + st2.zz()
855  );
856 }
857 
858 
859 template<class Cmpt>
860 inline Tensor<Cmpt>
862 {
863  return Tensor<Cmpt>
864  (
865  st1.xx() - t2.xx(), st1.xy() - t2.xy(), st1.xz() - t2.xz(),
866  st1.xy() - t2.yx(), st1.yy() - t2.yy(), st1.yz() - t2.yz(),
867  st1.xz() - t2.zx(), st1.yz() - t2.zy(), st1.zz() - t2.zz()
868  );
869 }
870 
871 
872 template<class Cmpt>
873 inline Tensor<Cmpt>
875 {
876  return Tensor<Cmpt>
877  (
878  t1.xx() - st2.xx(), t1.xy() - st2.xy(), t1.xz() - st2.xz(),
879  t1.yx() - st2.xy(), t1.yy() - st2.yy(), t1.yz() - st2.yz(),
880  t1.zx() - st2.xz(), t1.zy() - st2.yz(), t1.zz() - st2.zz()
881  );
882 }
883 
884 
885 //- Inner-product between a symmetric tensor and a tensor
886 template<class Cmpt>
887 inline Tensor<Cmpt>
889 {
890  return Tensor<Cmpt>
891  (
892  st1.xx()*t2.xx() + st1.xy()*t2.yx() + st1.xz()*t2.zx(),
893  st1.xx()*t2.xy() + st1.xy()*t2.yy() + st1.xz()*t2.zy(),
894  st1.xx()*t2.xz() + st1.xy()*t2.yz() + st1.xz()*t2.zz(),
895 
896  st1.xy()*t2.xx() + st1.yy()*t2.yx() + st1.yz()*t2.zx(),
897  st1.xy()*t2.xy() + st1.yy()*t2.yy() + st1.yz()*t2.zy(),
898  st1.xy()*t2.xz() + st1.yy()*t2.yz() + st1.yz()*t2.zz(),
899 
900  st1.xz()*t2.xx() + st1.yz()*t2.yx() + st1.zz()*t2.zx(),
901  st1.xz()*t2.xy() + st1.yz()*t2.yy() + st1.zz()*t2.zy(),
902  st1.xz()*t2.xz() + st1.yz()*t2.yz() + st1.zz()*t2.zz()
903  );
904 }
905 
906 
907 //- Inner-product between a tensor and a symmetric tensor
908 template<class Cmpt>
909 inline Tensor<Cmpt>
911 {
912  return Tensor<Cmpt>
913  (
914  t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz(),
915  t1.xx()*st2.xy() + t1.xy()*st2.yy() + t1.xz()*st2.yz(),
916  t1.xx()*st2.xz() + t1.xy()*st2.yz() + t1.xz()*st2.zz(),
917 
918  t1.yx()*st2.xx() + t1.yy()*st2.xy() + t1.yz()*st2.xz(),
919  t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz(),
920  t1.yx()*st2.xz() + t1.yy()*st2.yz() + t1.yz()*st2.zz(),
921 
922  t1.zx()*st2.xx() + t1.zy()*st2.xy() + t1.zz()*st2.xz(),
923  t1.zx()*st2.xy() + t1.zy()*st2.yy() + t1.zz()*st2.yz(),
924  t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
925  );
926 }
927 
928 
929 //- Double-dot-product between a symmetric tensor and a tensor
930 template<class Cmpt>
931 inline Cmpt
933 {
934  return
935  (
936  st1.xx()*t2.xx() + st1.xy()*t2.xy() + st1.xz()*t2.xz() +
937  st1.xy()*t2.yx() + st1.yy()*t2.yy() + st1.yz()*t2.yz() +
938  st1.xz()*t2.zx() + st1.yz()*t2.zy() + st1.zz()*t2.zz()
939  );
940 }
941 
942 
943 //- Double-dot-product between a tensor and a symmetric tensor
944 template<class Cmpt>
945 inline Cmpt
947 {
948  return
949  (
950  t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz() +
951  t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz() +
952  t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
953  );
954 }
955 
956 
957 template<class Cmpt>
958 class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt>>
959 {
960 public:
961 
963 };
964 
965 
966 template<class Cmpt>
967 class typeOfSum<Tensor<Cmpt>, SymmTensor<Cmpt>>
968 {
969 public:
970 
972 };
973 
974 
975 template<class Cmpt>
976 class innerProduct<SymmTensor<Cmpt>, Tensor<Cmpt>>
977 {
978 public:
979 
981 };
982 
983 
984 template<class Cmpt>
985 class innerProduct<Tensor<Cmpt>, SymmTensor<Cmpt>>
986 {
987 public:
988 
990 };
991 
992 
993 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
994 
995 } // End namespace Foam
996 
997 // ************************************************************************* //
scalar y
Templated 3D DiagTensor derived from VectorSpace.
Definition: DiagTensor.H:56
const Cmpt & xx() const
Definition: DiagTensorI.H:85
const Cmpt & zz() const
Definition: DiagTensorI.H:97
const Cmpt & yy() const
Definition: DiagTensorI.H:91
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
Templated matrix space.
Definition: MatrixSpace.H:58
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component,...
const Cmpt & ii() const
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components,...
Definition: SymmTensor.H:56
const Cmpt & xx() const
Definition: SymmTensorI.H:87
const Cmpt & yz() const
Definition: SymmTensorI.H:111
const Cmpt & xz() const
Definition: SymmTensorI.H:99
const Cmpt & zz() const
Definition: SymmTensorI.H:117
const Cmpt & xy() const
Definition: SymmTensorI.H:93
const Cmpt & yy() const
Definition: SymmTensorI.H:105
Templated 3D tensor derived from MatrixSpace adding construction from 9 components,...
Definition: Tensor.H:67
Tensor()
Construct null.
Definition: TensorI.H:32
Tensor< Cmpt > T() const
Return transpose.
Definition: TensorI.H:331
const Cmpt & xx() const
Definition: TensorI.H:163
void operator&=(const Tensor< Cmpt > &)
Inner-product with a Tensor.
Definition: TensorI.H:345
const Cmpt & yx() const
Definition: TensorI.H:184
const Cmpt & yz() const
Definition: TensorI.H:198
Vector< Cmpt > z() const
Definition: TensorI.H:303
const Cmpt & xz() const
Definition: TensorI.H:177
const Cmpt & zz() const
Definition: TensorI.H:219
Tensor< Cmpt > inv() const
Return inverse.
Definition: TensorI.H:661
void operator=(const VectorSpace< Tensor< Cmpt2 >, Cmpt2, 9 > &)
Assign to an equivalent vector space.
Definition: TensorI.H:370
const Cmpt & xy() const
Definition: TensorI.H:170
const Cmpt & zx() const
Definition: TensorI.H:205
const Cmpt & zy() const
Definition: TensorI.H:212
const Cmpt & yy() const
Definition: TensorI.H:191
Vector< Cmpt > y() const
Definition: TensorI.H:296
Vector< Cmpt > vectorComponent(const direction) const
Definition: TensorI.H:311
Vector< Cmpt > x() const
Definition: TensorI.H:289
Templated vector space.
Definition: VectorSpace.H:85
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:60
const Cmpt & z() const
Definition: VectorI.H:87
const Cmpt & y() const
Definition: VectorI.H:81
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:66
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:50
Namespace for OpenFOAM.
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensionedScalar det(const dimensionedSphericalTensor &dt)
static const zero Zero
Definition: zero.H:97
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Cmpt invariantI(const SymmTensor< Cmpt > &st)
Return the 1st invariant of a symmetric tensor.
Definition: SymmTensorI.H:395
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a diagonal tensor.
Definition: DiagTensorI.H:353
Cmpt invariantIII(const SymmTensor< Cmpt > &st)
Return the 3rd invariant of a symmetric tensor.
Definition: SymmTensorI.H:415
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Cmpt tr(const Tensor< Cmpt > &t)
Return the trace of a tensor.
Definition: TensorI.H:520
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a symmetric tensor.
Definition: SymmTensorI.H:403
tmp< VolField< Type > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
dimensionedTensor skew(const dimensionedTensor &dt)
uint8_t direction
Definition: direction.H:45
tmp< fvMatrix< Type > > operator/(const fvMatrix< Type > &, const volScalarField::Internal &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dimensioned< typename scalarProduct< Type1, Type2 >::type > operator&&(const dimensioned< Type1 > &, const dimensioned< Type2 > &)