CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Paraview & paraFoam (http://www.cfd-online.com/Forums/openfoam-paraview/)
-   -   Take derivative of mean velocity in paraFoam (http://www.cfd-online.com/Forums/openfoam-paraview/129168-take-derivative-mean-velocity-parafoam.html)

hiuluom January 30, 2014 02:28

Take derivative of mean velocity in paraFoam
 
I run LES simulation with pisoFoam and it's finish. And now, I would like to calculate derivative of mean velocity in parafoam also paraview.
\frac{\partial^2 \langle u_i\rangle}{\partial x_j^2}
\frac{\partial \langle u_i\rangle}{\partial x_j}
<u> it means umean.
I computed umean by fieldAverage in OpenFOAM and now I want to compute derivative above.

Anyone can help me how to get it in parafoam?

Thanks your help.

Bernhard January 30, 2014 04:30

Why not using the FOAM framework for this with utilities foamCalc and foamCalcEx?

hiuluom January 30, 2014 05:04

Quote:

Originally Posted by Bernhard (Post 472488)
Why not using the FOAM framework for this with utilities foamCalc and foamCalcEx?

Hi Bernhard,

I see in command foamCalc has div function.But \frac{\partial^2 \langle u_i\rangle}{\partial x_j^2} is the laplacian, which is div(grad(umean)).
and about first derivative of umean?

I use OpenFOAm 2.1.1, I don't see foamCalcEx as you said. Could you show me clearly?

Thank you,
Thanh

hiuluom January 30, 2014 05:43

Hi Bernhard,

I saw your code extended of foamCalcEx on google. Thank you so much your code.

Best regards,
Thanh.

hiuluom January 30, 2014 12:07

When I used command foamCalc or foamCalcEx to calculate div(U) and grad(U) but I meet error. Can anyone check help me?
Code:

Selecting calcType div
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.1.1-221db2718bbb
Exec  : foamCalc div U
Date  : Jan 30 2014
Time  : 23:03:37
Host  : "compeng"
PID    : 7276
Case  : /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Time = 0
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.01
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.02
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.03
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.04
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.05
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.06
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.07
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.08
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.09
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.1
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.10001
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.11
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.12
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

Time = 0.13
    Reading U
    Calculating divU
--> FOAM Warning :
--> FOAM FATAL IO ERROR:
keyword div(U) is undefined in dictionary "/home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes"

file: /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily/system/fvSchemes::divSchemes from line 36 to line 45.

    From function dictionary::lookupEntry(const word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 400.

End


wyldckat February 1, 2014 09:48

Greetings to all!

To answer the original question: there is a filter named "Compute Derivatives", but it doesn't seem to be able to calculate the laplacian.
edit: In the Python Calculator, it does seem possible to use the "laplacian" function: http://www.paraview.org/Wiki/ParaVie...hon_Calculator


As for the latest post: the "div(U)" entry is missing from the file "system/fvSchemes". You can find several examples for such an entry by running this command:
Code:

find $FOAM_TUTORIALS -name "fvSchemes" | xargs grep "div(U)"
If you have a look into the file "compressible/rhoPimpleFoam/ras/cavity/system/fvSchemes" on the tutorials folder, you'll see this block of code:
Code:

divSchemes
{
    default none;
    div(phi,U) Gauss limitedLinearV 1;
    div(phid,p) Gauss limitedLinear 1;
    div(phi,K) Gauss linear;
    div(phi,h) Gauss limitedLinear 1;
    div(phi,k) Gauss limitedLinear 1;
    div(phi,epsilon) Gauss limitedLinear 1;
    div(phi,R) Gauss limitedLinear 1;
    div(phi,omega) Gauss limitedLinear 1;
    div((rho*R)) Gauss linear;
    div(R) Gauss linear;
    div(U) Gauss linear;
    div((muEff*dev2(T(grad(U))))) Gauss linear;
}

If you look carefully, you'll see the line that starts with "div(U)". You need to add that line to the file "system/fvSchemes" in your case, inside the same block "divSchemes".

Best regards,
Bruno

hiuluom February 2, 2014 12:42

Hi Bruno,

I thank you so much about this guide, I can calculate div(U) but grad(U) can not compute. In fvscheme has defined grad(U):
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.x                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
    default backward;
}

d2dt2Schemes
{
}

gradSchemes
{
    default        Gauss linear;

    grad(nuTilda)  cellLimited Gauss linear 1;
    grad(U)        cellLimited Gauss linear 1;
}

divSchemes
{
    default        none;

    div(phi,U)      Gauss LUST unlimitedGrad(U);
    //div(phi,U)      Gauss linearUpwind unlimitedGrad(U);
    //div(phi,k)      Gauss limitedLinear 1;
    //div(phi,k)      Gauss upwind;
    div(phi,k)      Gauss SFCD;
    div(phi,nuTilda) Gauss limitedLinear 1;
        div(U)          Gauss linear;
    div((nuEff*dev(T(grad(U))))) Gauss linear;
}

laplacianSchemes
{
    default        Gauss linear limited 0.33;
}

interpolationSchemes
{
    default        linear;
}

snGradSchemes
{
    default        limited 0.33;
}

fluxRequired
{
    default        no;
    p;
}

// ************************************************************************* //

And this is error.
Code:

Selecting calcType grad
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.1.1-221db2718bbb
Exec  : foamCalcEx grad U
Date  : Feb 02 2014
Time  : 23:33:44
Host  : "compeng"
PID    : 2674
Case  : /home/huynh/OpenFOAM/huynh-2.1.1/run/pitzDaily
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Time = 0


--> FOAM FATAL ERROR:
Unable to process U
No call to grad for fields of type volVectorField

I really want to calculate \frac{\partial \langle u_i\rangle}{\partial x_j}= grad(UMean) and \frac{\partial^2 \langle u_i\rangle}{\partial x_j^2} =laplacian(UMean) = div(grad(UMean)). I only have computed div(UMean) up to now. Could you show me my error?

wyldckat February 2, 2014 14:22

Hi Huynh,

foamCalcEx is missing the ability to handle "grad(U)" and "div(gradU)".
I've finished doing a bug report and respective patch for this here: http://code.google.com/p/foamcalcex/issues/detail?id=2

Download the patch file "changes.patch" from that bug report and place the file inside the folder "foamCalcEx". Then run:
Code:

patch -p1 < changes.patch
./Allwmake

Now go into your case folder and run:
Code:

foamCalcEx grad U
foamCalcEx div gradU

It will likely complain about the missing "div(gradU)", but I think you now know what to do ;)


WARNING: I have not checked if the results given are correct. I simply did what seemed logical in the source code... and the results seemed sane enough.

Best regards,
Bruno

hiuluom February 3, 2014 02:03

Hi Bruno,

It worked very good. I thank you so much.

Best regards,
Thanh.

Bernhard February 3, 2014 04:54

Quote:

Originally Posted by wyldckat (Post 473006)
WARNING: I have not checked if the results given are correct. I simply did you seemed logical in the source code... and the results seemed sane enough.

That's why we didn't include it in the utility up till now, following the Gschaider-philosophy to implement what you need. Anton is working on including your patch.

Thanh, can you let us know your experience with using this patch?

hiuluom February 3, 2014 05:54

Quote:

Originally Posted by Bernhard (Post 473081)
Thanh, can you let us know your experience with using this patch?

Actually I am proving the variance of pressure equation:
\begin{split}
\frac{1}{2\rho}\frac{\partial\langle p'^2\rangle}{\partial x_i} &=\nu\langle p\frac{\partial^2 u_i}{x_j^2}\rangle -\nu\langle p\rangle\frac{\partial^2\langle u_i\rangle}{\partial x_j^2} \\
& \quad -\langle pu_j\frac{\partial u_i}{\partial x_j}\rangle + \langle p\rangle\langle u_j\rangle\frac{\partial\langle u_i\rangle}{\partial x_j} + \langle p\rangle\frac{\partial\langle u'_iu'_j\rangle}{\partial x_j}\\
& \quad-\langle p\frac{\partial u_i}{\partial t}\rangle
\end{split}
I have average of all these terms above by edit pisoFoam. I only prove left hand side equal to the right hand side of equation by using paraFoam, but gradient and laplacian of mean velocity does not have. So I must calculate it and using parafoam insert equation above.

About the patch of Bruno, I only did following the guide of him. I added command div(U) and div(grad(U)) in fvscheme.

Best regards,
Thanh.

Bernhard February 3, 2014 06:04

foamCalcEx was mainly designed for quick and dirty calculation of single operations. If you want to do whole expressions like this, I would recommend funkyDoCalc.

hiuluom February 4, 2014 06:46

Quote:

Originally Posted by Bernhard (Post 473096)
foamCalcEx was mainly designed for quick and dirty calculation of single operations. If you want to do whole expressions like this, I would recommend funkyDoCalc.

Thanks Bermhard. I will try funkyDoCalc.


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