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.

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

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

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 and . 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: 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.  FlorisvdBeek April 26, 2016 06:44 "grad(phi) undefined" error Hi guys! [EDIT]: Pffff my bad, lack of reading the error message properly.. It was referring to the multiRegion fvScheme file (in system/FluidRegion1), not the original file (system/fvScheme) which I had not defined at all yet. So, problem solved! I am quite new to OpenFOAM (so I hope this is a piece of cake for you guys ;) ) and Im modifying the electrostaticsFoam into a multiRegion solver, but Im running into a similar problem as reported. Im trying to calculate the electric field (just as they do in the original electrostaticsFoam) during createField initialization. Compiling goes well, but when I run a case I get the following error: Code: $ electrostaticMultiRegionFoam /*---------------------------------------------------------------------------*\ | =========                |                                                | | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          | |  \\    /  O peration    | Version:  3.0.1                                | |  \\  /    A nd          | Web:      www.OpenFOAM.org                      | |    \\/    M anipulation  |                                                | \*---------------------------------------------------------------------------*/ Build  : 3.0.1-119cac7e8750 Exec  : electrostaticMultiRegionFoam Date  : Apr 26 2016 Time  : 12:29:04 Host  : "floris-SATELLITE-L850-184" PID    : 5875 Case  : /home/floris/OpenFOAM/floris-3.0.1/run/dischargeCase/electrostaticFoam/02_opposingConductorsMultiRegion nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create fluid mesh for region Fluid1 for time = 0 Create solid mesh for region Solid1 for time = 0 Reading physicalProperties *** Reading fluid mesh thermophysical properties for region Fluid1     Adding to rho     Adding to phi     Calculating field magE --> FOAM FATAL IO ERROR: keyword grad(phi) is undefined in dictionary "/home/floris/OpenFOAM/floris-3.0.1/run/dischargeCase/electrostaticFoam/02_opposingConductorsMultiRegion/system/Fluid1/fvSchemes.gradSchemes" file: /home/floris/OpenFOAM/floris-3.0.1/run/dischargeCase/electrostaticFoam/02_opposingConductorsMultiRegion/system/Fluid1/fvSchemes.gradSchemes     From function dictionary::lookupEntry(const word&, bool, bool) const     in file db/dictionary/dictionary.C at line 442. FOAM exiting
I am calculating the electric field magnitude magE in "createField.H" accordingly:

Code:

// Initialise fluid field pointer lists PtrList<volScalarField> rhoFluid(fluidRegions.size()); PtrList<volScalarField> phiFluid(fluidRegions.size()); PtrList<surfaceScalarField> rhoFluxFluid(fluidRegions.size()); PtrList<volScalarField> magEFluid(fluidRegions.size()); PtrList<volVectorField> EFluid(fluidRegions.size()); PtrList<dimensionedScalar> kFluid(fluidRegions.size()); PtrList<dimensionedScalar> epsilon0Fluid(fluidRegions.size()); // Populate fluid field pointer lists forAll(fluidRegions, i) {         Info<< "Reading physicalProperties\n" << endl;     IOdictionary physicalProperties     (         IOobject         (             "physicalProperties",             runTime.constant(),             fluidRegions[i],             IOobject::MUST_READ_IF_MODIFIED,             IOobject::NO_WRITE         )     );             dimensionedScalar epsilon0     (         physicalProperties.lookup("epsilon0")     );     dimensionedScalar k     (         physicalProperties.lookup("k")     );         Info<< "*** Reading fluid mesh thermophysical properties for region "         << fluidRegions[i].name() << nl << endl;             Info<< "    Adding to rho\n" << endl;         rhoFluid.set         (             i,             new volScalarField             (                 IOobject                 (                     "rho",                     runTime.timeName(),                     fluidRegions[i],                     IOobject::MUST_READ,                     IOobject::AUTO_WRITE                 ),                 fluidRegions[i]             )         );         Info<< "    Adding to phi\n" << endl;         phiFluid.set         (             i,             new volScalarField             (                 IOobject                 (                     "phi",                     runTime.timeName(),                     fluidRegions[i],                     IOobject::MUST_READ,                     IOobject::AUTO_WRITE                 ),                 fluidRegions[i]             )         );             Info<< "    Calculating field magE\n" << endl;         magEFluid.set         (             i,             new volScalarField             (                 IOobject                 (                     "magE",                     runTime.timeName(),                     fluidRegions[i],                     IOobject::NO_READ,                     IOobject::AUTO_WRITE                 ),                 mag(fvc::grad(phiFluid[i]))             )         );         Info<< "    Calculating field E\n" << endl;         EFluid.set         (             i,             new volVectorField             (                 IOobject                 (                     "E",                     runTime.timeName(),                     fluidRegions[i],                     IOobject::NO_READ,                     IOobject::AUTO_WRITE                 ),                 -fvc::grad(phiFluid[i])             )         );         Info<< "    Calculating field rhoFlux\n" << endl;                rhoFluxFluid.set         (             i,             new surfaceScalarField             (                 IOobject                 (                     "rhoFlux",                     runTime.timeName(),                     fluidRegions[i],                     IOobject::NO_READ,                     IOobject::NO_WRITE                 ),         -k*fluidRegions[i].magSf()*fvc::snGrad(phiFluid[i])             )         ); }
I should have the grad operator defined properly in fvSchemes:

Code:

/*--------------------------------*- C++ -*----------------------------------*\ | =========                |                                                | | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          | |  \\    /  O peration    | Version:  3.0.1                                | |  \\  /    A nd          | Web:      www.OpenFOAM.org                      | |    \\/    M anipulation  |                                                | \*---------------------------------------------------------------------------*/ FoamFile {     version    2.0;     format      ascii;     class      dictionary;     location    "system";     object      fvSchemes; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ddtSchemes {     default        Euler; } gradSchemes {     default        leastSquares;     grad(phi)      leastSquares;     grad(phiFluid[i])      leastSquares;     grad(phiFluid)      leastSquares; } divSchemes {     default        none;     div(rhoFlux,rho) Gauss upwind; } laplacianSchemes {     default        none;     laplacian(phi)  Gauss linear corrected; } interpolationSchemes {     default        linear; } snGradSchemes {     default        corrected;     snGrad(phi)    corrected; } // ************************************************************************* //
I have tried playing around with the fvSchemes input, but haven't found a solution yet.

Anyone any idea what may go wrong here ?

Thanks,
Floris

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