CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   3 Part Question about cell access and averaging (https://www.cfd-online.com/Forums/openfoam-programming-development/227066-3-part-question-about-cell-access-averaging.html)

Akshay_11235 May 16, 2020 01:38

3 Part Question about cell access and averaging
 
Hi Guys,

I have been working to write some routines within the DNS solver I made. I want to achieve the following two things, hope I can get some help to write a fast and sensible piece of code.

1. I want to get planform average of the velocity. Consider a channel flow with streamwise (x), span wise (y) and vertical (z) coordinates. I would like to average the velocity field along the streamwise and spanwise coordinate (both are periodic ) and get U as a function of vertical coordinate only. What is the best way to compute such a planform average in runtime within the solver.

2. Consider the same channel flow case for only the bottom boundary (lets call it bottom). I would like to access the first two cells immediately above the bottom boundary (for the entire boundary) and carry out certain operation using these values. A quick schematic would look something like this


- - - - -
| o | Cell at z = n - 1
- - - - -
| o | Cell at z = n (last grid cell)
_______
BOTTOM


I want to extrapolate the value at a ghost cell z = n + 1 using a linear extrapolation over the entire bottom boundary something like

C[n+1] = C[n-1] + ((z[n+1] - z[n-1])/(z[n] - z[n-1] ))*(C[n] - C[n-1]), where C is some flow parameter.

Can someone suggest a good way to first access these cells and then compute the external value?


3. I want to access and get values of the cell centres along the vertical direction. I don't want all the z coordinates but only the unique z coordinates. I know that writeCellCenters gives all the z coordinates, however I only want the unique z coordinates i.e. cell centre z values.


Looking forward to your responses. Thanks!

Akshay_11235 May 16, 2020 17:21

Any thoughts on the above problem will be highly vappreciated!

Akshay_11235 May 17, 2020 21:23

Hi Guys,

Still hopeful that someone might shed some light into this. I managed to fix the algorithm for question 2 by creating topoSet cells to read the bottom two rows of cells and then operate on them. Since my mesh does not change in this application this is a valid approach. However, for the other things I would really love to hear your opinions.

Since I am dealing with DNS using (RK4 projection method and/or Adams-Bashforth 3rd order time integration projection method) I really need to compute the planform averages on the fly and not later given my grid is something like 44 million grid cells.


All times are GMT -4. The time now is 10:22.