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

Numerical Diffusion

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By FMDenaro

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 29, 2020, 10:19
Default Numerical Diffusion
  #1
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 157
Rep Power: 17
Ford Prefect is on a distinguished road
Hey,


So normally in textbooks on CFD the standard example of numerical diffusion is to do a oblique flow scalar transport on a square mesh with quad cells. I have not seen any text book examples of momentum numerical diffusion (numerical viscosity). Does anyone have any references for this?


I have made a simple setup for pressure driven flow between two parallel plates. The idea is that a triangular mesh should increase the numerical viscosity and thus affect the mass flow rate. But this case seems too simplistic and produces near identical results for triangular and quad meshes. I have kept the boundary layers identical and the number of cells similar. Any suggestions?


Attaching high Re and low Re cases.
Attached Images
File Type: jpg numericalDiffusionLowRE.jpg (118.0 KB, 46 views)
File Type: jpg numericalDiffusion.jpg (111.9 KB, 37 views)
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

Old   March 29, 2020, 13:02
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by Ford Prefect View Post
Hey,


So normally in textbooks on CFD the standard example of numerical diffusion is to do a oblique flow scalar transport on a square mesh with quad cells. I have not seen any text book examples of momentum numerical diffusion (numerical viscosity). Does anyone have any references for this?


I have made a simple setup for pressure driven flow between two parallel plates. The idea is that a triangular mesh should increase the numerical viscosity and thus affect the mass flow rate. But this case seems too simplistic and produces near identical results for triangular and quad meshes. I have kept the boundary layers identical and the number of cells similar. Any suggestions?


Attaching high Re and low Re cases.







If I understand, you want to evaluate the effects of the numerical viscosity for a real solution of the NSE, right?

First, you have to consider that the numerical viscosity is due to the upwind discretization of the convection, that means you have to solve a high Re number flow and a case where the convection plays a relevant role.
I suggest to use the backward facing step flow at Re=100-400 and check the reattachment lenght.
Moreza7 likes this.
FMDenaro is offline   Reply With Quote

Old   March 29, 2020, 14:49
Default
  #3
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 157
Rep Power: 17
Ford Prefect is on a distinguished road
Thank you for the suggestion.


Is circulating flow really a good measure of numerical diffusion effects? A flow that is aligned with the quad mesh is naturally free of numerical diffusion. However, with a backward facing step and quad mesh it seems like a rather large part of the important zone is actually not aligned with the flow. So how do I assess numerical diffusion in the triangle mesh when I compare it to the quad mesh that also has numerical diffusion in this case?


I have used first order upwind to make sure the effect of numerical diffusion is as large as possible, for the triangular mesh. For the quad mesh it does not matter since the flow is aligned with the mesh and therefore does not have any numerical diffusion (in space at least).



Many (most) numerical results on backward facing step use higher order approximations and although they surely also have numerical diffusion it is far less. This makes it difficult to use such studies. There are a few approximate analytical solutions to the backward facing step, but comparing against those, how can you tell how much of the error is actually due to numerical diffusion?
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

Old   March 29, 2020, 15:03
Default
  #4
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by Ford Prefect View Post
Thank you for the suggestion.


Is circulating flow really a good measure of numerical diffusion effects? A flow that is aligned with the quad mesh is naturally free of numerical diffusion. However, with a backward facing step and quad mesh it seems like a rather large part of the important zone is actually not aligned with the flow. So how do I assess numerical diffusion in the triangle mesh when I compare it to the quad mesh that also has numerical diffusion in this case?


I have used first order upwind to make sure the effect of numerical diffusion is as large as possible, for the triangular mesh. For the quad mesh it does not matter since the flow is aligned with the mesh and therefore does not have any numerical diffusion (in space at least).



Many (most) numerical results on backward facing step use higher order approximations and although they surely also have numerical diffusion it is far less. This makes it difficult to use such studies. There are a few approximate analytical solutions to the backward facing step, but comparing against those, how can you tell how much of the error is actually due to numerical diffusion?





1) the numerical diffusion appears also on structured homogenous grid. Just think to the 1D example where the first order upwind (with first order Euler in time) starts producing numerical viscosity at cfl <1.


2) you can estimate the numerical diffusion by evaluating the modified equation, of course in a 2d NSE case that requires some long manipulation.


3) a further test could be the 2D inviscid flow in a periodic box where you have that the total kinetic energy must be constant. The numerical diffusion will dissipate it in time
FMDenaro is offline   Reply With Quote

Old   March 29, 2020, 16:08
Default
  #5
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 157
Rep Power: 17
Ford Prefect is on a distinguished road
1) Yes and no. Isn't this more of a phase error problem? If we look at the steady-state solution of my test case there are no such errors. This is similar to having zero space derivatives (a domain where the velocity is constant in space will not have any numerical viscosity).



