CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [blockMesh] About Simple Grading in blockMesh (https://www.cfd-online.com/Forums/openfoam-meshing/165146-about-simple-grading-blockmesh.html)

ce73stargazer January 10, 2016 20:47

About Simple Grading in blockMesh
 
I understand simple grading is the ratio between the size of the end cell and the size of initial cell.
How about the cell size in between, what kind of changes they follow to reach the final cell?
Like constant changes?
For instane, the first cell is size 10 and the last cell is size 5, the middle cells will have a size 10-dx*(N-1) ? where the dx is the constant changes between cells, N is the number of cells in that direction.

This is how i understand it, not sure if thats right.

I am writing a small code to output the cell ID by just inputting the x,y coordinates, however i realised that it only work fine for uniform distributed mesh, not the one with gradings. Hence i came out with this question. Any one have any suggestions? (Or if anyone has faster way to output cell ID (in paraview) and dont mind share with me)

Many Thanks.

Antimony January 12, 2016 04:45

Hi,

The expansion is geometric, not arithmetic.

Here is a useful tool that gives you an idea about the expansion from the start cell to the end cell:

https://openfoamwiki.net/index.php/S...ng_calculation

Zetison May 7, 2020 05:50

What is the exact formula used here? With n being the number of cells, r=\frac{\delta_e}{\delta_s} being the expansion ratio, L the total length, and based on the distribution of the nodes
x_i = x_0 + L\left(\frac{i}{n}\right)^g\quad i=0,\dots,n
the following formula seems reasonable to me
\delta_s = \frac{L}{n^g}
\delta_e = L\left[1-\left(\frac{n-1}{n}\right)^g\right]
Alternatively, the formulas for a geometric expansion
x_i = x_0 + L\frac{g^i-1}{g^n-1}\quad i=0,\dots,n
\delta_s = L\frac{g-1}{g^n-1}
\delta_e = L\left[1-\frac{g^{n-1}-1}{g^n-1}\right]
but neither matches the program (or OpenFoam?). What is wrong here?

Tobermory May 8, 2020 07:47

Apologies, I did not try to debug your maths above, but for simplicity I will give you the correct expressions below in a simpler and more standard terminology.

For a set of n cells, with vertices x_i, where i varies from 0 to N, then the cell width is the gap between the vertices. If we define a constant stretching rate of \beta then:

\delta_i = (x_{i+1} - x_i) = \beta \delta_{i-1}

Armed with this, you can get to the following:

\delta_i = \beta^i \delta_0

now r = \delta_{n-1} / \delta_0, the ratio of the last to the first cell width, so:

r = \beta^{n-1}

The \delta_i's form a geometric progression, the sum of which is:

Sum_i = \delta_0 + \delta_1 + ... + \delta_i = \delta_0 (1 - \beta^i)/(1 - \beta)

So, the coord of vertex i is:

x_i = x_0 + Sum_i = x_0 + \delta_0 (1 - \beta^i)/(1 - \beta)

Finally, the cell centre is defined as

xc_i = x_i + 0.5 \delta_i

so you can then calculate the cell coords using xc_i. This is probably what you are outputing from OpenFOAM when you are doing the comparison.

Here's a worked example:
n = 5
beta = 1.3
r = 2.8561

i, x, dx, xc
0 0.000 0.100 0.050
1 0.100 0.130 0.165
2 0.230 0.169 0.315
3 0.399 0.220 0.509
4 0.619 0.286 0.762
5 0.904

Hope this helps - good luck!

(PS - can someone tell me how to format a table in a post, to get the spacing right?)

Zetison May 9, 2020 05:37

Thanks for your reply, your formula gets me very close. Given a length L=x_N-x_0, the width of the start cell \delta_0 and the end cell \delta_{N-1} one can compute the number of cells N using the equations

r = \beta^{n-1}=\frac{\delta_{n-1}}{\delta_0}
L = x_N-x_0
Solving yields
\beta = \frac{L-\delta_0}{L-\delta_{N-1}}
such that
N = 1+\frac{\ln\frac{\delta_{N-1}}{\delta_0}}{\ln\frac{L-\delta_0}{L-\delta_{N-1}}}
For L = 1, \delta_0 = 0.05, \delta_{N-1}=0.2 I then get
\beta = 1.1875 and \lfloor N\rceil = 9 (rounded from 9.066873951)


Comparing this to the "Scripts/blockMesh grading calculation"-tool we have
Code:

   
                        \beta              N
My computation          1.1875          9.066873951 
Calculator-tool          1.189207115    9.066872597

Ps. I do not think it is possible to create tables here considering the lacking response on this post https://www.cfd-online.com/Forums/vi...t-example.html


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