User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 January 28, 2012, 12:58 fvc::grad only gaussGrad #1 Senior Member   Join Date: Nov 2009 Location: Michigan Posts: 135 Rep Power: 10 Does fvc::grad() calculates gradients using gauss grad scheme only? Because in the file fvcGrad.C only gaussGrad is being referred.

 January 29, 2012, 10:39 #2 Senior Member     Philip Cardiff Join Date: Mar 2009 Location: Dublin, Ireland Posts: 642 Rep Power: 23 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 Tushar@cfd likes this.

 May 24, 2013, 08:28 #3 Member   Join Date: Aug 2011 Posts: 83 Rep Power: 8 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

 May 24, 2013, 08:38 #4 Senior Member     Philip Cardiff Join Date: Mar 2009 Location: Dublin, Ireland Posts: 642 Rep Power: 23 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 pmdelgado2, kosan and HuZexi like this.

 May 25, 2013, 04:14 #5 Member   Join Date: Aug 2011 Posts: 83 Rep Power: 8 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

April 16, 2014, 09:57
#7
Senior Member

Philipp
Join Date: Jun 2011
Location: Germany
Posts: 1,297
Rep Power: 20
Quote:
 Originally Posted by bigphil 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.
bigphil, thank you for the explanations.
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.
__________________
The skeleton ran out of shampoo in the shower.

April 16, 2014, 10:48
#8
Senior Member

Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 642
Rep Power: 23
Quote:
 Originally Posted by RodriguezFatz 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)?
Using "grad(p) Gauss linear" calculates the cell gradient using the Gauss theorem,
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:
 Originally Posted by RodriguezFatz 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.
OpenFOAM is written in a general fashion such that you could choose any gradient calculation method for grad(p) even if 'Gauss' is mostly selected by the user.

Best regards,
Philip

April 16, 2014, 10:51
#9
Senior Member

Philipp
Join Date: Jun 2011
Location: Germany
Posts: 1,297
Rep Power: 20
Quote:
 Originally Posted by bigphil Using "grad(p) Gauss linear" calculates the cell gradient using the Gauss theorem, whereas "grad(p) leastSquares" calculates the cell gradient by fitting a 'least squares' plane, no need to calculate any volume integrals.
Yes, but momentum equation is solved in conservative form, i.e. all parts of the differential equation are integrated over space. Also the "grad p" term, thus the reason why "grad p" needs to be known is because You actually want to solve "Integral( grad p) dV)". That's why I was talking about volume integrals.
__________________
The skeleton ran out of shampoo in the shower.

April 16, 2014, 11:00
#10
Senior Member

Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 642
Rep Power: 23
Quote:
 Originally Posted by RodriguezFatz Yes, but momentum equation is solved in conservative form, i.e. all parts of the differential equation are integrated over space. Also the "grad p" term, thus the reason why "grad p" needs to be known is because You actually want to solve "Integral( grad p) dV)". That's why I was talking about volume integrals.
The volume integral is not considered when the gradient is calculated, as you may want a gradient for some other reason;

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>
01065 void Foam::fvMatrix<Type>::operator+=
01066 (
01067     const DimensionedField<Type, volMesh>& su
01068 )
01069 {
01070     checkMethod(*this, su, "+=");
01071     source() -= su.mesh().V()*su.field();
01072 }
Philip

April 16, 2014, 11:02
#11
Senior Member

Philipp
Join Date: Jun 2011
Location: Germany
Posts: 1,297
Rep Power: 20
Quote:
 Originally Posted by bigphil The volume integral is not considered when the gradient is calculated, as you may want a gradient for some other reason;
Great, that was exactly what I wasn't keeping in mind. Thanks!
__________________
The skeleton ran out of shampoo in the shower.

 August 24, 2015, 06:09 #12 New Member   Carla Join Date: Jun 2015 Posts: 16 Rep Power: 4 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

August 25, 2015, 04:15
#13
Senior Member

Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 642
Rep Power: 23
Quote:
 Originally Posted by cvillescas 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
Hi Carla,

The definition of the gradient in OpenFOAM is given in Equation 2.3 (Page 25) of the Programmer's Guide.

Best,
Philip

 August 25, 2015, 04:30 #14 New Member   Carla Join Date: Jun 2015 Posts: 16 Rep Power: 4 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

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post pino@JAEA OpenFOAM 1 August 24, 2011 23:02 jaswi OpenFOAM Running, Solving & CFD 1 September 13, 2010 08:43 ivan_cozza OpenFOAM Running, Solving & CFD 2 October 14, 2008 10:30

All times are GMT -4. The time now is 00:03.

 Contact Us - CFD Online - Privacy Statement - Top