# fvc::div() strange behaviour

 Register Blogs Members List Search Today's Posts Mark Forums Read

 February 5, 2010, 09:34 fvc::div() strange behaviour #1 Senior Member   Ivan Flaminio Cozza Join Date: Mar 2009 Location: Torino, Piemonte, Italia Posts: 207 Rep Power: 11 Dear Foamers, I noticed a strange behaviour in fvc::div() operator: I have a fluctuating velocity field ut, evaluated as follows: ut = fvc::curl(psi), where psi is a vector-stream function. Obviously, ut is divergence-free, as div(ut) = div(curl(psi)) = 0 analitically. In order to verify this identity I calculated fvc::div(ut), but it's nothing but zero! I found high values of divergence. But if I do this test as follows: volTensorField gradUt = fvc::grad(ut); volScalarField divUt = gradUt.component(0) + gradUt.component(4) + gradUt.component(8); (Div is the trace of Grad, so...) Now, divUt is zero, consistently with the analytical expression. Someone can explain me this discrepancy? Thanks, Ivan

 February 6, 2010, 05:23 #2 Senior Member   Hrvoje Jasak Join Date: Mar 2009 Location: London, England Posts: 1,806 Rep Power: 25 Nice, but you are forgetting the discretisation error. Remember, field approximation of any FVM field is piecewise linear (with discontinuities). Thus, even if you have analyical values of stream function in cell centres, the field will not be perfect (eg who says it's linear?). First, you use curl which will interpolate from cell centres to faces for the Gauss Theorem = discretisation error. This one you can actually avoid by analytically picking up the stream function values at Face (rather than cell) centres. Second, the velocity vector is numerically calculated in the cell centres again, and for div() you again need it on faces: same story. In conclusion: you are completely right in the analytical world, but in a discrete representation you will pick up discretisation error along the way: this is what you are seeing. Enjoy, Hrv utkunun likes this. __________________ Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk

February 6, 2010, 07:09
#3
Senior Member

Ivan Flaminio Cozza
Join Date: Mar 2009
Location: Torino, Piemonte, Italia
Posts: 207
Rep Power: 11
Hrvoje,
thank you for your reply, very good idea to calculate the stream-function on cell faces, I will implement it soon.
I have taken into account the discretization error in my test, so I didn't expect to see div(ut) = 0, but something like div(ut) = "something small related to numerics" (and this "something small" is another time questionable, how much small this div must be?).
The very strange feature that I noticed is that if I calculate the same thing with two equivalent methods I find two very different results, like:

div(ut) = 1000

I wonder if I'm missing something...

Quote:
 Originally Posted by hjasak Nice, but you are forgetting the discretisation error. Remember, field approximation of any FVM field is piecewise linear (with discontinuities). Thus, even if you have analyical values of stream function in cell centres, the field will not be perfect (eg who says it's linear?). First, you use curl which will interpolate from cell centres to faces for the Gauss Theorem = discretisation error. This one you can actually avoid by analytically picking up the stream function values at Face (rather than cell) centres. Second, the velocity vector is numerically calculated in the cell centres again, and for div() you again need it on faces: same story. In conclusion: you are completely right in the analytical world, but in a discrete representation you will pick up discretisation error along the way: this is what you are seeing. Enjoy, Hrv

 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 hani OpenFOAM Running, Solving & CFD 20 March 6, 2013 11:06 markc OpenFOAM Programming & Development 12 November 23, 2011 11:18 segersson OpenFOAM Running, Solving & CFD 0 December 9, 2009 04:57 cfdmarkus OpenFOAM Running, Solving & CFD 18 August 14, 2009 05:33 Zitron CFX 4 July 12, 2007 15:32

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