CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Mathematic expression of grad(U)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 24, 2015, 07:35
Default Mathematic expression of grad(U)
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

I have just one question. In mostly all literature we find the gradient of a scalar \vec \nabla \phi or vector \vec \nabla \textbf{U} in that way. But in a mathematic point of view this is not correct for vectors.

So we get for any scalar:
\mathrm{grad}(\phi) = \vec \nabla \phi = \sum_{i=1}^{3} \frac{\partial \phi}{\partial x_i} \vec e_i
Of course I assume \vec \nabla as the partial differentials of the three directions and this is correct but

For any vector:
\mathrm{grad}(\textbf{U}) = (\vec \nabla \otimes \textbf{U})^T = (\vec \nabla \textbf{U})^T

My question now. Is it just a definition that we suppose that everybody know that \vec \nabla \textbf{U} is the transposed dyadic product of these two vectors? Because normally, \vec \nabla and \textbf{U} are two vectors with the matrix notation (3x1) and (3x1). Therefore we have to use the dyadic product of this operation and after that we really have to transpose that matrix to get the correct form of the gradient matrix.

Example:
\vec \nabla \textbf{U} = \vec\nabla \otimes \textbf{U}  \neq \mathrm{grad}(\textbf{U})

(\vec \nabla \textbf{U})^T = (\vec\nabla \otimes \textbf{U})^T = \vec\nabla \textbf{U}^T \overset{!}{=} \mathrm{grad}(\textbf{U})

Again. Is it a definition that in CFD numerics we say:
\vec \nabla \textbf{U} \overset{!}{=} (\vec \nabla \textbf{U})^T

I would kindly appreciate some feedback.
__________________
Keep foaming,
Tobias Holzmann

Last edited by Tobi; November 24, 2015 at 11:36.
Tobi is offline   Reply With Quote

Old   November 24, 2015, 12:12
Default
  #2
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Just for clarify the stuff. If we have the momentum equation we are using it in the same way like:

\vec \nabla \bullet (\rho \textbf{U}\textbf{U}) \overset{!}{=} \vec \nabla \bullet (\rho \textbf{U} \otimes \textbf{U})

Maybe I should ask more carefully. Are we always talking about the dyadic product if we have two vectors like above (\textbf{U} \textbf{U}) or \vec \nabla  \textbf{U}...
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   November 25, 2015, 07:20
Default
  #3
Member
 
Eysteinn Helgason
Join Date: Sep 2009
Location: Gothenburg, Sweden
Posts: 53
Rep Power: 16
eysteinn is on a distinguished road
Hi Tobias,

Just to give you some feedback
You are not the only one that thinks this notation can be unclear. I prefer
myself to use Einstein notation as it is clear what opperation is being performed.

