59 tensor2D::uniform(VGREAT)
65 tensor2D::uniform(-VGREAT)
71 tensor2D::uniform(ROOTVGREAT)
77 tensor2D::uniform(-ROOTVGREAT)
92 const scalar a =
T.xx();
93 const scalar
b =
T.xy();
94 const scalar
c =
T.yx();
95 const scalar d =
T.yy();
103 const scalar trace = a + d;
107 scalar
e = std::fma(-
b,
c, w);
108 scalar
f = std::fma(a, d, -w);
109 const scalar determinant =
f +
e;
112 const scalar gapSqr = std::fma(-4.0, determinant,
sqr(trace));
120 if (
mag(firstRoot) < SMALL)
123 <<
"Zero-valued root is found. Adding SMALL to the root " 124 <<
"to avoid floating-point exception." <<
nl;
128 Vector2D<complex> eVals
131 complex(determinant/firstRoot, 0)
135 if (eVals.x().real() > eVals.y().real())
137 std::swap(eVals.x(), eVals.y());
147 return Vector2D<complex>
160 const Vector2D<complex>& standardBasis
164 const Tensor2D<complex>
A 173 Vector2D<complex> eVec(
complex(1), -
A.yx()/
A.yy());
176 if (
mag(eVec) < SMALL)
179 <<
"Eigenvector magnitude should be non-zero:" 180 <<
"mag(eigenvector) = " <<
mag(eVec)
185 return eVec/
mag(eVec);
187 else if (
mag(
A.xx()) > SMALL)
189 Vector2D<complex> eVec(-
A.xy()/
A.xx(),
complex(1));
192 if (
mag(eVec) < SMALL)
195 <<
"Eigenvector magnitude should be non-zero:" 196 <<
"mag(eigenvector) = " <<
mag(eVec)
201 return eVec/
mag(eVec);
204 else if (
mag(
T.yx()) >
mag(
T.xy()) &&
mag(
T.yx()) > SMALL)
206 const Vector2D<complex> eVec(eVal -
T.yy(),
complex(
T.yx()));
209 if (
mag(eVec) < SMALL)
212 <<
"Eigenvector magnitude should be non-zero:" 213 <<
"mag(eigenvector) = " <<
mag(eVec)
218 return eVec/
mag(eVec);
220 else if (
mag(
T.xy()) > SMALL)
222 const Vector2D<complex> eVec(
complex(
T.xy()), eVal -
T.xx());
225 if (
mag(eVec) < SMALL)
228 <<
"Eigenvector magnitude should be non-zero:" 229 <<
"mag(eigenvector) = " <<
mag(eVec)
234 return eVec/
mag(eVec);
238 return Vector2D<complex>(-standardBasis.y(), standardBasis.x());
245 const Vector2D<complex>& eVals
248 Vector2D<complex> Ux(pTraits<complex>::one,
Zero);
249 Vector2D<complex> Uy(
Zero, pTraits<complex>::one);
254 return Tensor2D<complex>(Ux, Uy);
vector eigenVector(const symmTensor &T, const scalar eVal, const vector &standardBasis1, const vector &standardBasis2)
Return a real eigenvector corresponding to a given real eigenvalue of a given symmTensor.
dimensionedScalar sign(const dimensionedScalar &ds)
static const char *const typeName
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
static const char *const componentNames[]
static const Form rootMin
dimensionedScalar sqrt(const dimensionedScalar &ds)
A templated (2 x 2) tensor of objects of <T> derived from VectorSpace.
dimensionedTensor eigenVectors(const dimensionedSymmTensor &dt)
const dimensionedScalar e
Elementary charge.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
errorManip< error > abort(error &err)
static const Form rootMax
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar c
Speed of light in a vacuum.
dimensionedVector eigenValues(const dimensionedSymmTensor &dt)
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).
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
static constexpr const zero Zero
Global zero (0)
Tensor2D< scalar > tensor2D
Tensor2D of scalars, i.e. Tensor2D<scalar>.