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

Tensor manipulation for custom vector equation source term

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 19, 2021, 04:59
Default Tensor manipulation for custom vector equation source term
  #1
Member
 
Andrea Di Ronco
Join Date: Nov 2016
Location: Milano, Italy
Posts: 55
Rep Power: 9
Diro7 is on a distinguished road
Hi!

In a solver I'm working on I need to perform some algebraic manipulation of tensors in order to build a source term for a vector equation.
More specifically, I need to implement this expression:

F_i \propto \sum_{\substack{k=1\\k \neq i}}^3 \left| \frac{\partial U_k}{\partial x_i} \right|^{\frac{1}{2}} (U_k - V_k)

Where \textbf{V} is an additional velocity field for which the equation is solved, and \textbf{U} is the standard fluid velocity field.
I thought it could be useful to write the same expression in vector form in order to directly implement it as a vector equation. With some manipulation

\mathbf{F} \propto \left| \nabla \textbf{U} - \textrm{diag}(\nabla \textbf{U}) \right|^{\frac{1}{2}} (\textbf{U} - \textbf{V})

where the operation \left| \cdot \right|^{\frac{1}{2}} is intended element-wise. Now I'm faced with at least a couple of issues:

1) assemble the tensor \textbf{T} = \nabla \textbf{U} - \textrm{diag}(\nabla \textbf{U})

2) perform the operation \left| \textbf{T} \right|^{\frac{1}{2}}

3) perform the matrix product between \left| \textbf{T} \right|^{\frac{1}{2}} and (\textbf{U} - \textbf{V})

Due to my somewhat limited knowledge of the OpenFOAM library, for the moment I neglected 2).
What I came up with is:
Code:
fvVectorMatrix F(fvc::grad(U) - diag(fvc::grad(U)) & (U - V));
Unfortunately the extraction of the diagonal is not working as expected and I keep getting
Code:
error: no match for ‘operator-’ (operand types are ‘Foam::tmp<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >’ and ‘Foam::tmp<Foam::Field<Foam::DiagTensor<double> > >’)
     fvVectorMatrix F(fvc::grad(U) - diag(fvc::grad(U)) & (U - V));
It seems like the diag(volTensorField) function returns a different type which is incompatible with volTensorField.

Does anyone know how to properly extract/subtract the diagonal contribution from a volTensorField object? In my limited experience, I couldn't find any other related function.
Furthermore, how can I perform the element-wise operations described in 2)?

Or maybe I'm just following the wrong road and someone knows a better way to perform my task.
Of course any advice or observation would be greatly appreciated!

Regards,
Andrea
Diro7 is offline   Reply With Quote

Reply

Tags
tensor

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[Other] Tabulated thermophysicalProperties library chriss85 OpenFOAM Community Contributions 62 October 2, 2022 03:50
Source Term due to evaporation in energy transport equation styleworker OpenFOAM Programming & Development 3 September 7, 2022 03:09
Source term for EVAPORATION in Energy Equ. - technical difficulty ? Kummi OpenFOAM 1 September 9, 2019 09:32
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 09:07
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24


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