symmTensor2D.C
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) 2020 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 "symmTensor2D.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33template<>
34const char* const Foam::symmTensor2D::vsType::typeName = "symmTensor2D";
35
36template<>
38{
39 "xx", "xy",
40 "yy"
41};
42
43template<>
45(
46 symmTensor2D::uniform(0)
47);
48
49template<>
51(
52 symmTensor2D::uniform(1)
53);
54
55template<>
57(
58 symmTensor2D::uniform(VGREAT)
59);
60
61template<>
63(
64 symmTensor2D::uniform(-VGREAT)
65);
66
67template<>
69(
70 symmTensor2D::uniform(ROOTVGREAT)
71);
72
73template<>
75(
76 symmTensor2D::uniform(-ROOTVGREAT)
77);
78
79template<>
81(
82 1, 0,
83 1
84);
85
86
87// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88
90{
91 // Return diagonal if T is effectively diagonal tensor
92 if (sqr(T.xy()) < ROOTSMALL)
93 {
94 return vector2D(T.diag());
95 }
96
97 //(K:Eqs. 3.2-3.3)
98 const scalar skewTrace = T.xx() - T.yy();
99 const scalar trace = tr(T);
100 const scalar gap = sign(skewTrace)*hypot(skewTrace, 2*T.xy());
101
102 return vector2D(0.5*(trace + gap), 0.5*(trace - gap));
103}
104
105
107(
108 const symmTensor2D& T,
109 const scalar eVal,
110 const vector2D& standardBasis
111)
112{
113 // Construct the characteristic equation system for this eigenvalue
114 const tensor2D A(T - eVal*tensor2D::I);
115
116 // Evaluate the eigenvector using the largest divisor
117 if (mag(A.yy()) > mag(A.xx()) && mag(A.yy()) > SMALL)
118 {
119 const vector2D eVec(1, -A.yx()/A.yy());
120
121 #ifdef FULLDEBUG
122 if (mag(eVec) < SMALL)
123 {
125 << "Eigenvector magnitude should be non-zero:"
126 << "mag(eigenvector) = " << mag(eVec)
127 << abort(FatalError);
128 }
129 #endif
130
131 return eVec/mag(eVec);
132 }
133 else if (mag(A.xx()) > SMALL)
134 {
135 const vector2D eVec(-A.xy()/A.xx(), 1);
136
137 #ifdef FULLDEBUG
138 if (mag(eVec) < SMALL)
139 {
141 << "Eigenvector magnitude should be non-zero:"
142 << "mag(eigenvector) = " << mag(eVec)
143 << abort(FatalError);
144 }
145 #endif
146
147 return eVec/mag(eVec);
148 }
149
150 // Repeated eigenvalue
151 return vector2D(-standardBasis.y(), standardBasis.x());
152}
153
154
156(
157 const symmTensor2D& T,
158 const vector2D& eVals
159)
160{
161 // (K:Eq. 3.5)
162 const scalar skewTrace = T.xx() - T.yy();
163
164 if (mag(skewTrace) > SMALL)
165 {
166 const scalar phi = 0.5*atan(2*T.xy()/skewTrace);
167 const scalar cphi = cos(phi);
168 const scalar sphi = sin(phi);
169 return tensor2D(cphi, sphi, -sphi, cphi);
170 }
171 else if (mag(T.xy()) > SMALL)
172 {
173 const scalar a = 0.70710678; // phi ~ 45deg
174 return tensor2D(a, sign(T.xy())*a, -1*sign(T.xy())*a, a);
175 }
176
177 // (K:p. 3)
178 return tensor2D(1, 0, 0, 1);
179}
180
181
183{
184 const vector2D eVals(eigenValues(T));
185
186 return eigenVectors(T, eVals);
187}
188
189
190// ************************************************************************* //
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
surfaceScalarField & phi
A templated (2 x 2) symmetric tensor of objects of <T>, effectively containing 3 elements,...
Definition: SymmTensor2D.H:61
static const SymmTensor2D I
Definition: SymmTensor2D.H:78
A templated (2 x 2) tensor of objects of <T> derived from VectorSpace.
Definition: Tensor2D.H:59
const Cmpt & y() const
Access to the vector y component.
Definition: Vector2DI.H:73
const Cmpt & x() const
Access to the vector x component.
Definition: Vector2DI.H:66
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:62
static const char *const componentNames[]
Definition: bool.H:104
static const complex rootMax
complex (ROOTVGREAT, ROOTVGREAT)
Definition: complex.H:295
static const complex min
complex (-VGREAT,-VGREAT)
Definition: complex.H:292
static const complex max
complex (VGREAT,VGREAT)
Definition: complex.H:293
static const complex rootMin
complex (-ROOTVGREAT, -ROOTVGREAT)
Definition: complex.H:294
const volScalarField & T
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
dimensionedTensor eigenVectors(const dimensionedSymmTensor &dt)
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedVector eigenValues(const dimensionedSymmTensor &dt)
dimensionedScalar sin(const dimensionedScalar &ds)
vector eigenVector(const symmTensor &T, const scalar eVal, const vector &standardBasis1, const vector &standardBasis2)
Definition: symmTensor.C:152
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
dimensionedScalar atan(const dimensionedScalar &ds)
dimensionedScalar cos(const dimensionedScalar &ds)
static const char *const typeName
The type name used in ensight case files.
A non-counting (dummy) refCount.
Definition: refCount.H:59