Tensor2DI.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Cmpt>
33 :
35 {}
36 
37 
38 template<class Cmpt>
40 (
41  const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>& vs
42 )
43 :
44  Tensor2D::vsType(vs)
45 {}
46 
47 
48 template<class Cmpt>
50 {
51  this->v_[XX] = st.xx(); this->v_[XY] = st.xy();
52  this->v_[YX] = st.xy(); this->v_[YY] = st.yy();
53 }
54 
55 
56 template<class Cmpt>
58 {
59  this->v_[XX] = st.ii(); this->v_[XY] = Zero;
60  this->v_[YX] = Zero; this->v_[YY] = st.ii();
61 }
62 
63 
64 template<class Cmpt>
66 (
67  const Vector2D<Cmpt>& x,
68  const Vector2D<Cmpt>& y
69 )
70 {
71  this->v_[XX] = x.x(); this->v_[XY] = x.y();
72  this->v_[YX] = y.x(); this->v_[YY] = y.y();
73 }
74 
75 
76 template<class Cmpt>
78 (
79  const Cmpt txx, const Cmpt txy,
80  const Cmpt tyx, const Cmpt tyy
81 )
82 {
83  this->v_[XX] = txx; this->v_[XY] = txy;
84  this->v_[YX] = tyx; this->v_[YY] = tyy;
85 }
86 
87 
88 template<class Cmpt>
90 :
92 {}
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
97 template<class Cmpt>
99 {
100  return Vector2D<Cmpt>(this->v_[XX], this->v_[XY]);
101 }
102 
103 template<class Cmpt>
105 {
106  return Vector2D<Cmpt>(this->v_[YX], this->v_[YY]);
107 }
108 
109 
110 template<class Cmpt>
112 {
113  return Vector2D<Cmpt>(this->v_[XX], this->v_[YX]);
114 }
115 
116 template<class Cmpt>
118 {
119  return Vector2D<Cmpt>(this->v_[XY], this->v_[YY]);
120 }
121 
122 
123 template<class Cmpt>
124 template<Foam::direction Idx>
126 {
127  if (Idx == 0) return cx();
128  else if (Idx == 1) return cy();
130  static_assert(Idx < 2, "Invalid column access");
131  return Zero;
132 }
133 
134 
135 template<class Cmpt>
137 {
138  switch (c)
139  {
140  case 0: return cx(); break;
141  case 1: return cy(); break;
142  default:
144  << "Invalid column access " << c << abort(FatalError);
145  }
147  return Zero;
148 }
149 
150 
151 template<class Cmpt>
152 template<Foam::direction Idx>
154 {
155  if (Idx == 0) return x();
156  else if (Idx == 1) return y();
158  static_assert(Idx < 2, "Invalid row access");
159  return Zero;
160 }
161 
162 
163 template<class Cmpt>
165 {
166  switch (r)
167  {
168  case 0: return x(); break;
169  case 1: return y(); break;
170  default:
172  << "Invalid row access " << r << abort(FatalError);
173  }
175  return Zero;
176 }
177 
178 
179 template<class Cmpt>
180 template<Foam::direction Idx>
181 inline void Foam::Tensor2D<Cmpt>::col(const Vector2D<Cmpt>& v)
182 {
183  if (Idx == 0)
184  {
185  this->v_[XX] = v.x();
186  this->v_[YX] = v.y();
187  }
188  else if (Idx == 1)
189  {
190  this->v_[XY] = v.x();
191  this->v_[YY] = v.y();
192  }
194  static_assert(Idx < 2, "Invalid column access");
195 }
196 
197 
198 template<class Cmpt>
199 template<Foam::direction Idx>
200 inline void Foam::Tensor2D<Cmpt>::row(const Vector2D<Cmpt>& v)
201 {
202  if (Idx == 0)
203  {
204  this->v_[XX] = v.x(); this->v_[XY] = v.y();
205  }
206  else if (Idx == 1)
207  {
208  this->v_[YX] = v.x(); this->v_[YY] = v.y();
209  }
211  static_assert(Idx < 2, "Invalid row access");
212 }
213 
214 
215 template<class Cmpt>
216 inline void Foam::Tensor2D<Cmpt>::cols
217 (
218  const Vector2D<Cmpt>& x,
219  const Vector2D<Cmpt>& y
220 )
221 {
222  this->v_[XX] = x.x(); this->v_[XY] = y.x();
223  this->v_[YX] = x.y(); this->v_[YY] = y.y();
224 }
225 
226 
227 template<class Cmpt>
228 inline void Foam::Tensor2D<Cmpt>::rows
229 (
230  const Vector2D<Cmpt>& x,
231  const Vector2D<Cmpt>& y
232 )
233 {
234  this->v_[XX] = x.x(); this->v_[XY] = x.y();
235  this->v_[YX] = y.x(); this->v_[YY] = y.y();
236 }
237 
238 
239 template<class Cmpt>
240 inline void Foam::Tensor2D<Cmpt>::col
241 (
242  const direction c,
243  const Vector2D<Cmpt>& v
244 )
245 {
246  switch (c)
247  {
248  case 0: col<0>(v); break;
249  case 1: col<1>(v); break;
250  default:
252  << "Invalid column access " << c << abort(FatalError);
253  }
254 }
255 
256 
257 template<class Cmpt>
258 inline void Foam::Tensor2D<Cmpt>::row
259 (
260  const direction r,
261  const Vector2D<Cmpt>& v
262 )
263 {
264  switch (r)
265  {
266  case 0: row<0>(v); break;
267  case 1: row<1>(v); break;
268  default:
270  << "Invalid row access " << r << abort(FatalError);
271  }
272 }
273 
274 
275 template<class Cmpt>
277 {
278  return Vector2D<Cmpt>(this->v_[XX], this->v_[YY]);
279 }
280 
281 
282 template<class Cmpt>
284 {
285  this->v_[XX] = v.x(); this->v_[YY] = v.y();
286 }
287 
288 
289 template<class Cmpt>
290 inline Foam::scalar Foam::Tensor2D<Cmpt>::diagSqr() const
291 {
292  return
293  (
294  Foam::magSqr(this->xx())
295  + Foam::magSqr(this->yy())
296  );
297 }
298 
299 
300 // * * * * * * * * * * * * * * * Member Operations * * * * * * * * * * * * * //
301 
302 template<class Cmpt>
304 {
305  return Tensor2D<Cmpt>
306  (
307  xx(), yx(),
308  xy(), yy()
309  );
310 }
311 
312 
313 template<class Cmpt>
314 inline Cmpt Foam::Tensor2D<Cmpt>::det() const
315 {
316  return (xx()*yy() - xy()*yx());
317 }
318 
319 
320 template<class Cmpt>
322 {
323  return Tensor2D<Cmpt>
324  (
325  yy(), -xy(),
326  -yx(), xx()
327  );
328 }
329 
330 
331 template<class Cmpt>
333 {
334  return this->adjunct().T();
335 }
336 
337 
338 template<class Cmpt>
341 {
342  const Tensor2D<Cmpt>& t1 = *this;
343 
344  return Tensor2D<Cmpt>
345  (
346  t1.xx()*t2.xx() + t1.xy()*t2.yx(),
347  t1.xx()*t2.xy() + t1.xy()*t2.yy(),
348 
349  t1.yx()*t2.xx() + t1.yy()*t2.yx(),
350  t1.yx()*t2.xy() + t1.yy()*t2.yy()
351  );
352 }
353 
354 
355 template<class Cmpt>
358 {
359  const Tensor2D<Cmpt>& t1 = *this;
360 
361  return Tensor2D<Cmpt>
362  (
363  t1.xx()*t2.xx(), t1.xy()*t2.xy(),
364  t1.yx()*t2.yx(), t1.yy()*t2.yy()
365  );
366 }
367 
368 
369 // Invert without much error handling
370 template<class Cmpt>
372 {
373  const Cmpt detval = this->det();
374 
375  #ifdef FULLDEBUG
376  if (mag(detval) < SMALL)
377  {
379  << "SymmTensor2D not properly invertible, determinant:"
380  << detval << " tensor:" << *this << nl
381  << abort(FatalError);
382  }
383  #endif
384 
385  return this->adjunct()/detval;
386 }
387 
388 
389 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
390 
391 template<class Cmpt>
393 {
394  this->v_[XX] = st.xx(); this->v_[XY] = st.xy();
395  this->v_[YX] = st.xy(); this->v_[YY] = st.yy();
396 }
397 
398 
399 template<class Cmpt>
401 {
402  this->v_[XX] = st.ii(); this->v_[XY] = Zero;
403  this->v_[YX] = Zero; this->v_[YY] = st.ii();
404 }
405 
406 
407 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
408 
409 namespace Foam
410 {
412 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
413 
414 //- Return the trace of a Tensor2D
415 template<class Cmpt>
416 inline Cmpt tr(const Tensor2D<Cmpt>& t)
417 {
418  return t.xx() + t.yy();
419 }
420 
422 //- Return the spherical part of a Tensor2D
423 template<class Cmpt>
425 {
427  (
428  0.5*tr(t)
429  );
430 }
431 
432 
433 //- Return the symmetric part of a Tensor2D
434 template<class Cmpt>
435 inline SymmTensor2D<Cmpt> symm(const Tensor2D<Cmpt>& t)
436 {
437  return SymmTensor2D<Cmpt>
438  (
439  t.xx(), 0.5*(t.xy() + t.yx()),
440  t.yy()
441  );
442 }
443 
444 
445 //- Return the twice the symmetric part of a Tensor2D
446 template<class Cmpt>
447 inline SymmTensor2D<Cmpt> twoSymm(const Tensor2D<Cmpt>& t)
448 {
449  return SymmTensor2D<Cmpt>
450  (
451  t.xx() + t.xx(), t.xy() + t.yx(),
452  t.yy() + t.yy()
453  );
454 }
455 
456 
457 //- Return the skew-symmetric part of a Tensor2D
458 template<class Cmpt>
459 inline Tensor2D<Cmpt> skew(const Tensor2D<Cmpt>& t)
460 {
461  return Tensor2D<Cmpt>
462  (
463  Zero, 0.5*(t.xy() - t.yx()),
464  0.5*(t.yx() - t.xy()), Zero
465  );
466 }
467 
468 
469 //- Return the deviatoric part of a Tensor2D
470 template<class Cmpt>
471 inline Tensor2D<Cmpt> dev(const Tensor2D<Cmpt>& t)
472 {
473  return t - sph(t);
474 }
475 
477 //- Return the two-third deviatoric part of a Tensor2D
478 template<class Cmpt>
479 inline Tensor2D<Cmpt> dev2(const Tensor2D<Cmpt>& t)
480 {
481  return t - 2*sph(t);
482 }
483 
484 
485 //- Return the determinant of a Tensor2D
486 template<class Cmpt>
487 inline Cmpt det(const Tensor2D<Cmpt>& t)
488 {
489  return t.det();
490 }
491 
492 
493 //- Return the cofactor of a Tensor2D
494 template<class Cmpt>
495 inline Tensor2D<Cmpt> cof(const Tensor2D<Cmpt>& t)
496 {
497  return t.cof();
498 }
499 
500 
501 //- Return the inverse of a Tensor2D, using given determinant value
502 template<class Cmpt>
503 inline Tensor2D<Cmpt> inv(const Tensor2D<Cmpt>& t, const Cmpt detval)
504 {
505  #ifdef FULLDEBUG
506  if (mag(detval) < SMALL)
507  {
509  << "Tensor2D not properly invertible, determinant:"
510  << detval << " tensor:" << t << nl
511  << abort(FatalError);
512  }
513  #endif
514 
515  return t.adjunct()/detval;
516 }
517 
518 
519 //- Return the inverse of a Tensor2D
520 template<class Cmpt>
521 inline Tensor2D<Cmpt> inv(const Tensor2D<Cmpt>& t)
522 {
523  return t.inv();
524 }
525 
526 
527 //- Return the 1st invariant of a Tensor2D
528 template<class Cmpt>
529 inline Cmpt invariantI(const Tensor2D<Cmpt>& t)
530 {
531  return tr(t);
532 }
533 
534 
535 //- Return the 2nd invariant of a Tensor2D
536 template<class Cmpt>
537 inline Cmpt invariantII(const Tensor2D<Cmpt>& t)
538 {
539  return det(t);
540 }
541 
542 
543 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
544 
545 //- Sum of a SphericalTensor2D and a Tensor2D
546 template<class Cmpt>
547 inline Tensor2D<Cmpt>
548 operator+(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
549 {
550  return Tensor2D<Cmpt>
551  (
552  st1.ii() + t2.xx(), t2.xy(),
553  t2.yx(), st1.ii() + t2.yy()
554  );
555 }
557 
558 //- Sum of a Tensor2D and a SphericalTensor2D
559 template<class Cmpt>
560 inline Tensor2D<Cmpt>
561 operator+(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
562 {
563  return Tensor2D<Cmpt>
564  (
565  t1.xx() + st2.ii(), t1.xy(),
566  t1.yx(), t1.yy() + st2.ii()
567  );
568 }
570 
571 //- Sum of a SymmTensor2D and a Tensor2D
572 template<class Cmpt>
573 inline Tensor2D<Cmpt>
574 operator+(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
575 {
576  return Tensor2D<Cmpt>
577  (
578  st1.xx() + t2.xx(), st1.xy() + t2.xy(),
579  st1.xy() + t2.yx(), st1.yy() + t2.yy()
580  );
581 }
582 
583 
584 //- Sum of a Tensor2D and a SymmTensor2D
585 template<class Cmpt>
586 inline Tensor2D<Cmpt>
587 operator+(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
588 {
589  return Tensor2D<Cmpt>
590  (
591  t1.xx() + st2.xx(), t1.xy() + st2.xy(),
592  t1.yx() + st2.xy(), t1.yy() + st2.yy()
593  );
594 }
595 
596 
597 //- Subtract a Tensor2D from a SphericalTensor2D
598 template<class Cmpt>
600 operator-(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
601 {
602  return Tensor2D<Cmpt>
603  (
604  st1.ii() - t2.xx(), -t2.xy(),
605  -t2.yx(), st1.ii() - t2.yy()
606  );
607 }
608 
609 
610 //- Subtract a SphericalTensor2D from a Tensor2D
611 template<class Cmpt>
612 inline Tensor2D<Cmpt>
613 operator-(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
614 {
615  return Tensor2D<Cmpt>
616  (
617  t1.xx() - st2.ii(), t1.xy(),
618  t1.yx(), t1.yy() - st2.ii()
619  );
620 }
621 
622 
623 //- Subtract a Tensor2D from a SymmTensor2D
624 template<class Cmpt>
625 inline Tensor2D<Cmpt>
626 operator-(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
627 {
628  return Tensor2D<Cmpt>
629  (
630  st1.xx() - t2.xx(), st1.xy() - t2.xy(),
631  st1.xy() - t2.yx(), st1.yy() - t2.yy()
632  );
633 }
634 
635 
636 //- Subtract a SymmTensor2D from a Tensor2D
637 template<class Cmpt>
638 inline Tensor2D<Cmpt>
639 operator-(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
640 {
641  return Tensor2D<Cmpt>
642  (
643  t1.xx() - st2.xx(), t1.xy() - st2.xy(),
644  t1.yx() - st2.xy(), t1.yy() - st2.yy()
645  );
646 }
647 
648 
649 //- Division of a Tensor2D by a Cmpt
650 template<class Cmpt>
651 inline Tensor2D<Cmpt>
652 operator/(const Tensor2D<Cmpt>& t, const Cmpt s)
653 {
654  #ifdef FULLDEBUG
655  if (mag(s) < VSMALL)
656  {
658  << "Tensor2D = " << t
659  << " is not divisible due to a zero value in Cmpt:"
660  << "Cmpt = " << s
661  << abort(FatalError);
662  }
663  #endif
664 
665  return Tensor2D<Cmpt>
666  (
667  t.xx()/s, t.xy()/s,
668  t.yx()/s, t.yy()/s
669  );
670 }
671 
672 
673 //- Inner-product of a Tensor2D and a Tensor2D
674 template<class Cmpt>
676 operator&(const Tensor2D<Cmpt>& t1, const Tensor2D<Cmpt>& t2)
677 {
678  return t1.inner(t2);
679 }
680 
681 
682 //- Inner-product of a SphericalTensor2D and Tensor2D
683 template<class Cmpt>
684 inline Tensor2D<Cmpt>
685 operator&(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
686 {
687  return Tensor2D<Cmpt>
688  (
689  st1.ii()*t2.xx(),
690  st1.ii()*t2.xy(),
691  st1.ii()*t2.yx(),
692  st1.ii()*t2.yy()
693  );
694 }
695 
696 
697 //- Inner-product of a Tensor2D and a SphericalTensor2D
698 template<class Cmpt>
699 inline Tensor2D<Cmpt>
700 operator&(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
701 {
702  return Tensor2D<Cmpt>
703  (
704  t1.xx()*st2.ii(),
705  t1.xy()*st2.ii(),
706 
707  t1.yx()*st2.ii(),
708  t1.yy()*st2.ii()
709  );
710 }
711 
712 
713 //- Inner-product of a SymmTensor2D and Tensor2D
714 template<class Cmpt>
716 operator&(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
717 {
718  return Tensor2D<Cmpt>
719  (
720  st1.xx()*t2.xx() + st1.xy()*t2.yx(),
721  st1.xx()*t2.xy() + st1.xy()*t2.yy(),
722 
723  st1.xy()*t2.xx() + st1.yy()*t2.yx(),
724  st1.xy()*t2.xy() + st1.yy()*t2.yy()
725  );
726 }
727 
728 
729 //- Inner-product of a Tensor2D and a SymmTensor2D
730 template<class Cmpt>
731 inline Tensor2D<Cmpt>
732 operator&(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
733 {
734  return Tensor2D<Cmpt>
735  (
736  t1.xx()*st2.xx() + t1.xy()*st2.xy(),
737  t1.xx()*st2.xy() + t1.xy()*st2.yy(),
738 
739  t1.yx()*st2.xx() + t1.yy()*st2.xy(),
740  t1.yx()*st2.xy() + t1.yy()*st2.yy()
741  );
742 }
744 
745 
746 //- Inner-product of a Tensor2D and a Vector2D
747 template<class Cmpt>
749 operator&(const Tensor2D<Cmpt>& t, const Vector2D<Cmpt>& v)
750 {
751  return Vector2D<Cmpt>
752  (
753  t.xx()*v.x() + t.xy()*v.y(),
754  t.yx()*v.x() + t.yy()*v.y()
755  );
756 }
757 
758 
759 //- Inner-product of a Vector2D and a Tensor2D
760 template<class Cmpt>
762 operator&(const Vector2D<Cmpt>& v, const Tensor2D<Cmpt>& t)
763 {
764  return Vector2D<Cmpt>
765  (
766  v.x()*t.xx() + v.y()*t.yx(),
767  v.x()*t.xy() + v.y()*t.yy()
768  );
769 }
770 
771 
772 //- Double-inner-product of a SphericalTensor2D and a Tensor2D
773 template<class Cmpt>
774 inline Cmpt
775 operator&&(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
776 {
777  return (st1.ii()*t2.xx() + st1.ii()*t2.yy());
778 }
780 
781 //- Double-inner-product of a Tensor2D and a SphericalTensor2D
782 template<class Cmpt>
783 inline Cmpt
785 {
786  return (t1.xx()*st2.ii() + t1.yy()*st2.ii());
787 }
788 
789 
790 //- Double-inner-product of a SymmTensor2D and a Tensor2D
791 template<class Cmpt>
792 inline Cmpt
793 operator&&(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
794 {
795  return
796  (
797  st1.xx()*t2.xx() + st1.xy()*t2.xy()
798  + st1.xy()*t2.yx() + st1.yy()*t2.yy()
799  );
800 }
801 
802 
803 //- Double-inner-product of a Tensor2D and a SymmTensor2D
804 template<class Cmpt>
805 inline Cmpt
806 operator&&(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
807 {
808  return
809  (
810  t1.xx()*st2.xx() + t1.xy()*st2.xy()
811  + t1.yx()*st2.xy() + t1.yy()*st2.yy()
812  );
813 }
814 
815 
816 //- Outer-product of a Vector2D and a Vector2D
817 template<class Cmpt>
818 inline typename outerProduct<Vector2D<Cmpt>, Vector2D<Cmpt>>::type
819 operator*(const Vector2D<Cmpt>& v1, const Vector2D<Cmpt>& v2)
820 {
821  return Tensor2D<Cmpt>
822  (
823  v1.x()*v2.x(), v1.x()*v2.y(),
824  v1.y()*v2.x(), v1.y()*v2.y()
825  );
826 }
827 
829 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
830 
831 template<class Cmpt>
832 class typeOfSum<SphericalTensor2D<Cmpt>, Tensor2D<Cmpt>>
833 {
834 public:
835 
836  typedef Tensor2D<Cmpt> type;
837 };
838 
839 template<class Cmpt>
840 class typeOfSum<Tensor2D<Cmpt>, SphericalTensor2D<Cmpt>>
841 {
842 public:
843 
844  typedef Tensor2D<Cmpt> type;
845 };
846 
847 
848 template<class Cmpt>
849 class innerProduct<Tensor2D<Cmpt>, Tensor2D<Cmpt>>
850 {
851 public:
852 
853  typedef Tensor2D<Cmpt> type;
854 };
855 
856 template<class Cmpt>
857 class innerProduct<SphericalTensor2D<Cmpt>, Tensor2D<Cmpt>>
858 {
859 public:
860 
861  typedef Tensor2D<Cmpt> type;
862 };
863 
864 template<class Cmpt>
866 {
867 public:
868 
869  typedef Tensor2D<Cmpt> type;
870 };
871 
872 template<class Cmpt>
873 class innerProduct<Tensor2D<Cmpt>, Vector2D<Cmpt>>
874 {
875 public:
876 
877  typedef Vector2D<Cmpt> type;
878 };
879 
880 template<class Cmpt>
881 class innerProduct<Vector2D<Cmpt>, Tensor2D<Cmpt>>
882 {
883 public:
884 
885  typedef Vector2D<Cmpt> type;
886 };
887 
888 
889 template<class Cmpt>
890 class outerProduct<Vector2D<Cmpt>, Vector2D<Cmpt>>
891 {
892 public:
894  typedef Tensor2D<Cmpt> type;
895 };
896 
898 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
899 
900 } // End namespace Foam
902 // ************************************************************************* //
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a SymmTensor.
Definition: SymmTensorI.H:581
Tensor2D< Cmpt > T() const
Return non-Hermitian transpose.
Definition: Tensor2DI.H:296
const Cmpt & xy() const noexcept
Definition: Tensor2D.H:154
uint8_t direction
Definition: direction.H:46
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const Cmpt & y() const noexcept
Access to the vector y component.
Definition: Vector2D.H:132
const Cmpt & xx() const noexcept
Definition: SymmTensor2D.H:141
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
const Cmpt & ii() const noexcept
dimensionedTensor skew(const dimensionedTensor &dt)
Vector2D< Cmpt > x() const
Extract vector for row 0.
Definition: Tensor2DI.H:91
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
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Tensor2D< Cmpt > adjunct() const
Return adjunct matrix (transpose of cofactor matrix)
Definition: Tensor2DI.H:314
Tensor2D< Cmpt > schur(const Tensor2D< Cmpt > &t2) const
Schur-product of this with another Tensor2D.
Definition: Tensor2DI.H:350
const Cmpt & xy() const noexcept
Definition: SymmTensor2D.H:142
Templated vector space.
Definition: VectorSpace.H:52
dimensionSet operator &&(const dimensionSet &ds1, const dimensionSet &ds2)
Tensor2D< Cmpt > inv() const
Return inverse.
Definition: Tensor2DI.H:364
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:118
dimensionedScalar det(const dimensionedSphericalTensor &dt)
Vector2D< Cmpt > col() const
Extract vector for given column: compile-time check of index.
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
Definition: DiagTensorI.H:110
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
Vector2D< Cmpt > y() const
Extract vector for row 1.
Definition: Tensor2DI.H:97
A templated (2 x 2) tensor of objects of <T> derived from VectorSpace.
Definition: Tensor2D.H:52
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
const Cmpt & yy() const noexcept
Definition: SymmTensor2D.H:144
const Cmpt & yx() const noexcept
Definition: Tensor2D.H:155
scalar diagSqr() const
The L2-norm squared of the diagonal.
Definition: Tensor2DI.H:283
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
scalar y
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Cmpt det() const
The determinate.
Definition: Tensor2DI.H:307
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
Tensor2D< Cmpt > inner(const Tensor2D< Cmpt > &t2) const
Inner-product of this with another Tensor2D.
Definition: Tensor2DI.H:333
Vector2D< Cmpt > cy() const
Extract vector for column 1.
Definition: Tensor2DI.H:110
void rows(const Vector2D< Cmpt > &x, const Vector2D< Cmpt > &y)
Set row values.
Definition: Tensor2DI.H:222
Vector2D< Cmpt > row() const
Extract vector for given row: compile-time check of index.
Tensor2D & operator=(const Tensor2D &)=default
Copy assignment.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
errorManip< error > abort(error &err)
Definition: errorManip.H:139
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
Vector2D< Cmpt > cx() const
Extract vector for column 0.
Definition: Tensor2DI.H:104
const Cmpt & x() const noexcept
Access to the vector x component.
Definition: Vector2D.H:127
void cols(const Vector2D< Cmpt > &x, const Vector2D< Cmpt > &y)
Set column values.
Definition: Tensor2DI.H:210
Tensor2D()=default
Default construct.
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
A templated (2 x 2) diagonal tensor of objects of <T>, effectively containing 1 element, derived from VectorSpace.
tmp< GeometricField< Type, faPatchField, areaMesh > > operator &(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
const Cmpt & xx() const noexcept
Definition: Tensor2D.H:153
const dimensionedScalar c
Speed of light in a vacuum.
Cmpt invariantI(const SymmTensor< Cmpt > &st)
Return the 1st invariant of a SymmTensor.
Definition: SymmTensorI.H:571
A templated (2 x 2) symmetric tensor of objects of <T>, effectively containing 3 elements, derived from VectorSpace.
Definition: SymmTensor2D.H:54
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Templated 2D Vector derived from VectorSpace adding construction from 2 components, element access using x() and y() member functions and the inner-product (dot-product).
Definition: Vector2D.H:51
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) - 2 >::type type
Definition: products.H:155
const Cmpt & yy() const noexcept
Definition: Tensor2D.H:156
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Vector2D< Cmpt > diag() const
Extract the diagonal as a vector.
Definition: Tensor2DI.H:269
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Namespace for OpenFOAM.
Tensor2D< Cmpt > cof() const
Return cofactor matrix (transpose of adjunct matrix)
Definition: Tensor2DI.H:325
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127