CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   May I know more about tensor calculation? (

aki_yafuji July 2, 2011 13:53

May I know more about tensor calculation?
Hello, everyone!

How do I calculate partial derivative dA/dx (= (dAxx/dx, dAxy/dx, dAxz/dx, dAyy/dx, dAyz/dx, dAzz/dx)) of a symmetric tensor A (= (Axx, Axy, Axz, Ayy, Ayz, Azz))?
I tried to use "grad(A)" but failed. I am at a loss of what to do...
If anyone has information concerning this, please let me know!

Sincerely yours


kathrin_kissling July 4, 2011 02:05

Hi Aki,

fvc::grad(A) should do the trick



deepsterblue July 4, 2011 22:51


I don't think that would work... The gradient of a tensor would contain 27 components, which Foam doesn't cater for at the moment. It can be done, just that the templates need to be instantiated, but that wouldn't be trivial.


kathrin_kissling July 5, 2011 02:05


you are totally right. I overlooked A being a tensor. I feel a little embarrassed about it.

Thank you for letting me know!


for what do you need this?
Do you just need the single components?

Best Kathrin

deepsterblue July 5, 2011 13:53

A simple workaround would be to store the gradient of each row of the tensor as another tensor, and manipulating that as necessary.

kathrin_kissling July 6, 2011 02:33

A not so simple way would be to use the VectorN library, which would make possible to have this huge tensor as a whole and add the fvc::grad for this special case. But for me it seems to be overengineered, as least as long as Aki doesn't need the complete tensor.
The question really is for what it is needed...

All times are GMT -4. The time now is 03:16.