CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Individual element of a symmetric matrix (https://www.cfd-online.com/Forums/openfoam-programming-development/213816-individual-element-symmetric-matrix.html)

gu1 January 9, 2019 07:26

Individual element of a symmetric matrix
 
Hello,

I would like to know how to extract the xy element from the strain rate tensor:

Quote:

volSymmTensorField S = symm(fvc::grad(U()));
Could someone help me write the code? How would I call the extracted element in an equation (epsilon equation for example)?

gu1 January 9, 2019 13:31

I wrote this snippet of code:

Code:

    Dxy_
    (
        IOobject
        (
            IOobject::groupName("Dxy", U.group()),
            runTime_.timeName(),
            mesh_,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        //symm(fvc::grad(U))().component(symmTensor::XY)
        U.mesh(),
        dimensionSet(0, 0, -1, 0, 0, 0, 0)
    ),

    volSymmTensorField D = symm(gU);   
   
    forAll(D, i)
    {
            Dxy_[i] = D[i].xy();
    }

...and I succeeded in what I wanted.
Unfortunately, however, the gradient of xy on the wall is giving zero and this causes the solver to give a floating-point error.

log: LINK

Could someone help me with how to solve this problem?

gu1 January 10, 2019 11:51

Anyone can help?

simrego January 11, 2019 06:32

Hi!


Add a little number (for example SMALL) to it so you can avoid the division with zero.

gu1 January 11, 2019 07:04

Quote:

Originally Posted by simrego (Post 721634)
Hi!

Add a little number (for example SMALL) to it so you can avoid the division with zero.

But the problem is not this ... if I use another method, it extracts values on the wall, that is, it is missing a piece in the code that guarantees the calculation of the value of the gradient on the wall.


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