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-2026 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  return Vector<Cmpt>();
329 }
330 
331 
332 template<class Cmpt>
334 {
335  return Tensor<Cmpt>
336  (
337  xx(), yx(), zx(),
338  xy(), yy(), zy(),
339  xz(), yz(), zz()
340  );
341 }
342 
343 
344 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
345 
346 template<class Cmpt>
348 {
349  *this =
350  (
352  (
353  this->xx()*t.xx() + this->xy()*t.yx() + this->xz()*t.zx(),
354  this->xx()*t.xy() + this->xy()*t.yy() + this->xz()*t.zy(),
355  this->xx()*t.xz() + this->xy()*t.yz() + this->xz()*t.zz(),
356 
357  this->yx()*t.xx() + this->yy()*t.yx() + this->yz()*t.zx(),
358  this->yx()*t.xy() + this->yy()*t.yy() + this->yz()*t.zy(),
359  this->yx()*t.xz() + this->yy()*t.yz() + this->yz()*t.zz(),
360 
361  this->zx()*t.xx() + this->zy()*t.yx() + this->zz()*t.zx(),
362  this->zx()*t.xy() + this->zy()*t.yy() + this->zz()*t.zy(),
363  this->zx()*t.xz() + this->zy()*t.yz() + this->zz()*t.zz()
364  )
365  );
366 }
367 
368 
369 template<class Cmpt>
370 template<class Cmpt2>
372 (
373  const VectorSpace<Tensor<Cmpt2>, Cmpt2, 9>& vs
374 )
375 {
376  VectorSpace<Tensor<Cmpt>, Cmpt, 9>::operator=(vs);
377 }
378 
379 
380 template<class Cmpt>
382 {
383  this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
384  this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0;
385  this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii();
386 }
387 
388 
389 template<class Cmpt>
391 {
392  this->v_[XX] = dt.xx(); this->v_[XY] = 0; this->v_[XZ] = 0;
393  this->v_[YX] = 0; this->v_[YY] = dt.yy(); this->v_[YZ] = 0;
394  this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = dt.zz();
395 }
396 
397 
398 template<class Cmpt>
400 {
401  this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
402  this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz();
403  this->v_[ZX] = st.xz(); this->v_[ZY] = st.yz(); this->v_[ZZ] = st.zz();
404 }
405 
406 
407 template<class Cmpt>
409 {
410  this->v_[XX] = tr.x().x();
411  this->v_[XY] = tr.x().y();
412  this->v_[XZ] = tr.x().z();
413 
414  this->v_[YX] = tr.y().x();
415  this->v_[YY] = tr.y().y();
416  this->v_[YZ] = tr.y().z();
417 
418  this->v_[ZX] = tr.z().x();
419  this->v_[ZY] = tr.z().y();
420  this->v_[ZZ] = tr.z().z();
421 }
422 
423 
424 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
425 
426 namespace Foam
427 {
428 
429 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
430 
431 template<class Cmpt>
433 {
434  return Vector<Cmpt>(t.yz(), -t.xz(), t.xy());
435 }
436 
437 
438 template<class Cmpt>
440 {
441  return Tensor<Cmpt>
442  (
443  0, -v.z(), v.y(),
444  v.z(), 0, -v.x(),
445  -v.y(), v.x(), 0
446  );
447 }
448 
449 
450 template<class Cmpt>
451 inline typename innerProduct<Tensor<Cmpt>, Tensor<Cmpt>>::type
452 operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
453 {
454  return Tensor<Cmpt>
455  (
456  t1.xx()*t2.xx() + t1.xy()*t2.yx() + t1.xz()*t2.zx(),
457  t1.xx()*t2.xy() + t1.xy()*t2.yy() + t1.xz()*t2.zy(),
458  t1.xx()*t2.xz() + t1.xy()*t2.yz() + t1.xz()*t2.zz(),
459 
460  t1.yx()*t2.xx() + t1.yy()*t2.yx() + t1.yz()*t2.zx(),
461  t1.yx()*t2.xy() + t1.yy()*t2.yy() + t1.yz()*t2.zy(),
462  t1.yx()*t2.xz() + t1.yy()*t2.yz() + t1.yz()*t2.zz(),
463 
464  t1.zx()*t2.xx() + t1.zy()*t2.yx() + t1.zz()*t2.zx(),
465  t1.zx()*t2.xy() + t1.zy()*t2.yy() + t1.zz()*t2.zy(),
466  t1.zx()*t2.xz() + t1.zy()*t2.yz() + t1.zz()*t2.zz()
467  );
468 }
469 
470 
471 template<class Cmpt>
472 inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
474 {
475  return Vector<Cmpt>
476  (
477  t.xx()*v.x() + t.xy()*v.y() + t.xz()*v.z(),
478  t.yx()*v.x() + t.yy()*v.y() + t.yz()*v.z(),
479  t.zx()*v.x() + t.zy()*v.y() + t.zz()*v.z()
480  );
481 }
482 
483 
484 template<class Cmpt>
485 inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
487 {
488  return Vector<Cmpt>
489  (
490  v.x()*t.xx() + v.y()*t.yx() + v.z()*t.zx(),
491  v.x()*t.xy() + v.y()*t.yy() + v.z()*t.zy(),
492  v.x()*t.xz() + v.y()*t.yz() + v.z()*t.zz()
493  );
494 }
495 
496 
497 template<class Cmpt>
498 inline typename outerProduct<Vector<Cmpt>, Vector<Cmpt>>::type
499 operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
500 {
501  return Tensor<Cmpt>
502  (
503  v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
504  v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
505  v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
506  );
507 }
508 
509 
510 template<class Cmpt>
511 inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
513 {
514  return inv(t) & v;
515 }
516 
517 
518 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
519 
520 //- Return the trace of a tensor
521 template<class Cmpt>
522 inline Cmpt tr(const Tensor<Cmpt>& t)
523 {
524  return t.xx() + t.yy() + t.zz();
525 }
526 
527 
528 //- Return the spherical part of a tensor
529 template<class Cmpt>
531 {
532  return (1.0/3.0)*tr(t);
533 }
534 
535 
536 //- Return the symmetric part of a tensor
537 template<class Cmpt>
539 {
540  return SymmTensor<Cmpt>
541  (
542  t.xx(), 0.5*(t.xy() + t.yx()), 0.5*(t.xz() + t.zx()),
543  t.yy(), 0.5*(t.yz() + t.zy()),
544  t.zz()
545  );
546 }
547 
548 
549 //- Return twice the symmetric part of a tensor
550 template<class Cmpt>
552 {
553  return SymmTensor<Cmpt>
554  (
555  2*t.xx(), (t.xy() + t.yx()), (t.xz() + t.zx()),
556  2*t.yy(), (t.yz() + t.zy()),
557  2*t.zz()
558  );
559 }
560 
561 
562 //- Return the skew-symmetric part of a tensor
563 template<class Cmpt>
565 {
566  return Tensor<Cmpt>
567  (
568  0.0, 0.5*(t.xy() - t.yx()), 0.5*(t.xz() - t.zx()),
569  0.5*(t.yx() - t.xy()), 0.0, 0.5*(t.yz() - t.zy()),
570  0.5*(t.zx() - t.xz()), 0.5*(t.zy() - t.yz()), 0.0
571  );
572 }
573 
574 
575 //- Return the skew-symmetric part of a symmetric tensor
576 template<class Cmpt>
577 inline const Tensor<Cmpt>& skew(const SymmTensor<Cmpt>& st)
578 {
579  return Tensor<Cmpt>::zero;
580 }
581 
582 
583 //- Return the deviatoric part of a tensor
584 template<class Cmpt>
585 inline Tensor<Cmpt> dev(const Tensor<Cmpt>& t)
586 {
587  return t - SphericalTensor<Cmpt>::oneThirdI*tr(t);
588 }
589 
590 
591 //- Return the deviatoric part of a tensor
592 template<class Cmpt>
594 {
596 }
597 
598 
599 //- Return the determinant of a tensor
600 template<class Cmpt>
601 inline Cmpt det(const Tensor<Cmpt>& t)
602 {
603  return
604  (
605  t.xx()*t.yy()*t.zz() + t.xy()*t.yz()*t.zx()
606  + t.xz()*t.yx()*t.zy() - t.xx()*t.yz()*t.zy()
607  - t.xy()*t.yx()*t.zz() - t.xz()*t.yy()*t.zx()
608  );
609 }
610 
611 
612 //- Return the cofactor tensor of a tensor
613 template<class Cmpt>
614 inline Tensor<Cmpt> cof(const Tensor<Cmpt>& t)
615 {
616  return Tensor<Cmpt>
617  (
618  t.yy()*t.zz() - t.zy()*t.yz(),
619  t.zx()*t.yz() - t.yx()*t.zz(),
620  t.yx()*t.zy() - t.yy()*t.zx(),
621 
622  t.xz()*t.zy() - t.xy()*t.zz(),
623  t.xx()*t.zz() - t.xz()*t.zx(),
624  t.xy()*t.zx() - t.xx()*t.zy(),
625 
626  t.xy()*t.yz() - t.xz()*t.yy(),
627  t.yx()*t.xz() - t.xx()*t.yz(),
628  t.xx()*t.yy() - t.yx()*t.xy()
629  );
630 }
631 
632 
633 //- Return the inverse of a tensor given the determinant
634 template<class Cmpt>
635 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t, const Cmpt dett)
636 {
637  return Tensor<Cmpt>
638  (
639  t.yy()*t.zz() - t.zy()*t.yz(),
640  t.xz()*t.zy() - t.xy()*t.zz(),
641  t.xy()*t.yz() - t.xz()*t.yy(),
642 
643  t.zx()*t.yz() - t.yx()*t.zz(),
644  t.xx()*t.zz() - t.xz()*t.zx(),
645  t.yx()*t.xz() - t.xx()*t.yz(),
646 
647  t.yx()*t.zy() - t.yy()*t.zx(),
648  t.xy()*t.zx() - t.xx()*t.zy(),
649  t.xx()*t.yy() - t.yx()*t.xy()
650  )/dett;
651 }
652 
653 
654 //- Return the inverse of a tensor
655 template<class Cmpt>
656 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t)
657 {
658  return inv(t, det(t));
659 }
660 
661 
662 template<class Cmpt>
664 {
665  return Foam::inv(*this);
666 }
667 
668 
669 //- Return the 1st invariant of a tensor
670 template<class Cmpt>
671 inline Cmpt invariantI(const Tensor<Cmpt>& t)
672 {
673  return tr(t);
674 }
675 
676 
677 //- Return the 2nd invariant of a tensor
678 template<class Cmpt>
679 inline Cmpt invariantII(const Tensor<Cmpt>& t)
680 {
681  return
682  (
683  t.xx()*t.yy() + t.yy()*t.zz() + t.xx()*t.zz()
684  - t.xy()*t.yx() - t.yz()*t.zy() - t.xz()*t.zx()
685  );
686 }
687 
688 
689 //- Return the 3rd invariant of a tensor
690 template<class Cmpt>
691 inline Cmpt invariantIII(const Tensor<Cmpt>& t)
692 {
693  return det(t);
694 }
695 
696 
697 // * * * * * * * * * Mixed Tensor SphericalTensor Operators * * * * * * * * //
698 
699 template<class Cmpt>
700 inline Tensor<Cmpt>
702 {
703  return Tensor<Cmpt>
704  (
705  st1.ii() + t2.xx(), t2.xy(), t2.xz(),
706  t2.yx(), st1.ii() + t2.yy(), t2.yz(),
707  t2.zx(), t2.zy(), st1.ii() + t2.zz()
708  );
709 }
710 
711 
712 template<class Cmpt>
713 inline Tensor<Cmpt>
715 {
716  return Tensor<Cmpt>
717  (
718  t1.xx() + st2.ii(), t1.xy(), t1.xz(),
719  t1.yx(), t1.yy() + st2.ii(), t1.yz(),
720  t1.zx(), t1.zy(), t1.zz() + st2.ii()
721  );
722 }
723 
724 
725 template<class Cmpt>
726 inline Tensor<Cmpt>
728 {
729  return Tensor<Cmpt>
730  (
731  st1.ii() - t2.xx(), -t2.xy(), -t2.xz(),
732  -t2.yx(), st1.ii() - t2.yy(), -t2.yz(),
733  -t2.zx(), -t2.zy(), st1.ii() - t2.zz()
734  );
735 }
736 
737 
738 template<class Cmpt>
739 inline Tensor<Cmpt>
741 {
742  return Tensor<Cmpt>
743  (
744  t1.xx() - st2.ii(), t1.xy(), t1.xz(),
745  t1.yx(), t1.yy() - st2.ii(), t1.yz(),
746  t1.zx(), t1.zy(), t1.zz() - st2.ii()
747  );
748 }
749 
750 
751 //- Inner-product between a spherical tensor and a tensor
752 template<class Cmpt>
753 inline Tensor<Cmpt>
755 {
756  return Tensor<Cmpt>
757  (
758  st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
759  st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
760  st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
761  );
762 }
763 
764 
765 //- Inner-product between a tensor and a spherical tensor
766 template<class Cmpt>
767 inline Tensor<Cmpt>
769 {
770  return Tensor<Cmpt>
771  (
772  t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
773  t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
774  t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
775  );
776 }
777 
778 
779 //- Double-dot-product between a spherical tensor and a tensor
780 template<class Cmpt>
781 inline Cmpt
783 {
784  return(st1.ii()*t2.xx() + st1.ii()*t2.yy() + st1.ii()*t2.zz());
785 }
786 
787 
788 //- Double-dot-product between a tensor and a spherical tensor
789 template<class Cmpt>
790 inline Cmpt
792 {
793  return(t1.xx()*st2.ii() + t1.yy()*st2.ii() + t1.zz()*st2.ii());
794 }
795 
796 
797 template<class Cmpt>
798 class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt>>
799 {
800 public:
801 
803 };
804 
805 
806 template<class Cmpt>
807 class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt>>
808 {
809 public:
810 
812 };
813 
814 
815 template<class Cmpt>
817 {
818 public:
819 
821 };
822 
823 
824 template<class Cmpt>
826 {
827 public:
828 
830 };
831 
832 
833 // * * * * * * * * * * Mixed Tensor SymmTensor Operators * * * * * * * * * * //
834 
835 template<class Cmpt>
836 inline Tensor<Cmpt>
838 {
839  return Tensor<Cmpt>
840  (
841  st1.xx() + t2.xx(), st1.xy() + t2.xy(), st1.xz() + t2.xz(),
842  st1.xy() + t2.yx(), st1.yy() + t2.yy(), st1.yz() + t2.yz(),
843  st1.xz() + t2.zx(), st1.yz() + t2.zy(), st1.zz() + t2.zz()
844  );
845 }
846 
847 
848 template<class Cmpt>
849 inline Tensor<Cmpt>
851 {
852  return Tensor<Cmpt>
853  (
854  t1.xx() + st2.xx(), t1.xy() + st2.xy(), t1.xz() + st2.xz(),
855  t1.yx() + st2.xy(), t1.yy() + st2.yy(), t1.yz() + st2.yz(),
856  t1.zx() + st2.xz(), t1.zy() + st2.yz(), t1.zz() + st2.zz()
857  );
858 }
859 
860 
861 template<class Cmpt>
862 inline Tensor<Cmpt>
864 {
865  return Tensor<Cmpt>
866  (
867  st1.xx() - t2.xx(), st1.xy() - t2.xy(), st1.xz() - t2.xz(),
868  st1.xy() - t2.yx(), st1.yy() - t2.yy(), st1.yz() - t2.yz(),
869  st1.xz() - t2.zx(), st1.yz() - t2.zy(), st1.zz() - t2.zz()
870  );
871 }
872 
873 
874 template<class Cmpt>
875 inline Tensor<Cmpt>
877 {
878  return Tensor<Cmpt>
879  (
880  t1.xx() - st2.xx(), t1.xy() - st2.xy(), t1.xz() - st2.xz(),
881  t1.yx() - st2.xy(), t1.yy() - st2.yy(), t1.yz() - st2.yz(),
882  t1.zx() - st2.xz(), t1.zy() - st2.yz(), t1.zz() - st2.zz()
883  );
884 }
885 
886 
887 //- Inner-product between a symmetric tensor and a tensor
888 template<class Cmpt>
889 inline Tensor<Cmpt>
891 {
892  return Tensor<Cmpt>
893  (
894  st1.xx()*t2.xx() + st1.xy()*t2.yx() + st1.xz()*t2.zx(),
895  st1.xx()*t2.xy() + st1.xy()*t2.yy() + st1.xz()*t2.zy(),
896  st1.xx()*t2.xz() + st1.xy()*t2.yz() + st1.xz()*t2.zz(),
897 
898  st1.xy()*t2.xx() + st1.yy()*t2.yx() + st1.yz()*t2.zx(),
899  st1.xy()*t2.xy() + st1.yy()*t2.yy() + st1.yz()*t2.zy(),
900  st1.xy()*t2.xz() + st1.yy()*t2.yz() + st1.yz()*t2.zz(),
901 
902  st1.xz()*t2.xx() + st1.yz()*t2.yx() + st1.zz()*t2.zx(),
903  st1.xz()*t2.xy() + st1.yz()*t2.yy() + st1.zz()*t2.zy(),
904  st1.xz()*t2.xz() + st1.yz()*t2.yz() + st1.zz()*t2.zz()
905  );
906 }
907 
908 
909 //- Inner-product between a tensor and a symmetric tensor
910 template<class Cmpt>
911 inline Tensor<Cmpt>
913 {
914  return Tensor<Cmpt>
915  (
916  t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz(),
917  t1.xx()*st2.xy() + t1.xy()*st2.yy() + t1.xz()*st2.yz(),
918  t1.xx()*st2.xz() + t1.xy()*st2.yz() + t1.xz()*st2.zz(),
919 
920  t1.yx()*st2.xx() + t1.yy()*st2.xy() + t1.yz()*st2.xz(),
921  t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz(),
922  t1.yx()*st2.xz() + t1.yy()*st2.yz() + t1.yz()*st2.zz(),
923 
924  t1.zx()*st2.xx() + t1.zy()*st2.xy() + t1.zz()*st2.xz(),
925  t1.zx()*st2.xy() + t1.zy()*st2.yy() + t1.zz()*st2.yz(),
926  t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
927  );
928 }
929 
930 
931 //- Double-dot-product between a symmetric tensor and a tensor
932 template<class Cmpt>
933 inline Cmpt
935 {
936  return
937  (
938  st1.xx()*t2.xx() + st1.xy()*t2.xy() + st1.xz()*t2.xz() +
939  st1.xy()*t2.yx() + st1.yy()*t2.yy() + st1.yz()*t2.yz() +
940  st1.xz()*t2.zx() + st1.yz()*t2.zy() + st1.zz()*t2.zz()
941  );
942 }
943 
944 
945 //- Double-dot-product between a tensor and a symmetric tensor
946 template<class Cmpt>
947 inline Cmpt
949 {
950  return
951  (
952  t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz() +
953  t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz() +
954  t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
955  );
956 }
957 
958 
959 template<class Cmpt>
960 class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt>>
961 {
962 public:
963 
965 };
966 
967 
968 template<class Cmpt>
969 class typeOfSum<Tensor<Cmpt>, SymmTensor<Cmpt>>
970 {
971 public:
972 
974 };
975 
976 
977 template<class Cmpt>
978 class innerProduct<SymmTensor<Cmpt>, Tensor<Cmpt>>
979 {
980 public:
981 
983 };
984 
985 
986 template<class Cmpt>
987 class innerProduct<Tensor<Cmpt>, SymmTensor<Cmpt>>
988 {
989 public:
990 
992 };
993 
994 
995 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
996 
997 } // End namespace Foam
998 
999 // ************************************************************************* //
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:117
const Cmpt & xz() const
Definition: SymmTensorI.H:99
const Cmpt & zz() const
Definition: SymmTensorI.H:135
const Cmpt & xy() const
Definition: SymmTensorI.H:93
const Cmpt & yy() const
Definition: SymmTensorI.H:111
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:333
const Cmpt & xx() const
Definition: TensorI.H:163
void operator&=(const Tensor< Cmpt > &)
Inner-product with a Tensor.
Definition: TensorI.H:347
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:663
void operator=(const VectorSpace< Tensor< Cmpt2 >, Cmpt2, 9 > &)
Assign to an equivalent vector space.
Definition: TensorI.H:372
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.
static const zero Zero
Definition: zero.H:97
void skew(pointPatchField< tensor > &, const pointPatchField< tensor > &)
Cmpt invariantI(const SymmTensor< Cmpt > &st)
Return the 1st invariant of a symmetric tensor.
Definition: SymmTensorI.H:413
tmp< DimensionedField< Type, GeoMesh, Field > > operator/(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< scalar, GeoMesh, PrimitiveField2 > &df2)
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a diagonal tensor.
Definition: DiagTensorI.H:353
tmp< DimensionedField< typename typeOfSum< Type1, Type2 >::type, GeoMesh, Field > > operator+(const DimensionedField< Type1, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type2, GeoMesh, PrimitiveField2 > &df2)
tmp< DimensionedField< Type, GeoMesh, Field > > operator*(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< scalar, GeoMesh, PrimitiveField2 > &df2)
void dev2(pointPatchField< tensor > &, const pointPatchField< tensor > &)
Cmpt invariantIII(const SymmTensor< Cmpt > &st)
Return the 3rd invariant of a symmetric tensor.
Definition: SymmTensorI.H:433
void tr(pointPatchField< scalar > &, const pointPatchField< tensor > &)
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
tmp< DimensionedField< Type, GeoMesh, Field > > operator-(const DimensionedField< Type, GeoMesh, PrimitiveField > &df1)
void inv(pointPatchField< tensor > &, const pointPatchField< tensor > &)
Cmpt tr(const Tensor< Cmpt > &t)
Return the trace of a tensor.
Definition: TensorI.H:522
void dev(pointPatchField< tensor > &, const pointPatchField< tensor > &)
tmp< DimensionedField< typename scalarProduct< Type1, Type2 >::type, GeoMesh, Field > > operator&&(const DimensionedField< Type1, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type2, GeoMesh, PrimitiveField2 > &df2)
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a symmetric tensor.
Definition: SymmTensorI.H:421
void symm(pointPatchField< tensor > &, const pointPatchField< tensor > &)
void det(pointPatchField< scalar > &, const pointPatchField< tensor > &)
void twoSymm(pointPatchField< tensor > &, const pointPatchField< tensor > &)
tmp< DimensionedField< typename innerProduct< Type1, Type2 >::type, GeoMesh, Field > > operator&(const DimensionedField< Type1, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type2, GeoMesh, PrimitiveField2 > &df2)
uint8_t direction
Definition: direction.H:45
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488