SymmTensor2DI.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 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 #include "Tensor2D.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Cmpt>
35 {}
36 
37 
38 template<class Cmpt>
40 :
42 {}
43 
44 
45 template<class Cmpt>
47 (
48  const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>& vs
49 )
50 :
52 {}
53 
54 
55 template<class Cmpt>
57 {
58  this->v_[XX] = st.ii(); this->v_[XY] = 0;
59  this->v_[YY] = st.ii();
60 }
61 
62 
63 template<class Cmpt>
65 (
66  const Cmpt txx, const Cmpt txy,
67  const Cmpt tyy
68 )
69 {
70  this->v_[XX] = txx; this->v_[XY] = txy;
71  this->v_[YY] = tyy;
72 }
73 
74 
75 template<class Cmpt>
77 :
78  SymmTensor2D::vsType(is)
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
84 template<class Cmpt>
85 inline const Cmpt& Foam::SymmTensor2D<Cmpt>::xx() const
86 {
87  return this->v_[XX];
88 }
89 
90 template<class Cmpt>
91 inline const Cmpt& Foam::SymmTensor2D<Cmpt>::xy() const
92 {
93  return this->v_[XY];
94 }
95 
96 template<class Cmpt>
97 inline const Cmpt& Foam::SymmTensor2D<Cmpt>::yy() const
98 {
99  return this->v_[YY];
100 }
101 
102 
103 template<class Cmpt>
105 {
106  return this->v_[XX];
107 }
108 
109 template<class Cmpt>
111 {
112  return this->v_[XY];
113 }
114 
115 template<class Cmpt>
117 {
118  return this->v_[YY];
119 }
120 
121 
122 template<class Cmpt>
124 {
125  return Vector2D<Cmpt>(this->v_[XX], this->v_[YY]);
126 }
127 
128 
129 template<class Cmpt>
131 {
132  this->v_[XX] = v.x(); this->v_[YY] = v.y();
133 }
134 
135 
136 template<class Cmpt>
138 {
139  return *this;
140 }
141 
142 
143 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
144 
145 template<class Cmpt>
147 (
148  const SphericalTensor2D<Cmpt>& st
149 )
150 {
151  this->v_[XX] = st.ii(); this->v_[XY] = 0;
152  this->v_[YY] = st.ii();
153 }
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 namespace Foam
159 {
160 
161 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
162 
163 //- Inner-product between two symmetric tensors
164 template<class Cmpt>
165 inline Tensor2D<Cmpt>
167 {
168  return Tensor2D<Cmpt>
169  (
170  st1.xx()*st2.xx() + st1.xy()*st2.xy(),
171  st1.xx()*st2.xy() + st1.xy()*st2.yy(),
172 
173  st1.xy()*st2.xx() + st1.yy()*st2.xy(),
174  st1.xy()*st2.xy() + st1.yy()*st2.yy()
175  );
176 }
177 
178 
179 //- Double-dot-product between a symmetric tensor and a symmetric tensor
180 template<class Cmpt>
181 inline Cmpt
183 {
184  return
185  (
186  st1.xx()*st2.xx() + 2*st1.xy()*st2.xy()
187  + st1.yy()*st2.yy()
188  );
189 }
190 
191 
192 //- Inner-product between a symmetric tensor and a vector
193 template<class Cmpt>
194 inline Vector2D<Cmpt>
196 {
197  return Vector2D<Cmpt>
198  (
199  st.xx()*v.x() + st.xy()*v.y(),
200  st.xy()*v.x() + st.yy()*v.y()
201  );
202 }
203 
204 
205 //- Inner-product between a vector and a symmetric tensor
206 template<class Cmpt>
207 inline Vector2D<Cmpt>
209 {
210  return Vector2D<Cmpt>
211  (
212  v.x()*st.xx() + v.y()*st.xy(),
213  v.x()*st.xy() + v.y()*st.yy()
214  );
215 }
216 
217 
218 //- Inner-sqr of a symmetric tensor
219 template<class Cmpt>
220 inline SymmTensor2D<Cmpt>
222 {
223  return SymmTensor2D<Cmpt>
224  (
225  st.xx()*st.xx() + st.xy()*st.xy(),
226  st.xx()*st.xy() + st.xy()*st.yy(),
227  st.xy()*st.xy() + st.yy()*st.yy()
228  );
229 }
230 
231 
232 template<class Cmpt>
233 inline Cmpt magSqr(const SymmTensor2D<Cmpt>& st)
234 {
235  return
236  (
237  magSqr(st.xx()) + 2*magSqr(st.xy())
238  + magSqr(st.yy())
239  );
240 }
241 
242 
243 //- Return the trace of a symmetric tensor
244 template<class Cmpt>
245 inline Cmpt tr(const SymmTensor2D<Cmpt>& st)
246 {
247  return st.xx() + st.yy();
248 }
249 
250 
251 //- Return the spherical part of a symmetric tensor
252 template<class Cmpt>
254 {
255  return (1.0/2.0)*tr(st);
256 }
257 
258 
259 //- Return the symmetric part of a symmetric tensor, i.e. itself
260 template<class Cmpt>
262 {
263  return st;
264 }
265 
266 
267 //- Return twice the symmetric part of a symmetric tensor
268 template<class Cmpt>
270 {
271  return 2*st;
272 }
273 
274 
275 //- Return the deviatoric part of a symmetric tensor
276 template<class Cmpt>
278 {
279  return st - SphericalTensor2D<Cmpt>::oneThirdI*tr(st);
280 }
281 
282 
283 //- Return the deviatoric part of a symmetric tensor
284 template<class Cmpt>
286 {
287  return st - SphericalTensor2D<Cmpt>::twoThirdsI*tr(st);
288 }
289 
290 
291 //- Return the determinant of a symmetric tensor
292 template<class Cmpt>
293 inline Cmpt det(const SymmTensor2D<Cmpt>& st)
294 {
295  return
296  (
297  st.xx()*st.yy() - st.xy()*st.xy()
298  );
299 }
300 
301 
302 //- Return the cofactor symmetric tensor of a symmetric tensor
303 template<class Cmpt>
305 {
306  return SymmTensor2D<Cmpt>
307  (
308  st.yy(), -st.xy(),
309  st.xx()
310  );
311 }
312 
313 
314 //- Return the inverse of a symmetric tensor give the determinant
315 template<class Cmpt>
316 inline SymmTensor2D<Cmpt> inv(const SymmTensor2D<Cmpt>& st, const Cmpt detst)
317 {
318  return cof(st)/detst;
319 }
320 
321 
322 //- Return the inverse of a symmetric tensor
323 template<class Cmpt>
325 {
326  return inv(st, det(st));
327 }
328 
329 
330 //- Return the 1st invariant of a symmetric tensor
331 template<class Cmpt>
332 inline Cmpt invariantI(const SymmTensor2D<Cmpt>& st)
333 {
334  return tr(st);
335 }
336 
337 
338 //- Return the 2nd invariant of a symmetric tensor
339 template<class Cmpt>
340 inline Cmpt invariantII(const SymmTensor2D<Cmpt>& st)
341 {
342  return
343  (
344  0.5*sqr(tr(st))
345  - 0.5*
346  (
347  st.xx()*st.xx() + st.xy()*st.xy()
348  + st.xy()*st.xy() + st.yy()*st.yy()
349  )
350  );
351 }
352 
353 
354 //- Return the 3rd invariant of a symmetric tensor
355 template<class Cmpt>
356 inline Cmpt invariantIII(const SymmTensor2D<Cmpt>& st)
357 {
358  return det(st);
359 }
360 
361 
362 template<class Cmpt>
363 inline SymmTensor2D<Cmpt>
365 {
366  return SymmTensor2D<Cmpt>
367  (
368  spt1.ii() + st2.xx(), st2.xy(),
369  spt1.ii() + st2.yy()
370  );
371 }
372 
373 
374 template<class Cmpt>
375 inline SymmTensor2D<Cmpt>
377 {
378  return SymmTensor2D<Cmpt>
379  (
380  st1.xx() + spt2.ii(), st1.xy(),
381  st1.yy() + spt2.ii()
382  );
383 }
384 
385 
386 template<class Cmpt>
387 inline SymmTensor2D<Cmpt>
389 {
390  return SymmTensor2D<Cmpt>
391  (
392  spt1.ii() - st2.xx(), -st2.xy(),
393  spt1.ii() - st2.yy()
394  );
395 }
396 
397 
398 template<class Cmpt>
399 inline SymmTensor2D<Cmpt>
401 {
402  return SymmTensor2D<Cmpt>
403  (
404  st1.xx() - spt2.ii(), st1.xy(),
405  st1.yy() - spt2.ii()
406  );
407 }
408 
409 
410 //- Inner-product between a spherical symmetric tensor and a symmetric tensor
411 template<class Cmpt>
412 inline SymmTensor2D<Cmpt>
414 {
415  return SymmTensor2D<Cmpt>
416  (
417  spt1.ii()*st2.xx(), spt1.ii()*st2.xy(),
418  spt1.ii()*st2.yy()
419  );
420 }
421 
422 
423 //- Inner-product between a tensor and a spherical tensor
424 template<class Cmpt>
425 inline SymmTensor2D<Cmpt>
427 {
428  return SymmTensor2D<Cmpt>
429  (
430  st1.xx()*spt2.ii(), st1.xy()*spt2.ii(),
431  st1.yy()*spt2.ii()
432  );
433 }
434 
435 
436 //- Double-dot-product between a spherical tensor and a symmetric tensor
437 template<class Cmpt>
438 inline Cmpt
440 {
441  return(spt1.ii()*st2.xx() + spt1.ii()*st2.yy());
442 }
443 
444 
445 //- Double-dot-product between a tensor and a spherical tensor
446 template<class Cmpt>
447 inline Cmpt
449 {
450  return(st1.xx()*spt2.ii() + st1.yy()*spt2.ii());
451 }
452 
453 
454 template<class Cmpt>
456 {
457  return SymmTensor2D<Cmpt>
458  (
459  v.x()*v.x(), v.x()*v.y(),
460  v.y()*v.y()
461  );
462 }
463 
464 
465 template<class Cmpt>
466 class outerProduct<SymmTensor2D<Cmpt>, Cmpt>
467 {
468 public:
469 
471 };
472 
473 template<class Cmpt>
474 class outerProduct<Cmpt, SymmTensor2D<Cmpt>>
475 {
476 public:
477 
479 };
480 
481 template<class Cmpt>
483 {
484 public:
485 
487 };
488 
489 template<class Cmpt>
490 class innerProduct<SymmTensor2D<Cmpt>, Vector2D<Cmpt>>
491 {
492 public:
493 
495 };
496 
497 template<class Cmpt>
498 class innerProduct<Vector2D<Cmpt>, SymmTensor2D<Cmpt>>
499 {
500 public:
501 
503 };
504 
505 
506 template<class Cmpt>
508 {
509 public:
510 
512 };
513 
514 template<class Cmpt>
516 {
517 public:
518 
520 };
521 
522 template<class Cmpt>
524 {
525 public:
526 
528 };
529 
530 template<class Cmpt>
532 {
533 public:
534 
536 };
537 
538 
539 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
540 
541 } // End namespace Foam
542 
543 // ************************************************************************* //
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:84
Foam::SymmTensor2D::SymmTensor2D
SymmTensor2D()
Construct null.
Definition: SymmTensor2DI.H:34
Foam::innerProduct< SymmTensor2D< Cmpt >, Vector2D< Cmpt > >::type
Vector2D< Cmpt > type
Definition: SymmTensor2DI.H:494
Foam::invariantIII
Cmpt invariantIII(const SymmTensor< Cmpt > &st)
Return the 3rd invariant of a symmetric tensor.
Definition: SymmTensorI.H:431
Foam::operator&
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
Foam::invariantI
Cmpt invariantI(const SymmTensor< Cmpt > &st)
Return the 1st invariant of a symmetric tensor.
Definition: SymmTensorI.H:411
Tensor2D.H
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::innerProduct
Definition: products.H:141
Foam::SymmTensor2D
Templated 2D symmetric tensor derived from VectorSpace adding construction from 4 components,...
Definition: SymmTensor2D.H:57
Foam::operator-
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Foam::innerProduct< SphericalTensor2D< Cmpt >, SymmTensor2D< Cmpt > >::type
SymmTensor2D< Cmpt > type
Definition: SymmTensor2DI.H:527
Foam::SphericalTensor2D::ii
const Cmpt & ii() const
Definition: SphericalTensor2DI.H:71
Foam::Vector2D
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition: Vector2D.H:55
Foam::dev2
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:117
Foam::innerSqr
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:62
Foam::innerProduct< SymmTensor2D< Cmpt >, SphericalTensor2D< Cmpt > >::type
SymmTensor2D< Cmpt > type
Definition: SymmTensor2DI.H:535
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::Tensor2D
Templated 2D tensor derived from VectorSpace adding construction from 4 components,...
Definition: Tensor2D.H:59
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::outerProduct< SymmTensor2D< Cmpt >, Cmpt >::type
SymmTensor2D< Cmpt > type
Definition: SymmTensor2DI.H:470
Foam::typeOfSum
Definition: products.H:97
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:73
Foam::SymmTensor2D::diag
Vector2D< Cmpt > diag() const
Extract the diagonal as a vector.
Definition: SymmTensor2DI.H:123
Foam::sph
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a diagonal tensor.
Definition: DiagTensorI.H:290
Foam::VectorSpace< SymmTensor2D< Cmpt >, Cmpt, 3 >::vsType
VectorSpace< SymmTensor2D< Cmpt >, Cmpt, Ncmpts > vsType
VectorSpace type.
Definition: VectorSpace.H:86
Foam::operator&&
dimensioned< typename scalarProduct< Type1, Type2 >::type > operator&&(const dimensioned< Type1 > &, const dimensioned< Type2 > &)
Foam::invariantII
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a symmetric tensor.
Definition: SymmTensorI.H:419
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cof
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:139
Foam::SymmTensor2D::T
const SymmTensor2D< Cmpt > & T() const
Transpose.
Definition: SymmTensor2DI.H:137
Foam::typeOfSum< SphericalTensor2D< Cmpt >, SymmTensor2D< Cmpt > >::type
SymmTensor2D< Cmpt > type
Definition: SymmTensor2DI.H:511
Foam::innerProduct< Vector2D< Cmpt >, SymmTensor2D< Cmpt > >::type
Vector2D< Cmpt > type
Definition: SymmTensor2DI.H:502
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::typeOfSum< SymmTensor2D< Cmpt >, SphericalTensor2D< Cmpt > >::type
SymmTensor2D< Cmpt > type
Definition: SymmTensor2DI.H:519
Foam::outerProduct< Cmpt, SymmTensor2D< Cmpt > >::type
SymmTensor2D< Cmpt > type
Definition: SymmTensor2DI.H:478
Foam::operator+
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::innerProduct< SymmTensor2D< Cmpt >, SymmTensor2D< Cmpt > >::type
Tensor2D< Cmpt > type
Definition: SymmTensor2DI.H:486
Foam::SymmTensor2D::xx
const Cmpt & xx() const
Definition: SymmTensor2DI.H:85
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:51
Foam::det
dimensionedScalar det(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:62
Foam::SymmTensor2D::yy
const Cmpt & yy() const
Definition: SymmTensor2DI.H:97
Foam::Vector2D::y
const Cmpt & y() const
Access to the vector y component.
Definition: Vector2DI.H:78
Foam::twoSymm
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:95
Foam::outerProduct
Definition: products.H:106
Foam::Vector2D::x
const Cmpt & x() const
Access to the vector x component.
Definition: Vector2DI.H:71
Foam::SphericalTensor2D
Templated 2D sphericalTensor derived from VectorSpace adding construction from 1 component,...
Definition: SphericalTensor2D.H:55
Foam::SymmTensor2D::xy
const Cmpt & xy() const
Definition: SymmTensor2DI.H:91
Foam::zero
A class representing the concept of 0 (zero), which can be used to avoid manipulating objects that ar...
Definition: zero.H:61
Foam::dev
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:106