CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Diagonal elements of a volTensorField (http://www.cfd-online.com/Forums/openfoam-solving/80304-diagonal-elements-voltensorfield.html)

CpCaniggia September 22, 2010 05:47

Diagonal elements of a volTensorField
 
Dear All,

I need to compute the diagonal elements of a volTensorField. The tensor field has the form,

volTensorField tmp ("tmp", fvc::grad(U));

It seems OpenFoam 1.6 doesn't have a function like diag(tmp). Does OpenFoam 1.7 have such kinds of function? Do any people know how to compute the diagonal elements?

Many thanks,
Y. J.

eugene September 23, 2010 11:06

If you want the sum of the diagonal elements then:

volScalarField trTmp = tr(tmp);

If you just want the diagonal components, then

tmp.xx()
tmp.yy()
tmp.zz()

will provide the individual fields.


All times are GMT -4. The time now is 08:25.