|
[Sponsors] |
September 15, 2021, 11:42 |
Write a script to modify the data in files?
|
#1 |
Senior Member
|
Hi,
I wrote a script to arrange the files based on the data post-processed by openfoam automatically, as below. However, I cannot use the original data in the 'p' files. Instead, I have to subtract p by a value. Anyone has ideas to make this change? Thanks. Code:
patchname='patch_ground' newpatchname='top' variableFoldername=$patchname variablename='p' variaWriteName='p' cp -r postProcessing/toppressuredata/surface . for d in ./surface/* do mkdir -p ./boundaryData/$newpatchname/$d/ #Write the default headline contents into the files echo 'FoamFile { version 2.0; format ascii; class scalarAverageField; object values; } // **********************************************************************// 0.0' > ./boundaryData/$newpatchname/$d/$variaWriteName #copy values from /surface folder to /boundaryData folder cat ./$d/$variableFoldername/scalarField/$variablename >> ./boundaryData/$newpatchname/$d/$variaWriteName #mv ./boundaryData/newpatchname/$d ./boundaryData/newpatchname done #Transfer the format of the corresponding 'points' file echo 'FoamFile { version 2.0; format ascii; class vectorField; object points; } // ******************************************************************************************// ' > ./boundaryData/$newpatchname/points cat ./$d/$variableFoldername/faceCentres >> ./boundaryData/$newpatchname/points #Transfer the format of the corresponding 'faces' file echo 'FoamFile { version 2.0; format ascii; class faceList; object faces; } // ******************************************************************************************// ' > ./boundaryData/$newpatchname/faces cat ./$d/$variableFoldername/faces >> ./boundaryData/$newpatchname/faces mv boundaryData/top/surface/* boundaryData/top |
|
September 15, 2021, 12:16 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
If you are using an "incompressible" solver such as pimpleFoam or simpleFoam, the pressure is not the real pressure. This pressure field p is actually p' which is p' = p/rho. As the value of p' is not of interest for the numerical process (it does not matter if p' has negative values as we don't have any EOS) you commonly need to multiply your pressure value by the density and add a reference pressure such as the atmosphere one. You simply can see it by checking the pressure dimensions in the 0/p file.
__________________
Keep foaming, Tobias Holzmann |
|
September 15, 2021, 12:36 |
|
#3 | |
Senior Member
|
Quote:
Thanks for your reply. I am using interfoam and the p is the real p that I need. Due to the fact that I require dynamic pressure, namely p-rho*g*h. Do you have any ideas to make this change based on my script? |
||
September 15, 2021, 15:21 |
|
#4 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
The solver actually computes (and writes) both! The field you're looking for is p_rgh (where p == p_rgh + rho*gh) -- you can check e.g. the pEqn to see this to be true.
Caelan
__________________
Public git repository : https://github.com/clapointe2011/public Last edited by clapointe; September 21, 2021 at 17:10. |
|
September 15, 2021, 15:28 |
|
#5 | |
Senior Member
|
Quote:
Yes, I understood this but what makes me confused is that the p_rgh and p is the same at the bottom of the wave. After I used p_rgh or p at the bottom minus rho*g*h is the correct dynamic wave pressure that I need. I don't know why. Additionally, my objective is to process the files. thanks anyway. Last edited by qi.yang@polimi.it; September 16, 2021 at 04:04. |
||
September 21, 2021, 06:53 |
|
#6 |
Senior Member
|
Hi,
I found p_rgh is definitely what I need after I modified the coordinates of gemetry. Now it is clear. Thank you both. |
|
September 21, 2021, 12:43 |
|
#7 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Probably you can also change the "hRef" file (not given and is constructed by default).
It is similar to the gravity field and you specify the reference height here. This could solve your problem too. Take a try and feel free to give feedback. Code:
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 9 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { format ascii; class uniformDimensionedScalarField; location "constant"; object hRef; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 0 0 0 0 0]; value 0.244; // ************************************************************************* //
__________________
Keep foaming, Tobias Holzmann |
|
September 22, 2021, 04:16 |
|
#8 | |
Senior Member
|
Quote:
|
||
September 23, 2021, 04:10 |
|
#9 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hey,
it corresponds to the reference height which is related to: Code:
p_rgh = p - rho*gh Code:
#include "readGravitationalAcceleration.H" #include "readhRef.H" #include "gh.H"
Code:
Info<< "\nReading hRef" << endl; uniformDimensionedScalarField hRef ( IOobject ( "hRef", runTime.constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), dimensionedScalar(dimLength, Zero) ); Code:
Info<< "Calculating field g.h\n" << endl; dimensionedScalar ghRef ( mag(g.value()) > SMALL ? g & (cmptMag(g.value())/mag(g.value()))*hRef : dimensionedScalar("ghRef", g.dimensions()*dimLength, 0) ); volScalarField gh("gh", (g & mesh.C()) - ghRef); surfaceScalarField ghf("ghf", (g & mesh.Cf()) - ghRef); Tobi PS: Code snippet taken from v2106
__________________
Keep foaming, Tobias Holzmann |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] “Upload” vtk data from client to server in paraview script | Jack001 | ParaView | 0 | March 8, 2018 08:27 |
CGNS files contain no data | ansys_matt | FLUENT | 1 | August 19, 2016 23:22 |
[PyFoam] and paraview | eelcovv | OpenFOAM Community Contributions | 28 | May 30, 2016 10:23 |
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem | Attesz | OpenFOAM Meshing & Mesh Conversion | 12 | May 2, 2013 11:52 |
Results saving in CFD | hawk | Main CFD Forum | 16 | July 21, 2005 21:51 |