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

How can I access to a volTensorField elements? urgent!!!

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 1 Post By Lieven
  • 5 Post By Lieven

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 14, 2013, 05:34
Default How can I access to a volTensorField elements? urgent!!!
  #1
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
Hi everybody,

I want to access to elements of a volTensorField. any body knows how can I do that?

thanks,
Mostafa
adambarfi is offline   Reply With Quote

Old   May 14, 2013, 07:27
Default
  #2
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 23
Lieven will become famous soon enough
Hi Mostafa,

This is from the top of my head so don't know if it's fully correct but it might help you in the right direction. Sepose T is the name of the tensorField:
Code:
forAll(T,cellI)
{
    const Tensor& t = T[cellI];

    // The components:
    scalar txx = t.xx();
    scalar txy = t.xy();
    ...
}
Cheers,

L
mm.abdollahzadeh likes this.
Lieven is offline   Reply With Quote

Old   May 14, 2013, 07:33
Default
  #3
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
thank you Lieven,

It's just for a Tensor not a volTensorField. I tried it before but it said that volTensorField has no member named ‘yy’.

again thank you.
Mostafa
adambarfi is offline   Reply With Quote

Old   May 14, 2013, 08:37
Default
  #4
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 23
Lieven will become famous soon enough
Hi Mostafa,

I don't really understand your post. First you say that it's not a volTensorField but only a tensor, and next you say that the error states "volTensorField has no member named 'yy'". I hope you can see the contradiction in this and clarify it for me...

Cheers,

L
Lieven is offline   Reply With Quote

Old   May 14, 2013, 09:31
Default
  #5
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
Quote:
Originally Posted by Lieven View Post
Hi Mostafa,

I don't really understand your post. First you say that it's not a volTensorField but only a tensor, and next you say that the error states "volTensorField has no member named 'yy'". I hope you can see the contradiction in this and clarify it for me...

Cheers,

L
pardon me Lieven,
I meant that what you said is applicable for Tensor type and when I used it for volTensorField it didn't work.

a question: what is the meaning of cellI in your post?
Code:
const Tensor& t=T[cellI]
adambarfi is offline   Reply With Quote

Old   May 14, 2013, 09:41
Default
  #6
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 23
Lieven will become famous soon enough
That's why I put it inside the forAll-loop so that it would loop over each cell (hence the meaning of CellI).
Just found out that the easier way to get the whole field immediately is (e.g. for component xy):
Code:
scalarField Txy = T.component(tensor::XY);
Cheers,

L
Lieven is offline   Reply With Quote

Old   May 14, 2013, 17:28
Default
  #7
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
A volTensorField is comprised of both internal values as well as boundary values assigned to patch faces.

I'm assuming you need to get to the internal field, this is how you do it:

Code:

       const tensorField& myTenF = myVolTensorField.internalField();


        forAll(myTenF,cellI)
        {
          tensor t = myTenF[cellI];
          scalar txx = t.xx();
          scalar txy = t.xy(); //etc...

         }
kmooney 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
Operate on volScalarField as whole v access elements adhiraj OpenFOAM 2 November 29, 2012 13:35
Urgent: Attempt to access un-allocated densityLe devesh.baghel STAR-CCM+ 0 July 19, 2011 03:44
Diagonal elements of a volTensorField CpCaniggia OpenFOAM Running, Solving & CFD 1 September 23, 2010 12:06
Urgent! Access violation of UDF using VOF Rucy FLUENT 0 January 9, 2006 05:01
CFX4.3 -build analysis form Chie Min CFX 5 July 13, 2001 00:19


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