2) Yes, this is done in some textbooks. I would like to test it. The only numerical test I've seen is the common oblique scalar transport case I mentioned. This case is constructed to maximize numerical diffusion on quad meshes. It is fully possible to construct a case with zero (visible) numerical diffusion, using triangular mesh and first order upwind for that particular test case (by aligning the triangle hypotenuse with the flow direction, cutting the two regions of different scalar value).



3) This may be a good test! This ensures that we can have a flow that is aligned with the mesh for comparison! However, as mentioned above, we must probably ensure that a velocity gradient exist, otherwise numerical diffusion should not happen.
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

Old   March 29, 2020, 16:23
Default
  #6
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by Ford Prefect View Post
1) Yes and no. Isn't this more of a phase error problem? If we look at the steady-state solution of my test case there are no such errors. This is similar to having zero space derivatives (a domain where the velocity is constant in space will not have any numerical viscosity).



2) Yes, this is done in some textbooks. I would like to test it. The only numerical test I've seen is the common oblique scalar transport case I mentioned. This case is constructed to maximize numerical diffusion on quad meshes. It is fully possible to construct a case with zero (visible) numerical diffusion, using triangular mesh and first order upwind for that particular test case (by aligning the triangle hypotenuse with the flow direction, cutting the two regions of different scalar value).



3) This may be a good test! This ensures that we can have a flow that is aligned with the mesh for comparison! However, as mentioned above, we must probably ensure that a velocity gradient exist, otherwise numerical diffusion should not happen.





1) That is not correct. If you see the modified wavenumber for the upwind formula you see both a real and an imaginary part. To undestand the result, just integrate analytically the equation df/dt +u * d_s f /h = 0 using the Fourier component with the modified wavenumber.
Furthermore, if you use the first order Euler scheme in time, using u=constant, you see that the numerical diffusion appears immediatly when cfl<1.



2) the construction of the modified equation analysis is different, you have to start fro the discrete scheme and, using the Taylor expansion, write the PDE that the numerical solution really satisfies.
FMDenaro is offline   Reply With Quote

Old   March 30, 2020, 00:55
Default
  #7
Senior Member
 
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 220
Rep Power: 19
tas38 is on a distinguished road
If you are interested in the topic of numerical diffusion, you may also want to take a look at "vorticity confinement" techniques in CFD. These methods have been developed and applied in aerodynamic applications specifically to the counteract numerical diffusion which undesirably causes spreading of vortical structures shed from lifting surfaces.
tas38 is offline   Reply With Quote

Old   March 30, 2020, 04:07
Default
  #8
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 157
Rep Power: 17
Ford Prefect is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
1) That is not correct. If you see the modified wavenumber for the upwind formula you see both a real and an imaginary part. To undestand the result, just integrate analytically the equation df/dt +u * d_s f /h = 0 using the Fourier component with the modified wavenumber.
Furthermore, if you use the first order Euler scheme in time, using u=constant, you see that the numerical diffusion appears immediatly when cfl<1.

But the CFL number has little meaning in steady state flows.


Anyways, for the first order Euler scheme in time using u=constant, it is fully possible to have zero numerical diffusion in space-time. If your initial field is constant then there will be no change. This may seem trivial but it is very relevant in the incompressible steady-state example I gave above, where the flow will be more or less fully developed within one solution of the pressure Poisson equation (steady state or not does not matter). This will be true in all cases where we have no gradients, so in the standard test case (attached), if we are to measure the numerical diffusion in the lower right or top left corners it will likely be zero. You will only see the effect in the vicinity of the main diagonal. Perhaps we can argue that there is always numerical diffusion even when the field is constant, but it is not measurable since the cell-to-cell differences are zero if the field is constant.


@tas38, thank you for the suggestion. Could you point to any test case where numerical diffusion can be measured for the momentum equations?
Attached Images
File Type: jpg classicalExample.jpg (107.7 KB, 17 views)
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

Old   March 30, 2020, 04:26
Default
  #9
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by Ford Prefect View Post
But the CFL number has little meaning in steady state flows.


Anyways, for the first order Euler scheme in time using u=constant, it is fully possible to have zero numerical diffusion in space-time. If your initial field is constant then there will be no change. This may seem trivial but it is very relevant in the incompressible steady-state example I gave above, where the flow will be more or less fully developed within one solution of the pressure Poisson equation (steady state or not does not matter). This will be true in all cases where we have no gradients, so in the standard test case (attached), if we are to measure the numerical diffusion in the lower right or top left corners it will likely be zero. You will only see the effect in the vicinity of the main diagonal. Perhaps we can argue that there is always numerical diffusion even when the field is constant, but it is not measurable since the cell-to-cell differences are zero if the field is constant.


