symmTensor: Add support for the innerSqr function

which takes the inner product of a symmTensor with itself and returns a symmTensor
This commit is contained in:
Henry
2015-02-28 16:09:55 +00:00
parent c350b22cd5
commit 6e217f31c2
13 changed files with 81 additions and 17 deletions

View File

@ -24,9 +24,11 @@ int main()
tensor t6(1,0,-4,0,5,4,-4,4,3);
//tensor t6(1,2,0,2,5,0,0,0,0);
Info<< "tensor " << t6 << endl;
vector e = eigenValues(t6);
Info<< "eigenvalues " << e << endl;
tensor ev = eigenVectors(t6);
Info<< "eigenvectors " << ev << endl;
@ -58,6 +60,17 @@ int main()
Info<< "Check for dot product of symmetric tensors "
<< (st1 & st2) << endl;
Info<< "Check for inner sqr of a symmetric tensor "
<< innerSqr(st1) << " " << innerSqr(st1) - (st1 & st1) << endl;
Info<< "Check for symmetric part of dot product of symmetric tensors "
<< twoSymm(st1&st2) - ((st1&st2) + (st2&st1)) << endl;
tensor sk1 = skew(t6);
tensor sk2 = skew(t7);
Info<< "Check for symmetric part of dot product of skew tensors "
<< twoSymm(sk1&sk2) - ((sk1&sk2) - (sk2&sk1)) << endl;
vector v1(1, 2, 3);
Info<< sqr(v1) << endl;
@ -184,6 +197,5 @@ int main()
Debug(U_triple);
*/
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -57,6 +57,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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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&);
@ -77,4 +78,3 @@ dimensionedVector operator*(const dimensionedSymmTensor&);
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,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)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,6 +37,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)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,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)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -248,6 +248,25 @@ operator&(const Vector<Cmpt>& v, const SymmTensor<Cmpt>& st)
}
//- 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)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -189,6 +189,20 @@ operator&(const Vector2D<Cmpt>& v, const SymmTensor2D<Cmpt>& st)
}
//- 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)
{