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

Diagonal Form of a Symmetric Tensor

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

Reply
 
LinkBack Thread Tools Display Modes
Old   July 31, 2015, 11:48
Default Diagonal Form of a Symmetric Tensor
  #1
Member
 
Paolo Capobianchi
Join Date: Sep 2014
Posts: 32
Rep Power: 4
pablitobass is on a distinguished road
Hello everyone,

I'm trying to calculate the diagonal of a symmetric tensor, but without success. The part of code I wrote is this one:
Code:
Foam::symmTensor 
Foam::ConfOldroyd_B::D() const
{
   return diag(a_);
}
Since the tensor a_ is symmetric, the diagonal form must exist.

Furthermore I have extracted the tensor a_ from the symmTensorField

Code:
    A_
    (
            IOobject
            (
            "A",
            U.time().timeName(),
            U.mesh(),
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
            ),
            U.mesh()
    )
using a forAll loop
Code:
Foam::symmTensor 
Foam::ConfOldroyd_B::a() const
{
    
    forAll(A_,celli)
    {
       A_[celli];
    }
        
    return a_;              

}
If I did everything in the right way, the loop should give me an array whose element are symmetric tensors associated whit each celli. Is that right?

This is the error message I get when I compile

Quote:
error: could not convert ‘Foam::diag(const Foam::SymmTensor<Cmpt>&) [with Cmpt = double]()’ from ‘Foam:iagTensor<double>’ to ‘Foam::symmTensor {aka Foam::SymmTensor<double>}
p.s I have tried all the operation "exclusive to tensors of rank 2" I found on the user manual. All of them work fine except the "diag(T)" one.

Does anyone have an idea about what might be the problem?

Many thanks in advantage.

Regards,
Paolo
pablitobass is offline   Reply With Quote

Old   July 31, 2015, 19:35
Default
  #2
Member
 
Paolo Capobianchi
Join Date: Sep 2014
Posts: 32
Rep Power: 4
pablitobass is on a distinguished road
I have just found another thread about the same topic.

It seems that the problem can be solved by using DiagTensor instead of diag().

However, I had a look into the file DiagTensor.H and it seems that it returns a tensor whose elements are only the diagonal of the original tensor. In other words, the result is a tensor whose out diagonal elements have been deleted.

In my case, I need the diagonal form of the tensor as a solution of the eigenvalues problem, therefore the previous method does not work for me.

Sorry for the useless question.

Regards,
Paolo
pablitobass is offline   Reply With Quote

Old   August 5, 2015, 11:22
Default
  #3
Member
 
Paolo Capobianchi
Join Date: Sep 2014
Posts: 32
Rep Power: 4
pablitobass is on a distinguished road
I hope I found a way to get the tensor I was looking for. I also used it to calculate the logartihm of the tensor A_. The code I wrote is this one
Code:
Foam::tensor 
Foam::Oldroyd_B_Conform::teta() const
{
    
    forAll(A_, cellI)
    {

        tensor a_ = A_[cellI];


        tensor Omega_ = eigenVectors(a_);
        tensor OmegaT_ = eigenVectors(a_).T();

        OmegaT_ & a_ & Omega_ =  D_ ;

        scalar log_d_x = log(D_.xx());
        scalar log_d_y = log(D_.yy());
        scalar log_d_z = log(D_.zz());

        tensor (

           log_d_x,    0,      0,
               0,  log_d_y,    0,
               0,      0,   log_d_z

           ) = log_D_;

           Omega_ & log_D_ & OmegaT_ =  teta_;

    }

    return teta_;

}
I tried to output the tensor and at least something has bee calculated; I still do not know whether is right or not.

However, I have a couple of (more) doubts:

1. Is it normal that the code prints on screen just one tensor teta_? I expected it to be an array of tensors.

2. Since I have to solve a trasport equation for teta_, does anyone know how to re-create a volTensorField from the teta_ tensors?

Thanks

Paolo
pablitobass is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is symmetric tensor assumed in CFD? andyCas Main CFD Forum 6 June 26, 2014 08:02
why divergence occures in these cases immortality OpenFOAM Running, Solving & CFD 2 January 25, 2013 11:21
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 04:34
Problems compiling with the 'diag' tensor function (diagonal components matrix) danihuso OpenFOAM Programming & Development 12 January 31, 2012 11:45
pressure equation in tensor form student Main CFD Forum 0 August 10, 2009 13:41


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