@tas38, thank you for the suggestion. Could you point to any test case where numerical diffusion can be measured for the momentum equations?



Coming back to the steady Poiseulle flow, the numerical diffusion would act due to the du/dy gradient. But the convective term is v*du/dy and v=0 in such a case. Thus, the only way to let the numerical diffusion acting is to solve the unsteady flow, starting from an initial condition having a superimposition of the non-vanishing v velocity and check the final steady state to compare using the anlytical Poiseulle solution.

But, again, that is not the best test to check what you want.

A test you can find in literature is the 2D inviscid flow where the numerical dissipation of kinetic energy can be measured https://en.wikipedia.org/wiki/Taylor...93Green_vortex
FMDenaro is offline   Reply With Quote

Old   March 30, 2020, 07:13
Default
  #10
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 157
Rep Power: 17
Ford Prefect is on a distinguished road
Good suggestion!



You have suggested this test many times before, for instance to verify new codes. Do you know if the pressure interpolation method in OpenFOAM admits conservation of the kinetic energy (I rather use a verified code as opposed to my own codes for this)? I guess we can test that by using your previous suggestion with inviscid flow with periodic boundaries.


So basically, if we know that it conserves kinetic energy for a non-rotational case then we can be fairly certain that it is numerical diffusion that causes dissipation in the Taylor-Green vortex case, right?


I could setup a quad mesh and triangular mesh and compare the rate of decay between them.
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

Old   March 30, 2020, 07:35
Default
  #11
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
yes, for a 2d periodic box and inviscid condition the total kinetic energy is constant and that is the way you can evaluate in a quantitative way the presence of the numerical dissipation at any time.
FMDenaro is offline   Reply With Quote

Old   March 30, 2020, 08:36
Default
  #12
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 157
Rep Power: 17
Ford Prefect is on a distinguished road
I doubt the inviscid test case in 2d. We really need to have a velocity gradient in the flow in that case, right? With uniform velocity there will be no numerical diffusion, regardless of the mesh and/or numerical scheme. Or do you propose to set the initial velocity to say 1 everywhere and then run the simulation for a long time and see if the magnitude changes?
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

Old   March 30, 2020, 08:40
Default
  #13
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
TGV for vanishing viscosity has all the gradient a you need
FMDenaro is offline   Reply With Quote

Old   March 30, 2020, 09:00
Default
  #14
Senior Member
 
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 220
Rep Power: 19
tas38 is on a distinguished road
I second the suggestion of Filippo to examine the Taylor-Green vortex.

See the following paper...

https://arxiv.org/abs/2003.00173

Note that in Fig. 2 the vortex kinetic energy loss (due to numerical diffusion) is explicitly plotted.

Although implemented in MATLAB, the same case can be setup in OpenFOAM.
tas38 is offline   Reply With Quote

Old   March 30, 2020, 11:03
Default
  #15
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 157
Rep Power: 17
Ford Prefect is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
TGV for vanishing viscosity has all the gradient a you need

Yes, agreed, that is a better test case than the inviscid 2d flow case with cyclic boundaries.


@tas38, thank you for the reference.
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

Old   March 30, 2020, 11:54
Default
  #16
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,897
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by Ford Prefect View Post
Yes, agreed, that is a better test case than the inviscid 2d flow case with cyclic boundaries.


@tas38, thank you for the reference.
Inviscid 2d flows has gradient...why do you think only about a constant flow??
FMDenaro is offline   Reply With Quote

Old   March 31, 2020, 16:38
Default
  #17
Senior Member
 
Ford Prefect's Avatar
 
Join Date: Mar 2009
Posts: 157
Rep Power: 17
Ford Prefect is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
Inviscid 2d flows has gradient...why do you think only about a constant flow??

Perhaps I misunderstood. It seemed to me that you talked about an inviscid version similar to the case I showed, but with cyclic boundaries instead of inlet and outlet.


Anyhow, you mentioned TGV later so that is one example that might be useful here.
__________________
"Trying is the first step to failure." - Homer Simpson
Ford Prefect is offline   Reply With Quote

Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between diffusion, dissipation and dispersion in physical and numerical TurbJet Main CFD Forum 9 October 6, 2018 19:15
Why numerical diffusion is related to the advection term Houthuys Main CFD Forum 6 January 28, 2017 23:01
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
Numerical Diffusion in CFX John S. CFX 4 August 17, 2008 20:47
Estimation of numerical diffusion varghese FLUENT 0 March 24, 2003 06:02


All times are GMT -4. The time now is 19:18.