CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Cell-centered and Face-centered values (https://www.cfd-online.com/Forums/main/9473-cell-centered-face-centered-values.html)

coolblizz July 7, 2005 01:29

Cell-centered and Face-centered values
 
Hi....

I am working on a flow problem using FVM on non-orthogonal grids. I need to extrapolate the cell-centered values to the face-center of the computational cell.

For the extrapolation, I add the scalar product of the cell-centered gradient and the distance between the face-center and cell-center, to the cell-centered value. The cell-centered gradient is calculated using the Gauss Theorem.

My problem is, the Gauss Theorem requires the face-centered values to be first available in order to calculate the gradient.

Can anyone please help me with this dilemma?

Thank you so much.


ramp July 7, 2005 05:26

Re: Cell-centered and Face-centered values
 
You might find your solution in the folowing book: Computational Methods For Fluid Dynamics by Ferziger, J. H. & Peric,M.

O. July 7, 2005 11:08

Re: Cell-centered and Face-centered values
 
use a least squares approach to compute your gradients

Mani July 7, 2005 12:45

Re: Cell-centered and Face-centered values
 
Why do you need extrapolation? Interpolation between neighboring cells is not an option? Your dilemma stems from a lack of information. If you have only cell centered values available, you need to make use of information from neighboring cells.

coolblizz July 8, 2005 00:16

Re: Cell-centered and Face-centered values
 
Hi....

Thank your so much for your response.

Ramp, I have gone through that book by Peric before, but it only describes how to calculate for the cell-centered gradients. My problem stems from how to find the gradients, which must be available first for the gradient calculation....

O., could you please describe how to use the least squares method?

Mani, yes, I do mean interpolating between neighbouring cells. Can you please tell me how to interpolate between neighbouring cells on non-orthogonal grids?

Thank you so much.

zxaar July 8, 2005 01:10

Re: Cell-centered and Face-centered values
 
for gradient calculations, what you do is to store the last calculated gradient in old arrays, like

dUdX_old, etc.

so when you need face values use these _old gradients to calculate the values at the face center.

and once the gradient is done, update these _old gradients with latest values.

this way after iterations, when you reach convergence , these _old values are not much varying and do not create much difference. hope this solves the problem.


coolblizz July 8, 2005 11:43

Re: Cell-centered and Face-centered values
 
Hi Zxaar...

Your method seems to make sense, at least it solves the dilemma issue of needing the gradient before finding it. I will try out this method.

Can this method be also applied to interpolating the individual velocity components, before a Riemann procedure on both sides of the cell face is done?

My only worry is the disagreement between the old face-centered values and the current cell-centered values.

Thank you so much for your suggestion.


coolblizz July 8, 2005 11:45

Re: Cell-centered and Face-centered values
 
Hi O....

Could you please describe how to use the least squares method? Or is there any easy-to-understand books/articles on this approach?

Thank you.

coolblizz July 8, 2005 11:47

Re: Cell-centered and Face-centered values
 
Hi Mani....

Yes, I do mean interpolating between neighbouring cells. Can you please tell me how to interpolate between neighbouring cells on non-orthogonal grids?

Thank you.

Mani July 8, 2005 14:59

Re: Cell-centered and Face-centered values
 
Take an average of two neighboring cell centers to define the variables at the face between the cell centers. For higher order approximations you may need to take the distances between face and cell-centers into account, but assuming you have a relatively good grid (aspect ratios not too high), then you would simply take the arithmetic average. This is consistent with a second order scheme.

Praveen July 9, 2005 00:49

Re: Cell-centered and Face-centered values
 
Or you could form a new cell by joining the centroids of the neighbouring cells, and apply Green-Gauss theorem on this new cell.

coolblizz July 9, 2005 11:53

Re: Cell-centered and Face-centered values
 
Hi Mani....

I am actually doing what you are recommending by taking the average for the face values as a preliminary step. Then I do the extra step of considering the distance between the cell center and face as a further update to the face value.

Just a further question, can interpolating a velocity from cell center to face center be done the same as when interpolating a scalar?

zxaar July 10, 2005 23:08

Re: Cell-centered and Face-centered values
 
if you honestly ask me, what would i prefer between the method i told you and between taking simple average of two cells as face value for gradient calculations, i would prefer average of two cells.

the reason is this, earlier my code use to work with the method i mentioned you, but then i observed that my code runs well with sturctured meshes but suddenly diverges with unstructured meshes, for three months i tried everythign but couldn't find any problem. since thre were no problems with the code i wrote.

well then i always used to wonder that same mesh runs well in fluent, the question was why?

i found that the only thing me and fluent do differntly is they take average for gradient calculations and i bother too much (like you) about the face values. so then i wrote new grad function with averages, and yes after that my code has not diverged.

hope this will help.

coolblizz July 11, 2005 11:58

Re: Cell-centered and Face-centered values
 
Hi Zxaar....

Thank you very much for the information. Precisely, as what you have said, I have this nagging worry about whether averaging is sufficient. Your findings have put that worry of mine to rest. Thank you so much again.

Mani July 12, 2005 00:47

Re: Cell-centered and Face-centered values
 
Yes. No problem. Think of each velocity component as a scalar quantity.

Mani July 12, 2005 00:53

Re: Cell-centered and Face-centered values
 
true. this wasn't quite the original question, but it's actually a better way to obtain the derivatives. in this case, the derivatives will be vertex based, not cell centered. you can then obtain face-centered derivatives by averaging four vertices on each face. essentially you're ending up with a larger stencil, but it's more robust.

zxaar July 12, 2005 01:38

Re: Cell-centered and Face-centered values
 
mani fluent also gives user and option to use node based gradient (as you just mentioned), and according to them its better to use.

O. July 13, 2005 04:38

Re: Cell-centered and Face-centered values
 
Sorry for the somewhat late reply.

To compute the gradient for a cell you can do the following:

Assume your cell has N neighbours and you know the values of your variables in the neigbouring cells, Q(i=1..N), and you also know the value in the cell you want to compute the gradients for Q(p). Assume further that you do have the gradient in the cell dQ/dx and dQ/dy. Now you can compute the values in the neighbouring cells with the help of a Taylor expansion (only linear):

Q'(i) = Q(p) + dQ/dx*(x(i)-x(p) + dQ/dy*(y(i)-y(p))

The values Q and Q' are different, unless Q is a linear function. Now you compute the error squares for all neighbours:

err^2(i) = (Q(i) - Q'(i))^2

and sum them. The sum of all error squares

S = sum(err^2(i),i=1..N)

will be a function of dQ/dx and dQ/dy, the gradients in your cell. To minimise the error square you differentiate S and then you have to solve the following system of equations:

dS/(dQ/dx) = 0 dS/(dQ/dy) = 0

This is a simple set of linear equations and it is easy to solve. Please let me know if this is helpfull. If you want, I can send you a small piece of C++ source code, which does exactly this. The extension to three dimensions is straight forward, just add dQ/dz and that's it.

Cheers, O.

coolblizz July 13, 2005 12:17

Re: Cell-centered and Face-centered values
 
Hi Mani....

Thank you very much for your reply. It certainly goes a long way in clearing up this age-old doubts of mine.

coolblizz July 13, 2005 12:50

Re: Cell-centered and Face-centered values
 
Hi O....

In your 1st equation, Q'(i) = Q(p) + dQ/dx*(x(i)-x(p) + dQ/dy*(y(i)-y(p)),

is Q'(i) the face-centered value and Q(p) the cell-centered value? Then the expression is an extrapolation from the cell-center to the face-center, am I right? It looks very similar to the method I am using now.

After the minimization of the error squares, are the gradients dQ/dx and dQ/dy the subjects? And I plough these gradients back into the 1st equation to get an update for Q'(i)?

I will be most grateful if you can let me have a copy of the C++ code that you have. I hope it comes with some documentations.

Thank you so much for your help.


All times are GMT -4. The time now is 04:47.