CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How can I access to a volTensorField elements? urgent!!! (http://www.cfd-online.com/Forums/openfoam-solving/117716-how-can-i-access-voltensorfield-elements-urgent.html)

adambarfi May 14, 2013 04:34

How can I access to a volTensorField elements? urgent!!!
 
Hi everybody,

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

thanks,
Mostafa

Lieven May 14, 2013 06:27

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

adambarfi May 14, 2013 06:33

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

Lieven May 14, 2013 07:37

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

adambarfi May 14, 2013 08:31

Quote:

Originally Posted by Lieven (Post 427425)
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]

Lieven May 14, 2013 08:41

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

kmooney May 14, 2013 16:28

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...

        }



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