TensorI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 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 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Cmpt>
32 {}
33 
34 
35 template<class Cmpt>
37 :
39 {}
40 
41 
42 template<class Cmpt>
43 template<class Cmpt2>
45 (
46  const MatrixSpace<Tensor<Cmpt2>, Cmpt2, 3, 3>& vs
47 )
48 :
49  Tensor::msType(vs)
50 {}
51 
52 
53 template<class Cmpt>
54 template<class Cmpt2>
56 (
57  const VectorSpace<Tensor<Cmpt2>, Cmpt2, 9>& vs
58 )
59 :
60  Tensor::msType(vs)
61 {}
62 
63 
64 template<class Cmpt>
66 {
67  this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
68  this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0;
69  this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii();
70 }
71 
72 
73 template<class Cmpt>
75 {
76  this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
77  this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz();
78  this->v_[ZX] = st.xz(); this->v_[ZY] = st.yz(); this->v_[ZZ] = st.zz();
79 }
80 
81 
82 template<class Cmpt>
84 {
85  this->v_[XX] = tr.x().x();
86  this->v_[XY] = tr.x().y();
87  this->v_[XZ] = tr.x().z();
88 
89  this->v_[YX] = tr.y().x();
90  this->v_[YY] = tr.y().y();
91  this->v_[YZ] = tr.y().z();
92 
93  this->v_[ZX] = tr.z().x();
94  this->v_[ZY] = tr.z().y();
95  this->v_[ZZ] = tr.z().z();
96 }
97 
98 
99 template<class Cmpt>
101 (
102  const Vector<Cmpt>& x,
103  const Vector<Cmpt>& y,
104  const Vector<Cmpt>& z
105 )
106 {
107  this->v_[XX] = x.x(); this->v_[XY] = x.y(); this->v_[XZ] = x.z();
108  this->v_[YX] = y.x(); this->v_[YY] = y.y(); this->v_[YZ] = y.z();
109  this->v_[ZX] = z.x(); this->v_[ZY] = z.y(); this->v_[ZZ] = z.z();
110 }
111 
112 
113 template<class Cmpt>
115 (
116  const Cmpt txx, const Cmpt txy, const Cmpt txz,
117  const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
118  const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
119 )
120 {
121  this->v_[XX] = txx; this->v_[XY] = txy; this->v_[XZ] = txz;
122  this->v_[YX] = tyx; this->v_[YY] = tyy; this->v_[YZ] = tyz;
123  this->v_[ZX] = tzx; this->v_[ZY] = tzy; this->v_[ZZ] = tzz;
124 }
125 
126 
127 template<class Cmpt>
128 template
129 <
130  template<class, Foam::direction, Foam::direction> class Block2,
131  Foam::direction BRowStart,
132  Foam::direction BColStart
133 >
135 (
136  const Block2<Tensor<Cmpt>, BRowStart, BColStart>& block
137 )
138 :
140 {}
141 
142 
143 template<class Cmpt>
145 :
146  Tensor::msType(is)
147 {}
148 
149 
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151 
152 template<class Cmpt>
153 inline const Cmpt& Foam::Tensor<Cmpt>::xx() const
154 {
155  return this->v_[XX];
156 }
157 
158 
159 template<class Cmpt>
160 inline const Cmpt& Foam::Tensor<Cmpt>::xy() const
161 {
162  return this->v_[XY];
163 }
164 
165 
166 template<class Cmpt>
167 inline const Cmpt& Foam::Tensor<Cmpt>::xz() const
168 {
169  return this->v_[XZ];
170 }
171 
172 
173 template<class Cmpt>
174 inline const Cmpt& Foam::Tensor<Cmpt>::yx() const
175 {
176  return this->v_[YX];
177 }
178 
179 
180 template<class Cmpt>
181 inline const Cmpt& Foam::Tensor<Cmpt>::yy() const
182 {
183  return this->v_[YY];
184 }
185 
186 
187 template<class Cmpt>
188 inline const Cmpt& Foam::Tensor<Cmpt>::yz() const
189 {
190  return this->v_[YZ];
191 }
192 
193 
194 template<class Cmpt>
195 inline const Cmpt& Foam::Tensor<Cmpt>::zx() const
196 {
197  return this->v_[ZX];
198 }
199 
200 
201 template<class Cmpt>
202 inline const Cmpt& Foam::Tensor<Cmpt>::zy() const
203 {
204  return this->v_[ZY];
205 }
206 
207 
208 template<class Cmpt>
209 inline const Cmpt& Foam::Tensor<Cmpt>::zz() const
210 {
211  return this->v_[ZZ];
212 }
213 
214 
215 template<class Cmpt>
217 {
218  return this->v_[XX];
219 }
220 
221 
222 template<class Cmpt>
224 {
225  return this->v_[XY];
226 }
227 
228 
229 template<class Cmpt>
231 {
232  return this->v_[XZ];
233 }
234 
235 
236 template<class Cmpt>
238 {
239  return this->v_[YX];
240 }
241 
242 
243 template<class Cmpt>
245 {
246  return this->v_[YY];
247 }
248 
249 
250 template<class Cmpt>
252 {
253  return this->v_[YZ];
254 }
255 
256 
257 template<class Cmpt>
259 {
260  return this->v_[ZX];
261 }
262 
263 
264 template<class Cmpt>
266 {
267  return this->v_[ZY];
268 }
269 
270 
271 template<class Cmpt>
273 {
274  return this->v_[ZZ];
275 }
276 
277 
278 template<class Cmpt>
280 {
281  return Vector<Cmpt>(this->v_[XX], this->v_[XY], this->v_[XZ]);
282 }
283 
284 
285 template<class Cmpt>
287 {
288  return Vector<Cmpt>(this->v_[YX], this->v_[YY], this->v_[YZ]);
289 }
290 
291 
292 template<class Cmpt>
294 {
295  return Vector<Cmpt>(this->v_[ZX], this->v_[ZY], this->v_[ZZ]);
296 }
297 
298 
299 template<class Cmpt>
301 (
302  const direction cmpt
303 ) const
304 {
305  switch (cmpt)
306  {
307  case 0:
308  return x();
309  break;
310  case 1:
311  return y();
312  break;
313  case 2:
314  return z();
315  break;
316  }
317 }
318 
319 
320 template<class Cmpt>
322 {
323  return Tensor<Cmpt>
324  (
325  xx(), yx(), zx(),
326  xy(), yy(), zy(),
327  xz(), yz(), zz()
328  );
329 }
330 
331 
332 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
333 
334 template<class Cmpt>
336 {
337  *this =
338  (
340  (
341  this->xx()*t.xx() + this->xy()*t.yx() + this->xz()*t.zx(),
342  this->xx()*t.xy() + this->xy()*t.yy() + this->xz()*t.zy(),
343  this->xx()*t.xz() + this->xy()*t.yz() + this->xz()*t.zz(),
344 
345  this->yx()*t.xx() + this->yy()*t.yx() + this->yz()*t.zx(),
346  this->yx()*t.xy() + this->yy()*t.yy() + this->yz()*t.zy(),
347  this->yx()*t.xz() + this->yy()*t.yz() + this->yz()*t.zz(),
348 
349  this->zx()*t.xx() + this->zy()*t.yx() + this->zz()*t.zx(),
350  this->zx()*t.xy() + this->zy()*t.yy() + this->zz()*t.zy(),
351  this->zx()*t.xz() + this->zy()*t.yz() + this->zz()*t.zz()
352  )
353  );
354 }
355 
356 
357 template<class Cmpt>
358 template<class Cmpt2>
359 inline void Foam::Tensor<Cmpt>::operator=
360 (
361  const VectorSpace<Tensor<Cmpt2>, Cmpt2, 9>& vs
362 )
363 {
364  VectorSpace<Tensor<Cmpt>, Cmpt, 9>::operator=(vs);
365 }
366 
367 
368 template<class Cmpt>
370 {
371  this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
372  this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0;
373  this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii();
374 }
375 
376 
377 template<class Cmpt>
379 {
380  this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
381  this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz();
382  this->v_[ZX] = st.xz(); this->v_[ZY] = st.yz(); this->v_[ZZ] = st.zz();
383 }
384 
385 
386 template<class Cmpt>
388 {
389  this->v_[XX] = tr.x().x();
390  this->v_[XY] = tr.x().y();
391  this->v_[XZ] = tr.x().z();
392 
393  this->v_[YX] = tr.y().x();
394  this->v_[YY] = tr.y().y();
395  this->v_[YZ] = tr.y().z();
396 
397  this->v_[ZX] = tr.z().x();
398  this->v_[ZY] = tr.z().y();
399  this->v_[ZZ] = tr.z().z();
400 }
401 
402 
403 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
404 
405 namespace Foam
406 {
407 
408 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
409 
410 template<class Cmpt>
412 {
413  return Vector<Cmpt>(t.yz(), -t.xz(), t.xy());
414 }
415 
416 
417 template<class Cmpt>
419 {
420  return Tensor<Cmpt>
421  (
422  0, -v.z(), v.y(),
423  v.z(), 0, -v.x(),
424  -v.y(), v.x(), 0
425  );
426 }
427 
428 
429 template<class Cmpt>
431 operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
432 {
433  return Tensor<Cmpt>
434  (
435  t1.xx()*t2.xx() + t1.xy()*t2.yx() + t1.xz()*t2.zx(),
436  t1.xx()*t2.xy() + t1.xy()*t2.yy() + t1.xz()*t2.zy(),
437  t1.xx()*t2.xz() + t1.xy()*t2.yz() + t1.xz()*t2.zz(),
438 
439  t1.yx()*t2.xx() + t1.yy()*t2.yx() + t1.yz()*t2.zx(),
440  t1.yx()*t2.xy() + t1.yy()*t2.yy() + t1.yz()*t2.zy(),
441  t1.yx()*t2.xz() + t1.yy()*t2.yz() + t1.yz()*t2.zz(),
442 
443  t1.zx()*t2.xx() + t1.zy()*t2.yx() + t1.zz()*t2.zx(),
444  t1.zx()*t2.xy() + t1.zy()*t2.yy() + t1.zz()*t2.zy(),
445  t1.zx()*t2.xz() + t1.zy()*t2.yz() + t1.zz()*t2.zz()
446  );
447 }
448 
449 
450 template<class Cmpt>
451 inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
453 {
454  return Vector<Cmpt>
455  (
456  t.xx()*v.x() + t.xy()*v.y() + t.xz()*v.z(),
457  t.yx()*v.x() + t.yy()*v.y() + t.yz()*v.z(),
458  t.zx()*v.x() + t.zy()*v.y() + t.zz()*v.z()
459  );
460 }
461 
462 
463 template<class Cmpt>
466 {
467  return Vector<Cmpt>
468  (
469  v.x()*t.xx() + v.y()*t.yx() + v.z()*t.zx(),
470  v.x()*t.xy() + v.y()*t.yy() + v.z()*t.zy(),
471  v.x()*t.xz() + v.y()*t.yz() + v.z()*t.zz()
472  );
473 }
474 
475 
476 template<class Cmpt>
478 operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
479 {
480  return Tensor<Cmpt>
481  (
482  v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
483  v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
484  v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
485  );
486 }
487 
488 
489 template<class Cmpt>
490 inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
492 {
493  return inv(t) & v;
494 }
495 
496 
497 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
498 
499 //- Return the trace of a tensor
500 template<class Cmpt>
501 inline Cmpt tr(const Tensor<Cmpt>& t)
502 {
503  return t.xx() + t.yy() + t.zz();
504 }
505 
506 
507 //- Return the spherical part of a tensor
508 template<class Cmpt>
510 {
511  return (1.0/3.0)*tr(t);
512 }
513 
514 
515 //- Return the symmetric part of a tensor
516 template<class Cmpt>
518 {
519  return SymmTensor<Cmpt>
520  (
521  t.xx(), 0.5*(t.xy() + t.yx()), 0.5*(t.xz() + t.zx()),
522  t.yy(), 0.5*(t.yz() + t.zy()),
523  t.zz()
524  );
525 }
526 
527 
528 //- Return twice the symmetric part of a tensor
529 template<class Cmpt>
531 {
532  return SymmTensor<Cmpt>
533  (
534  2*t.xx(), (t.xy() + t.yx()), (t.xz() + t.zx()),
535  2*t.yy(), (t.yz() + t.zy()),
536  2*t.zz()
537  );
538 }
539 
540 
541 //- Return the skew-symmetric part of a tensor
542 template<class Cmpt>
544 {
545  return Tensor<Cmpt>
546  (
547  0.0, 0.5*(t.xy() - t.yx()), 0.5*(t.xz() - t.zx()),
548  0.5*(t.yx() - t.xy()), 0.0, 0.5*(t.yz() - t.zy()),
549  0.5*(t.zx() - t.xz()), 0.5*(t.zy() - t.yz()), 0.0
550  );
551 }
552 
553 
554 //- Return the skew-symmetric part of a symmetric tensor
555 template<class Cmpt>
556 inline const Tensor<Cmpt>& skew(const SymmTensor<Cmpt>& st)
557 {
558  return Tensor<Cmpt>::zero;
559 }
560 
561 
562 //- Return the deviatoric part of a tensor
563 template<class Cmpt>
564 inline Tensor<Cmpt> dev(const Tensor<Cmpt>& t)
565 {
566  return t - SphericalTensor<Cmpt>::oneThirdI*tr(t);
567 }
568 
569 
570 //- Return the deviatoric part of a tensor
571 template<class Cmpt>
573 {
575 }
576 
577 
578 //- Return the determinant of a tensor
579 template<class Cmpt>
580 inline Cmpt det(const Tensor<Cmpt>& t)
581 {
582  return
583  (
584  t.xx()*t.yy()*t.zz() + t.xy()*t.yz()*t.zx()
585  + t.xz()*t.yx()*t.zy() - t.xx()*t.yz()*t.zy()
586  - t.xy()*t.yx()*t.zz() - t.xz()*t.yy()*t.zx()
587  );
588 }
589 
590 
591 //- Return the cofactor tensor of a tensor
592 template<class Cmpt>
593 inline Tensor<Cmpt> cof(const Tensor<Cmpt>& t)
594 {
595  return Tensor<Cmpt>
596  (
597  t.yy()*t.zz() - t.zy()*t.yz(),
598  t.zx()*t.yz() - t.yx()*t.zz(),
599  t.yx()*t.zy() - t.yy()*t.zx(),
600 
601  t.xz()*t.zy() - t.xy()*t.zz(),
602  t.xx()*t.zz() - t.xz()*t.zx(),
603  t.xy()*t.zx() - t.xx()*t.zy(),
604 
605  t.xy()*t.yz() - t.xz()*t.yy(),
606  t.yx()*t.xz() - t.xx()*t.yz(),
607  t.xx()*t.yy() - t.yx()*t.xy()
608  );
609 }
610 
611 
612 //- Return the inverse of a tensor given the determinant
613 template<class Cmpt>
614 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t, const Cmpt dett)
615 {
616  return Tensor<Cmpt>
617  (
618  t.yy()*t.zz() - t.zy()*t.yz(),
619  t.xz()*t.zy() - t.xy()*t.zz(),
620  t.xy()*t.yz() - t.xz()*t.yy(),
621 
622  t.zx()*t.yz() - t.yx()*t.zz(),
623  t.xx()*t.zz() - t.xz()*t.zx(),
624  t.yx()*t.xz() - t.xx()*t.yz(),
625 
626  t.yx()*t.zy() - t.yy()*t.zx(),
627  t.xy()*t.zx() - t.xx()*t.zy(),
628  t.xx()*t.yy() - t.yx()*t.xy()
629  )/dett;
630 }
631 
632 
633 //- Return the inverse of a tensor
634 template<class Cmpt>
635 inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t)
636 {
637  return inv(t, det(t));
638 }
639 
640 
641 template<class Cmpt>
643 {
644  return Foam::inv(*this);
645 }
646 
647 
648 //- Return the 1st invariant of a tensor
649 template<class Cmpt>
650 inline Cmpt invariantI(const Tensor<Cmpt>& t)
651 {
652  return tr(t);
653 }
654 
655 
656 //- Return the 2nd invariant of a tensor
657 template<class Cmpt>
658 inline Cmpt invariantII(const Tensor<Cmpt>& t)
659 {
660  return
661  (
662  t.xx()*t.yy() + t.yy()*t.zz() + t.xx()*t.zz()
663  - t.xy()*t.yx() - t.yz()*t.zy() - t.xz()*t.zx()
664  );
665 }
666 
667 
668 //- Return the 3rd invariant of a tensor
669 template<class Cmpt>
670 inline Cmpt invariantIII(const Tensor<Cmpt>& t)
671 {
672  return det(t);
673 }
674 
675 
676 // * * * * * * * * * Mixed Tensor SphericalTensor Operators * * * * * * * * //
677 
678 template<class Cmpt>
679 inline Tensor<Cmpt>
681 {
682  return Tensor<Cmpt>
683  (
684  st1.ii() + t2.xx(), t2.xy(), t2.xz(),
685  t2.yx(), st1.ii() + t2.yy(), t2.yz(),
686  t2.zx(), t2.zy(), st1.ii() + t2.zz()
687  );
688 }
689 
690 
691 template<class Cmpt>
692 inline Tensor<Cmpt>
694 {
695  return Tensor<Cmpt>
696  (
697  t1.xx() + st2.ii(), t1.xy(), t1.xz(),
698  t1.yx(), t1.yy() + st2.ii(), t1.yz(),
699  t1.zx(), t1.zy(), t1.zz() + st2.ii()
700  );
701 }
702 
703 
704 template<class Cmpt>
705 inline Tensor<Cmpt>
707 {
708  return Tensor<Cmpt>
709  (
710  st1.ii() - t2.xx(), -t2.xy(), -t2.xz(),
711  -t2.yx(), st1.ii() - t2.yy(), -t2.yz(),
712  -t2.zx(), -t2.zy(), st1.ii() - t2.zz()
713  );
714 }
715 
716 
717 template<class Cmpt>
718 inline Tensor<Cmpt>
720 {
721  return Tensor<Cmpt>
722  (
723  t1.xx() - st2.ii(), t1.xy(), t1.xz(),
724  t1.yx(), t1.yy() - st2.ii(), t1.yz(),
725  t1.zx(), t1.zy(), t1.zz() - st2.ii()
726  );
727 }
728 
729 
730 //- Inner-product between a spherical tensor and a tensor
731 template<class Cmpt>
732 inline Tensor<Cmpt>
734 {
735  return Tensor<Cmpt>
736  (
737  st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
738  st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
739  st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
740  );
741 }
742 
743 
744 //- Inner-product between a tensor and a spherical tensor
745 template<class Cmpt>
746 inline Tensor<Cmpt>
748 {
749  return Tensor<Cmpt>
750  (
751  t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
752  t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
753  t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
754  );
755 }
756 
757 
758 //- Double-dot-product between a spherical tensor and a tensor
759 template<class Cmpt>
760 inline Cmpt
762 {
763  return(st1.ii()*t2.xx() + st1.ii()*t2.yy() + st1.ii()*t2.zz());
764 }
765 
766 
767 //- Double-dot-product between a tensor and a spherical tensor
768 template<class Cmpt>
769 inline Cmpt
771 {
772  return(t1.xx()*st2.ii() + t1.yy()*st2.ii() + t1.zz()*st2.ii());
773 }
774 
775 
776 template<class Cmpt>
777 class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt>>
778 {
779 public:
780 
782 };
783 
784 
785 template<class Cmpt>
786 class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt>>
787 {
788 public:
789 
791 };
792 
793 
794 template<class Cmpt>
796 {
797 public:
798 
800 };
801 
802 
803 template<class Cmpt>
805 {
806 public:
807 
809 };
810 
811 
812 // * * * * * * * * * * Mixed Tensor SymmTensor Operators * * * * * * * * * * //
813 
814 template<class Cmpt>
815 inline Tensor<Cmpt>
817 {
818  return Tensor<Cmpt>
819  (
820  st1.xx() + t2.xx(), st1.xy() + t2.xy(), st1.xz() + t2.xz(),
821  st1.xy() + t2.yx(), st1.yy() + t2.yy(), st1.yz() + t2.yz(),
822  st1.xz() + t2.zx(), st1.yz() + t2.zy(), st1.zz() + t2.zz()
823  );
824 }
825 
826 
827 template<class Cmpt>
828 inline Tensor<Cmpt>
830 {
831  return Tensor<Cmpt>
832  (
833  t1.xx() + st2.xx(), t1.xy() + st2.xy(), t1.xz() + st2.xz(),
834  t1.yx() + st2.xy(), t1.yy() + st2.yy(), t1.yz() + st2.yz(),
835  t1.zx() + st2.xz(), t1.zy() + st2.yz(), t1.zz() + st2.zz()
836  );
837 }
838 
839 
840 template<class Cmpt>
841 inline Tensor<Cmpt>
843 {
844  return Tensor<Cmpt>
845  (
846  st1.xx() - t2.xx(), st1.xy() - t2.xy(), st1.xz() - t2.xz(),
847  st1.xy() - t2.yx(), st1.yy() - t2.yy(), st1.yz() - t2.yz(),
848  st1.xz() - t2.zx(), st1.yz() - t2.zy(), st1.zz() - t2.zz()
849  );
850 }
851 
852 
853 template<class Cmpt>
854 inline Tensor<Cmpt>
856 {
857  return Tensor<Cmpt>
858  (
859  t1.xx() - st2.xx(), t1.xy() - st2.xy(), t1.xz() - st2.xz(),
860  t1.yx() - st2.xy(), t1.yy() - st2.yy(), t1.yz() - st2.yz(),
861  t1.zx() - st2.xz(), t1.zy() - st2.yz(), t1.zz() - st2.zz()
862  );
863 }
864 
865 
866 //- Inner-product between a symmetric tensor and a tensor
867 template<class Cmpt>
868 inline Tensor<Cmpt>
870 {
871  return Tensor<Cmpt>
872  (
873  st1.xx()*t2.xx() + st1.xy()*t2.yx() + st1.xz()*t2.zx(),
874  st1.xx()*t2.xy() + st1.xy()*t2.yy() + st1.xz()*t2.zy(),
875  st1.xx()*t2.xz() + st1.xy()*t2.yz() + st1.xz()*t2.zz(),
876 
877  st1.xy()*t2.xx() + st1.yy()*t2.yx() + st1.yz()*t2.zx(),
878  st1.xy()*t2.xy() + st1.yy()*t2.yy() + st1.yz()*t2.zy(),
879  st1.xy()*t2.xz() + st1.yy()*t2.yz() + st1.yz()*t2.zz(),
880 
881  st1.xz()*t2.xx() + st1.yz()*t2.yx() + st1.zz()*t2.zx(),
882  st1.xz()*t2.xy() + st1.yz()*t2.yy() + st1.zz()*t2.zy(),
883  st1.xz()*t2.xz() + st1.yz()*t2.yz() + st1.zz()*t2.zz()
884  );
885 }
886 
887 
888 //- Inner-product between a tensor and a symmetric tensor
889 template<class Cmpt>
890 inline Tensor<Cmpt>
892 {
893  return Tensor<Cmpt>
894  (
895  t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz(),
896  t1.xx()*st2.xy() + t1.xy()*st2.yy() + t1.xz()*st2.yz(),
897  t1.xx()*st2.xz() + t1.xy()*st2.yz() + t1.xz()*st2.zz(),
898 
899  t1.yx()*st2.xx() + t1.yy()*st2.xy() + t1.yz()*st2.xz(),
900  t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz(),
901  t1.yx()*st2.xz() + t1.yy()*st2.yz() + t1.yz()*st2.zz(),
902 
903  t1.zx()*st2.xx() + t1.zy()*st2.xy() + t1.zz()*st2.xz(),
904  t1.zx()*st2.xy() + t1.zy()*st2.yy() + t1.zz()*st2.yz(),
905  t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
906  );
907 }
908 
909 
910 //- Double-dot-product between a symmetric tensor and a tensor
911 template<class Cmpt>
912 inline Cmpt
914 {
915  return
916  (
917  st1.xx()*t2.xx() + st1.xy()*t2.xy() + st1.xz()*t2.xz() +
918  st1.xy()*t2.yx() + st1.yy()*t2.yy() + st1.yz()*t2.yz() +
919  st1.xz()*t2.zx() + st1.yz()*t2.zy() + st1.zz()*t2.zz()
920  );
921 }
922 
923 
924 //- Double-dot-product between a tensor and a symmetric tensor
925 template<class Cmpt>
926 inline Cmpt
928 {
929  return
930  (
931  t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz() +
932  t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz() +
933  t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
934  );
935 }
936 
937 
938 template<class Cmpt>
939 class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt>>
940 {
941 public:
942 
944 };
945 
946 
947 template<class Cmpt>
948 class typeOfSum<Tensor<Cmpt>, SymmTensor<Cmpt>>
949 {
950 public:
951 
953 };
954 
955 
956 template<class Cmpt>
957 class innerProduct<SymmTensor<Cmpt>, Tensor<Cmpt>>
958 {
959 public:
960 
962 };
963 
964 
965 template<class Cmpt>
966 class innerProduct<Tensor<Cmpt>, SymmTensor<Cmpt>>
967 {
968 public:
969 
971 };
972 
973 
974 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
975 
976 } // End namespace Foam
977 
978 // ************************************************************************* //
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a symmetric tensor.
Definition: SymmTensorI.H:403
const Cmpt & z() const
Definition: VectorI.H:87
const Cmpt & xx() const
Definition: SymmTensorI.H:87
Vector< Cmpt > vectorComponent(const direction) const
Definition: TensorI.H:301
const Cmpt & yy() const
Definition: TensorI.H:181
uint8_t direction
Definition: direction.H:46
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components...
Definition: SymmTensor.H:53
const Cmpt & x() const
Definition: VectorI.H:75
dimensionedTensor skew(const dimensionedTensor &dt)
const Cmpt & xz() const
Definition: SymmTensorI.H:99
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Templated vector space.
Definition: VectorSpace.H:53
const Cmpt & zy() const
Definition: TensorI.H:202
MatrixSpace< Tensor< Cmpt >, Cmpt, Mrows, Ncols > msType
MatrixSpace type.
Definition: MatrixSpace.H:63
const Cmpt & yz() const
Definition: TensorI.H:188
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
tmp< fvMatrix< Type > > operator*(const DimensionedField< scalar, volMesh > &, const fvMatrix< Type > &)
dimensionedScalar det(const dimensionedSphericalTensor &dt)
Vector< Cmpt > x() const
Definition: TensorI.H:279
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a diagonal tensor.
Definition: DiagTensorI.H:288
Templated matrix space.
Definition: MatrixSpace.H:55
Vector< Cmpt > y() const
Definition: TensorI.H:286
Tensor()
Construct null.
Definition: TensorI.H:31
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
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.
const Cmpt & xz() const
Definition: TensorI.H:167
Tensor< Cmpt > inv() const
Return inverse.
Definition: TensorI.H:642
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
const Cmpt & xy() const
Definition: SymmTensorI.H:93
void operator=(const VectorSpace< Tensor< Cmpt2 >, Cmpt2, 9 > &)
Assign to an equivalent vector space.
Definition: TensorI.H:360
Cmpt invariantIII(const SymmTensor< Cmpt > &st)
Return the 3rd invariant of a symmetric tensor.
Definition: SymmTensorI.H:415
const Cmpt & yz() const
Definition: SymmTensorI.H:111
const Cmpt & xx() const
Definition: TensorI.H:153
const Cmpt & y() const
Definition: VectorI.H:81
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
const Cmpt & xy() const
Definition: TensorI.H:160
static const zero Zero
Definition: zero.H:91
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
const Cmpt & yx() const
Definition: TensorI.H:174
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
Vector< Cmpt > z() const
Definition: TensorI.H:293
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
void operator&=(const Tensor< Cmpt > &)
Inner-product with a Tensor.
Definition: TensorI.H:335
Tensor< Cmpt > T() const
Return transpose.
Definition: TensorI.H:321
const Cmpt & zz() const
Definition: TensorI.H:209
const Cmpt & yy() const
Definition: SymmTensorI.H:105
friend Ostream & operator(Ostream &, const VectorSpace< Tensor< Cmpt >, Cmpt, Ncmpts > &)
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:461
const Cmpt & zz() const
Definition: SymmTensorI.H:117
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
Cmpt invariantI(const SymmTensor< Cmpt > &st)
Return the 1st invariant of a symmetric tensor.
Definition: SymmTensorI.H:395
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
const Cmpt & zx() const
Definition: TensorI.H:195
const Cmpt & ii() const
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:222
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
dimensioned< typename scalarProduct< Type1, Type2 >::type > operator&&(const dimensioned< Type1 > &, const dimensioned< Type2 > &)
Cmpt v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:81
Namespace for OpenFOAM.