|
[Sponsors] |
How to compute gradient for non-orthogonal grids? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 7, 2003, 16:50 |
How to compute gradient for non-orthogonal grids?
|
#1 |
Guest
Posts: n/a
|
HI,
I am reading the CFD book written by Peric (2nd edition). I am confused about calculating gradient of a scalar function when dealing with body-fitted, non-orthogonal grid. Especially, when reading the code that he placed on the internet. This is the piece of code that calculates gradient, it will be highly appreciate if anyone can descibe in "plain english" how the gradient is calculated. Paul PS: Peric has this code available for download on the internet. I hope that it is OK to put this small piece of code here. ------------------------- FI: scalar function DFX: gradient, X-component DFY: gradient, Y-component FAC: ratio: (cell center to cell face)/(cell center at P to cell center to it's neighbor E) -- Pe/PE IJP: node P IJN: neighbor node E (east side) IJ1: node P IJ2: neight node S (south side) C################################################# ############## SUBROUTINE GRADCO(FI,DFX,DFY,FAC,IJP,IJN,IJ1,IJ2) C################################################# ############## C This routine calculates contribution to the gradient C vector of a scalar FI at the CV center, arising from C an inner cell face (cell-face value of FI times the C corresponding component of the surface vector). C================================================= ==============C C.....COORDINATES OF POINT ON THE LINE CONNECTING CENTER AND NEIGHBOR, C OLD GRADIENT VECTOR COMPONENTS INTERPOLATED FOR THIS LOCATION C FACP=1.-FAC XI=XC(IJN)*FAC+XC(IJP)*FACP YI=YC(IJN)*FAC+YC(IJP)*FACP DFXI=DFXO(IJN)*FAC+DFXO(IJP)*FACP DFYI=DFYO(IJN)*FAC+DFYO(IJP)*FACP C C.....COORDINATES OF THE CELL-FACE CENTER, VARIABLE VALUE THERE C XF=0.5*(X(IJ1)+X(IJ2)) YF=0.5*(Y(IJ1)+Y(IJ2)) FIE=FI(IJN)*FAC+FI(IJP)*FACP+DFXI*(XF-XI)+DFYI*(YF-YI) C C.....SURFACE VECTOR COMPONENTS, GRADIENT CONTRIBUTION FROM CELL FACE C RE=(R(IJ1)+R(IJ2))*0.5 SX=(Y(IJ1)-Y(IJ2))*RE SY=(X(IJ2)-X(IJ1))*RE DFXE=FIE*SX DFYE=FIE*SY C C.....ACCUMULATE CONTRIBUTION AT CELL CENTER AND NEIGHBOR C DFX(IJP)=DFX(IJP)+DFXE DFY(IJP)=DFY(IJP)+DFYE DFX(IJN)=DFX(IJN)-DFXE DFY(IJN)=DFY(IJN)-DFYE C RETURN END C |
|
November 9, 2003, 09:08 |
Re: How to compute gradient for non-orthogonal gri
|
#2 |
Guest
Posts: n/a
|
The gradient of a function F at cell center is calculated by Gauss Theorem. \int_Vol{ gadient F dV} == \int_S { F * n_j * dS_j}.
|
|
November 9, 2003, 18:22 |
Re: How to compute gradient for non-orthogonal gri
|
#3 |
Guest
Posts: n/a
|
Hi,
Thanks for the reply. Yes, but, what confuses me is the "correction" due to non-orthogonality. In Peric's book, it mentioned using gradient at previous step when calculating the correction. But, in his code, it looks like it only used gradient at previous step when calculating Fi (function in interests) at e (not E). Paul |
|
November 11, 2003, 05:52 |
Re: How to compute gradient for non-orthogonal gri
|
#4 |
Guest
Posts: n/a
|
When dealing with the diffusion term you need the gradient of a property dotted with the face area vector (the dot product between the gradient and the face area vector). Thus "in English", you need the gradient of the property in the direction of the face area vector. On an orthogonal mesh the face area vector points in the direction of the line connection the centres of the two cells bracketing a face. The gradient of your property is simply the difference of the two centre values divided by the distance between the two cell centres.
In the case of the non-orthogonal meshes the face area vector (say A) is decomposed into two vectors, one parallel to the line connection the two cell centres (say D), and the other (say k) such that A=D+k. The gradient of your property is now multiplied to D + k instead. The portion in the direction of the neighbouring cell centre is similar to the orthogonal mesh case. The non-orthogonal contribution (gradient of the property times k) is treated somewhat differently. This is your question. Versi mentioned the formula for calculating the gradient of your property at a cell centre. Use the formulation for the two cell centres bracketing the face and interpolate this value to the face centre and get the dot product with your vector k. You do this with old iteration level values (as mentioned in your follow up question). Thus the contribution of non-orthogonality is treated "explicitly" and slightly lagged in "time". By the time you have convergence, the values does not change and it does not matter whether you used old or new values. However, the process to convergence might be a tedious one with more under-relaxation. This is the price you pay for grid non-orthogonality. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to compute the gradient of a scalar as a post-processing | ayoros | OpenFOAM Post-Processing | 16 | March 21, 2018 07:02 |
Pressure Gradient discretisation in MAC curvilinear grids | Jodo | Main CFD Forum | 0 | July 12, 2010 06:20 |
How to compute UDS fourth order gradient | Emma66 | FLUENT | 1 | April 27, 2010 06:44 |
Gradient of Scalar calculation in 3D BFCskew grids | james T | Phoenics | 0 | March 28, 2007 08:12 |
N-S non orthogonal grids | Harish | Main CFD Forum | 4 | November 18, 2005 02:05 |