For openfoam you can take a look in the ProgrammersGuide around page 25 (some old version had an error in this chapter, don't remember which one, but the new one should be up to date)

To my knowledge, this is generally used for outer (dyadic) product.

/Eysteinn
eysteinn is offline   Reply With Quote

Old   November 25, 2015, 07:36
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

thanks for the replay. So its clear now ... it is the the outer product of two vectors (dyadic). Of course it is clear that it has to be the outer product (dyadic) but you know, if you start derivating all the equations you get sometimes confused what they mean exactly.

So actually it is:

\textbf{U}\textbf{U}   \overset{!}{=} \textbf{U} \otimes \textbf{U}

\vec\nabla \textbf{U} \overset{!}{=} \vec \nabla \otimes \textbf{U}


Thanks for the replay. But at least I could answer my question myself due to the fact that I derived all equations and you always have to take the outer product. Otherwise it's not defined (:


Kind regards,
Tobi
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   December 1, 2015, 04:22
Default
  #5
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 14
danny123 is on a distinguished road
Hi Tobi,

Maybe this is of some help to you, this is my understanding:

OpenFOAM uses different notations whether it is applied to fields and tensors. The standard tensor or matrix multiplication is the sum of the multiplication of elements within one row of the left hand tensor with the elements of one column of the right hand tensor.

So, in short, you always apply the rule: go horizontal left hand side, then vertical right hand side. This is easy to grasp using some better software, which can handle matrix operations such as Mathcad.

The standard matrix multiplication typically has no operator (x, * or whatever, just nothing). Since this is difficult to descibe within a programming language, I guess, OpenFOAM uses dot and cross product for tensor operations:

a \cdot b = a^{T} b

and

a \times b = a b^{T}

In OpenFOAM, the dot product sign is "&", the cross product sign is "*". Since there is also a transpose operator ("T(...)"), you can describe all standard tensor multiplications by transposing either the right hand tensor or the left hand tensor.

This works for all tensor operations since the number are limited (3 dimensions)

3 x 1 and 3 x 1 (vector multiplied by vector),
3 x 3 and 3 x 1 (quadratic tensor multiplied by vector)
3 x 3 and 3 x 3 (
quadratic tensor multiplied by quadratic tensor)

To make things more confusing, OpenFOAM uses the "*" sign also as scalar multiplication sign (scalar multiplied by vector or tensor). There is no dyadic product in tensor multiplication of OpenFOAM that I know of. The dyadic product of 2 vectors is the product of each row, so you get a vector again. This method does not comply to the standard matrix multiplication.

For field operations, the annotation is totally different. In OpenFOAM, the multiplication of two fields is always the
dyadic product. The sign that is used for mutiplication then defines what is done within one field element, e.g. dot product or cross product. The word "field" in OpenFOAM is a vector of a number of elements (e.g. cells) that can be scalars, vectors or tensors. For matrix field multiplication, OpenFOAM uses the standard multiplication form (Apsi for A psi or Atpsi for transpose A psi). A matrix (fv matrix class) is always a quadratic cell volume matrix (rows = columns = number of cells), whereas fields can be volume fields (rows = number of cells, + patches) and surface fields (rows are number of internal faces, + patches). This is also why a matrix multiplication between a matrix and a surface field is not possible (the number of columns of the matrix needs to be identical to the number of rows of the field).

Hope this makes things a little more clear.

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   December 14, 2015, 06:15
Default
  #6
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 14
danny123 is on a distinguished road
Hello,

I have to excuse myself, but some of my above statements are wrong. What I have called "standard" multiplication is, according to Wikipedia, just a matrix multiplication. According to the same source, the outer product and the dyadic product is the same, just a different annotation.

The multiplications of fields in OpenFOAM, row by row, has no name that I know of. It is not the dyadic product though.

The rule of transformation of outer and scalar products by transposing the left or right vector does not work for vector and tensor multiplication. A matrix multiplication of a vector by a tensor is not defined, since column number of the vector has to correpond to the row number of the tensor. Transposing the tensor does not help, you only can transpose the vector. You then get a one row tensor as a result. The result is the same as the transpose of the matrix multiplication of the transposed tensor by the vector.

In OpenFOAM, the multiplication of a vector by a tensor do exist (e.g. in the fvc::reconstruct code). The code uses the "*" sign. It is not clear to me what this sign means in this context. The result should be a vector.

If you look at your example of nabla dot U x U: Since the dot sign shall reduce the dimension, so U x U is a tensor, the dot sign reduces back to a vector. This makes sense. But which matrix multiplication is applied, using the tensor as it is or the transpose of it?

The last example is obviously of no practicable use, since the code looks very differently (It is a surface integrate of a surface multiplication of phi or rhoPhi and u using weight factors).

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   December 14, 2015, 06:34
Default
  #7
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by danny123 View Post
Hello,
If you look at your example of nabla dot U x U: Since the dot sign shall reduce the dimension, so U x U is a tensor, the dot sign reduces back to a vector. This makes sense. But which matrix multiplication is applied, using the tensor as it is or the transpose of it?

Daniel
Dear Daniel,

you use the tensor which you get as it is by the dyadic product. Then just use the divergence convention and thats it.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   December 14, 2015, 08:17
Default
  #8
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 14
danny123 is on a distinguished road
Hello Tobi,

Thanks for the hint, but what is the dot convention for vector tensor multiplications?

In OpenFOAM, fvcReconstruct.C:

Code:
inv(surfaceSum(SfHat*mesh.Sf()))&surfaceSum(SfHat*ssf)
inv(surfaceSum(SfHat*mesh.Sf()) is a tensor (outer product SfHat and mesh.Sf()). surfaceSum(SfHat*ssf) is a vector. So, something like this:

A = \left [ \sum_{f}\left ( \frac{S_{f}}{\left |S_{f}  \right |}\times S_{f} \right ) \right ]^{-1}

and:

x =  \sum_{f}\left ( \frac{S_{f}}{\left |S_{f}  \right |}  \varphi _{f} \right )

Remark: for the multiplication between scalar and vector, I left the multiplier sign off how it is usually done in mathematic formula, in OpenFOAM, the "*" is used.

So (b shall be the result vector):

b =  A\cdot x

The result of this multiplication is a vector. This, I am sure. A is the inverse of a symmetric tensor. This, I know too, since the outer product of two vectors is a symmetric tensor. I want to rewrite this into a matrix multiplication, something like:

b =  A^{\ast } x

So, is A* equal to A or A transpose or what? If I want to invert A*, then do a multiplication to b, how does it look like? How to use the dot sign then?

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   December 14, 2015, 08:34
Default
  #9
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Dear Daniel

please do not mix that one:

\otimes \neq \times

The first one is the dyadic product the second one is the curl. They are treated in different ways!
Additionally your equation is somehow not identical with the code (--> x = ). Where is mesh.Sf() in the second term in the code?

At least I did not check the equation. Its just some hint, especially with the curl and dyadic product.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   December 14, 2015, 09:41
Default
  #10
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 14
danny123 is on a distinguished road
Hello Tobi,

You are correct. In MatCad, the X sign is the vector product sign. Since vector product = outer product = dyadic product, this is just another way to confuse people.

So, let's settle on \otimes for that product.

I found the following link:

http://people.rit.edu/pnveme/EMEM851...sors_rect.html

a and b shall be vectors, A and B tensors:


a\cdot b =  a^{T}b

and:


a\otimes b =  a b^{T}

Now, according to that above link:

A\cdot b =  A\, b

This is such in MathCad, in OpenFOAM?

The reverse is:

a\cdot B =  B^{T}\, a

Finally two tensors:

A\cdot B =  A\, B

This basically solves that problem, that you have (if the link is correct):

\nabla\cdot \left (U\otimes U \right )  = \left (U\, U^{T}  \right )^{T}\nabla

Do you agree?

Regards,

Daniel
danny123 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlet boundary condition in interFoam Andrea_85 OpenFOAM Running, Solving & CFD 51 July 20, 2017 13:31
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 18:44
CGNS lib and Fortran compiler manaliac Main CFD Forum 2 November 29, 2010 06:25
Lift, Drag Vs time chart,calculations Jamesd69climber CFX 8 February 17, 2005 17:23


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