CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (https://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   Bug in the programmer's guide: divergence of a tensor field (https://www.cfd-online.com/Forums/openfoam-bugs/104867-bug-programmers-guide-divergence-tensor-field.html)

sebastian July 17, 2012 11:01

Bug in the programmer's guide: divergence of a tensor field
 
Hi everybody!

I wonder if there is a bug in the programmer's guide of OpenFOAM.

In chapter 2.1.2 the divergence of a tensor field is given as

\nabla \bullet T = \partial_i T_{ij}=\left( 
\begin{matrix}
 \frac{\partial T_{11}}{\partial x_1} 	+ \frac{\partial T_{12}}{\partial x_1} 	+ \frac{\partial T_{13}}{\partial x_1}\\
 \frac{\partial T_{21}}{\partial x_2} 	+ \frac{\partial T_{22}}{\partial x_2} 	+ \frac{\partial T_{23}}{\partial x_2}\\
 \frac{\partial T_{31}}{\partial x_3} 	+ \frac{\partial T_{32}}{\partial x_3} 	+ \frac{\partial T_{33}}{\partial x_3}	
\end{matrix}
 \right)

In my opinion this is wrong. After the convention in chapter 1.3.1 (inner product) it should be instead

\nabla \bullet T =
\left( 
\begin{matrix}
 \frac{\partial }{\partial x_1}, & \frac{\partial }{\partial x_2}, & \frac{\partial}{\partial x_3}
\end{matrix}
 \right)
\bullet
\left( 
\begin{matrix}
  T_{11} &	T_{12} &	T_{13}	\\
  T_{21} &	T_{22} &	T_{33}	\\
  T_{31} &	T_{32} &	T_{33}	\\
\end{matrix}
 \right) 
=\partial_j T_{ji}=\left( 
\begin{matrix}
 \frac{\partial T_{11}}{\partial x_1} 	+ \frac{\partial T_{21}}{\partial x_2} 	+ \frac{\partial T_{31}}{\partial x_3}\\
 \frac{\partial T_{12}}{\partial x_1} 	+ \frac{\partial T_{22}}{\partial x_2} 	+ \frac{\partial T_{33}}{\partial x_3}\\
 \frac{\partial T_{13}}{\partial x_1} 	+ \frac{\partial T_{32}}{\partial x_2} 	+ \frac{\partial T_{33}}{\partial x_3}	
\end{matrix}
 \right)

Can anybody confirm that or do I make something wrong here?
How is the implementation, does anybody know?


Sebastian

l_r_mcglashan July 17, 2012 14:54

It depends on if you multiply a row vector by a tensor or a tensor by a column vector. We want the tensor to act on the vector. What you've written should be:

\nabla \bullet T =
\left( 
\begin{matrix}
  T_{11} &    T_{12} &    T_{13}    \\
  T_{21} &    T_{22} &    T_{33}    \\
  T_{31} &    T_{32} &    T_{33}    \\
\end{matrix}
\right)
\left(
\begin{matrix}
  \frac{\partial }{\partial x_1} \\
  \frac{\partial }{\partial x_2} \\
  \frac{\partial }{\partial x_3} 
\end{matrix}
\right)

sebastian July 17, 2012 15:35

Dear Laurence, thanks for your post.

When I look up for the definition of the divergence of a tensor field, on wikipedia for instance this is
\nabla \bullet T = \frac{\partial T_{ki}}{\partial x_i} e_k
This does not agree with the programmer's guide. Why should it be different in OpenFOAM?

Sebastian

l_r_mcglashan July 17, 2012 17:15

The programmer's guide is not maintained anymore.

Anyway, how about:

\partial_j T_{ji} = \partial_i T_{ij}

sebastian July 18, 2012 02:38

I am not talking about if it's a i, j or k.

\text{div}T=
\left( 
\begin{matrix}
 \frac{\partial T_{11}}{\partial x_1} 	+ \frac{\partial T_{21}}{\partial x_2} 	+ \frac{\partial T_{31}}{\partial x_3}\\
 \frac{\partial T_{12}}{\partial x_1} 	+ \frac{\partial T_{22}}{\partial x_2} 	+ \frac{\partial T_{32}}{\partial x_3}\\
 \frac{\partial T_{13}}{\partial x_1} 	+ \frac{\partial T_{23}}{\partial x_2} 	+ \frac{\partial T_{33}}{\partial x_3}	
\end{matrix}
 \right)
\neq
\left(
\begin{matrix}
 \frac{\partial T_{11}}{\partial x_1} 	+ \frac{\partial T_{12}}{\partial x_1} 	+ \frac{\partial T_{13}}{\partial x_1}\\
 \frac{\partial T_{21}}{\partial x_2} 	+ \frac{\partial T_{22}}{\partial x_2} 	+ \frac{\partial T_{23}}{\partial x_2}\\
 \frac{\partial T_{31}}{\partial x_3} 	+ \frac{\partial T_{32}}{\partial x_3} 	+ \frac{\partial T_{33}}{\partial x_3}	
\end{matrix}
 \right)

The programmer's guide is obviously wrong.

l_r_mcglashan July 18, 2012 05:53

Ah, sorry! Yes, the programmer's guide is incorrect.

hhouston January 18, 2013 22:03

error in wikipedia
 
Hey, the following eq from wikipedia posted higher up in this thread has a typo:

"When I look up for the definition of the divergence of a tensor field, on wikipedia for instance this is
http://www.cfd-online.com/Forums/vbL...3f1e0b73-1.gif "
and further it is not consistent with the other parts of this thread - it should be Tik not Tki .

Also there are some typos in the matrices you put up, but they are not too hard to figure out. And the overall thrust of the thread is correct.

hhouston January 18, 2013 22:05

that is,

http://www.cfd-online.com/Forums/vbL...6d6ea3a6-1.gif

wyldckat September 7, 2013 06:09

FYI: I've consolidated this information here: http://openfoamwiki.net/index.php/Op...s_Guide_Errata

Feel free to add to this wiki page.

By the way, the issue reported on this thread has already been fixed on the Programmer's Guide since OpenFOAM 2.2.0, at least from what I could find.

gustavorp June 9, 2016 14:21

2 Attachment(s)
I found several books and papers about tensors. Most of them are showing this:

Attachment 48139

and

Attachment 48140

I have implemented an algorithm in python to compute the tensor divergence to a 3d tensor field.

I am not sure if my implementation is correct. Does any one have some tensor field and its divergence to compare?

It could be a .txt, .mat, .py, etc.

Thank you


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