mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: reorder global funcs and opers in Tensor types
- In the course of time, global funcs/opers of Tensor types expanded
leaving funcs/opers unordered.
- Therefore, by following the order designated in Matrix class, the order
of global funcs and global opers are reordered:
- oper+ oper- oper* oper/ inner-product double-inner-product outer-product
This commit is contained in:
committed by
Andrew Heather
parent
66b02ca5ca
commit
6a53794e0a
@ -115,6 +115,69 @@ inline Cmpt& Foam::DiagTensor<Cmpt>::zz()
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the trace of a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
return dt.xx() + dt.yy() + dt.zz();
|
||||
}
|
||||
|
||||
|
||||
//- Return the spherical part of a DiagTensor as a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> sph(const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
return SphericalTensor<Cmpt>
|
||||
(
|
||||
(1.0/3.0)*tr(dt)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the determinant of a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
return dt.xx()*dt.yy()*dt.zz();
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a DiagTensor as a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt> inv(const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(det(dt)) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "DiagTensor is not invertible due to the zero determinant:"
|
||||
<< "det(DiagTensor) = " << det(dt)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return DiagTensor<Cmpt>(1/dt.xx(), 1/dt.yy(), 1/dt.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Return the diagonal of a Tensor as a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt> diag(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return DiagTensor<Cmpt>(t.xx(), t.yy(), t.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Return the diagonal of a SymmTensor as a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt> diag(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return DiagTensor<Cmpt>(st.xx(), st.yy(), st.zz());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Sum of a DiagTensor and a Tensor
|
||||
@ -173,6 +236,66 @@ operator-(const Tensor<Cmpt>& t1, const DiagTensor<Cmpt>& dt2)
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Cmpt by a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt>
|
||||
operator/(const Cmpt s, const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(det(dt)) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cmpt = " << s
|
||||
<< " is not divisible by the DiagTensor due to a zero element:"
|
||||
<< "DiagTensor = " << dt
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return DiagTensor<Cmpt>(s/dt.xx(), s/dt.yy(), s/dt.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Division of a DiagTensor by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt>
|
||||
operator/(const DiagTensor<Cmpt>& dt, const Cmpt s)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(s) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "DiagTensor = " << dt
|
||||
<< " is not divisible due to a zero value in Cmpt:"
|
||||
<< "Cmpt = " << s
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return DiagTensor<Cmpt>(dt.xx()/s, dt.yy()/s, dt.zz()/s);
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Vector by a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator/(const Vector<Cmpt> v, const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(det(dt)) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Vector = " << v
|
||||
<< " is not divisible by the DiagTensor due to a zero element:"
|
||||
<< "DiagTensor = " << dt
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Vector<Cmpt>(v.x()/dt.xx(), v.y()/dt.yy(), v.z()/dt.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a DiagTensor and a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt>
|
||||
@ -259,127 +382,6 @@ operator&(const Vector<Cmpt>& v, const DiagTensor<Cmpt>& dt)
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Cmpt by a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt>
|
||||
operator/(const Cmpt s, const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(det(dt)) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cmpt = " << s
|
||||
<< " is not divisible by the DiagTensor due to a zero element:"
|
||||
<< "DiagTensor = " << dt
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return DiagTensor<Cmpt>(s/dt.xx(), s/dt.yy(), s/dt.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Division of a DiagTensor by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt>
|
||||
operator/(const DiagTensor<Cmpt>& dt, const Cmpt s)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(s) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "DiagTensor = " << dt
|
||||
<< " is not divisible due to a zero value in Cmpt:"
|
||||
<< "Cmpt = " << s
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return DiagTensor<Cmpt>(dt.xx()/s, dt.yy()/s, dt.zz()/s);
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Vector by a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator/(const Vector<Cmpt> v, const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(det(dt)) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Vector = " << v
|
||||
<< " is not divisible by the DiagTensor due to a zero element:"
|
||||
<< "DiagTensor = " << dt
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Vector<Cmpt>(v.x()/dt.xx(), v.y()/dt.yy(), v.z()/dt.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Return the trace of a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
return dt.xx() + dt.yy() + dt.zz();
|
||||
}
|
||||
|
||||
|
||||
//- Return the spherical part of a DiagTensor as a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> sph(const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
return SphericalTensor<Cmpt>
|
||||
(
|
||||
(1.0/3.0)*tr(dt)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the determinant of a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
return dt.xx()*dt.yy()*dt.zz();
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a DiagTensor as a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt> inv(const DiagTensor<Cmpt>& dt)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(det(dt)) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "DiagTensor is not invertible due to the zero determinant:"
|
||||
<< "det(DiagTensor) = " << det(dt)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return DiagTensor<Cmpt>(1/dt.xx(), 1/dt.yy(), 1/dt.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Return the diagonal of a Tensor as a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt> diag(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return DiagTensor<Cmpt>(t.xx(), t.yy(), t.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Return the diagonal of a SymmTensor as a DiagTensor
|
||||
template<class Cmpt>
|
||||
inline DiagTensor<Cmpt> diag(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return DiagTensor<Cmpt>(st.xx(), st.yy(), st.zz());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -91,8 +91,132 @@ Foam::SphericalTensor<Cmpt>::T() const
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the trace of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return 3*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the spherical part of a SphericalTensor, i.e. itself
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> sph(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
//- Return the determinant of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii()*st.ii()*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(st.ii()) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "SphericalTensor is not invertible due to the zero determinant:"
|
||||
<< "det(SphericalTensor) = " << det(st)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return SphericalTensor<Cmpt>(1/st.ii());
|
||||
}
|
||||
|
||||
|
||||
//- Return the square of Frobenius norm of a SphericalTensor as a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return Cmpt(3*mag(st.ii()*st.ii()));
|
||||
}
|
||||
|
||||
|
||||
//- Return the max component of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt cmptMax(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the min component of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt cmptMin(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the sum of components of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt cmptSum(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return 3*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the arithmetic average of components of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt cmptAv(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Division of a Cmpt by a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>
|
||||
operator/(const Cmpt s, const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(st.ii()) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cmpt = " << s
|
||||
<< " is not divisible due to a zero element in SphericalTensor:"
|
||||
<< "SphericalTensor = " << st
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return SphericalTensor<Cmpt>(s/st.ii());
|
||||
}
|
||||
|
||||
|
||||
//- Division of a SphericalTensor by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>
|
||||
operator/(const SphericalTensor<Cmpt>& st, const Cmpt s)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(s) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "SphericalTensor = " << st
|
||||
<< " is not divisible due to a zero value in Cmpt:"
|
||||
<< "Cmpt = " << s
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return SphericalTensor<Cmpt>(st.ii()/s);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SphericalTensor and a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>
|
||||
@ -139,128 +263,6 @@ operator&&(const SphericalTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Cmpt by a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>
|
||||
operator/(const Cmpt s, const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(st.ii()) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cmpt = " << s
|
||||
<< " is not divisible due to a zero element in SphericalTensor:"
|
||||
<< "SphericalTensor = " << st
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return SphericalTensor<Cmpt>(s/st.ii());
|
||||
}
|
||||
|
||||
|
||||
//- Division of a SphericalTensor by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>
|
||||
operator/(const SphericalTensor<Cmpt>& st, const Cmpt s)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(s) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "SphericalTensor = " << st
|
||||
<< " is not divisible due to a zero value in Cmpt:"
|
||||
<< "Cmpt = " << s
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return SphericalTensor<Cmpt>(st.ii()/s);
|
||||
}
|
||||
|
||||
|
||||
//- Return the square of Frobenius norm of a SphericalTensor as a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return Cmpt(3*mag(st.ii()*st.ii()));
|
||||
}
|
||||
|
||||
|
||||
//- Return the max component of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt cmptMax(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the min component of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt cmptMin(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the sum of components of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt cmptSum(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return 3*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the arithmetic average of components of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt cmptAv(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the trace of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return 3*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the spherical part of a SphericalTensor, i.e. itself
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> sph(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
//- Return the determinant of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii()*st.ii()*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(st.ii()) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "SphericalTensor is not invertible due to the zero determinant:"
|
||||
<< "det(SphericalTensor) = " << det(st)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return SphericalTensor<Cmpt>(1/st.ii());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
|
||||
@ -82,47 +82,52 @@ inline Cmpt& Foam::SphericalTensor2D<Cmpt>::ii()
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the trace of a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
return 2*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the spherical part of a SphericalTensor2D, i.e. itself
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt> sph(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
//- Return the determinant of a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st.ii()*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt> inv(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(st.ii()) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "SphericalTensor2D is not invertible due to zero determinant:"
|
||||
<< "det(SphericalTensor2D) = " << det(st)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return SphericalTensor2D<Cmpt>(1/st.ii());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Inner-product of a SphericalTensor2D and a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt>
|
||||
operator&
|
||||
(
|
||||
const SphericalTensor2D<Cmpt>& st1,
|
||||
const SphericalTensor2D<Cmpt>& st2
|
||||
)
|
||||
{
|
||||
return SphericalTensor2D<Cmpt>(st1.ii()*st2.ii());
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SphericalTensor2D and a Vector2D
|
||||
template<class Cmpt>
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const SphericalTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
st.ii()*v.x(),
|
||||
st.ii()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Vector2D and a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const Vector2D<Cmpt>& v, const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
v.x()*st.ii(),
|
||||
v.y()*st.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Cmpt by a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt>
|
||||
@ -163,45 +168,42 @@ operator/(const SphericalTensor2D<Cmpt>& st, const Cmpt s)
|
||||
}
|
||||
|
||||
|
||||
//- Return the trace of a SphericalTensor2D
|
||||
//- Inner-product of a SphericalTensor2D and a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const SphericalTensor2D<Cmpt>& st)
|
||||
inline SphericalTensor2D<Cmpt>
|
||||
operator&
|
||||
(
|
||||
const SphericalTensor2D<Cmpt>& st1,
|
||||
const SphericalTensor2D<Cmpt>& st2
|
||||
)
|
||||
{
|
||||
return 2*st.ii();
|
||||
return SphericalTensor2D<Cmpt>(st1.ii()*st2.ii());
|
||||
}
|
||||
|
||||
|
||||
//- Return the spherical part of a SphericalTensor2D, i.e. itself
|
||||
//- Inner-product of a SphericalTensor2D and a Vector2D
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt> sph(const SphericalTensor2D<Cmpt>& st)
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const SphericalTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return st;
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
st.ii()*v.x(),
|
||||
st.ii()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the determinant of a SphericalTensor2D
|
||||
//- Inner-product of a Vector2D and a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const SphericalTensor2D<Cmpt>& st)
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const Vector2D<Cmpt>& v, const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st.ii()*st.ii();
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt> inv(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(st.ii()) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "SphericalTensor2D is not invertible due to zero determinant:"
|
||||
<< "det(SphericalTensor2D) = " << det(st)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return SphericalTensor2D<Cmpt>(1/st.ii());
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
v.x()*st.ii(),
|
||||
v.y()*st.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -227,111 +227,7 @@ inline void Foam::SymmTensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st)
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the Hodge dual of a SymmTensor as a Vector
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> operator*(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return Vector<Cmpt>(st.yz(), -st.xz(), st.xy());
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
st1.xx()*st2.xx() + st1.xy()*st2.xy() + st1.xz()*st2.xz(),
|
||||
st1.xx()*st2.xy() + st1.xy()*st2.yy() + st1.xz()*st2.yz(),
|
||||
st1.xx()*st2.xz() + st1.xy()*st2.yz() + st1.xz()*st2.zz(),
|
||||
|
||||
st1.xy()*st2.xx() + st1.yy()*st2.xy() + st1.yz()*st2.xz(),
|
||||
st1.xy()*st2.xy() + st1.yy()*st2.yy() + st1.yz()*st2.yz(),
|
||||
st1.xy()*st2.xz() + st1.yy()*st2.yz() + st1.yz()*st2.zz(),
|
||||
|
||||
st1.xz()*st2.xx() + st1.yz()*st2.xy() + st1.zz()*st2.xz(),
|
||||
st1.xz()*st2.xy() + st1.yz()*st2.yy() + st1.zz()*st2.yz(),
|
||||
st1.xz()*st2.xz() + st1.yz()*st2.yz() + st1.zz()*st2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SymmTensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
return
|
||||
(
|
||||
st1.xx()*st2.xx() + 2*st1.xy()*st2.xy() + 2*st1.xz()*st2.xz()
|
||||
+ st1.yy()*st2.yy() + 2*st1.yz()*st2.yz()
|
||||
+ st1.zz()*st2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor and a Vector
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st, const Vector<Cmpt>& v)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
(
|
||||
st.xx()*v.x() + st.xy()*v.y() + st.xz()*v.z(),
|
||||
st.xy()*v.x() + st.yy()*v.y() + st.yz()*v.z(),
|
||||
st.xz()*v.x() + st.yz()*v.y() + st.zz()*v.z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Vector and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const Vector<Cmpt>& v, const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
(
|
||||
v.x()*st.xx() + v.y()*st.xy() + v.z()*st.xz(),
|
||||
v.x()*st.xy() + v.y()*st.yy() + v.z()*st.yz(),
|
||||
v.x()*st.xz() + v.y()*st.yz() + v.z()*st.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the inner-product of a SymmTensor with itself
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
innerSqr(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
(
|
||||
st.xx()*st.xx() + st.xy()*st.xy() + st.xz()*st.xz(),
|
||||
st.xx()*st.xy() + st.xy()*st.yy() + st.xz()*st.yz(),
|
||||
st.xx()*st.xz() + st.xy()*st.yz() + st.xz()*st.zz(),
|
||||
|
||||
st.xy()*st.xy() + st.yy()*st.yy() + st.yz()*st.yz(),
|
||||
st.xy()*st.xz() + st.yy()*st.yz() + st.yz()*st.zz(),
|
||||
|
||||
st.xz()*st.xz() + st.yz()*st.yz() + st.zz()*st.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the square of Frobenius norm of a SymmTensor as a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return Cmpt
|
||||
(
|
||||
mag(st.xx()*st.xx()) + 2*mag(st.xy()*st.xy()) + 2*mag(st.xz()*st.xz())
|
||||
+ mag(st.yy()*st.yy()) + 2*mag(st.yz()*st.yz())
|
||||
+ mag(st.zz()*st.zz())
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the trace of a SymmTensor
|
||||
template<class Cmpt>
|
||||
@ -469,6 +365,53 @@ inline Cmpt invariantIII(const SymmTensor<Cmpt>& st)
|
||||
}
|
||||
|
||||
|
||||
//- Return the inner-product of a SymmTensor with itself
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
innerSqr(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
(
|
||||
st.xx()*st.xx() + st.xy()*st.xy() + st.xz()*st.xz(),
|
||||
st.xx()*st.xy() + st.xy()*st.yy() + st.xz()*st.yz(),
|
||||
st.xx()*st.xz() + st.xy()*st.yz() + st.xz()*st.zz(),
|
||||
|
||||
st.xy()*st.xy() + st.yy()*st.yy() + st.yz()*st.yz(),
|
||||
st.xy()*st.xz() + st.yy()*st.yz() + st.yz()*st.zz(),
|
||||
|
||||
st.xz()*st.xz() + st.yz()*st.yz() + st.zz()*st.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the square of Frobenius norm of a SymmTensor as a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return Cmpt
|
||||
(
|
||||
mag(st.xx()*st.xx()) + 2*mag(st.xy()*st.xy()) + 2*mag(st.xz()*st.xz())
|
||||
+ mag(st.yy()*st.yy()) + 2*mag(st.yz()*st.yz())
|
||||
+ mag(st.zz()*st.zz())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the square of a Vector as a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> sqr(const Vector<Cmpt>& v)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
(
|
||||
v.x()*v.x(), v.x()*v.y(), v.x()*v.z(),
|
||||
v.y()*v.y(), v.y()*v.z(),
|
||||
v.z()*v.z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Sum of a SphericalTensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
@ -525,6 +468,50 @@ operator-(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
||||
}
|
||||
|
||||
|
||||
//- Return the Hodge dual of a SymmTensor as a Vector
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> operator*(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return Vector<Cmpt>(st.yz(), -st.xz(), st.xy());
|
||||
}
|
||||
|
||||
|
||||
//- Division of a SymmTensor by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator/(const SymmTensor<Cmpt>& st, const Cmpt s)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
(
|
||||
st.xx()/s, st.xy()/s, st.xz()/s,
|
||||
st.yy()/s, st.yz()/s,
|
||||
st.zz()/s
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
st1.xx()*st2.xx() + st1.xy()*st2.xy() + st1.xz()*st2.xz(),
|
||||
st1.xx()*st2.xy() + st1.xy()*st2.yy() + st1.xz()*st2.yz(),
|
||||
st1.xx()*st2.xz() + st1.xy()*st2.yz() + st1.xz()*st2.zz(),
|
||||
|
||||
st1.xy()*st2.xx() + st1.yy()*st2.xy() + st1.yz()*st2.xz(),
|
||||
st1.xy()*st2.xy() + st1.yy()*st2.yy() + st1.yz()*st2.yz(),
|
||||
st1.xy()*st2.xz() + st1.yy()*st2.yz() + st1.yz()*st2.zz(),
|
||||
|
||||
st1.xz()*st2.xx() + st1.yz()*st2.xy() + st1.zz()*st2.xz(),
|
||||
st1.xz()*st2.xy() + st1.yz()*st2.yy() + st1.zz()*st2.yz(),
|
||||
st1.xz()*st2.xz() + st1.yz()*st2.yz() + st1.zz()*st2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SphericalTensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
@ -553,6 +540,48 @@ operator&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor and a Vector
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st, const Vector<Cmpt>& v)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
(
|
||||
st.xx()*v.x() + st.xy()*v.y() + st.xz()*v.z(),
|
||||
st.xy()*v.x() + st.yy()*v.y() + st.yz()*v.z(),
|
||||
st.xz()*v.x() + st.yz()*v.y() + st.zz()*v.z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Vector and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const Vector<Cmpt>& v, const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
(
|
||||
v.x()*st.xx() + v.y()*st.xy() + v.z()*st.xz(),
|
||||
v.x()*st.xy() + v.y()*st.yy() + v.z()*st.yz(),
|
||||
v.x()*st.xz() + v.y()*st.yz() + v.z()*st.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SymmTensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
return
|
||||
(
|
||||
st1.xx()*st2.xx() + 2*st1.xy()*st2.xy() + 2*st1.xz()*st2.xz()
|
||||
+ st1.yy()*st2.yy() + 2*st1.yz()*st2.yz()
|
||||
+ st1.zz()*st2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SphericalTensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
@ -571,33 +600,6 @@ operator&&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
||||
}
|
||||
|
||||
|
||||
//- Return the square of a Vector as a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> sqr(const Vector<Cmpt>& v)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
(
|
||||
v.x()*v.x(), v.x()*v.y(), v.x()*v.z(),
|
||||
v.y()*v.y(), v.y()*v.z(),
|
||||
v.z()*v.z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Division of a SymmTensor by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator/(const SymmTensor<Cmpt>& st, const Cmpt s)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
(
|
||||
st.xx()/s, st.xy()/s, st.xz()/s,
|
||||
st.yy()/s, st.yz()/s,
|
||||
st.zz()/s
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
|
||||
@ -165,88 +165,7 @@ inline void Foam::SymmTensor2D<Cmpt>::operator=
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Inner-product of a SymmTensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx()*st2.xx() + st1.xy()*st2.xy(),
|
||||
st1.xx()*st2.xy() + st1.xy()*st2.yy(),
|
||||
|
||||
st1.xy()*st2.xx() + st1.yy()*st2.xy(),
|
||||
st1.xy()*st2.xy() + st1.yy()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SymmTensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor2D<Cmpt>& st1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return
|
||||
(
|
||||
st1.xx()*st2.xx() + 2*st1.xy()*st2.xy()
|
||||
+ st1.yy()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor2D and a Vector2D
|
||||
template<class Cmpt>
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
st.xx()*v.x() + st.xy()*v.y(),
|
||||
st.xy()*v.x() + st.yy()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Vector2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const Vector2D<Cmpt>& v, const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
v.x()*st.xx() + v.y()*st.xy(),
|
||||
v.x()*st.xy() + v.y()*st.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the inner-product of a SymmTensor2D with itself
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
innerSqr(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st.xx()*st.xx() + st.xy()*st.xy(),
|
||||
st.xx()*st.xy() + st.xy()*st.yy(),
|
||||
st.xy()*st.xy() + st.yy()*st.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the square of Frobenius norm of a SymmTensor2D as a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return Cmpt
|
||||
(
|
||||
mag(st.xx()*st.xx()) + 2*mag(st.xy()*st.xy())
|
||||
+ mag(st.yy()*st.yy())
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the trace of a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
@ -361,6 +280,46 @@ inline Cmpt invariantII(const SymmTensor2D<Cmpt>& st)
|
||||
}
|
||||
|
||||
|
||||
//- Return the inner-product of a SymmTensor2D with itself
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
innerSqr(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st.xx()*st.xx() + st.xy()*st.xy(),
|
||||
st.xx()*st.xy() + st.xy()*st.yy(),
|
||||
st.xy()*st.xy() + st.yy()*st.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the square of Frobenius norm of a SymmTensor2D as a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return Cmpt
|
||||
(
|
||||
mag(st.xx()*st.xx()) + 2*mag(st.xy()*st.xy())
|
||||
+ mag(st.yy()*st.yy())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Outer-product of a Vector2D with itself
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> sqr(const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
v.x()*v.x(), v.x()*v.y(),
|
||||
v.y()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Sum of a SphericalTensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
@ -413,6 +372,35 @@ operator-(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
}
|
||||
|
||||
|
||||
//- Division of a SymmTensor2D by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator/(const SymmTensor2D<Cmpt>& st, const Cmpt s)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st.xx()/s, st.xy()/s,
|
||||
st.yy()/s
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx()*st2.xx() + st1.xy()*st2.xy(),
|
||||
st1.xx()*st2.xy() + st1.xy()*st2.yy(),
|
||||
|
||||
st1.xy()*st2.xx() + st1.yy()*st2.xy(),
|
||||
st1.xy()*st2.xy() + st1.yy()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SphericalTensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
@ -439,6 +427,45 @@ operator&(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor2D and a Vector2D
|
||||
template<class Cmpt>
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
st.xx()*v.x() + st.xy()*v.y(),
|
||||
st.xy()*v.x() + st.yy()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Vector2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const Vector2D<Cmpt>& v, const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
v.x()*st.xx() + v.y()*st.xy(),
|
||||
v.x()*st.xy() + v.y()*st.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SymmTensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor2D<Cmpt>& st1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return
|
||||
(
|
||||
st1.xx()*st2.xx() + 2*st1.xy()*st2.xy()
|
||||
+ st1.yy()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SphericalTensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
@ -457,31 +484,6 @@ operator&&(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
}
|
||||
|
||||
|
||||
//- Outer-product of a Vector2D with itself
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> sqr(const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
v.x()*v.x(), v.x()*v.y(),
|
||||
v.y()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Division of a SymmTensor2D by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator/(const SymmTensor2D<Cmpt>& st, const Cmpt s)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st.xx()/s, st.xy()/s,
|
||||
st.yy()/s
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
|
||||
@ -610,114 +610,6 @@ inline void Foam::Tensor<Cmpt>::operator=(const Vector<Vector<Cmpt>>& tr)
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the Hodge dual of a Tensor as a Vector
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> operator*(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return Vector<Cmpt>(t.yz(), -t.xz(), t.xy());
|
||||
}
|
||||
|
||||
|
||||
//- Return the Hodge dual of a Vector as a Tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> operator*(const Vector<Cmpt>& v)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
Zero, -v.z(), v.y(),
|
||||
v.z(), Zero, -v.x(),
|
||||
-v.y(), v.x(), Zero
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Tensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor<Cmpt>, Tensor<Cmpt>>::type
|
||||
operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
return t1.inner(t2);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Tensor and a Vector
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
|
||||
operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
(
|
||||
t.xx()*v.x() + t.xy()*v.y() + t.xz()*v.z(),
|
||||
t.yx()*v.x() + t.yy()*v.y() + t.yz()*v.z(),
|
||||
t.zx()*v.x() + t.zy()*v.y() + t.zz()*v.z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Vector and a Tensor
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
|
||||
operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
(
|
||||
v.x()*t.xx() + v.y()*t.yx() + v.z()*t.zx(),
|
||||
v.x()*t.xy() + v.y()*t.yy() + v.z()*t.zy(),
|
||||
v.x()*t.xz() + v.y()*t.yz() + v.z()*t.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Outer-product of a Vector and a Vector
|
||||
template<class Cmpt>
|
||||
inline typename outerProduct<Vector<Cmpt>, Vector<Cmpt>>::type
|
||||
operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
|
||||
v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
|
||||
v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Vector by a Tensor
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
|
||||
operator/(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
||||
{
|
||||
return inv(t) & v;
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Tensor by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator/(const Tensor<Cmpt>& t, const Cmpt s)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(s) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Tensor = " << t
|
||||
<< " is not divisible due to a zero value in Cmpt:"
|
||||
<< "Cmpt = " << s
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
t.xx()/s, t.xy()/s, t.xz()/s,
|
||||
t.yx()/s, t.yy()/s, t.yz()/s,
|
||||
t.zx()/s, t.zy()/s, t.zz()/s
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the trace of a Tensor
|
||||
@ -898,7 +790,7 @@ inline Cmpt invariantIII(const Tensor<Cmpt>& t)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * Mixed Tensor SphericalTensor Operators * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Sum of a SphericalTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
@ -928,6 +820,34 @@ operator+(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Sum of a SymmTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator+(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
st1.xx() + t2.xx(), st1.xy() + t2.xy(), st1.xz() + t2.xz(),
|
||||
st1.xy() + t2.yx(), st1.yy() + t2.yy(), st1.yz() + t2.yz(),
|
||||
st1.xz() + t2.zx(), st1.yz() + t2.zy(), st1.zz() + t2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Sum of a Tensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator+(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
t1.xx() + st2.xx(), t1.xy() + st2.xy(), t1.xz() + st2.xz(),
|
||||
t1.yx() + st2.xy(), t1.yy() + st2.yy(), t1.yz() + st2.yz(),
|
||||
t1.zx() + st2.xz(), t1.zy() + st2.yz(), t1.zz() + st2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Subtract a Tensor from a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
@ -956,118 +876,6 @@ operator-(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SphericalTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
|
||||
st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
|
||||
st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Tensor and a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
|
||||
t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
|
||||
t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SphericalTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
return (st1.ii()*t2.xx() + st1.ii()*t2.yy() + st1.ii()*t2.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a Tensor and a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
return (t1.xx()*st2.ii() + t1.yy()*st2.ii() + t1.zz()*st2.ii());
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt>>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt>>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SphericalTensor<Cmpt>, Tensor<Cmpt>>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<Tensor<Cmpt>, SphericalTensor<Cmpt>>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * Mixed Tensor SymmTensor Operators * * * * * * * * * * //
|
||||
|
||||
//- Sum of a SymmTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator+(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
st1.xx() + t2.xx(), st1.xy() + t2.xy(), st1.xz() + t2.xz(),
|
||||
st1.xy() + t2.yx(), st1.yy() + t2.yy(), st1.yz() + t2.yz(),
|
||||
st1.xz() + t2.zx(), st1.yz() + t2.zy(), st1.zz() + t2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Sum of a Tensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator+(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
t1.xx() + st2.xx(), t1.xy() + st2.xy(), t1.xz() + st2.xz(),
|
||||
t1.yx() + st2.xy(), t1.yy() + st2.yy(), t1.yz() + st2.yz(),
|
||||
t1.zx() + st2.xz(), t1.zy() + st2.yz(), t1.zz() + st2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Subtract a Tensor from a SymmTensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
@ -1096,6 +904,98 @@ operator-(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Return the Hodge dual of a Tensor as a Vector
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> operator*(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return Vector<Cmpt>(t.yz(), -t.xz(), t.xy());
|
||||
}
|
||||
|
||||
|
||||
//- Return the Hodge dual of a Vector as a Tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> operator*(const Vector<Cmpt>& v)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
Zero, -v.z(), v.y(),
|
||||
v.z(), Zero, -v.x(),
|
||||
-v.y(), v.x(), Zero
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Vector by a Tensor
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
|
||||
operator/(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
||||
{
|
||||
return inv(t) & v;
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Tensor by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator/(const Tensor<Cmpt>& t, const Cmpt s)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(s) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Tensor = " << t
|
||||
<< " is not divisible due to a zero value in Cmpt:"
|
||||
<< "Cmpt = " << s
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
t.xx()/s, t.xy()/s, t.xz()/s,
|
||||
t.yx()/s, t.yy()/s, t.yz()/s,
|
||||
t.zx()/s, t.zy()/s, t.zz()/s
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Tensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor<Cmpt>, Tensor<Cmpt>>::type
|
||||
operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
return t1.inner(t2);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SphericalTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
|
||||
st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
|
||||
st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Tensor and a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
|
||||
t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
|
||||
t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
@ -1140,6 +1040,52 @@ operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Tensor and a Vector
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
|
||||
operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
(
|
||||
t.xx()*v.x() + t.xy()*v.y() + t.xz()*v.z(),
|
||||
t.yx()*v.x() + t.yy()*v.y() + t.yz()*v.z(),
|
||||
t.zx()*v.x() + t.zy()*v.y() + t.zz()*v.z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Vector and a Tensor
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
|
||||
operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
(
|
||||
v.x()*t.xx() + v.y()*t.yx() + v.z()*t.zx(),
|
||||
v.x()*t.xy() + v.y()*t.yy() + v.z()*t.zy(),
|
||||
v.x()*t.xz() + v.y()*t.yz() + v.z()*t.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SphericalTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
return (st1.ii()*t2.xx() + st1.ii()*t2.yy() + st1.ii()*t2.zz());
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a Tensor and a SphericalTensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
return (t1.xx()*st2.ii() + t1.yy()*st2.ii() + t1.zz()*st2.ii());
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SymmTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
@ -1168,6 +1114,58 @@ operator&&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Outer-product of a Vector and a Vector
|
||||
template<class Cmpt>
|
||||
inline typename outerProduct<Vector<Cmpt>, Vector<Cmpt>>::type
|
||||
operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
|
||||
v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
|
||||
v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt>>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt>>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SphericalTensor<Cmpt>, Tensor<Cmpt>>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<Tensor<Cmpt>, SphericalTensor<Cmpt>>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt>>
|
||||
{
|
||||
|
||||
@ -405,53 +405,7 @@ inline void Foam::Tensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st)
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Inner-product of a Tensor2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor2D<Cmpt>, Tensor2D<Cmpt>>::type
|
||||
operator&(const Tensor2D<Cmpt>& t1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return t1.inner(t2);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Tensor2D and a Vector2D
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor2D<Cmpt>, Vector2D<Cmpt>>::type
|
||||
operator&(const Tensor2D<Cmpt>& t, const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
t.xx()*v.x() + t.xy()*v.y(),
|
||||
t.yx()*v.x() + t.yy()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
//- Inner-product of a Vector2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector2D<Cmpt>, Tensor2D<Cmpt>>::type
|
||||
operator&(const Vector2D<Cmpt>& v, const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
v.x()*t.xx() + v.y()*t.yx(),
|
||||
v.x()*t.xy() + v.y()*t.yy()
|
||||
);
|
||||
}
|
||||
|
||||
//- Outer-product of a Vector2D and a Vector2D
|
||||
template<class Cmpt>
|
||||
inline typename outerProduct<Vector2D<Cmpt>, Vector2D<Cmpt>>::type
|
||||
operator*(const Vector2D<Cmpt>& v1, const Vector2D<Cmpt>& v2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
v1.x()*v2.x(), v1.x()*v2.y(),
|
||||
v1.y()*v2.x(), v1.y()*v2.y()
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the trace of a Tensor2D
|
||||
template<class Cmpt>
|
||||
@ -586,7 +540,7 @@ inline Cmpt invariantII(const Tensor2D<Cmpt>& t)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * Mixed Tensor SphericalTensor Operators * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Sum of a SphericalTensor2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
@ -614,6 +568,32 @@ operator+(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Sum of a SymmTensor2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator+(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() + t2.xx(), st1.xy() + t2.xy(),
|
||||
st1.xy() + t2.yx(), st1.yy() + t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Sum of a Tensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator+(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t1.xx() + st2.xx(), t1.xy() + st2.xy(),
|
||||
t1.yx() + st2.xy(), t1.yy() + st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Subtract a Tensor2D from a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
@ -640,6 +620,65 @@ operator-(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Subtract a Tensor2D from a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator-(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() - t2.xx(), st1.xy() - t2.xy(),
|
||||
st1.xy() - t2.yx(), st1.yy() - t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Subtract a SymmTensor2D from a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator-(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t1.xx() - st2.xx(), t1.xy() - st2.xy(),
|
||||
t1.yx() - st2.xy(), t1.yy() - st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Tensor2D by a Cmpt
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator/(const Tensor2D<Cmpt>& t, const Cmpt s)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(s) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Tensor2D = " << t
|
||||
<< " is not divisible due to a zero value in Cmpt:"
|
||||
<< "Cmpt = " << s
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t.xx()/s, t.xy()/s,
|
||||
t.yx()/s, t.yy()/s
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Tensor2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor2D<Cmpt>, Tensor2D<Cmpt>>::type
|
||||
operator&(const Tensor2D<Cmpt>& t1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return t1.inner(t2);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SphericalTensor2D and Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
@ -671,78 +710,6 @@ operator&(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SphericalTensor2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return (st1.ii()*t2.xx() + st1.ii()*t2.yy());
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a Tensor2D and a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return (t1.xx()*st2.ii() + t1.yy()*st2.ii());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * Mixed Tensor SymmTensor Operators * * * * * * * * * * //
|
||||
|
||||
//- Sum of a SymmTensor2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator+(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() + t2.xx(), st1.xy() + t2.xy(),
|
||||
st1.xy() + t2.yx(), st1.yy() + t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Sum of a Tensor2D and a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator+(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t1.xx() + st2.xx(), t1.xy() + st2.xy(),
|
||||
t1.yx() + st2.xy(), t1.yy() + st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Subtract a Tensor2D from a SymmTensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator-(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() - t2.xx(), st1.xy() - t2.xy(),
|
||||
st1.xy() - t2.yx(), st1.yy() - t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Subtract a SymmTensor2D from a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator-(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t1.xx() - st2.xx(), t1.xy() - st2.xy(),
|
||||
t1.yx() - st2.xy(), t1.yy() - st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a SymmTensor2D and Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
@ -775,6 +742,51 @@ operator&(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//- Inner-product of a Tensor2D and a Vector2D
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor2D<Cmpt>, Vector2D<Cmpt>>::type
|
||||
operator&(const Tensor2D<Cmpt>& t, const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
t.xx()*v.x() + t.xy()*v.y(),
|
||||
t.yx()*v.x() + t.yy()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product of a Vector2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector2D<Cmpt>, Tensor2D<Cmpt>>::type
|
||||
operator&(const Vector2D<Cmpt>& v, const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
v.x()*t.xx() + v.y()*t.yx(),
|
||||
v.x()*t.xy() + v.y()*t.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SphericalTensor2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return (st1.ii()*t2.xx() + st1.ii()*t2.yy());
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a Tensor2D and a SphericalTensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return (t1.xx()*st2.ii() + t1.yy()*st2.ii());
|
||||
}
|
||||
|
||||
|
||||
//- Double-inner-product of a SymmTensor2D and a Tensor2D
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
@ -801,26 +813,15 @@ operator&&(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
//- Division of a Tensor2D by a Cmpt
|
||||
//- Outer-product of a Vector2D and a Vector2D
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator/(const Tensor2D<Cmpt>& t, const Cmpt s)
|
||||
inline typename outerProduct<Vector2D<Cmpt>, Vector2D<Cmpt>>::type
|
||||
operator*(const Vector2D<Cmpt>& v1, const Vector2D<Cmpt>& v2)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
if (mag(s) < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Tensor2D = " << t
|
||||
<< " is not divisible due to a zero value in Cmpt:"
|
||||
<< "Cmpt = " << s
|
||||
<< abort(FatalError);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t.xx()/s, t.xy()/s,
|
||||
t.yx()/s, t.yy()/s
|
||||
v1.x()*v2.x(), v1.x()*v2.y(),
|
||||
v1.y()*v2.x(), v1.y()*v2.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user