SymmTensor2DI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 "Vector2D.H"
27 #include "Tensor2D.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Cmpt>
33 {}
34 
35 
36 template<class Cmpt>
38 :
40 {}
41 
42 
43 template<class Cmpt>
45 (
46  const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>& vs
47 )
48 :
50 {}
51 
52 
53 template<class Cmpt>
55 {
56  this->v_[XX] = st.ii(); this->v_[XY] = 0;
57  this->v_[YY] = st.ii();
58 }
59 
60 
61 template<class Cmpt>
63 (
64  const Cmpt txx, const Cmpt txy,
65  const Cmpt tyy
66 )
67 {
68  this->v_[XX] = txx; this->v_[XY] = txy;
69  this->v_[YY] = tyy;
70 }
71 
72 
73 template<class Cmpt>
75 :
76  SymmTensor2D::vsType(is)
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class Cmpt>
83 inline const Cmpt& Foam::SymmTensor2D<Cmpt>::xx() const
84 {
85  return this->v_[XX];
86 }
87 
88 template<class Cmpt>
89 inline const Cmpt& Foam::SymmTensor2D<Cmpt>::xy() const
90 {
91  return this->v_[XY];
92 }
93 
94 template<class Cmpt>
95 inline const Cmpt& Foam::SymmTensor2D<Cmpt>::yy() const
96 {
97  return this->v_[YY];
98 }
99 
100 
101 template<class Cmpt>
103 {
104  return this->v_[XX];
105 }
106 
107 template<class Cmpt>
109 {
110  return this->v_[XY];
111 }
112 
113 template<class Cmpt>
115 {
116  return this->v_[YY];
117 }
118 
119 
120 template<class Cmpt>
122 {
123  return *this;
124 }
125 
126 
127 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
128 
129 template<class Cmpt>
130 inline void Foam::SymmTensor2D<Cmpt>::operator=
131 (
132  const SphericalTensor2D<Cmpt>& st
133 )
134 {
135  this->v_[XX] = st.ii(); this->v_[XY] = 0;
136  this->v_[YY] = st.ii();
137 }
138 
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 namespace Foam
143 {
144 
145 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
146 
147 //- Inner-product between two symmetric tensors
148 template<class Cmpt>
149 inline Tensor2D<Cmpt>
151 {
152  return Tensor2D<Cmpt>
153  (
154  st1.xx()*st2.xx() + st1.xy()*st2.xy(),
155  st1.xx()*st2.xy() + st1.xy()*st2.yy(),
156 
157  st1.xy()*st2.xx() + st1.yy()*st2.xy(),
158  st1.xy()*st2.xy() + st1.yy()*st2.yy()
159  );
160 }
161 
162 
163 //- Double-dot-product between a symmetric tensor and a symmetric tensor
164 template<class Cmpt>
165 inline Cmpt
167 {
168  return
169  (
170  st1.xx()*st2.xx() + 2*st1.xy()*st2.xy()
171  + st1.yy()*st2.yy()
172  );
173 }
174 
175 
176 //- Inner-product between a symmetric tensor and a vector
177 template<class Cmpt>
178 inline Vector2D<Cmpt>
180 {
181  return Vector2D<Cmpt>
182  (
183  st.xx()*v.x() + st.xy()*v.y(),
184  st.xy()*v.x() + st.yy()*v.y()
185  );
186 }
187 
188 
189 //- Inner-product between a vector and a symmetric tensor
190 template<class Cmpt>
191 inline Vector2D<Cmpt>
193 {
194  return Vector2D<Cmpt>
195  (
196  v.x()*st.xx() + v.y()*st.xy(),
197  v.x()*st.xy() + v.y()*st.yy()
198  );
199 }
200 
201 
202 //- Inner-sqr of a symmetric tensor
203 template<class Cmpt>
204 inline SymmTensor2D<Cmpt>
206 {
207  return SymmTensor2D<Cmpt>
208  (
209  st.xx()*st.xx() + st.xy()*st.xy(),
210  st.xx()*st.xy() + st.xy()*st.yy(),
211  st.xy()*st.xy() + st.yy()*st.yy()
212  );
213 }
214 
215 
216 template<class Cmpt>
217 inline Cmpt magSqr(const SymmTensor2D<Cmpt>& st)
218 {
219  return
220  (
221  magSqr(st.xx()) + 2*magSqr(st.xy())
222  + magSqr(st.yy())
223  );
224 }
225 
226 
227 //- Return the trace of a symmetric tensor
228 template<class Cmpt>
229 inline Cmpt tr(const SymmTensor2D<Cmpt>& st)
230 {
231  return st.xx() + st.yy();
232 }
233 
234 
235 //- Return the spherical part of a symmetric tensor
236 template<class Cmpt>
238 {
239  return (1.0/2.0)*tr(st);
240 }
241 
242 
243 //- Return the symmetric part of a symmetric tensor, i.e. itself
244 template<class Cmpt>
246 {
247  return st;
248 }
249 
250 
251 //- Return twice the symmetric part of a symmetric tensor
252 template<class Cmpt>
254 {
255  return 2*st;
256 }
257 
258 
259 //- Return the deviatoric part of a symmetric tensor
260 template<class Cmpt>
262 {
263  return st - SphericalTensor2D<Cmpt>::oneThirdI*tr(st);
264 }
265 
266 
267 //- Return the deviatoric part of a symmetric tensor
268 template<class Cmpt>
270 {
271  return st - SphericalTensor2D<Cmpt>::twoThirdsI*tr(st);
272 }
273 
274 
275 //- Return the determinant of a symmetric tensor
276 template<class Cmpt>
277 inline Cmpt det(const SymmTensor2D<Cmpt>& st)
278 {
279  return
280  (
281  st.xx()*st.yy() - st.xy()*st.xy()
282  );
283 }
284 
285 
286 //- Return the cofactor symmetric tensor of a symmetric tensor
287 template<class Cmpt>
289 {
290  return SymmTensor2D<Cmpt>
291  (
292  st.yy(), -st.xy(),
293  st.xx()
294  );
295 }
296 
297 
298 //- Return the inverse of a symmetric tensor give the determinant
299 template<class Cmpt>
300 inline SymmTensor2D<Cmpt> inv(const SymmTensor2D<Cmpt>& st, const Cmpt detst)
301 {
302  return cof(st)/detst;
303 }
304 
305 
306 //- Return the inverse of a symmetric tensor
307 template<class Cmpt>
309 {
310  return inv(st, det(st));
311 }
312 
313 
314 //- Return the 1st invariant of a symmetric tensor
315 template<class Cmpt>
316 inline Cmpt invariantI(const SymmTensor2D<Cmpt>& st)
317 {
318  return tr(st);
319 }
320 
321 
322 //- Return the 2nd invariant of a symmetric tensor
323 template<class Cmpt>
324 inline Cmpt invariantII(const SymmTensor2D<Cmpt>& st)
325 {
326  return
327  (
328  0.5*sqr(tr(st))
329  - 0.5*
330  (
331  st.xx()*st.xx() + st.xy()*st.xy()
332  + st.xy()*st.xy() + st.yy()*st.yy()
333  )
334  );
335 }
336 
337 
338 //- Return the 3rd invariant of a symmetric tensor
339 template<class Cmpt>
340 inline Cmpt invariantIII(const SymmTensor2D<Cmpt>& st)
341 {
342  return det(st);
343 }
344 
345 
346 template<class Cmpt>
347 inline SymmTensor2D<Cmpt>
349 {
350  return SymmTensor2D<Cmpt>
351  (
352  spt1.ii() + st2.xx(), st2.xy(),
353  spt1.ii() + st2.yy()
354  );
355 }
356 
357 
358 template<class Cmpt>
359 inline SymmTensor2D<Cmpt>
361 {
362  return SymmTensor2D<Cmpt>
363  (
364  st1.xx() + spt2.ii(), st1.xy(),
365  st1.yy() + spt2.ii()
366  );
367 }
368 
369 
370 template<class Cmpt>
371 inline SymmTensor2D<Cmpt>
373 {
374  return SymmTensor2D<Cmpt>
375  (
376  spt1.ii() - st2.xx(), -st2.xy(),
377  spt1.ii() - st2.yy()
378  );
379 }
380 
381 
382 template<class Cmpt>
383 inline SymmTensor2D<Cmpt>
385 {
386  return SymmTensor2D<Cmpt>
387  (
388  st1.xx() - spt2.ii(), st1.xy(),
389  st1.yy() - spt2.ii()
390  );
391 }
392 
393 
394 //- Inner-product between a spherical symmetric tensor and a symmetric tensor
395 template<class Cmpt>
396 inline SymmTensor2D<Cmpt>
398 {
399  return SymmTensor2D<Cmpt>
400  (
401  spt1.ii()*st2.xx(), spt1.ii()*st2.xy(),
402  spt1.ii()*st2.yy()
403  );
404 }
405 
406 
407 //- Inner-product between a tensor and a spherical tensor
408 template<class Cmpt>
409 inline SymmTensor2D<Cmpt>
411 {
412  return SymmTensor2D<Cmpt>
413  (
414  st1.xx()*spt2.ii(), st1.xy()*spt2.ii(),
415  st1.yy()*spt2.ii()
416  );
417 }
418 
419 
420 //- Double-dot-product between a spherical tensor and a symmetric tensor
421 template<class Cmpt>
422 inline Cmpt
424 {
425  return(spt1.ii()*st2.xx() + spt1.ii()*st2.yy());
426 }
427 
428 
429 //- Double-dot-product between a tensor and a spherical tensor
430 template<class Cmpt>
431 inline Cmpt
433 {
434  return(st1.xx()*spt2.ii() + st1.yy()*spt2.ii());
435 }
436 
437 
438 template<class Cmpt>
440 {
441  return SymmTensor2D<Cmpt>
442  (
443  v.x()*v.x(), v.x()*v.y(),
444  v.y()*v.y()
445  );
446 }
447 
448 
449 template<class Cmpt>
450 class outerProduct<SymmTensor2D<Cmpt>, Cmpt>
451 {
452 public:
453 
455 };
456 
457 template<class Cmpt>
458 class outerProduct<Cmpt, SymmTensor2D<Cmpt>>
459 {
460 public:
461 
463 };
464 
465 template<class Cmpt>
467 {
468 public:
469 
471 };
472 
473 template<class Cmpt>
474 class innerProduct<SymmTensor2D<Cmpt>, Vector2D<Cmpt>>
475 {
476 public:
477 
479 };
480 
481 template<class Cmpt>
482 class innerProduct<Vector2D<Cmpt>, SymmTensor2D<Cmpt>>
483 {
484 public:
485 
487 };
488 
489 
490 template<class Cmpt>
492 {
493 public:
494 
496 };
497 
498 template<class Cmpt>
500 {
501 public:
502 
504 };
505 
506 template<class Cmpt>
508 {
509 public:
510 
512 };
513 
514 template<class Cmpt>
516 {
517 public:
518 
520 };
521 
522 
523 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
524 
525 } // End namespace Foam
526 
527 // ************************************************************************* //
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a symmetric tensor.
Definition: SymmTensorI.H:403
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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
dimensionedScalar det(const dimensionedSphericalTensor &dt)
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a diagonal tensor.
Definition: DiagTensorI.H:353
SymmTensor2D()
Construct null.
Definition: SymmTensor2DI.H:32
const Cmpt & x() const
Definition: Vector2DI.H:68
Templated 2D tensor derived from VectorSpace adding construction from 4 components, element access using xx(), xy(), yx() and yy() member functions and the iner-product (dot-product) and outer-product of two Vector2Ds (tensor-product) operators.
Definition: Tensor2D.H:56
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
tmp< GeometricField< Type, fvPatchField, volMesh > > operator &(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
dimensionSet operator &&(const dimensionSet &, const dimensionSet &)
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
const Cmpt & y() const
Definition: Vector2DI.H:74
Cmpt invariantIII(const SymmTensor< Cmpt > &st)
Return the 3rd invariant of a symmetric tensor.
Definition: SymmTensorI.H:415
const SymmTensor2D< Cmpt > & T() const
Transpose.
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
static const zero Zero
Definition: zero.H:97
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
const Cmpt & ii() const
const Cmpt & xx() const
Definition: SymmTensor2DI.H:83
const Cmpt & yy() const
Definition: SymmTensor2DI.H:95
dimensioned< scalar > magSqr(const dimensioned< Type > &)
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Templated 2D sphericalTensor derived from VectorSpace adding construction from 1 component, element access using ii() member function and the inner-product (dot-product) and outer-product operators.
Cmpt invariantI(const SymmTensor< Cmpt > &st)
Return the 1st invariant of a symmetric tensor.
Definition: SymmTensorI.H:395
Templated 2D symmetric tensor derived from VectorSpace adding construction from 4 components...
Definition: SymmTensor2D.H:53
const Cmpt & xy() const
Definition: SymmTensor2DI.H:89
VectorSpace< SymmTensor2D< Cmpt >, Cmpt, Ncmpts > vsType
VectorSpace type.
Definition: VectorSpace.H:87
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
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
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Cmpt v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:84
Namespace for OpenFOAM.