Loading...
Searching...
No Matches
SymmTensorI.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) 2019-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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#include "Tensor.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Cmpt>
37{}
38
39
40template<class Cmpt>
41template<class Cmpt2>
43(
44 const VectorSpace<SymmTensor<Cmpt2>, Cmpt2, 6>& vs
46:
48{}
49
50
51template<class Cmpt>
53{
54 this->v_[XX] = st.ii(); this->v_[XY] = Zero; this->v_[XZ] = Zero;
55 this->v_[YY] = st.ii(); this->v_[YZ] = Zero;
56 this->v_[ZZ] = st.ii();
57}
58
59
60template<class Cmpt>
62(
63 const Vector<Cmpt>& x,
64 const Vector<Cmpt>& y,
65 const Vector<Cmpt>& z,
66 const bool transposed /* ignored */
68{
69 this->rows(x, y, z);
70}
71
72
73template<class Cmpt>
75(
76 const Cmpt txx, const Cmpt txy, const Cmpt txz,
77 const Cmpt tyy, const Cmpt tyz,
78 const Cmpt tzz
79)
80{
81 this->v_[XX] = txx; this->v_[XY] = txy; this->v_[XZ] = txz;
82 this->v_[YY] = tyy; this->v_[YZ] = tyz;
83 this->v_[ZZ] = tzz;
84}
85
86
87template<class Cmpt>
89:
91{}
92
93
94// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95
96template<class Cmpt>
98{
99 return Vector<Cmpt>(this->v_[XX], this->v_[XY], this->v_[XZ]);
100}
101
102
103template<class Cmpt>
105{
106 return Vector<Cmpt>(this->v_[XY], this->v_[YY], this->v_[YZ]);
107}
108
109
110template<class Cmpt>
113 return Vector<Cmpt>(this->v_[XZ], this->v_[YZ], this->v_[ZZ]);
114}
115
116
117template<class Cmpt>
118template<Foam::direction Idx>
120{
121 if (Idx == 0) return x();
122 else if (Idx == 1) return y();
123 else if (Idx == 2) return z();
125 static_assert(Idx < 3, "Invalid row access");
126 return Zero;
127}
128
129
130template<class Cmpt>
132{
133 switch (r)
134 {
135 case 0: return x(); break;
136 case 1: return y(); break;
137 case 2: return z(); break;
138 default:
140 << "Invalid row access " << r << abort(FatalError);
141 }
143 return Zero;
144}
145
146
147template<class Cmpt>
148template<Foam::direction Idx>
149inline void Foam::SymmTensor<Cmpt>::row(const Vector<Cmpt>& v)
150{
151 if (Idx == 0)
152 {
153 this->v_[XX] = v.x(); this->v_[XY] = v.y(); this->v_[XZ] = v.z();
154 }
155 else if (Idx == 1)
156 {
157 this->v_[XY] = v.x(); this->v_[YY] = v.y(); this->v_[YZ] = v.z();
158 }
159 else if (Idx == 2)
160 {
161 this->v_[XZ] = v.x(); this->v_[YZ] = v.y(); this->v_[ZZ] = v.z();
163
164 static_assert(Idx < 3, "Invalid row access");
165}
166
167
168template<class Cmpt>
170(
171 const Vector<Cmpt>& x,
172 const Vector<Cmpt>& y,
173 const Vector<Cmpt>& z
174)
175{
176 this->v_[XX] = x.x(); this->v_[XY] = x.y(); this->v_[XZ] = x.z();
177 this->v_[YY] = y.y(); this->v_[YZ] = y.z();
178 this->v_[ZZ] = z.z();
179}
180
181
182template<class Cmpt>
184(
185 const direction r,
186 const Vector<Cmpt>& v
187)
188{
189 switch (r)
190 {
191 case 0: row<0>(v); break;
192 case 1: row<1>(v); break;
193 case 2: row<2>(v); break;
194 default:
196 << "Invalid row access " << r << abort(FatalError);
197 }
198}
199
200
201template<class Cmpt>
203{
204 return Vector<Cmpt>(this->v_[XX], this->v_[YY], this->v_[ZZ]);
205}
206
207
208template<class Cmpt>
210{
211 this->v_[XX] = v.x(); this->v_[YY] = v.y(); this->v_[ZZ] = v.z();
212}
213
214
215template<class Cmpt>
217{
218 this->v_[XX] += v.x(); this->v_[YY] += v.y(); this->v_[ZZ] += v.z();
219}
220
221
222template<class Cmpt>
224{
225 this->v_[XX] -= v.x(); this->v_[YY] -= v.y(); this->v_[ZZ] -= v.z();
226}
227
228
229template<class Cmpt>
230inline Foam::scalar Foam::SymmTensor<Cmpt>::diagSqr() const
231{
232 return
233 (
234 Foam::magSqr(this->xx())
235 + Foam::magSqr(this->yy())
236 + Foam::magSqr(this->zz())
237 );
238}
239
240
241template<class Cmpt>
242inline bool Foam::SymmTensor<Cmpt>::is_identity(const scalar tol) const
243{
244 return
245 (
246 Foam::mag(xx() - pTraits<Cmpt>::one) < tol
247 && Foam::mag(yy() - pTraits<Cmpt>::one) < tol
248 && Foam::mag(zz() - pTraits<Cmpt>::one) < tol
249 && Foam::mag(xy()) < tol
250 && Foam::mag(xz()) < tol
251 && Foam::mag(yz()) < tol
252 );
253}
254
255
256template<class Cmpt>
257inline Cmpt Foam::SymmTensor<Cmpt>::det() const
258{
259 return
260 (
261 xx()*yy()*zz() + xy()*yz()*xz()
262 + xz()*xy()*yz() - xx()*yz()*yz()
263 - xy()*xy()*zz() - xz()*yy()*xz()
264 );
265}
266
267
268template<class Cmpt>
269inline Cmpt Foam::SymmTensor<Cmpt>::det2D(const direction excludeCmpt) const
270{
271 switch (excludeCmpt)
272 {
273 case 0: // Eliminate x
274 {
275 return (yy()*zz() - yz()*yz());
276 }
277
278 case 1: // Eliminate y
279 {
280 return (xx()*zz() - xz()*xz());
281 }
282 }
284 // Fall-through: Eliminate z
285 return (xx()*yy() - xy()*xy());
286}
287
288
289template<class Cmpt>
291{
292 // symmetric: cof() == adjunct()
293 return SymmTensor<Cmpt>
294 (
295 yy()*zz() - yz()*yz(), xz()*yz() - xy()*zz(), xy()*yz() - xz()*yy(),
296 xx()*zz() - xz()*xz(), xy()*xz() - xx()*yz(),
297 xx()*yy() - xy()*xy()
298 );
299}
300
301
302template<class Cmpt>
305 // symmetric: cof() == adjunct()
306 return this->adjunct();
307}
308
309
310template<class Cmpt>
312(
313 const direction excludeCmpt
314) const
315{
316 switch (excludeCmpt)
317 {
318 case 0: // Eliminate x
319 {
320 return SymmTensor<Cmpt>
321 (
322 Zero, Zero, Zero,
323 zz(), -yz(),
324 yy()
325 );
326 }
327
328 case 1: // Eliminate y
329 {
330 return SymmTensor<Cmpt>
331 (
332 zz(), Zero, -xz(),
333 Zero, Zero,
334 xx()
335 );
336 }
337 }
338
339 // Fall-through: Eliminate z
340 return SymmTensor<Cmpt>
341 (
342 yy(), -xy(), Zero,
344 Zero
345 );
346}
347
348
349template<class Cmpt>
351(
352 const direction excludeCmpt
353) const
354{
355 const Cmpt detval = this->det2D(excludeCmpt);
357 return this->adjunct2D(excludeCmpt)/detval;
358}
359
360
361// Invert without much error handling
362template<class Cmpt>
364{
365 const Cmpt detval = this->det();
366
367 #ifdef FULLDEBUG
368 if (mag(detval) < VSMALL)
369 {
371 << "Tensor not properly invertible, determinant:"
372 << detval << " tensor:" << *this << nl
373 << abort(FatalError);
374 }
375 #endif
377 return this->adjunct()/detval;
378}
379
380
381// Invert with some error handling
382template<class Cmpt>
384{
385 {
386 // Attempt to identify and handle 2-D cases.
387 // - use diagSqr instead of magSqr for fewer operations
388 const scalar magSqr_xx = Foam::magSqr(xx());
389 const scalar magSqr_yy = Foam::magSqr(yy());
390 const scalar magSqr_zz = Foam::magSqr(zz());
391
392 // SMALL: 1e-15 (double), 1e-6 (float), but 1e-6 may be adequate
393
394 const scalar threshold = SMALL * (magSqr_xx + magSqr_yy + magSqr_zz);
395
396 const bool small_xx = (magSqr_xx < threshold);
397 const bool small_yy = (magSqr_yy < threshold);
398 const bool small_zz = (magSqr_zz < threshold);
399
400 if (small_xx || small_yy || small_zz)
401 {
402 SymmTensor<Cmpt> work(*this);
403
404 if (small_xx) { work.xx() += pTraits<Cmpt>::one; }
405 if (small_yy) { work.yy() += pTraits<Cmpt>::one; }
406 if (small_zz) { work.zz() += pTraits<Cmpt>::one; }
407
408 const Cmpt detval = work.det();
409
410 if (mag(detval) < ROOTVSMALL)
411 {
412 // Appears to be nearly zero - leave untouched?
413 return SymmTensor<Cmpt>(Zero);
414 }
415
416 work = work.adjunct()/detval;
417
418 if (small_xx) { work.xx() -= pTraits<Cmpt>::one; }
419 if (small_yy) { work.yy() -= pTraits<Cmpt>::one; }
420 if (small_zz) { work.zz() -= pTraits<Cmpt>::one; }
421
422 return work;
423 }
424 }
425
426 const Cmpt detval = this->det();
427
428 if (mag(detval) < ROOTVSMALL)
429 {
430 // Appears to be nearly zero - leave untouched?
431 return SymmTensor<Cmpt>(Zero);
432 }
433
434 return this->adjunct()/detval;
435}
436
437
438// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
439
440template<class Cmpt>
442{
443 this->v_[XX] = st.ii(); this->v_[XY] = Zero; this->v_[XZ] = Zero;
444 this->v_[YY] = st.ii(); this->v_[YZ] = Zero;
445 this->v_[ZZ] = st.ii();
446}
447
448
449// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
450
451namespace Foam
452{
454// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
455
456//- Return the trace of a SymmTensor
457template<class Cmpt>
458inline Cmpt tr(const SymmTensor<Cmpt>& st)
459{
460 return st.xx() + st.yy() + st.zz();
461}
462
464//- Return the spherical part of a SymmTensor
465template<class Cmpt>
467{
469 (
470 (1.0/3.0)*tr(st)
471 );
472}
473
474
475//- Return the symmetric part of a SymmTensor, i.e. itself
476template<class Cmpt>
477inline const SymmTensor<Cmpt>& symm(const SymmTensor<Cmpt>& st)
478{
479 return st;
480}
481
482
483//- Return twice the symmetric part of a SymmTensor
484template<class Cmpt>
485inline SymmTensor<Cmpt> twoSymm(const SymmTensor<Cmpt>& st)
487 return 2*st;
488}
489
490
491//- Return the deviatoric part of the symmetric part of a SymmTensor
492template<class Cmpt>
493inline SymmTensor<Cmpt> devSymm(const SymmTensor<Cmpt>& st)
494{
495 return dev(st);
497
498
499//- Return the deviatoric part of twice the symmetric part of a SymmTensor
500template<class Cmpt>
501inline SymmTensor<Cmpt> devTwoSymm(const SymmTensor<Cmpt>& st)
502{
503 return dev2(st);
504}
505
507//- Return the deviatoric part of a SymmTensor
508template<class Cmpt>
509inline SymmTensor<Cmpt> dev(const SymmTensor<Cmpt>& st)
510{
511 return st - sph(st);
512}
513
514
515//- Return the two-third deviatoric part of a SymmTensor
516template<class Cmpt>
517inline SymmTensor<Cmpt> dev2(const SymmTensor<Cmpt>& st)
518{
519 return st - 2*sph(st);
520}
521
522
523//- Return the determinant of a SymmTensor
524template<class Cmpt>
525inline Cmpt det(const SymmTensor<Cmpt>& st)
527 return st.det();
528}
529
530
531//- Return the cofactor of a SymmTensor as a SymmTensor
532template<class Cmpt>
533inline SymmTensor<Cmpt> cof(const SymmTensor<Cmpt>& st)
534{
535 return st.cof();
537
538
539//- Return the inverse of a SymmTensor, using given determinant value
540template<class Cmpt>
541inline SymmTensor<Cmpt> inv(const SymmTensor<Cmpt>& st, const Cmpt detval)
542{
543 #ifdef FULLDEBUG
544 if (mag(detval) < VSMALL)
545 {
547 << "SymmTensor not properly invertible, determinant:"
548 << detval << " tensor:" << st << nl
549 << abort(FatalError);
550 }
551 #endif
552
553 return st.adjunct()/detval;
554}
555
557//- Return the inverse of a SymmTensor
558template<class Cmpt>
559inline SymmTensor<Cmpt> inv(const SymmTensor<Cmpt>& st)
560{
561 return st.inv();
562}
563
564
565//- Return the 1st invariant of a SymmTensor
566template<class Cmpt>
567inline Cmpt invariantI(const SymmTensor<Cmpt>& st)
568{
569 return tr(st);
570}
571
572
573//- Return the 2nd invariant of a SymmTensor
574template<class Cmpt>
575inline Cmpt invariantII(const SymmTensor<Cmpt>& st)
577 return
578 (
579 st.xx()*st.yy() + st.yy()*st.zz() + st.xx()*st.zz()
580 - st.xy()*st.xy() - st.yz()*st.yz() - st.xz()*st.xz()
581 );
582}
583
584
585//- Return the 3rd invariant of a SymmTensor
586template<class Cmpt>
587inline Cmpt invariantIII(const SymmTensor<Cmpt>& st)
588{
589 return det(st);
590}
591
592
593//- Return the inner-product of a SymmTensor with itself
594template<class Cmpt>
595inline SymmTensor<Cmpt>
597{
598 return SymmTensor<Cmpt>
599 (
600 st.xx()*st.xx() + st.xy()*st.xy() + st.xz()*st.xz(),
601 st.xx()*st.xy() + st.xy()*st.yy() + st.xz()*st.yz(),
602 st.xx()*st.xz() + st.xy()*st.yz() + st.xz()*st.zz(),
603
604 st.xy()*st.xy() + st.yy()*st.yy() + st.yz()*st.yz(),
605 st.xy()*st.xz() + st.yy()*st.yz() + st.yz()*st.zz(),
606
607 st.xz()*st.xz() + st.yz()*st.yz() + st.zz()*st.zz()
608 );
609}
611
612//- Return the square of Frobenius norm of a SymmTensor
613template<class Cmpt>
614inline Foam::scalar magSqr(const SymmTensor<Cmpt>& st)
615{
616 return
617 (
618 magSqr(st.xx()) + 2*magSqr(st.xy()) + 2*magSqr(st.xz())
619 + magSqr(st.yy()) + 2*magSqr(st.yz())
620 + magSqr(st.zz())
621 );
622}
623
624
625//- Return the square of a Vector as a SymmTensor
626template<class Cmpt>
627inline SymmTensor<Cmpt> sqr(const Vector<Cmpt>& v)
628{
629 return SymmTensor<Cmpt>
630 (
631 v.x()*v.x(), v.x()*v.y(), v.x()*v.z(),
632 v.y()*v.y(), v.y()*v.z(),
633 v.z()*v.z()
634 );
635}
636
637
638//- Linear interpolation of symmetric tensors a and b by factor t
639template<class Cmpt>
642 const SymmTensor<Cmpt>& a,
643 const SymmTensor<Cmpt>& b,
644 const scalar t
645)
646{
647 const scalar onet = (1-t);
648
649 return SymmTensor<Cmpt>
650 (
651 onet*a.xx() + t*b.xx(),
652 onet*a.xy() + t*b.xy(),
653 onet*a.xz() + t*b.xz(),
654 onet*a.yy() + t*b.yy(),
655 onet*a.yz() + t*b.yz(),
656 onet*a.zz() + t*b.zz()
657 );
658}
659
660
661// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
662
663//- Sum of a SphericalTensor and a SymmTensor
664template<class Cmpt>
665inline SymmTensor<Cmpt>
666operator+(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
667{
668 return SymmTensor<Cmpt>
669 (
670 spt1.ii() + st2.xx(), st2.xy(), st2.xz(),
671 spt1.ii() + st2.yy(), st2.yz(),
672 spt1.ii() + st2.zz()
673 );
674}
675
676
677//- Sum of a SymmTensor and a SphericalTensor
678template<class Cmpt>
679inline SymmTensor<Cmpt>
680operator+(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
681{
682 return SymmTensor<Cmpt>
683 (
684 st1.xx() + spt2.ii(), st1.xy(), st1.xz(),
685 st1.yy() + spt2.ii(), st1.yz(),
686 st1.zz() + spt2.ii()
687 );
688}
689
690
691//- Subtract a SymmTensor from a SphericalTensor
692template<class Cmpt>
693inline SymmTensor<Cmpt>
694operator-(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
695{
696 return SymmTensor<Cmpt>
697 (
698 spt1.ii() - st2.xx(), -st2.xy(), -st2.xz(),
699 spt1.ii() - st2.yy(), -st2.yz(),
700 spt1.ii() - st2.zz()
701 );
702}
703
704
705//- Subtract a SphericalTensor from a SymmTensor
706template<class Cmpt>
707inline SymmTensor<Cmpt>
708operator-(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
709{
710 return SymmTensor<Cmpt>
711 (
712 st1.xx() - spt2.ii(), st1.xy(), st1.xz(),
713 st1.yy() - spt2.ii(), st1.yz(),
714 st1.zz() - spt2.ii()
715 );
716}
717
718
719//- Return the Hodge dual of a SymmTensor as a Vector
720template<class Cmpt>
721inline Vector<Cmpt> operator*(const SymmTensor<Cmpt>& st)
722{
723 return Vector<Cmpt>(st.yz(), -st.xz(), st.xy());
724}
725
726
727//- Division of a SymmTensor by a Cmpt
728template<class Cmpt>
729inline SymmTensor<Cmpt>
730operator/(const SymmTensor<Cmpt>& st, const Cmpt s)
732 return SymmTensor<Cmpt>
733 (
734 st.xx()/s, st.xy()/s, st.xz()/s,
735 st.yy()/s, st.yz()/s,
736 st.zz()/s
737 );
738}
739
740
741//- Inner-product of a SymmTensor and a SymmTensor
742template<class Cmpt>
743inline Tensor<Cmpt>
744operator&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
745{
746 return Tensor<Cmpt>
748 st1.xx()*st2.xx() + st1.xy()*st2.xy() + st1.xz()*st2.xz(),
749 st1.xx()*st2.xy() + st1.xy()*st2.yy() + st1.xz()*st2.yz(),
750 st1.xx()*st2.xz() + st1.xy()*st2.yz() + st1.xz()*st2.zz(),
751
752 st1.xy()*st2.xx() + st1.yy()*st2.xy() + st1.yz()*st2.xz(),
753 st1.xy()*st2.xy() + st1.yy()*st2.yy() + st1.yz()*st2.yz(),
754 st1.xy()*st2.xz() + st1.yy()*st2.yz() + st1.yz()*st2.zz(),
755
756 st1.xz()*st2.xx() + st1.yz()*st2.xy() + st1.zz()*st2.xz(),
757 st1.xz()*st2.xy() + st1.yz()*st2.yy() + st1.zz()*st2.yz(),
758 st1.xz()*st2.xz() + st1.yz()*st2.yz() + st1.zz()*st2.zz()
759 );
760}
761
763//- Inner-product of a SphericalTensor and a SymmTensor
764template<class Cmpt>
765inline SymmTensor<Cmpt>
766operator&(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
767{
768 return SymmTensor<Cmpt>
769 (
770 spt1.ii()*st2.xx(), spt1.ii()*st2.xy(), spt1.ii()*st2.xz(),
771 spt1.ii()*st2.yy(), spt1.ii()*st2.yz(),
772 spt1.ii()*st2.zz()
773 );
774}
775
776
777//- Inner-product of a SymmTensor and a SphericalTensor
778template<class Cmpt>
779inline SymmTensor<Cmpt>
780operator&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
781{
782 return SymmTensor<Cmpt>
783 (
784 st1.xx()*spt2.ii(), st1.xy()*spt2.ii(), st1.xz()*spt2.ii(),
785 st1.yy()*spt2.ii(), st1.yz()*spt2.ii(),
786 st1.zz()*spt2.ii()
787 );
788}
790
791//- Inner-product of a SymmTensor and a Vector
792template<class Cmpt>
793inline Vector<Cmpt>
794operator&(const SymmTensor<Cmpt>& st, const Vector<Cmpt>& v)
795{
796 return Vector<Cmpt>
797 (
798 st.xx()*v.x() + st.xy()*v.y() + st.xz()*v.z(),
799 st.xy()*v.x() + st.yy()*v.y() + st.yz()*v.z(),
800 st.xz()*v.x() + st.yz()*v.y() + st.zz()*v.z()
801 );
802}
803
804
805//- Inner-product of a Vector and a SymmTensor
806template<class Cmpt>
807inline Vector<Cmpt>
808operator&(const Vector<Cmpt>& v, const SymmTensor<Cmpt>& st)
809{
810 return Vector<Cmpt>
811 (
812 v.x()*st.xx() + v.y()*st.xy() + v.z()*st.xz(),
813 v.x()*st.xy() + v.y()*st.yy() + v.z()*st.yz(),
814 v.x()*st.xz() + v.y()*st.yz() + v.z()*st.zz()
815 );
816}
817
818
819//- Double-inner-product of a SymmTensor and a SymmTensor
820template<class Cmpt>
821inline Cmpt
822operator&&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
823{
824 return
825 (
826 st1.xx()*st2.xx() + 2*st1.xy()*st2.xy() + 2*st1.xz()*st2.xz()
827 + st1.yy()*st2.yy() + 2*st1.yz()*st2.yz()
828 + st1.zz()*st2.zz()
829 );
830}
831
832
833//- Double-inner-product of a SphericalTensor and a SymmTensor
834template<class Cmpt>
835inline Cmpt
836operator&&(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
837{
838 return (spt1.ii()*st2.xx() + spt1.ii()*st2.yy() + spt1.ii()*st2.zz());
839}
840
841
842//- Double-inner-product of a SymmTensor and a SphericalTensor
843template<class Cmpt>
844inline Cmpt
846{
847 return (st1.xx()*spt2.ii() + st1.yy()*spt2.ii() + st1.zz()*spt2.ii());
848}
849
850
851// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
852
853template<class Cmpt>
854class outerProduct<SymmTensor<Cmpt>, Cmpt>
855{
856public:
857
858 typedef SymmTensor<Cmpt> type;
859};
860
861template<class Cmpt>
862class outerProduct<Cmpt, SymmTensor<Cmpt>>
863{
864public:
865
866 typedef SymmTensor<Cmpt> type;
867};
868
869template<class Cmpt>
870class innerProduct<SymmTensor<Cmpt>, SymmTensor<Cmpt>>
871{
872public:
873
874 typedef Tensor<Cmpt> type;
875};
876
877template<class Cmpt>
878class innerProduct<SymmTensor<Cmpt>, Vector<Cmpt>>
879{
880public:
881
882 typedef Vector<Cmpt> type;
883};
884
885template<class Cmpt>
886class innerProduct<Vector<Cmpt>, SymmTensor<Cmpt>>
887{
888public:
889
890 typedef Vector<Cmpt> type;
891};
892
894template<class Cmpt>
895class typeOfSum<SphericalTensor<Cmpt>, SymmTensor<Cmpt>>
896{
897public:
898
899 typedef SymmTensor<Cmpt> type;
900};
901
902template<class Cmpt>
903class typeOfSum<SymmTensor<Cmpt>, SphericalTensor<Cmpt>>
905public:
906
907 typedef SymmTensor<Cmpt> type;
908};
909
910template<class Cmpt>
911class innerProduct<SphericalTensor<Cmpt>, SymmTensor<Cmpt>>
912{
913public:
914
915 typedef SymmTensor<Cmpt> type;
916};
918template<class Cmpt>
919class innerProduct<SymmTensor<Cmpt>, SphericalTensor<Cmpt>>
920{
921public:
922
923 typedef SymmTensor<Cmpt> type;
924};
926
927// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
928
929} // End namespace Foam
930
931// ************************************************************************* //
scalar y
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element,...
const Cmpt & ii() const noexcept
A templated (3 x 3) symmetric tensor of objects of <T>, effectively containing 6 elements,...
Definition SymmTensor.H:53
scalar diagSqr() const
The L2-norm squared of the diagonal.
bool is_identity(const scalar tol=ROOTVSMALL) const
Is identity tensor?
SymmTensor< Cmpt > adjunct() const
Return adjunct matrix (transpose of cofactor matrix).
SymmTensor< Cmpt > inv2D(const direction excludeCmpt) const
Return inverse of 2D tensor (by excluding given direction).
const Cmpt & yy() const noexcept
Definition SymmTensor.H:154
void addDiag(const Vector< Cmpt > &v)
Add to the diagonal.
void rows(const Vector< Cmpt > &x, const Vector< Cmpt > &y, const Vector< Cmpt > &z)
Set row values.
Cmpt det2D(const direction excludeCmpt) const
The 2D determinant by excluding given direction.
Vector< Cmpt > row() const
Extract vector for given row: compile-time check of index.
void subtractDiag(const Vector< Cmpt > &v)
Subtract from the diagonal.
SymmTensor< Cmpt > cof() const
Return cofactor matrix (transpose of adjunct matrix).
Vector< Cmpt > z() const
Extract vector for row 2.
SymmTensor< Cmpt > adjunct2D(const direction excludeCmpt) const
Return 2D adjunct matrix by excluding given direction.
Cmpt det() const
The determinate.
Vector< Cmpt > y() const
Extract vector for row 1.
Definition SymmTensorI.H:97
const Cmpt & xx() const noexcept
Definition SymmTensor.H:150
SymmTensor< Cmpt > safeInv() const
Return inverse, with (ad hoc) failsafe handling of 2D tensors.
const Cmpt & yz() const noexcept
Definition SymmTensor.H:155
Vector< Cmpt > diag() const
Extract the diagonal as a vector.
SymmTensor< Cmpt > inv() const
Return inverse.
const Cmpt & zz() const noexcept
Definition SymmTensor.H:158
const Cmpt & xy() const noexcept
Definition SymmTensor.H:151
SymmTensor & operator=(const SymmTensor &)=default
Copy assignment.
SymmTensor()=default
Default construct.
const Cmpt & xz() const noexcept
Definition SymmTensor.H:152
Vector< Cmpt > x() const
Extract vector for row 0.
Definition SymmTensorI.H:90
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
Definition Tensor.H:60
Templated vector space.
Definition VectorSpace.H:75
VectorSpace< SymmTensor< Cmpt >, Cmpt, Ncmpts > vsType
Definition VectorSpace.H:86
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition Vector.H:61
const Cmpt & x() const noexcept
Access to the vector x component.
Definition Vector.H:135
const Cmpt & z() const noexcept
Access to the vector z component.
Definition Vector.H:145
const Cmpt & y() const noexcept
Access to the vector y component.
Definition Vector.H:140
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) -2 >::type type
Definition products.H:155
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition products.H:118
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
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))
Namespace for OpenFOAM.
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensionedScalar det(const dimensionedSphericalTensor &dt)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Cmpt invariantII(const SymmTensor2D< Cmpt > &st)
Return the 2nd invariant of a SymmTensor2D.
Cmpt invariantI(const SymmTensor2D< Cmpt > &st)
Return the 1st invariant of a SymmTensor2D.
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
SymmTensor< Cmpt > devSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of the symmetric part of a SymmTensor.
Cmpt invariantIII(const SymmTensor< Cmpt > &st)
Return the 3rd invariant of a SymmTensor.
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
tmp< GeometricField< Type, faPatchField, areaMesh > > operator&(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
Definition errorManip.H:139
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
uint8_t direction
Definition direction.H:49
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
dimensioned< typename scalarProduct< Type1, Type2 >::type > operator&&(const dimensioned< Type1 > &, const dimensioned< Type2 > &)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
volScalarField & b