mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -24,9 +24,11 @@ int main()
|
|||||||
|
|
||||||
tensor t6(1,0,-4,0,5,4,-4,4,3);
|
tensor t6(1,0,-4,0,5,4,-4,4,3);
|
||||||
//tensor t6(1,2,0,2,5,0,0,0,0);
|
//tensor t6(1,2,0,2,5,0,0,0,0);
|
||||||
|
|
||||||
Info<< "tensor " << t6 << endl;
|
Info<< "tensor " << t6 << endl;
|
||||||
vector e = eigenValues(t6);
|
vector e = eigenValues(t6);
|
||||||
Info<< "eigenvalues " << e << endl;
|
Info<< "eigenvalues " << e << endl;
|
||||||
|
|
||||||
tensor ev = eigenVectors(t6);
|
tensor ev = eigenVectors(t6);
|
||||||
Info<< "eigenvectors " << ev << endl;
|
Info<< "eigenvectors " << ev << endl;
|
||||||
|
|
||||||
@ -58,6 +60,17 @@ int main()
|
|||||||
Info<< "Check for dot product of symmetric tensors "
|
Info<< "Check for dot product of symmetric tensors "
|
||||||
<< (st1 & st2) << endl;
|
<< (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);
|
vector v1(1, 2, 3);
|
||||||
|
|
||||||
Info<< sqr(v1) << endl;
|
Info<< sqr(v1) << endl;
|
||||||
@ -184,6 +197,5 @@ int main()
|
|||||||
Debug(U_triple);
|
Debug(U_triple);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
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)
|
dimensionedScalar tr(const dimensionedSymmTensor& dt)
|
||||||
{
|
{
|
||||||
return dimensionedScalar
|
return dimensionedScalar
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -51,6 +51,7 @@ typedef dimensioned<symmTensor> dimensionedSymmTensor;
|
|||||||
// global functions
|
// global functions
|
||||||
|
|
||||||
dimensionedSymmTensor sqr(const dimensionedVector&);
|
dimensionedSymmTensor sqr(const dimensionedVector&);
|
||||||
|
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor&);
|
||||||
|
|
||||||
dimensionedScalar tr(const dimensionedSymmTensor&);
|
dimensionedScalar tr(const dimensionedSymmTensor&);
|
||||||
dimensionedSymmTensor symm(const dimensionedSymmTensor&);
|
dimensionedSymmTensor symm(const dimensionedSymmTensor&);
|
||||||
@ -77,4 +78,3 @@ dimensionedVector operator*(const dimensionedSymmTensor&);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
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(scalar, symmTensor, tr, transform)
|
||||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
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(scalar, symmTensor, tr, transform)
|
||||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -39,6 +39,7 @@ namespace Foam
|
|||||||
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
UNARY_FUNCTION(symmTensor, vector, sqr)
|
UNARY_FUNCTION(symmTensor, vector, sqr)
|
||||||
|
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr)
|
||||||
|
|
||||||
UNARY_FUNCTION(scalar, symmTensor, tr)
|
UNARY_FUNCTION(scalar, symmTensor, tr)
|
||||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -49,6 +49,7 @@ namespace Foam
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
UNARY_FUNCTION(symmTensor, vector, sqr)
|
UNARY_FUNCTION(symmTensor, vector, sqr)
|
||||||
|
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr)
|
||||||
|
|
||||||
UNARY_FUNCTION(scalar, symmTensor, tr)
|
UNARY_FUNCTION(scalar, symmTensor, tr)
|
||||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -37,6 +37,7 @@ namespace Foam
|
|||||||
// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
UNARY_FUNCTION(symmTensor, vector, sqr)
|
UNARY_FUNCTION(symmTensor, vector, sqr)
|
||||||
|
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr)
|
||||||
|
|
||||||
UNARY_FUNCTION(scalar, symmTensor, tr)
|
UNARY_FUNCTION(scalar, symmTensor, tr)
|
||||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -54,6 +54,7 @@ typedef Field<symmTensor> symmTensorField;
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
UNARY_FUNCTION(symmTensor, vector, sqr)
|
UNARY_FUNCTION(symmTensor, vector, sqr)
|
||||||
|
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr)
|
||||||
|
|
||||||
UNARY_FUNCTION(scalar, symmTensor, tr)
|
UNARY_FUNCTION(scalar, symmTensor, tr)
|
||||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
UNARY_FUNCTION(sphericalTensor, symmTensor, sph)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -37,6 +37,7 @@ namespace Foam
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
UNARY_FUNCTION(symmTensor, vector, sqr, sqr)
|
UNARY_FUNCTION(symmTensor, vector, sqr, sqr)
|
||||||
|
UNARY_FUNCTION(symmTensor, symmTensor, innerSqr, sqr)
|
||||||
|
|
||||||
UNARY_FUNCTION(scalar, symmTensor, tr, transform)
|
UNARY_FUNCTION(scalar, symmTensor, tr, transform)
|
||||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
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(scalar, symmTensor, tr, transform)
|
||||||
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
UNARY_FUNCTION(sphericalTensor, symmTensor, sph, transform)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
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>
|
template<class Cmpt>
|
||||||
inline Cmpt magSqr(const SymmTensor<Cmpt>& st)
|
inline Cmpt magSqr(const SymmTensor<Cmpt>& st)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
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>
|
template<class Cmpt>
|
||||||
inline Cmpt magSqr(const SymmTensor2D<Cmpt>& st)
|
inline Cmpt magSqr(const SymmTensor2D<Cmpt>& st)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user