CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

A few simple questions about linearUpwind and limitedLinear

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

Like Tree8Likes
  • 5 Post By chegdan
  • 1 Post By chegdan
  • 2 Post By chegdan

Reply
 
LinkBack Thread Tools Display Modes
Old   September 28, 2011, 13:58
Default A few simple questions about linearUpwind and limitedLinear
  #1
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 546
Rep Power: 18
chegdan will become famous soon enough
I am a writing about the schemes that I used in my simulations in my thesis and could use some clarification on the linearUpwind and limitedLinear schemes. I have read second order schemes and Alberto did a good explanation, but I need a little more clarification.

linearUpwind:

I know linearUpwind is second order and bounded by a limiter (e.g. cellMDLimited from cellMDLimited vs. cellLimited). This is different than the limiters used in limitedLinear. In Fluent documentation, the definition of second order upwind is given as:

\phi_f = \phi + \nabla\phi\cdot\vec{r}

where \phi_f and \phi are the face value of phi and the cell centered values of phi in the upstream cells respectively. I am reading through the code of linearUpwind and I see:

Code:
    GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();

    const surfaceScalarField& faceFlux = this->faceFlux_;

    const labelList& owner = mesh.owner();
    const labelList& neighbour = mesh.neighbour();

    const volVectorField& C = mesh.C();
    const surfaceVectorField& Cf = mesh.Cf();

    GeometricField
        <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
        gradVf = gradScheme_().grad(vf);

    forAll(faceFlux, facei)
    {
        if (faceFlux[facei] > 0)
        {
            label own = owner[facei];
            sfCorr[facei] = (Cf[facei] - C[own]) & gradVf[own];
        }
        else
        {
            label nei = neighbour[facei];
            sfCorr[facei] = (Cf[facei] - C[nei]) & gradVf[nei];
        }
    }
I see the mesh.C and mesh.Cf and I am led to believe that through quickly reading the code, these are the cell centroid and face centroid, thus producing an r vector that is dotted with the gradient between the owner and neighbor cells (&gradVf) controlled by gradSchemes. I then see some similar code to take care of the boundaries.

When is the sfCorr used to correct the value of the face? I guess I am just interested in generating a discussion and confirming or clarifying my thoughts.

