- **OpenFOAM Running, Solving & CFD**
(*https://www.cfd-online.com/Forums/openfoam-solving/*)

- - **Diagonal elements of a volTensorField**
(*https://www.cfd-online.com/Forums/openfoam-solving/80304-diagonal-elements-voltensorfield.html*)

Diagonal elements of a volTensorFieldDear 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. |

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 17:10. |