fvc::grad only gaussGrad
Does fvc::grad() calculates gradients using gauss grad scheme only? Because in the file fvcGrad.C only gaussGrad is being referred.
|
Hi,
As far as I can see (in fvcGrad.C), fvcGrad of a volumeField checks what gradScheme is specified (i.e. Gauss, leastSquares, etc.) and then uses that to calculate the grad. Philip |
Hello
I just wanted to know what OpenFOAM is calculating when I write: gradScheme default Gauss linear how is for example grad(p) calculated? Are the values on the faces used for this? I also looked at fvcGrad.C but I donīt understand the code and how I can get the answer to my question from code. Can anybody help me? Thanks a lot Idefix |
Hi,
Gauss linear means that the gradient is calculated using the Gauss method (i.e. volume integrals are converted to surface integrals) and linear means that cell centre values are interpolated linearly to the face centres. This presentation by Hrv gives a bit more info: http://powerlab.fsb.hr/ped/kturbo/Op...niteVolume.pdf By Gauss' law, the volume integral of the gradient can be written as a surface integral: volume_integral gradp dV == surface_integral dS p In discrete form, this means: gradp = (1/V) surface_sum Sf pf where V is the cell volume, Sf is a face area vector and pf is the value of p at that face. The surface_sum is performed over all the faces of the cell. You can find the relevant code in the $FOAM_SRC/finiteVolume/finiteVolume/gradSchemes/gaussGrad/GaussGrad.C file. Hope it helps, Philip |
Hey Philip,
thanks for your useful explanation. Now I understand the theory but I still donīt understand the code. Am I right that in GaussGrad.C only the sum (surface_sum Sf pf) is calculated? If itīs the case: where can I find the linear interpolation from the cell centre to the cell faces? Thanks a lot Idefix |
Idefix,
If you follow the trail of code from fvc::grad(volField) you can find where everything is calculated. In short, fvc::grad(volField) -> fvc::grad(volField, word) -> gradScheme.grad(volField, word) -> GaussGrad.calcGrad(volField, word) -> GaussGrad.gradf(surfaceField, name). The interpolation of the volField (cell centres) to surfaceField (face centres) occurs in GaussGrad.calcGrad(volField, word): Code:
00113 template<class Type> Code:
gradf(tinterpScheme_().interpolate(vsf), name) The surface sum happens in the GaussGrad.gradf(surfaceField, name) function: Code:
00082 forAll(owner, facei) Code:
00105 igGrad /= mesh.V(); Hope it helps, Philip |
Quote:
1) Does that additionally mean, that using "grad(p) Gaus ..." always calulates the volume integral over "grad p" as a sum of surface integrals (thus the using gauss theorem), whereas using "grad(p) leastSquares" actually calculates the gradient at the cell center and then calculates the volume integral (gradp * V)? 2) If the latter is true, can anyone confirm, that this is not available in Fluent? As far as I understand the Fluent help, pressure gradient integral is allways solved using Gauss theorem. Just the way of face interpolation can be choosen. |
Quote:
whereas "grad(p) leastSquares" calculates the cell gradient by fitting a 'least squares' plane, no need to calculate any volume integrals. See Hrv presentation here for some more info on gradient calculation: http://powerlab.fsb.hr/ped/kturbo/Op...niteVolume.pdf Quote:
Best regards, Philip |
Quote:
|
Quote:
the volume integral is performed when you add grad(p) to the momentum equation: The momentum equation in the solver is an object of type fvVectorMatrix and then grad(p) which is a scalar field is added to it; grad(p) times the volume is then added to the source of the fvVectorMatrix. You can see this in the fvMatrix.C file: Code:
01064 template<class Type> |
Quote:
|
Hi to everyone,
I have a question also related to the gradient. I suspect that in OpenFOAM the velocity gradient tensor is assigned as the transpose of the "standard". What I understand by "standard" is that the term du/dx would be in the first row&second column, and I suspect OpenFOAM places it in the second row&first column. However, I struggle to read the code. Can anyone confirm this or at least tell me the .C file where tensor components are assigned? Thanks in advance. Carla |
Quote:
The definition of the gradient in OpenFOAM is given in Equation 2.3 (Page 25) of the Programmer's Guide. Best, Philip |
Hi Philip,
Thank you for your answer. It hadn't even thougth about the programmers guide! But that is exactly what I was looking for. Thanks again. By the way, I've just noticed that in my previous post I was mentioning du/dx when I meant du/dy. Bests, Carla |
why neigbour cell igGrad[neighbour[facei]] -= Sfssf;?
|
Quote:
So, for this line, the contribution is added to the neighbour cell. |
All times are GMT -4. The time now is 08:48. |