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

Take derivative of mean velocity in paraFoam

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

Like Tree1Likes
  • 1 Post By Bernhard

Reply
 
LinkBack Thread Tools Display Modes
Old   January 30, 2014, 02:28
Default Take derivative of mean velocity in paraFoam
  #1
New Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 19
Rep Power: 3
hiuluom is on a distinguished road
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.
hiuluom is offline   Reply With Quote

Old   January 30, 2014, 04:30
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 788
Rep Power: 12
Bernhard is on a distinguished road
Why not using the FOAM framework for this with utilities foamCalc and foamCalcEx?
Bernhard is offline   Reply With Quote

Old   January 30, 2014, 05:04
Default
  #3
New Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 19
Rep Power: 3
hiuluom is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
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 is offline   Reply With Quote

Old   January 30, 2014, 05:43
Default
  #4
New Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 19
Rep Power: 3
hiuluom is on a distinguished road
Hi Bernhard,

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

Best regards,
Thanh.
hiuluom is offline   Reply With Quote

Old   January 30, 2014, 12:07
Default
  #5
New Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 19
Rep Power: 3
hiuluom is on a distinguished road
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
hiuluom is offline   Reply With Quote

Old   February 1, 2014, 09:48
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,441
Blog Entries: 33
Rep Power: 73
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
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

Last edited by wyldckat; February 1, 2014 at 17:55. Reason: see "edit:"
wyldckat is online now   Reply With Quote

Old   February 2, 2014, 12:42
Default
  #7
New Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 19
Rep Power: 3
hiuluom is on a distinguished road
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?
hiuluom is offline   Reply With Quote

Old   February 2, 2014, 14:22
Default
  #8
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,441
Blog Entries: 33
Rep Power: 73
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
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

Last edited by wyldckat; February 3, 2014 at 06:12. Reason: "I simply did you seemed logical" -> "I simply did what seemed logical"
wyldckat is online now   Reply With Quote

Old   February 3, 2014, 02:03
Default
  #9
New Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 19
Rep Power: 3
hiuluom is on a distinguished road
Hi Bruno,

It worked very good. I thank you so much.

Best regards,
Thanh.
hiuluom is offline   Reply With Quote

Old   February 3, 2014, 04:54
Default
  #10
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 788
Rep Power: 12
Bernhard is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
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?
Bernhard is offline   Reply With Quote

Old   February 3, 2014, 05:54
Default
  #11
New Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 19
Rep Power: 3
hiuluom is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
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.
hiuluom is offline   Reply With Quote

Old   February 3, 2014, 06:04
Default
  #12
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 788
Rep Power: 12
Bernhard is on a distinguished road
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.
wyldckat likes this.
Bernhard is offline   Reply With Quote

Old   February 4, 2014, 06:46
Default
  #13
New Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 19
Rep Power: 3
hiuluom is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
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.
hiuluom 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
unable to get parabolic velocity profile with pimplefoam houkensjtu OpenFOAM 4 October 8, 2012 05:41
WSS and normal velocity gradient for the slanted pipe wanna88 FLUENT 2 October 1, 2012 23:34
how to compute relative velocity from absolute? spk Main CFD Forum 3 July 9, 2010 09:42
Neumann pressure BC and velocity field Antech Main CFD Forum 0 April 25, 2006 03:15
what the result is negatif pressure at inlet chong chee nan FLUENT 0 December 29, 2001 06:13


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