Backport some Tensor classes (T() function in particular) from vanilla 3.0.1
This commit is contained in:
parent
da99a39109
commit
7c0b9aee42
29 changed files with 1249 additions and 247 deletions
|
@ -51,6 +51,7 @@ primitives/Vector/vector/vector.C
|
|||
|
||||
primitives/Tensor2D/tensor2D/tensor2D.C
|
||||
primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C
|
||||
primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C
|
||||
primitives/Vector2D/vector2D/vector2D.C
|
||||
|
||||
primitives/complex/complex.C
|
||||
|
|
|
@ -58,6 +58,17 @@ dimensionedSymmTensor sqr(const dimensionedVector& dv)
|
|||
}
|
||||
|
||||
|
||||
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor& dt)
|
||||
{
|
||||
return dimensionedSymmTensor
|
||||
(
|
||||
"innerSqr("+dt.name()+')',
|
||||
sqr(dt.dimensions()),
|
||||
innerSqr(dt.value())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
dimensionedScalar tr(const dimensionedSymmTensor& dt)
|
||||
{
|
||||
return dimensionedScalar
|
||||
|
@ -129,7 +140,7 @@ dimensionedSymmTensor cof(const dimensionedSymmTensor& dt)
|
|||
return dimensionedSymmTensor
|
||||
(
|
||||
"cof("+dt.name()+')',
|
||||
dt.dimensions(),
|
||||
pow(dt.dimensions(), symmTensor::dim - 1),
|
||||
cof(dt.value())
|
||||
);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ typedef dimensioned<symmTensor> dimensionedSymmTensor;
|
|||
// global functions
|
||||
|
||||
dimensionedSymmTensor sqr(const dimensionedVector&);
|
||||
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor&);
|
||||
|
||||
dimensionedScalar tr(const dimensionedSymmTensor&);
|
||||
dimensionedSymmTensor symm(const dimensionedSymmTensor&);
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Foam
|
|||
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(symmTensor, vector, sqr)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr)
|
||||
|
||||
UNARY_FUNCTION(scalar, symmTensor, tr)
|
||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
||||
|
@ -56,6 +57,9 @@ UNARY_FUNCTION(symmTensor, symmTensor, hinv)
|
|||
|
||||
UNARY_OPERATOR(vector, symmTensor, *, hdual)
|
||||
|
||||
BINARY_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
|
||||
BINARY_TYPE_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace Foam
|
|||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(symmTensor, vector, sqr)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr)
|
||||
|
||||
UNARY_FUNCTION(scalar, symmTensor, tr)
|
||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
||||
|
@ -66,6 +67,9 @@ UNARY_FUNCTION(symmTensor, symmTensor, hinv)
|
|||
|
||||
UNARY_OPERATOR(vector, symmTensor, *, hdual)
|
||||
|
||||
BINARY_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
|
||||
BINARY_TYPE_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace Foam
|
|||
// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(symmTensor, vector, sqr)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr)
|
||||
|
||||
UNARY_FUNCTION(scalar, symmTensor, tr)
|
||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
||||
|
@ -171,6 +172,9 @@ tmp<Field<symmTensor> > transformFieldMask<symmTensor>
|
|||
|
||||
UNARY_OPERATOR(vector, symmTensor, *, hdual)
|
||||
|
||||
BINARY_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
|
||||
BINARY_TYPE_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ SourceFiles
|
|||
#include "vectorField.H"
|
||||
#include "sphericalTensor.H"
|
||||
#include "symmTensor.H"
|
||||
#include "tensor.H"
|
||||
|
||||
#define TEMPLATE
|
||||
#include "FieldFunctionsM.H"
|
||||
|
@ -53,6 +54,7 @@ typedef Field<symmTensor> symmTensorField;
|
|||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(symmTensor, vector, sqr)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr)
|
||||
|
||||
UNARY_FUNCTION(scalar, symmTensor, tr)
|
||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
||||
|
@ -70,6 +72,9 @@ UNARY_FUNCTION(symmTensor, symmTensor, hinv)
|
|||
|
||||
UNARY_OPERATOR(vector, symmTensor, *, hdual)
|
||||
|
||||
BINARY_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
|
||||
BINARY_TYPE_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace Foam
|
|||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(symmTensor, vector, sqr, sqr)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr, sqr)
|
||||
|
||||
UNARY_FUNCTION(scalar, symmTensor, tr, transform)
|
||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
||||
|
@ -44,8 +45,8 @@ UNARY_FUNCTION(symmTensor, symmTensor, symm, transform)
|
|||
UNARY_FUNCTION(symmTensor, symmTensor, twoSymm, transform)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, dev, transform)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, dev2, transform)
|
||||
UNARY_FUNCTION(scalar, symmTensor, det, transform)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, cof, cof)
|
||||
UNARY_FUNCTION(scalar, symmTensor, det, pow3)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, cof, pow2)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, inv, inv)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, hinv, hinv)
|
||||
|
||||
|
@ -54,6 +55,9 @@ UNARY_FUNCTION(symmTensor, symmTensor, hinv, hinv)
|
|||
|
||||
UNARY_OPERATOR(vector, symmTensor, *, hdual, transform)
|
||||
|
||||
BINARY_OPERATOR(tensor, symmTensor, symmTensor, &, '&', dot)
|
||||
BINARY_TYPE_OPERATOR(tensor, symmTensor, symmTensor, &, '&', dot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ namespace Foam
|
|||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(symmTensor, vector, sqr, transform)
|
||||
UNARY_FUNCTION(symmTensor, vector, sqr, sqr)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr, sqr)
|
||||
|
||||
UNARY_FUNCTION(scalar, symmTensor, tr, transform)
|
||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
||||
|
@ -66,6 +67,10 @@ UNARY_FUNCTION(symmTensor, symmTensor, hinv, hinv)
|
|||
|
||||
UNARY_OPERATOR(vector, symmTensor, *, hdual, transform)
|
||||
|
||||
BINARY_OPERATOR(tensor, symmTensor, symmTensor, &, '&', dot)
|
||||
BINARY_TYPE_OPERATOR(tensor, symmTensor, symmTensor, &, '&', dot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace Foam
|
|||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(tensor, tensor, T, transform)
|
||||
UNARY_FUNCTION(scalar, tensor, tr, transform)
|
||||
UNARY_FUNCTION(sphericalTensor, tensor, sph, transform)
|
||||
UNARY_FUNCTION(symmTensor, tensor, symm, transform)
|
||||
|
@ -43,15 +44,15 @@ UNARY_FUNCTION(symmTensor, tensor, twoSymm, transform)
|
|||
UNARY_FUNCTION(tensor, tensor, skew, transform)
|
||||
UNARY_FUNCTION(tensor, tensor, dev, transform)
|
||||
UNARY_FUNCTION(tensor, tensor, dev2, transform)
|
||||
UNARY_FUNCTION(scalar, tensor, det, transform)
|
||||
UNARY_FUNCTION(tensor, tensor, cof, cof)
|
||||
UNARY_FUNCTION(scalar, tensor, det, pow3)
|
||||
UNARY_FUNCTION(tensor, tensor, cof, pow2)
|
||||
UNARY_FUNCTION(tensor, tensor, inv, inv)
|
||||
UNARY_FUNCTION(tensor, tensor, hinv, hinv)
|
||||
UNARY_FUNCTION(vector, tensor, eigenValues, sign)
|
||||
UNARY_FUNCTION(tensor, tensor, eigenVectors, transform)
|
||||
|
||||
UNARY_FUNCTION(vector, symmTensor, eigenValues, sign)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, transform)
|
||||
UNARY_FUNCTION(vector, tensor, eigenValues, transform)
|
||||
UNARY_FUNCTION(tensor, tensor, eigenVectors, sign)
|
||||
UNARY_FUNCTION(vector, symmTensor, eigenValues, transform)
|
||||
UNARY_FUNCTION(symmTensor, symmTensor, eigenVectors, sign)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace Foam
|
|||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(tensor, tensor, T, transform)
|
||||
UNARY_FUNCTION(scalar, tensor, tr, transform)
|
||||
UNARY_FUNCTION(sphericalTensor, tensor, sph, transform)
|
||||
UNARY_FUNCTION(symmTensor, tensor, symm, transform)
|
||||
|
|
|
@ -34,7 +34,7 @@ License
|
|||
#define TensorN_FieldFunctions(tensorType, diagTensorType, sphericalTensorType, \
|
||||
vectorType, CmptType, args...) \
|
||||
\
|
||||
UNARY_FUNCTION(tensorType, tensorType,inv,inv) \
|
||||
UNARY_FUNCTION(tensorType, tensorType, T, transform) \
|
||||
UNARY_FUNCTION(diagTensorType, tensorType,diag,diag) \
|
||||
UNARY_FUNCTION(tensorType, tensorType,negSumDiag,negSumDiag) \
|
||||
UNARY_FUNCTION(CmptType, tensorType,contractScalar,contractScalar) \
|
||||
|
|
|
@ -47,6 +47,7 @@ SourceFiles
|
|||
#define TensorN_FieldFunctions(tensorType, diagTensorType, sphericalTensorType, \
|
||||
vectorType, CmptType, args...) \
|
||||
\
|
||||
UNARY_FUNCTION(tensorType, tensorType,T,transform) \
|
||||
UNARY_FUNCTION(tensorType, tensorType,inv,inv) \
|
||||
UNARY_FUNCTION(diagTensorType, tensorType,diag,diag) \
|
||||
UNARY_FUNCTION(tensorType, tensorType,negSumDiag,negSumDiag) \
|
||||
|
|
|
@ -33,13 +33,13 @@ namespace Foam
|
|||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct null
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>::SphericalTensor()
|
||||
{}
|
||||
|
||||
|
||||
// Construct given VectorSpace
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>::SphericalTensor
|
||||
(
|
||||
const VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>& vs
|
||||
|
@ -50,7 +50,7 @@ inline SphericalTensor<Cmpt>::SphericalTensor
|
|||
|
||||
|
||||
// Construct given three Cmpts
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>::SphericalTensor(const Cmpt& stii)
|
||||
{
|
||||
this->v_[II] = stii;
|
||||
|
@ -58,7 +58,7 @@ inline SphericalTensor<Cmpt>::SphericalTensor(const Cmpt& stii)
|
|||
|
||||
|
||||
// Construct from Istream
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
|
||||
:
|
||||
VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(is)
|
||||
|
@ -67,21 +67,21 @@ inline SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SphericalTensor<Cmpt>::ii() const
|
||||
{
|
||||
return this->v_[II];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SphericalTensor<Cmpt>::ii()
|
||||
{
|
||||
return this->v_[II];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const SphericalTensor<Cmpt>& SphericalTensor<Cmpt>::T() const
|
||||
{
|
||||
return *this;
|
||||
|
@ -91,7 +91,7 @@ inline const SphericalTensor<Cmpt>& SphericalTensor<Cmpt>::T() const
|
|||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Inner-product between two spherical tensors
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>
|
||||
operator&(const SphericalTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ operator&(const SphericalTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Inner-product between a spherical tensor and a vector
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const SphericalTensor<Cmpt>& st, const Vector<Cmpt>& v)
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ operator&(const SphericalTensor<Cmpt>& st, const Vector<Cmpt>& v)
|
|||
|
||||
|
||||
//- Inner-product between a vector and a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const Vector<Cmpt>& v, const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ operator&(const Vector<Cmpt>& v, const SphericalTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Double-dot-product between a spherical tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ operator&&(const SphericalTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Division of a scalar by a sphericalTensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt>
|
||||
operator/(const scalar s, const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ operator/(const scalar s, const SphericalTensor<Cmpt>& st)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return 3*magSqr(st.ii());
|
||||
|
@ -153,7 +153,7 @@ inline Cmpt magSqr(const SphericalTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the trace of a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return 3*st.ii();
|
||||
|
@ -161,7 +161,7 @@ inline Cmpt tr(const SphericalTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the spherical part of a spherical tensor, i.e. itself
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> sph(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st;
|
||||
|
@ -169,7 +169,7 @@ inline SphericalTensor<Cmpt> sph(const SphericalTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the determinant of a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return st.ii()*st.ii()*st.ii();
|
||||
|
@ -177,7 +177,7 @@ inline Cmpt det(const SphericalTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the inverse of a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
return SphericalTensor<Cmpt>(1.0/st.ii());
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Foam
|
|||
Class SymmTensor Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
class SymmTensor
|
||||
:
|
||||
public VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>
|
||||
|
@ -79,6 +79,7 @@ public:
|
|||
static const SymmTensor one;
|
||||
static const SymmTensor max;
|
||||
static const SymmTensor min;
|
||||
static const SymmTensor I;
|
||||
|
||||
|
||||
//- Component labeling enumeration
|
||||
|
|
|
@ -33,12 +33,12 @@ namespace Foam
|
|||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>::SymmTensor()
|
||||
{}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>::SymmTensor
|
||||
(
|
||||
const VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>& vs
|
||||
|
@ -48,7 +48,7 @@ inline SymmTensor<Cmpt>::SymmTensor
|
|||
{}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>::SymmTensor(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
|
||||
|
@ -57,7 +57,7 @@ inline SymmTensor<Cmpt>::SymmTensor(const SphericalTensor<Cmpt>& st)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>::SymmTensor
|
||||
(
|
||||
const Cmpt txx, const Cmpt txy, const Cmpt txz,
|
||||
|
@ -71,7 +71,7 @@ inline SymmTensor<Cmpt>::SymmTensor
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>::SymmTensor(Istream& is)
|
||||
:
|
||||
VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>(is)
|
||||
|
@ -80,81 +80,81 @@ inline SymmTensor<Cmpt>::SymmTensor(Istream& is)
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor<Cmpt>::xx() const
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor<Cmpt>::xy() const
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor<Cmpt>::xz() const
|
||||
{
|
||||
return this->v_[XZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor<Cmpt>::yy() const
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor<Cmpt>::yz() const
|
||||
{
|
||||
return this->v_[YZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor<Cmpt>::zz() const
|
||||
{
|
||||
return this->v_[ZZ];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor<Cmpt>::xx()
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor<Cmpt>::xy()
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor<Cmpt>::xz()
|
||||
{
|
||||
return this->v_[XZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor<Cmpt>::yy()
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor<Cmpt>::yz()
|
||||
{
|
||||
return this->v_[YZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor<Cmpt>::zz()
|
||||
{
|
||||
return this->v_[ZZ];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const SymmTensor<Cmpt>& SymmTensor<Cmpt>::T() const
|
||||
{
|
||||
return *this;
|
||||
|
@ -163,7 +163,7 @@ inline const SymmTensor<Cmpt>& SymmTensor<Cmpt>::T() const
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline void SymmTensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
|
||||
|
@ -176,7 +176,7 @@ inline void SymmTensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st)
|
|||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Hodge Dual operator (tensor -> vector)
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> operator*(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return Vector<Cmpt>(st.yz(), -st.xz(), st.xy());
|
||||
|
@ -184,7 +184,7 @@ inline Vector<Cmpt> operator*(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Inner-product between two symmetric tensors
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ operator&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Double-dot-product between a symmetric tensor and a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -220,7 +220,7 @@ operator&&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Inner-product between a symmetric tensor and a vector
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st, const Vector<Cmpt>& v)
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ operator&(const SymmTensor<Cmpt>& st, const Vector<Cmpt>& v)
|
|||
|
||||
|
||||
//- Inner-product between a vector and a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const Vector<Cmpt>& v, const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
|
@ -247,7 +247,26 @@ operator&(const Vector<Cmpt>& v, const SymmTensor<Cmpt>& st)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
//- Inner-sqr of a symmetric tensor
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
|
@ -260,7 +279,7 @@ inline Cmpt magSqr(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the trace of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return st.xx() + st.yy() + st.zz();
|
||||
|
@ -268,7 +287,7 @@ inline Cmpt tr(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the spherical part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> sph(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return (1.0/3.0)*tr(st);
|
||||
|
@ -276,7 +295,7 @@ inline SphericalTensor<Cmpt> sph(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the symmetric part of a symmetric tensor, i.e. itself
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const SymmTensor<Cmpt>& symm(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return st;
|
||||
|
@ -284,7 +303,7 @@ inline const SymmTensor<Cmpt>& symm(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return twice the symmetric part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> twoSymm(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return 2*st;
|
||||
|
@ -292,7 +311,7 @@ inline SymmTensor<Cmpt> twoSymm(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the deviatoric part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> dev(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return st - SphericalTensor<Cmpt>::oneThirdI*tr(st);
|
||||
|
@ -300,7 +319,7 @@ inline SymmTensor<Cmpt> dev(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the deviatoric part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> dev2(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return st - SphericalTensor<Cmpt>::twoThirdsI*tr(st);
|
||||
|
@ -308,7 +327,7 @@ inline SymmTensor<Cmpt> dev2(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the determinant of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
|
@ -321,7 +340,7 @@ inline Cmpt det(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the cofactor symmetric tensor of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> cof(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
|
@ -339,7 +358,7 @@ inline SymmTensor<Cmpt> cof(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the inverse of a symmetric tensor give the determinant
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> inv(const SymmTensor<Cmpt>& st, const Cmpt detst)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
|
@ -357,7 +376,7 @@ inline SymmTensor<Cmpt> inv(const SymmTensor<Cmpt>& st, const Cmpt detst)
|
|||
|
||||
|
||||
//- Return the inverse of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> inv(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return inv(st, det(st));
|
||||
|
@ -365,7 +384,7 @@ inline SymmTensor<Cmpt> inv(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the 1st invariant of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantI(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return tr(st);
|
||||
|
@ -373,7 +392,7 @@ inline Cmpt invariantI(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the 2nd invariant of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantII(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
|
@ -390,14 +409,14 @@ inline Cmpt invariantII(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the 3rd invariant of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantIII(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return det(st);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator+(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -410,7 +429,7 @@ operator+(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator+(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
||||
{
|
||||
|
@ -423,7 +442,7 @@ operator+(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator-(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -436,7 +455,7 @@ operator-(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator-(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
||||
{
|
||||
|
@ -450,7 +469,7 @@ operator-(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
|||
|
||||
|
||||
//- Inner-product between a spherical symmetric tensor and a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator&(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -469,7 +488,7 @@ operator&(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Inner-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
||||
{
|
||||
|
@ -488,7 +507,7 @@ operator&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
|||
|
||||
|
||||
//- Double-dot-product between a spherical tensor and a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -497,7 +516,7 @@ operator&&(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Double-dot-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
||||
{
|
||||
|
@ -505,7 +524,7 @@ operator&&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> sqr(const Vector<Cmpt>& v)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
|
|
|
@ -75,6 +75,14 @@ const symmTensor symmTensor::min
|
|||
-VGREAT
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor symmTensor::I
|
||||
(
|
||||
1, 0, 0,
|
||||
1, 0,
|
||||
1
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
|
147
src/foam/primitives/SymmTensor2D/SymmTensor2DTemplate.H
Normal file
147
src/foam/primitives/SymmTensor2D/SymmTensor2DTemplate.H
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::SymmTensor2D
|
||||
|
||||
Description
|
||||
Templated 2D symmetric tensor derived from VectorSpace adding construction
|
||||
from 4 components, element access using xx(), xy() etc. member functions
|
||||
and the inner-product (dot-product) and outer-product of two Vectors
|
||||
(tensor-product) operators.
|
||||
|
||||
SourceFiles
|
||||
SymmTensor2DTemplateI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SymmTensor2D_H
|
||||
#define SymmTensor2D_H
|
||||
|
||||
#include "VectorTemplate.H"
|
||||
#include "SphericalTensor2DTemplate.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SymmTensor2D Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Cmpt>
|
||||
class SymmTensor2D
|
||||
:
|
||||
public VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Equivalent type of labels used for valid component indexing
|
||||
typedef SymmTensor2D<label> labelType;
|
||||
|
||||
|
||||
// Member constants
|
||||
|
||||
enum
|
||||
{
|
||||
rank = 2 // Rank of SymmTensor2D is 2
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
static const char* componentNames[];
|
||||
|
||||
static const SymmTensor2D zero;
|
||||
static const SymmTensor2D one;
|
||||
static const SymmTensor2D max;
|
||||
static const SymmTensor2D min;
|
||||
static const SymmTensor2D I;
|
||||
|
||||
|
||||
//- Component labeling enumeration
|
||||
enum components { XX, XY, YY };
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline SymmTensor2D();
|
||||
|
||||
//- Construct given VectorSpace
|
||||
inline SymmTensor2D(const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>&);
|
||||
|
||||
//- Construct given SphericalTensor
|
||||
inline SymmTensor2D(const SphericalTensor2D<Cmpt>&);
|
||||
|
||||
//- Construct given the three components
|
||||
inline SymmTensor2D
|
||||
(
|
||||
const Cmpt txx, const Cmpt txy,
|
||||
const Cmpt tyy
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
SymmTensor2D(Istream&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
inline const Cmpt& xx() const;
|
||||
inline const Cmpt& xy() const;
|
||||
inline const Cmpt& yy() const;
|
||||
|
||||
inline Cmpt& xx();
|
||||
inline Cmpt& xy();
|
||||
inline Cmpt& yy();
|
||||
|
||||
//- Transpose
|
||||
inline const SymmTensor2D<Cmpt>& T() const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Construct given SphericalTensor2D
|
||||
inline void operator=(const SphericalTensor2D<Cmpt>&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Include inline implementations
|
||||
#include "SymmTensor2DTemplateI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
517
src/foam/primitives/SymmTensor2D/SymmTensor2DTemplateI.H
Normal file
517
src/foam/primitives/SymmTensor2D/SymmTensor2DTemplateI.H
Normal file
|
@ -0,0 +1,517 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Vector2DTemplate.H"
|
||||
#include "Tensor2DTemplate.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D()
|
||||
{}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D
|
||||
(
|
||||
const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>& vs
|
||||
)
|
||||
:
|
||||
VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>(vs)
|
||||
{}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0;
|
||||
this->v_[YY] = st.ii();
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D
|
||||
(
|
||||
const Cmpt txx, const Cmpt txy,
|
||||
const Cmpt tyy
|
||||
)
|
||||
{
|
||||
this->v_[XX] = txx; this->v_[XY] = txy;
|
||||
this->v_[YY] = tyy;
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D(Istream& is)
|
||||
:
|
||||
VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>(is)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor2D<Cmpt>::xx() const
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor2D<Cmpt>::xy() const
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor2D<Cmpt>::yy() const
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor2D<Cmpt>::xx()
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor2D<Cmpt>::xy()
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor2D<Cmpt>::yy()
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline const SymmTensor2D<Cmpt>& SymmTensor2D<Cmpt>::T() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
inline void SymmTensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0;
|
||||
this->v_[YY] = st.ii();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Inner-product between two symmetric tensors
|
||||
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-dot-product between a symmetric tensor and a symmetric tensor
|
||||
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 between a symmetric tensor and a vector
|
||||
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 between a vector and a symmetric tensor
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-sqr of a symmetric tensor
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt magSqr(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
(
|
||||
magSqr(st.xx()) + 2*magSqr(st.xy())
|
||||
+ magSqr(st.yy())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the trace of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st.xx() + st.yy();
|
||||
}
|
||||
|
||||
|
||||
//- Return the spherical part of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt> sph(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return (1.0/2.0)*tr(st);
|
||||
}
|
||||
|
||||
|
||||
//- Return the symmetric part of a symmetric tensor, i.e. itself
|
||||
template<class Cmpt>
|
||||
inline const SymmTensor2D<Cmpt>& symm(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
//- Return twice the symmetric part of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> twoSymm(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return 2*st;
|
||||
}
|
||||
|
||||
|
||||
//- Return the deviatoric part of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> dev(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st - SphericalTensor2D<Cmpt>::oneThirdI*tr(st);
|
||||
}
|
||||
|
||||
|
||||
//- Return the deviatoric part of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> dev2(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st - SphericalTensor2D<Cmpt>::twoThirdsI*tr(st);
|
||||
}
|
||||
|
||||
|
||||
//- Return the determinant of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
(
|
||||
st.xx()*st.yy() - st.xy()*st.xy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the cofactor symmetric tensor of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> cof(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st.yy(), -st.xy(),
|
||||
st.xx()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a symmetric tensor give the determinant
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> inv(const SymmTensor2D<Cmpt>& st, const Cmpt detst)
|
||||
{
|
||||
return cof(st)/detst;
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> inv(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return inv(st, det(st));
|
||||
}
|
||||
|
||||
|
||||
//- Return the 1st invariant of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantI(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return tr(st);
|
||||
}
|
||||
|
||||
|
||||
//- Return the 2nd invariant of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantII(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
(
|
||||
0.5*sqr(tr(st))
|
||||
- 0.5*
|
||||
(
|
||||
st.xx()*st.xx() + st.xy()*st.xy()
|
||||
+ st.xy()*st.xy() + st.yy()*st.yy()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the 3rd invariant of a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantIII(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return det(st);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator+(const SphericalTensor2D<Cmpt>& spt1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
spt1.ii() + st2.xx(), st2.xy(),
|
||||
spt1.ii() + st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator+(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() + spt2.ii(), st1.xy(),
|
||||
st1.yy() + spt2.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator-(const SphericalTensor2D<Cmpt>& spt1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
spt1.ii() - st2.xx(), -st2.xy(),
|
||||
spt1.ii() - st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator-(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() - spt2.ii(), st1.xy(),
|
||||
st1.yy() - spt2.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product between a spherical symmetric tensor and a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator&(const SphericalTensor2D<Cmpt>& spt1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
spt1.ii()*st2.xx(), spt1.ii()*st2.xy(),
|
||||
spt1.ii()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product between a tensor and a spherical tensor
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st1.xx()*spt2.ii(), st1.xy()*spt2.ii(),
|
||||
st1.yy()*spt2.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a spherical tensor and a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor2D<Cmpt>& spt1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return(spt1.ii()*st2.xx() + spt1.ii()*st2.yy());
|
||||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a tensor and a spherical tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
{
|
||||
return(st1.xx()*spt2.ii() + st1.yy()*spt2.ii());
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class outerProduct<SymmTensor2D<Cmpt>, Cmpt>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class outerProduct<Cmpt, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SymmTensor2D<Cmpt>, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Tensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SymmTensor2D<Cmpt>, Vector2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Vector2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<Vector2D<Cmpt>, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Vector2D<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SphericalTensor2D<Cmpt>, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SymmTensor2D<Cmpt>, SphericalTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SphericalTensor2D<Cmpt>, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SymmTensor2D<Cmpt>, SphericalTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
85
src/foam/primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C
Normal file
85
src/foam/primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "symmTensor2D.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
const char* const symmTensor2D::typeName = "symmTensor2D";
|
||||
|
||||
template<>
|
||||
const char* symmTensor2D::componentNames[] =
|
||||
{
|
||||
"xx", "xy",
|
||||
"yy"
|
||||
};
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::zero
|
||||
(
|
||||
0, 0,
|
||||
0
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::one
|
||||
(
|
||||
1, 1,
|
||||
1
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::max
|
||||
(
|
||||
VGREAT, VGREAT,
|
||||
VGREAT
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::min
|
||||
(
|
||||
-VGREAT, -VGREAT,
|
||||
-VGREAT
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::I
|
||||
(
|
||||
1, 0,
|
||||
1
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
63
src/foam/primitives/SymmTensor2D/symmTensor2D/symmTensor2D.H
Normal file
63
src/foam/primitives/SymmTensor2D/symmTensor2D/symmTensor2D.H
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::symmTensor2D
|
||||
|
||||
Description
|
||||
SymmTensor2D of scalars.
|
||||
|
||||
SourceFiles
|
||||
symmTensor2D.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef symmTensor2D_H
|
||||
#define symmTensor2D_H
|
||||
|
||||
#include "SymmTensor2DTemplate.H"
|
||||
#include "contiguous.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef SymmTensor2D<scalar> symmTensor2D;
|
||||
|
||||
//- Data associated with symmTensor2D type are contiguous
|
||||
template<>
|
||||
inline bool contiguous<symmTensor2D>() {return true;}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -66,7 +66,7 @@ namespace Foam
|
|||
Class SymmTensor4thOrder Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
class SymmTensor4thOrder
|
||||
:
|
||||
public VectorSpace<SymmTensor4thOrder<Cmpt>, Cmpt, 9>
|
||||
|
|
|
@ -34,13 +34,13 @@ namespace Foam
|
|||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct null
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor4thOrder<Cmpt>::SymmTensor4thOrder()
|
||||
{}
|
||||
|
||||
|
||||
// Construct given VectorSpace
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor4thOrder<Cmpt>::SymmTensor4thOrder
|
||||
(
|
||||
const VectorSpace<SymmTensor4thOrder<Cmpt>, Cmpt, 9>& vs
|
||||
|
@ -51,7 +51,7 @@ inline SymmTensor4thOrder<Cmpt>::SymmTensor4thOrder
|
|||
|
||||
|
||||
// Construct given three Cmpts
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor4thOrder<Cmpt>::SymmTensor4thOrder
|
||||
(
|
||||
const Cmpt txxxx, const Cmpt txxyy, const Cmpt txxzz,
|
||||
|
@ -72,7 +72,7 @@ inline SymmTensor4thOrder<Cmpt>::SymmTensor4thOrder
|
|||
|
||||
|
||||
// Construct from Istream
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor4thOrder<Cmpt>::SymmTensor4thOrder(Istream& is)
|
||||
:
|
||||
VectorSpace<SymmTensor4thOrder<Cmpt>, Cmpt, 9>(is)
|
||||
|
@ -81,110 +81,110 @@ inline SymmTensor4thOrder<Cmpt>::SymmTensor4thOrder(Istream& is)
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::xxxx() const
|
||||
{
|
||||
return this->v_[XXXX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::xxyy() const
|
||||
{
|
||||
return this->v_[XXYY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::xxzz() const
|
||||
{
|
||||
return this->v_[XXZZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::yyyy() const
|
||||
{
|
||||
return this->v_[YYYY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::yyzz() const
|
||||
{
|
||||
return this->v_[YYZZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::zzzz() const
|
||||
{
|
||||
return this->v_[ZZZZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::xyxy() const
|
||||
{
|
||||
return this->v_[XYXY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::yzyz() const
|
||||
{
|
||||
return this->v_[YZYZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& SymmTensor4thOrder<Cmpt>::zxzx() const
|
||||
{
|
||||
return this->v_[ZXZX];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::xxxx()
|
||||
{
|
||||
return this->v_[XXXX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::xxyy()
|
||||
{
|
||||
return this->v_[XXYY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::xxzz()
|
||||
{
|
||||
return this->v_[XXZZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::yyyy()
|
||||
{
|
||||
return this->v_[YYYY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::yyzz()
|
||||
{
|
||||
return this->v_[YYZZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::zzzz()
|
||||
{
|
||||
return this->v_[ZZZZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::xyxy()
|
||||
{
|
||||
return this->v_[XYXY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::yzyz()
|
||||
{
|
||||
return this->v_[YZYZ];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& SymmTensor4thOrder<Cmpt>::zxzx()
|
||||
{
|
||||
return this->v_[ZXZX];
|
||||
|
@ -196,7 +196,7 @@ inline Cmpt& SymmTensor4thOrder<Cmpt>::zxzx()
|
|||
|
||||
//- Double-dot-product between a fourth order symmetric tensor and
|
||||
// a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator&&(const SymmTensor4thOrder<Cmpt>& t4th, const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
|
@ -216,7 +216,7 @@ operator&&(const SymmTensor4thOrder<Cmpt>& t4th, const SymmTensor<Cmpt>& st)
|
|||
|
||||
//- Double-dot-product between a symmetric tensor and a symmetric
|
||||
// fourth order tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt>
|
||||
operator&&(const SymmTensor<Cmpt>& st, const SymmTensor4thOrder<Cmpt>& t4th)
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ operator&&(const SymmTensor<Cmpt>& st, const SymmTensor4thOrder<Cmpt>& t4th)
|
|||
|
||||
//- Inner-product between a symmTensor4thOrder and a vector
|
||||
// this is not implemented
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const SymmTensor4thOrder<Cmpt>& st, const Vector<Cmpt>& v)
|
||||
{
|
||||
|
@ -259,7 +259,7 @@ operator&(const SymmTensor4thOrder<Cmpt>& st, const Vector<Cmpt>& v)
|
|||
|
||||
//- Inner-product between a vector and a symmTensor4thOrder
|
||||
// this is not implemented
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt>
|
||||
operator&(const Vector<Cmpt>& v, const SymmTensor4thOrder<Cmpt>& st)
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ class SymmTensor;
|
|||
Class Tensor Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
class Tensor
|
||||
:
|
||||
public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
|
||||
|
@ -82,6 +82,7 @@ public:
|
|||
static const Tensor one;
|
||||
static const Tensor max;
|
||||
static const Tensor min;
|
||||
static const Tensor I;
|
||||
|
||||
|
||||
//- Component labeling enumeration
|
||||
|
@ -93,7 +94,7 @@ public:
|
|||
//- Construct null
|
||||
inline Tensor();
|
||||
|
||||
//- Construct given VectorSpace
|
||||
//- Construct given VectorSpace of the same rank
|
||||
inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
|
||||
|
||||
//- Construct given SphericalTensor
|
||||
|
@ -102,7 +103,10 @@ public:
|
|||
//- Construct given SymmTensor
|
||||
inline Tensor(const SymmTensor<Cmpt>&);
|
||||
|
||||
//- Construct given the three vectors
|
||||
//- Construct given triad
|
||||
inline Tensor(const Vector<Vector<Cmpt> >&);
|
||||
|
||||
//- Construct given the three vector components
|
||||
inline Tensor
|
||||
(
|
||||
const Vector<Cmpt>& x,
|
||||
|
@ -149,9 +153,10 @@ public:
|
|||
// Access vector components.
|
||||
// Note: returning const only to find out lhs usage
|
||||
|
||||
inline const Vector<Cmpt> x() const;
|
||||
inline const Vector<Cmpt> y() const;
|
||||
inline const Vector<Cmpt> z() const;
|
||||
inline Vector<Cmpt> x() const;
|
||||
inline Vector<Cmpt> y() const;
|
||||
inline Vector<Cmpt> z() const;
|
||||
inline Vector<Cmpt> vectorComponent(const direction) const;
|
||||
|
||||
//- Return (i, j) component. Consistency with VectorN
|
||||
inline const Cmpt& operator()
|
||||
|
@ -179,6 +184,9 @@ public:
|
|||
|
||||
//- Assign to a SymmTensor
|
||||
inline void operator=(const SymmTensor<Cmpt>&);
|
||||
|
||||
//- Assign to a triad
|
||||
inline void operator=(const Vector<Vector<Cmpt> >&);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -33,13 +33,13 @@ namespace Foam
|
|||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
//- Construct null
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>::Tensor()
|
||||
{}
|
||||
|
||||
|
||||
//- Construct given VectorSpace
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>::Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>& vs)
|
||||
:
|
||||
VectorSpace<Tensor<Cmpt>, Cmpt, 9>(vs)
|
||||
|
@ -47,7 +47,7 @@ inline Tensor<Cmpt>::Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>& vs)
|
|||
|
||||
|
||||
//- Construct given SphericalTensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>::Tensor(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
|
||||
|
@ -57,7 +57,7 @@ inline Tensor<Cmpt>::Tensor(const SphericalTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Construct given SymmTensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>::Tensor(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
|
||||
|
@ -66,8 +66,26 @@ inline Tensor<Cmpt>::Tensor(const SymmTensor<Cmpt>& st)
|
|||
}
|
||||
|
||||
|
||||
//- Construct from a triad
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>::Tensor(const Vector<Vector<Cmpt> >& tr)
|
||||
{
|
||||
this->v_[XX] = tr.x().x();
|
||||
this->v_[XY] = tr.x().y();
|
||||
this->v_[XZ] = tr.x().z();
|
||||
|
||||
this->v_[YX] = tr.y().x();
|
||||
this->v_[YY] = tr.y().y();
|
||||
this->v_[YZ] = tr.y().z();
|
||||
|
||||
this->v_[ZX] = tr.z().x();
|
||||
this->v_[ZY] = tr.z().y();
|
||||
this->v_[ZZ] = tr.z().z();
|
||||
}
|
||||
|
||||
|
||||
//- Construct given the three vector components
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>::Tensor
|
||||
(
|
||||
const Vector<Cmpt>& x,
|
||||
|
@ -82,7 +100,7 @@ inline Tensor<Cmpt>::Tensor
|
|||
|
||||
|
||||
//- Construct from components
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>::Tensor
|
||||
(
|
||||
const Cmpt txx, const Cmpt txy, const Cmpt txz,
|
||||
|
@ -97,7 +115,7 @@ inline Tensor<Cmpt>::Tensor
|
|||
|
||||
|
||||
//- Construct from Istream
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>::Tensor(Istream& is)
|
||||
:
|
||||
VectorSpace<Tensor<Cmpt>, Cmpt, 9>(is)
|
||||
|
@ -106,133 +124,165 @@ inline Tensor<Cmpt>::Tensor(Istream& is)
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
inline const Vector<Cmpt> Tensor<Cmpt>::x() const
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> Tensor<Cmpt>::x() const
|
||||
{
|
||||
return Vector<Cmpt>(this->v_[XX], this->v_[XY], this->v_[XZ]);
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
inline const Vector<Cmpt> Tensor<Cmpt>::y() const
|
||||
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> Tensor<Cmpt>::y() const
|
||||
{
|
||||
return Vector<Cmpt>(this->v_[YX], this->v_[YY], this->v_[YZ]);
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
inline const Vector<Cmpt> Tensor<Cmpt>::z() const
|
||||
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> Tensor<Cmpt>::z() const
|
||||
{
|
||||
return Vector<Cmpt>(this->v_[ZX], this->v_[ZY], this->v_[ZZ]);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> Tensor<Cmpt>::vectorComponent(const direction cmpt) const
|
||||
{
|
||||
switch (cmpt)
|
||||
{
|
||||
case 0:
|
||||
return x();
|
||||
break;
|
||||
case 1:
|
||||
return y();
|
||||
break;
|
||||
case 2:
|
||||
return z();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::xx() const
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::xy() const
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::xz() const
|
||||
{
|
||||
return this->v_[XZ];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::yx() const
|
||||
{
|
||||
return this->v_[YX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::yy() const
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::yz() const
|
||||
{
|
||||
return this->v_[YZ];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::zx() const
|
||||
{
|
||||
return this->v_[ZX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::zy() const
|
||||
{
|
||||
return this->v_[ZY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::zz() const
|
||||
{
|
||||
return this->v_[ZZ];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::xx()
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::xy()
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::xz()
|
||||
{
|
||||
return this->v_[XZ];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::yx()
|
||||
{
|
||||
return this->v_[YX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::yy()
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::yz()
|
||||
{
|
||||
return this->v_[YZ];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::zx()
|
||||
{
|
||||
return this->v_[ZX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::zy()
|
||||
{
|
||||
return this->v_[ZY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::zz()
|
||||
{
|
||||
return this->v_[ZZ];
|
||||
|
@ -240,7 +290,7 @@ inline Cmpt& Tensor<Cmpt>::zz()
|
|||
|
||||
|
||||
//- Return tensor transpose
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> Tensor<Cmpt>::T() const
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
|
@ -252,7 +302,7 @@ inline Tensor<Cmpt> Tensor<Cmpt>::T() const
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor<Cmpt>::operator()
|
||||
(
|
||||
const direction i,
|
||||
|
@ -263,7 +313,7 @@ inline const Cmpt& Tensor<Cmpt>::operator()
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor<Cmpt>::operator()
|
||||
(
|
||||
const direction i,
|
||||
|
@ -276,7 +326,7 @@ inline Cmpt& Tensor<Cmpt>::operator()
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline void Tensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
|
||||
|
@ -285,7 +335,7 @@ inline void Tensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline void Tensor<Cmpt>::operator=(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz();
|
||||
|
@ -294,10 +344,27 @@ inline void Tensor<Cmpt>::operator=(const SymmTensor<Cmpt>& st)
|
|||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline void Tensor<Cmpt>::operator=(const Vector<Vector<Cmpt> >& tr)
|
||||
{
|
||||
this->v_[XX] = tr.x().x();
|
||||
this->v_[XY] = tr.x().y();
|
||||
this->v_[XZ] = tr.x().z();
|
||||
|
||||
this->v_[YX] = tr.y().x();
|
||||
this->v_[YY] = tr.y().y();
|
||||
this->v_[YZ] = tr.y().z();
|
||||
|
||||
this->v_[ZX] = tr.z().x();
|
||||
this->v_[ZY] = tr.z().y();
|
||||
this->v_[ZZ] = tr.z().z();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Hodge Dual operator (tensor -> vector)
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector<Cmpt> operator*(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return Vector<Cmpt>(t.yz(), -t.xz(), t.xy());
|
||||
|
@ -305,7 +372,7 @@ inline Vector<Cmpt> operator*(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Hodge Dual operator (vector -> tensor)
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> operator*(const Vector<Cmpt>& v)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
|
@ -318,7 +385,7 @@ inline Tensor<Cmpt> operator*(const Vector<Cmpt>& v)
|
|||
|
||||
|
||||
//- Inner-product between two tensors
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor<Cmpt>, Tensor<Cmpt> >::type
|
||||
operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -340,7 +407,7 @@ operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
|
|||
|
||||
|
||||
//- Inner-product between a tensor and a vector
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt> >::type
|
||||
operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
|
||||
{
|
||||
|
@ -354,7 +421,7 @@ operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
|
|||
|
||||
|
||||
//- Inner-product between a vector and a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt> >::type
|
||||
operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
||||
{
|
||||
|
@ -368,7 +435,7 @@ operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Outer-product between two vectors
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename outerProduct<Vector<Cmpt>, Vector<Cmpt> >::type
|
||||
operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
|
||||
{
|
||||
|
@ -382,7 +449,7 @@ operator*(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2)
|
|||
|
||||
|
||||
//- Division of a vector by a tensor, i.e. dot-product with the tensor inverse
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt> >::type
|
||||
operator/(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
||||
{
|
||||
|
@ -393,7 +460,7 @@ operator/(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
|||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return the trace of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return t.xx() + t.yy() + t.zz();
|
||||
|
@ -401,7 +468,7 @@ inline Cmpt tr(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the spherical part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor<Cmpt> sph(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return (1.0/3.0)*tr(t);
|
||||
|
@ -409,7 +476,7 @@ inline SphericalTensor<Cmpt> sph(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the symmetric part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> symm(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
|
@ -422,7 +489,7 @@ inline SymmTensor<Cmpt> symm(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return twice the symmetric part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SymmTensor<Cmpt> twoSymm(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return SymmTensor<Cmpt>
|
||||
|
@ -435,7 +502,7 @@ inline SymmTensor<Cmpt> twoSymm(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the skew-symmetric part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> skew(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
|
@ -448,7 +515,7 @@ inline Tensor<Cmpt> skew(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the skew-symmetric part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Tensor<Cmpt>& skew(const SymmTensor<Cmpt>& st)
|
||||
{
|
||||
return Tensor<Cmpt>::zero;
|
||||
|
@ -456,7 +523,7 @@ inline const Tensor<Cmpt>& skew(const SymmTensor<Cmpt>& st)
|
|||
|
||||
|
||||
//- Return the deviatoric part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> dev(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return t - SphericalTensor<Cmpt>::oneThirdI*tr(t);
|
||||
|
@ -464,7 +531,7 @@ inline Tensor<Cmpt> dev(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the deviatoric part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> dev2(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return t - SphericalTensor<Cmpt>::twoThirdsI*tr(t);
|
||||
|
@ -472,7 +539,7 @@ inline Tensor<Cmpt> dev2(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the determinant of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return
|
||||
|
@ -485,7 +552,7 @@ inline Cmpt det(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the cofactor tensor of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> cof(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
|
@ -505,8 +572,8 @@ inline Tensor<Cmpt> cof(const Tensor<Cmpt>& t)
|
|||
}
|
||||
|
||||
|
||||
//- Return the inverse of a tensor give the determinant
|
||||
template <class Cmpt>
|
||||
//- Return the inverse of a tensor given the determinant
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t, const Cmpt dett)
|
||||
{
|
||||
return Tensor<Cmpt>
|
||||
|
@ -527,7 +594,7 @@ inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t, const Cmpt dett)
|
|||
|
||||
|
||||
//- Return the inverse of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return inv(t, det(t));
|
||||
|
@ -535,7 +602,7 @@ inline Tensor<Cmpt> inv(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the 1st invariant of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantI(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return tr(t);
|
||||
|
@ -543,7 +610,7 @@ inline Cmpt invariantI(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the 2nd invariant of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantII(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return
|
||||
|
@ -560,7 +627,7 @@ inline Cmpt invariantII(const Tensor<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the 3rd invariant of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantIII(const Tensor<Cmpt>& t)
|
||||
{
|
||||
return det(t);
|
||||
|
@ -569,7 +636,7 @@ inline Cmpt invariantIII(const Tensor<Cmpt>& t)
|
|||
|
||||
// * * * * * * * * * Mixed Tensor SphericalTensor Operators * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator+(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -582,7 +649,7 @@ operator+(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator+(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -595,7 +662,7 @@ operator+(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator-(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -608,7 +675,7 @@ operator-(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator-(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -622,7 +689,7 @@ operator-(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Inner-product between a spherical tensor and a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -644,7 +711,7 @@ operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||
|
||||
|
||||
//- Inner-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -666,7 +733,7 @@ operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Double-dot-product between a spherical tensor and a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -675,13 +742,14 @@ operator&&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||
|
||||
|
||||
//- Double-dot-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
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> >
|
||||
{
|
||||
|
@ -690,6 +758,7 @@ public:
|
|||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt> >
|
||||
{
|
||||
|
@ -698,6 +767,7 @@ public:
|
|||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SphericalTensor<Cmpt>, Tensor<Cmpt> >
|
||||
{
|
||||
|
@ -706,6 +776,7 @@ public:
|
|||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<Tensor<Cmpt>, SphericalTensor<Cmpt> >
|
||||
{
|
||||
|
@ -717,7 +788,7 @@ public:
|
|||
|
||||
// * * * * * * * * * * Mixed Tensor SymmTensor Operators * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator+(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -730,7 +801,7 @@ operator+(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator+(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -743,7 +814,7 @@ operator+(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator-(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -756,7 +827,7 @@ operator-(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator-(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -769,8 +840,8 @@ operator-(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
|||
}
|
||||
|
||||
|
||||
//- Inner-product between a spherical tensor and a tensor
|
||||
template <class Cmpt>
|
||||
//- Inner-product between a symmetric tensor and a tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -791,8 +862,8 @@ operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||
}
|
||||
|
||||
|
||||
//- Inner-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
//- Inner-product between a tensor and a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -813,8 +884,8 @@ operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
|||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a spherical tensor and a tensor
|
||||
template <class Cmpt>
|
||||
//- Double-dot-product between a symmetric tensor and a tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
|
@ -827,8 +898,8 @@ operator&&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
|||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
//- Double-dot-product between a tensor and a symmetric tensor
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
|
@ -840,6 +911,7 @@ operator&&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt> >
|
||||
{
|
||||
|
@ -848,6 +920,7 @@ public:
|
|||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<Tensor<Cmpt>, SymmTensor<Cmpt> >
|
||||
{
|
||||
|
@ -865,6 +938,7 @@ public:
|
|||
typedef Tensor<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<Tensor<Cmpt>, SymmTensor<Cmpt> >
|
||||
{
|
||||
|
|
|
@ -76,6 +76,14 @@ const tensor tensor::min
|
|||
-VGREAT, -VGREAT, -VGREAT
|
||||
);
|
||||
|
||||
template<>
|
||||
const tensor tensor::I
|
||||
(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -221,9 +229,8 @@ vector eigenVector(const tensor& t, const scalar lambda)
|
|||
(A.yz()*A.zx() - A.zz()*A.yx())/sd0,
|
||||
(A.zy()*A.yx() - A.yy()*A.zx())/sd0
|
||||
);
|
||||
ev /= mag(ev);
|
||||
|
||||
return ev;
|
||||
return ev/mag(ev);
|
||||
}
|
||||
else if (magSd1 > magSd2 && magSd1 > SMALL)
|
||||
{
|
||||
|
@ -233,9 +240,8 @@ vector eigenVector(const tensor& t, const scalar lambda)
|
|||
1,
|
||||
(A.zx()*A.xy() - A.xx()*A.zy())/sd1
|
||||
);
|
||||
ev /= mag(ev);
|
||||
|
||||
return ev;
|
||||
return ev/mag(ev);
|
||||
}
|
||||
else if (magSd2 > SMALL)
|
||||
{
|
||||
|
@ -245,9 +251,8 @@ vector eigenVector(const tensor& t, const scalar lambda)
|
|||
(A.yx()*A.xz() - A.xx()*A.yz())/sd2,
|
||||
1
|
||||
);
|
||||
ev /= mag(ev);
|
||||
|
||||
return ev;
|
||||
return ev/mag(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -46,11 +46,14 @@ SourceFiles
|
|||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Cmpt>
|
||||
class SymmTensor2D;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Tensor2D Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
class Tensor2D
|
||||
:
|
||||
public VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>
|
||||
|
@ -75,6 +78,7 @@ public:
|
|||
static const Tensor2D one;
|
||||
static const Tensor2D max;
|
||||
static const Tensor2D min;
|
||||
static const Tensor2D I;
|
||||
|
||||
|
||||
//- Component labeling enumeration
|
||||
|
@ -89,6 +93,9 @@ public:
|
|||
//- Construct given VectorSpace
|
||||
inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
|
||||
|
||||
//- Construct given SymmTensor2D
|
||||
inline Tensor2D(const SymmTensor2D<Cmpt>&);
|
||||
|
||||
//- Construct given SphericalTensor2D
|
||||
inline Tensor2D(const SphericalTensor2D<Cmpt>&);
|
||||
|
||||
|
@ -150,6 +157,9 @@ public:
|
|||
|
||||
// Member Operators
|
||||
|
||||
//- Copy SymmTensor2D
|
||||
inline void operator=(const SymmTensor2D<Cmpt>&);
|
||||
|
||||
//- Copy SphericalTensor2D
|
||||
inline void operator=(const SphericalTensor2D<Cmpt>&);
|
||||
};
|
||||
|
|
|
@ -30,19 +30,27 @@ namespace Foam
|
|||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D()
|
||||
{}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>& vs)
|
||||
:
|
||||
VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>(vs)
|
||||
{}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.xx(); this->v_[XY] = st.xy();
|
||||
this->v_[YX] = st.xy(); this->v_[YY] = st.yy();
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0;
|
||||
|
@ -50,7 +58,7 @@ inline Tensor2D<Cmpt>::Tensor2D(const SphericalTensor2D<Cmpt>& st)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D
|
||||
(
|
||||
const Vector2D<Cmpt>& x,
|
||||
|
@ -62,7 +70,7 @@ inline Tensor2D<Cmpt>::Tensor2D
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D
|
||||
(
|
||||
const Cmpt txx, const Cmpt txy,
|
||||
|
@ -74,7 +82,7 @@ inline Tensor2D<Cmpt>::Tensor2D
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D(Istream& is)
|
||||
:
|
||||
VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>(is)
|
||||
|
@ -83,76 +91,76 @@ inline Tensor2D<Cmpt>::Tensor2D(Istream& is)
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector2D<Cmpt> Tensor2D<Cmpt>::x() const
|
||||
{
|
||||
return Vector2D<Cmpt>(this->v_[XX], this->v_[XY]);
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Vector2D<Cmpt> Tensor2D<Cmpt>::y() const
|
||||
{
|
||||
return Vector2D<Cmpt>(this->v_[YX], this->v_[YY]);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor2D<Cmpt>::xx() const
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor2D<Cmpt>::xy() const
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor2D<Cmpt>::yx() const
|
||||
{
|
||||
return this->v_[YX];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor2D<Cmpt>::yy() const
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor2D<Cmpt>::xx()
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor2D<Cmpt>::xy()
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor2D<Cmpt>::yx()
|
||||
{
|
||||
return this->v_[YX];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor2D<Cmpt>::yy()
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline const Cmpt& Tensor2D<Cmpt>::operator()
|
||||
(
|
||||
const direction i,
|
||||
|
@ -163,7 +171,7 @@ inline const Cmpt& Tensor2D<Cmpt>::operator()
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt& Tensor2D<Cmpt>::operator()
|
||||
(
|
||||
const direction i,
|
||||
|
@ -174,7 +182,7 @@ inline Cmpt& Tensor2D<Cmpt>::operator()
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt> Tensor2D<Cmpt>::T() const
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
|
@ -187,7 +195,15 @@ inline Tensor2D<Cmpt> Tensor2D<Cmpt>::T() const
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline void Tensor2D<Cmpt>::operator=(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.xx(); this->v_[XY] = st.xy();
|
||||
this->v_[YX] = st.xy(); this->v_[YY] = st.yy();
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline void Tensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0;
|
||||
|
@ -199,7 +215,7 @@ inline void Tensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st)
|
|||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Inner-product between two tensors
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor2D<Cmpt>, Tensor2D<Cmpt> >::type
|
||||
operator&(const Tensor2D<Cmpt>& t1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
|
@ -214,7 +230,7 @@ operator&(const Tensor2D<Cmpt>& t1, const Tensor2D<Cmpt>& t2)
|
|||
}
|
||||
|
||||
//- Inner-product between a tensor and a vector
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Tensor2D<Cmpt>, Vector2D<Cmpt> >::type
|
||||
operator&(const Tensor2D<Cmpt>& t, const Vector2D<Cmpt>& v)
|
||||
{
|
||||
|
@ -226,7 +242,7 @@ operator&(const Tensor2D<Cmpt>& t, const Vector2D<Cmpt>& v)
|
|||
}
|
||||
|
||||
//- Inner-product between a vector and a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename innerProduct<Vector2D<Cmpt>, Tensor2D<Cmpt> >::type
|
||||
operator&(const Vector2D<Cmpt>& v, const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
|
@ -238,7 +254,7 @@ operator&(const Vector2D<Cmpt>& v, const Tensor2D<Cmpt>& t)
|
|||
}
|
||||
|
||||
//- Outer-product between two vectors
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline typename outerProduct<Vector2D<Cmpt>, Vector2D<Cmpt> >::type
|
||||
operator*(const Vector2D<Cmpt>& v1, const Vector2D<Cmpt>& v2)
|
||||
{
|
||||
|
@ -251,7 +267,7 @@ operator*(const Vector2D<Cmpt>& v1, const Vector2D<Cmpt>& v2)
|
|||
|
||||
|
||||
//- Return the trace of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt tr(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return t.xx() + t.yy();
|
||||
|
@ -259,7 +275,7 @@ inline Cmpt tr(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the spherical part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt> sph(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return 0.5*tr(t);
|
||||
|
@ -267,29 +283,29 @@ inline SphericalTensor2D<Cmpt> sph(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the symmetric part of a tensor
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt> symm(const Tensor2D<Cmpt>& t)
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> symm(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
t.xx(), 0.5*(t.xy() + t.yx()),
|
||||
0.5*(t.yx() + t.xy()), t.yy()
|
||||
t.yy()
|
||||
);
|
||||
}
|
||||
|
||||
//- Return the twice the symmetric part of a tensor
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt> twoSymm(const Tensor2D<Cmpt>& t)
|
||||
template<class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> twoSymm(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
t.xx() + t.xx(), t.xy() + t.yx(),
|
||||
t.yx() + t.xy(), t.yy() + t.yy()
|
||||
t.yy() + t.yy()
|
||||
);
|
||||
}
|
||||
|
||||
//- Return the skew-symmetric part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt> skew(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
|
@ -301,7 +317,7 @@ inline Tensor2D<Cmpt> skew(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the deviatoric part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt> dev(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return t - SphericalTensor2D<Cmpt>::oneThirdI*tr(t);
|
||||
|
@ -309,7 +325,7 @@ inline Tensor2D<Cmpt> dev(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the deviatoric part of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt> dev2(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return t - SphericalTensor2D<Cmpt>::twoThirdsI*tr(t);
|
||||
|
@ -317,7 +333,7 @@ inline Tensor2D<Cmpt> dev2(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the determinant of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt det(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return(t.xx()*t.yy() - t.xy()*t.yx());
|
||||
|
@ -325,7 +341,7 @@ inline Cmpt det(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the cofactor tensor of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt> cof(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
|
@ -337,7 +353,7 @@ inline Tensor2D<Cmpt> cof(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the inverse of a tensor given the determinant
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt> inv(const Tensor2D<Cmpt>& t, const Cmpt dett)
|
||||
{
|
||||
return cof(t)/dett;
|
||||
|
@ -345,7 +361,7 @@ inline Tensor2D<Cmpt> inv(const Tensor2D<Cmpt>& t, const Cmpt dett)
|
|||
|
||||
|
||||
//- Return the inverse of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt> inv(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return inv(t, det(t));
|
||||
|
@ -353,7 +369,7 @@ inline Tensor2D<Cmpt> inv(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the 1st invariant of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantI(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return tr(t);
|
||||
|
@ -361,7 +377,7 @@ inline Cmpt invariantI(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the 2nd invariant of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantII(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return
|
||||
|
@ -377,7 +393,7 @@ inline Cmpt invariantII(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
//- Return the 3rd invariant of a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt invariantIII(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return det(t);
|
||||
|
@ -386,7 +402,7 @@ inline Cmpt invariantIII(const Tensor2D<Cmpt>& t)
|
|||
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator+(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
|
@ -398,7 +414,7 @@ operator+(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator+(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
{
|
||||
|
@ -410,7 +426,7 @@ operator+(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator-(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
|
@ -422,7 +438,7 @@ operator-(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
|||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator-(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
{
|
||||
|
@ -435,7 +451,7 @@ operator-(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Inner-product between a spherical tensor and a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator&(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
|
@ -450,7 +466,7 @@ operator&(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
|||
|
||||
|
||||
//- Inner-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator&(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
{
|
||||
|
@ -466,7 +482,7 @@ operator&(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
|||
|
||||
|
||||
//- Double-dot-product between a spherical tensor and a tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
|
@ -475,7 +491,7 @@ operator&&(const SphericalTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
|||
|
||||
|
||||
//- Double-dot-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
template<class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
{
|
||||
|
|
|
@ -71,6 +71,13 @@ const tensor2D tensor2D::min
|
|||
-VGREAT, -VGREAT
|
||||
);
|
||||
|
||||
template<>
|
||||
const tensor2D tensor2D::I
|
||||
(
|
||||
1, 0,
|
||||
0, 1
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
|
Reference in a new issue