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