limitedLinear
This again is second order and is bounded using a sweby limiter (second order schemes post 16). I am just a little fuzzy on what the final simplified form of the equation is for limitedLinear (I admit I haven't looked at it as much as linearUpwind). I am out of my office and will look through Richard Pletcher, John Tannehill and Dale Anderson when I get a chance. Laslty, correct me if I'm wrong but the parameter following a definition of a limitedLinear declaration is passed to the limiter, where 1 uses the limiter and 0 does not (with anything in between being a blend).

Sorry for the massive post, and any clarification would be fantastic and if I find an answer, I will post the result here. And for those interested on how I did the math in the forum, look at (Guide: Writing Equations in LaTeX on the CFD Online Forums)

Dan

Last edited by chegdan; September 29, 2011 at 13:24.
chegdan is offline   Reply With Quote

Old   September 28, 2011, 19:05
Default
  #2
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 546
Rep Power: 18
chegdan will become famous soon enough
on the limitedLinear, it seems that my knowledge of limiters is lacking and it may turn out to be a simple answer. Looking in Dr. Jasak's thesis (pg 98), I found that:

\phi_f = (\phi_f)_{UD} + \Psi(r)\left[(\phi_f)_{HO}-(\phi_f)_{UD}\right]

where (\phi_f)_{HO} is the value of phi at the face for a higher order scheme. For limitedLinear, it is just the central difference scheme as the "HO" and the limiter (\Psi(r)) is a Sweby limiter (http://www.cfd-online.com/Forums/ope...ar-scheme.html). if there is more to add here or there are corrections then please do.

Dan
rajibroy likes this.
chegdan is offline   Reply With Quote

Old   September 29, 2011, 04:48
Default
  #3
New Member
 
Chris
Join Date: Jun 2011
Posts: 12
Rep Power: 6
caramelo is on a distinguished road
Yes you are right. limitedLinear is using the Sweby limiter [1]. If you want further information about TVD Schemes and different limiters, I think [2] might be interesting to get a first brief impression.

About linearUpwind I don't know much. Till now I just thought it is something like linear upwind differencing but reading your post seems like its only half the story.

[1] P.K. Sweby. High resolution schemes using flux limiters for hyperbolic conservation laws.SIAM Journal on Numerical Analysis, (Vol. 21):pp. 9951011, 1984.
[2] H. K. Versteeg and W. Malalasekera. An Introduction to Computational Fluid Dynamics: The Finite Volume Method. Pearson, 2007.
caramelo is offline   Reply With Quote

Old   September 29, 2011, 14:37
Default
  #4
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 546
Rep Power: 18
chegdan will become famous soon enough
@caramelo : I found a mistake in my first post concerning the linearUpwind definition and just corrected it (sorry about that). I did have a chance to look at the Sweby paper and also a few other sources on TVD schemes, very interesting. Thanks for the sources.

I see throughout the forum that the linearUpwind is bounded, but Ferziger and Peric' note that second order upwind is unbounded.

My question is that if one uses Gauss linear as a grad scheme for linearUpwind, will this approach the traditional second order upwind and therefore unbounded?

Also, is Gauss linear just the arithmetic average of the two cells or is it the distance weighted average similar to the linear divScheme for advection?

Lastly, is the linearUpwind scheme only bounded if limited versions of the gradient scheme are used, i.e. limited linear, cellLimited, faceMDLimited etc.?

Dan
chegdan is offline   Reply With Quote

Old   October 1, 2011, 15:51
Default [Solved] A few simple questions about linearUpwind and limitedLinear
  #5
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 546
Rep Power: 18
chegdan will become famous soon enough
Quote:
Originally Posted by chegdan View Post
@caramelo : I found a mistake in my first post concerning the linearUpwind definition and just corrected it (sorry about that). I did have a chance to look at the Sweby paper and also a few other sources on TVD schemes, very interesting. Thanks for the sources.

I see throughout the forum that the linearUpwind is bounded, but Ferziger and Peric' note that second order upwind is unbounded.

My question is that if one uses Gauss linear as a grad scheme for linearUpwind, will this approach the traditional second order upwind and therefore unbounded?

Also, is Gauss linear just the arithmetic average of the two cells or is it the distance weighted average similar to the linear divScheme for advection?

Lastly, is the linearUpwind scheme only bounded if limited versions of the gradient scheme are used, i.e. limited linear, cellLimited, faceMDLimited etc.?

Dan
Sometimes I think I need to put the hash tag #dumbquestion or #thinking_out_loud on my comments to let everyone know that I'm thinking out loud about something. For my question:

Quote:
Also, is Gauss linear just the arithmetic average of the two cells or is it the distance weighted average similar to the linear divScheme for advection
The answer to that one is that it is the regular Gauss linear interpolation scheme that we use all the time.

In the end I think that I have the answer that I was looking for.

Dan
__________________
Dan

Find me on twitter @dancombest and LinkedIn
chegdan is offline   Reply With Quote

Old   October 3, 2011, 03:45
Default
  #6
Senior Member
 
Florian Krause
Join Date: Mar 2009
Location: Munich
Posts: 103
Rep Power: 8
florian_krause is on a distinguished road
Hi Dan,

Quote:
When is the sfCorr used to correct the value of the face? I guess I am just interested in generating a discussion and confirming or clarifying my thoughts
did you find an answer to this? I also had a look at the source and couldn't find the part where the pieces are put together, namely cell centered phi and gradient of phi.

Apart from this, as far as I understand, linearUpwind scheme is unbounded as long as you don't specify one of the limiters cellLimited, faceLimited etc.

Best,
Florian
florian_krause is offline   Reply With Quote

Old   October 3, 2011, 12:55
Default
  #7
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 546
Rep Power: 18
chegdan will become famous soon enough
Quote:
When is the sfCorr used to correct the value of the face? I guess I am just interested in generating a discussion and confirming or clarifying my thoughts
From what I can see in the Doxygen information for the limitedSurfaceInterpolationScheme class, everything is pieced together there. linearUpwind returns the weighting factors and then its all put together nicely by the limitedSurfaceInterpolationScheme class.

and of course:
Quote:
Apart from this, as far as I understand, linearUpwind scheme is unbounded as long as you don't specify one of the limiters cellLimited, faceLimited etc
This is what I have found as well...so far. Thanks for the reply and if anyone has a correction, please respond.

Dan
__________________
Dan

Find me on twitter @dancombest and LinkedIn
chegdan is offline   Reply With Quote

Old   October 18, 2013, 23:49
Default How can you find out which file contains the source code implementing the 'linearUpwi
  #8
Member
 
yehanyu
Join Date: Mar 2012
Location: Beijing, China
Posts: 36
Rep Power: 5
yhy20081016 is on a distinguished road
Quote:
Originally Posted by chegdan View Post
I am a writing about the schemes that I used in my simulations in my thesis and could use some clarification on the linearUpwind and limitedLinear schemes. I have read second order schemes and Alberto did a good explanation, but I need a little more clarification.

linearUpwind:

I know linearUpwind is second order and bounded by a limiter (e.g. cellMDLimited from cellMDLimited vs. cellLimited). This is different than the limiters used in limitedLinear. In Fluent documentation, the definition of second order upwind is given as:

\phi_f = \phi + \nabla\phi\cdot\vec{r}

where \phi_f and \phi are the face value of phi and the cell centered values of phi in the upstream cells respectively. I am reading through the code of linearUpwind and I see:

Code:
    GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();

    const surfaceScalarField& faceFlux = this->faceFlux_;

    const labelList& owner = mesh.owner();
    const labelList& neighbour = mesh.neighbour();

    const volVectorField& C = mesh.C();
    const surfaceVectorField& Cf = mesh.Cf();

    GeometricField
        <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
        gradVf = gradScheme_().grad(vf);

    forAll(faceFlux, facei)
    {
        if (faceFlux[facei] > 0)
        {
            label own = owner[facei];
            sfCorr[facei] = (Cf[facei] - C[own]) & gradVf[own];
        }
        else
        {
            label nei = neighbour[facei];
            sfCorr[facei] = (Cf[facei] - C[nei]) & gradVf[nei];
        }
    }
I see the mesh.C and mesh.Cf and I am led to believe that through quickly reading the code, these are the cell centroid and face centroid, thus producing an r vector that is dotted with the gradient between the owner and neighbor cells (&gradVf) controlled by gradSchemes. I then see some similar code to take care of the boundaries.

When is the sfCorr used to correct the value of the face? I guess I am just interested in generating a discussion and confirming or clarifying my thoughts.

limitedLinear
This again is second order and is bounded using a sweby limiter (second order schemes post 16). I am just a little fuzzy on what the final simplified form of the equation is for limitedLinear (I admit I haven't looked at it as much as linearUpwind). I am out of my office and will look through Richard Pletcher, John Tannehill and Dale Anderson when I get a chance. Laslty, correct me if I'm wrong but the parameter following a definition of a limitedLinear declaration is passed to the limiter, where 1 uses the limiter and 0 does not (with anything in between being a blend).

Sorry for the massive post, and any clarification would be fantastic and if I find an answer, I will post the result here. And for those interested on how I did the math in the forum, look at (Guide: Writing Equations in LaTeX on the CFD Online Forums)

Dan
How can you find out which file contains the source code implementing the 'linearUpwind' scheme? Please teach me. Thank you very much.
yhy20081016 is offline   Reply With Quote

Old   October 21, 2013, 09:57
Default
  #9
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 546
Rep Power: 18
chegdan will become famous soon enough
Linux commands to search for file names and within files are your friend. To look for the linearUpwind source, try

Code:
cd $FOAM_SRC
grep -R 'linearUpwind' .
and then look for references to linearUpwind (you will see many). From that you can go through source code files. If you already know the name of the source file (in this case its easy since we want linearUpwind.C or linearUpwind.H), you can do a

Code:
cd $FOAM_SRC
find . -name 'linearUpwind.C'
and that will tell you where a specific file lives. After a while you will learn where different source code resides and be able to find things without searching like this. Good luck.
hua1015 and seav like this.
__________________
Dan

Find me on twitter @dancombest and LinkedIn
chegdan is offline   Reply With Quote

Old   October 26, 2013, 22:44
Default
  #10
Member
 
yehanyu
Join Date: Mar 2012
Location: Beijing, China
Posts: 36
Rep Power: 5
yhy20081016 is on a distinguished road
Thank you very much.
yhy20081016 is offline   Reply With Quote

Old   January 10, 2014, 18:51
Default
  #11
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 152
Rep Power: 7
Anne Lincke is on a distinguished road
Quote:
Originally Posted by chegdan View Post
I am a writing about the schemes that I used in my simulations in my thesis and could use some clarification on the linearUpwind and limitedLinear schemes. I have read second order schemes and Alberto did a good explanation, but I need a little more clarification.

linearUpwind:

I know linearUpwind is second order and bounded by a limiter (e.g. cellMDLimited from cellMDLimited vs. cellLimited). This is different than the limiters used in limitedLinear. In Fluent documentation, the definition of second order upwind is given as:

\phi_f = \phi + \nabla\phi\cdot\vec{r}

where \phi_f and \phi are the face value of phi and the cell centered values of phi in the upstream cells respectively.
Dear Dan, Dear Foamers,

I found your post which is very interesting for me.
Could you please tell me how one can derive the equation above?
I found this equation implemented in OpenFOAM, and in Fluent it is obviously the same.
But I have problems in understanding this equation.
For LUDS (linear upwind) we discretize the face value as

\phi_f = \phi(C) + 0.5 (\phi(C) - \phi(U))

How is the implemented formula connected to that?

Thank you very much for an answer in advance!

Anne
Anne Lincke is offline   Reply With Quote

Old   April 10, 2015, 03:47
Default
  #12
Member
 
Join Date: Jun 2012
Posts: 40
Rep Power: 5
Bazinga is on a distinguished road
Quote:
Originally Posted by Anne Lincke View Post
Dear Dan, Dear Foamers,

I found your post which is very interesting for me.
Could you please tell me how one can derive the equation above?
I found this equation implemented in OpenFOAM, and in Fluent it is obviously the same.
But I have problems in understanding this equation.
For LUDS (linear upwind) we discretize the face value as

\phi_f = \phi(C) + 0.5 (\phi(C) - \phi(U))

How is the implemented formula connected to that?

Thank you very much for an answer in advance!

Anne
I am a bit late to the discussion but I am studying interpolation schemes a bit and I think I can answer your question. I am still fairly new to the topic so there might be an error so feel free to correct me.

Taylor Expansion around P gives you this formula:
\phi(x_e)=\phi(x_P)+\left ( x_e-x_P \right )\left(\frac{\partial \phi}{\partial x} \right)_P+\frac{\left ( x_e-x_P \right )^2}{2!}\left(\frac{\partial^2 \phi}{\partial x^2}  \right)_P+ \cdots+h.o.t

Now for upwind the flux over the east surface of a 2D CV for a flow from west:

\phi(x_e)=\phi(x_P)

The rest of the equation is the truncation error, thus first order.
If you also calculate the first truncated term your scheme will become second order and you will get this expression for your flux over face e:

\phi(x_e)=\phi(x_P)+\left ( x_e-x_P \right )\left(\frac{\partial \phi}{\partial x} \right)_P

CDS for the gradient gives:

\left(\frac{\partial \phi}{\partial x} \right)_P=\frac{\phi(x_E)-\phi(x_P)}{(x_E-x_P)}

For 2\left ( x_e-x_P \right ) =  (x_E-x_P)

You get:
\phi(x_e)=\phi(x_P)+\frac{\phi(x_E)-\phi(x_P)}{2}

That equals your expression:

\phi_f = \phi(C) + 0.5 (\phi(C) - \phi(U))

Hope that helps

Last edited by Bazinga; April 13, 2015 at 03:41.
Bazinga is offline   Reply With Quote

Old   April 10, 2015, 04:54
Default
  #13
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 152
Rep Power: 7
Anne Lincke is on a distinguished road
Thank you very much for your answer! Meanwhile I have also been able to understand the formula, but it is nice to see the answer here as well.

Have a nice day!

Anne
Anne Lincke is offline   Reply With Quote

Reply

Tags
limitedlinear, linearupwind

Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
linearUpwind scheme in OpenFOAM 2.0.1 ??? cabul OpenFOAM 8 November 9, 2011 07:57


All times are GMT -4. The time now is 15:21.