CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Cell areas in a patch (https://www.cfd-online.com/Forums/openfoam-post-processing/132538-cell-areas-patch.html)

EFoster2 April 2, 2014 08:59

Cell areas in a patch
 
Dear all,

I have a trapezoidal pipe network that I have completed a simulation for. I now need to find the area-weighted average of the wall shear stress of which I need to know the cell area.

Previously all my simulation have been with rectangular cross sections so I have been able to find out the cell area with ease by doing it manually.

I have come across this post about finding the cell areas:
http://www.cfd-online.com/Forums/ope...rea-patch.html

and that subsequently refers you to this post:
http://www.cfd-online.com/Forums/ope...tml#post297002

They suggest various lines of code to be implemented. But since I am a pretty new user of openFoam and linux in general, I am not too sure of how and where they are implementing this code? Does anyone have any suggestions?

Or an alternative technique?

EFoster2 April 5, 2014 09:59

The answer

http://www.cfd-online.com/Forums/ope...nt-planes.html

LeeRuns June 21, 2019 14:51

quick regex solution
 
TLDR:use this regex code, only tested in openfoam 4! ;)
Code:

postProcess -func 'patchIntegrate(name=somePatchName,someFiledName)' | grep -Po "((?<=total area  =).*([0-9])*)"
Full Description:
By using the postProcess function utility we can check the value of a field such as U,p,k,nut, T over a whole patch. To be able to have the integrated value the computer must have an area. Luckily that area gets printed when we perform a funciton such as integrate velocity over a face. So then you can just use regex string to manipulate the return from openfoam. Notes that I am not a regex star, so i did an exact string which requires that there is a line with 'total area' followed by 3 spaces and then an equals sign. If someone else has a better solution then pls supply :D



1. GO TO THE CASE DIRECTORY
  1. change directory to case you want to analyze
  2. punch this in
    (must replace somePatchName, someFieldName

    Code:

    postProcess -func 'patchIntegrate(name=somePatchName,someFiledName)' | grep -Po "((?<=total area  =).*([0-9])*)"

Here is an applied example in which the "inlet" patch is the one i want to find the area of and I use the U field to get it's area printed. This works because my simulation calculates the velocity. Whether the velocity is a set value or is varied by the solver is irrelevant.

Code:

postProcess -func 'patchIntegrate(name=inlet,U)' | grep -Po "((?<=total area  =).*([0-9])*)"
that will print the value to the terminal, in reality this will work with most programming languages bc they all support regex.







While the openfoam naitive compilation is a great solution. Here is a a


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