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

Discretization of the 2D Diffusion equation

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

Like Tree1Likes
  • 1 Post By LuckyTran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 23, 2025, 11:12
Default Discretization of the 2D Diffusion equation
  #1
New Member
 
Panagiotis Iatrou
Join Date: Oct 2024
Posts: 11
Rep Power: 2
panagiat is on a distinguished road
Hello,

During the discretization of the 2d Diffusion equation for the x-component of velocity u and diffusion coefficient \mu

\dfrac{\partial}{\partial x}\bigg(\mu \dfrac{\partial u}{\partial x}\bigg) + \dfrac{\partial}{\partial y}\bigg(\mu \dfrac{\partial u}{\partial y}\bigg) = 0

First of all, I know I can approach the discretization using the Gauss theorem. However I am interested in the alternative approach, where we evaluate each integral sequentially.
We start by integrating over an arbitrary cell

\int_{y=s}^{n} \int_{x=w}^{e} \Bigg[ \dfrac{\partial}{\partial x}\bigg(\mu \dfrac{\partial u}{\partial x}\bigg) + \dfrac{\partial}{\partial y}\bigg(\mu \dfrac{\partial u}{\partial y}\bigg) \Bigg] dx dy = 0 \\

\implies \int_{y=s}^{n} \int_{x=w}^{e} \dfrac{\partial}{\partial x} \bigg (\mu \dfrac{\partial u}{\partial x} \bigg ) dx dy + \int_{x=w}^{e} \int_{y=s}^{n} \dfrac{\partial}{\partial y} \bigg (\mu \dfrac{\partial u}{\partial y} \bigg ) dy dx = 0 \\

\implies \int_{y=s}^{n} \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{w} \Bigg] dy + \int_{x=w}^{e} \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{w} \Bigg] dx = 0

Then it is time to evaluate the second integral. Everyone seems to be assuming that the fluxes are constant throughout the cell faces and thus reaching the following:

\implies \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{w} \Bigg] \Delta y + \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{w} \Bigg] \Delta x = 0

(reaching the same equation as we would using the Gauss theorem)
(also can be seen here)

Is this the correct justification for the last step?
panagiat is offline   Reply With Quote

Old   January 23, 2025, 14:18
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,944
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by panagiat View Post
Hello,

During the discretization of the 2d Diffusion equation for the x-component of velocity u and diffusion coefficient \mu

\dfrac{\partial}{\partial x}\bigg(\mu \dfrac{\partial u}{\partial x}\bigg) + \dfrac{\partial}{\partial y}\bigg(\mu \dfrac{\partial u}{\partial y}\bigg) = 0

First of all, I know I can approach the discretization using the Gauss theorem. However I am interested in the alternative approach, where we evaluate each integral sequentially.
We start by integrating over an arbitrary cell

\int_{y=s}^{n} \int_{x=w}^{e} \Bigg[ \dfrac{\partial}{\partial x}\bigg(\mu \dfrac{\partial u}{\partial x}\bigg) + \dfrac{\partial}{\partial y}\bigg(\mu \dfrac{\partial u}{\partial y}\bigg) \Bigg] dx dy = 0 \\

\implies \int_{y=s}^{n} \int_{x=w}^{e} \dfrac{\partial}{\partial x} \bigg (\mu \dfrac{\partial u}{\partial x} \bigg ) dx dy + \int_{x=w}^{e} \int_{y=s}^{n} \dfrac{\partial}{\partial y} \bigg (\mu \dfrac{\partial u}{\partial y} \bigg ) dy dx = 0 \\

\implies \int_{y=s}^{n} \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{w} \Bigg] dy + \int_{x=w}^{e} \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{w} \Bigg] dx = 0

Then it is time to evaluate the second integral. Everyone seems to be assuming that the fluxes are constant throughout the cell faces and thus reaching the following:

\implies \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{w} \Bigg] \Delta y + \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{w} \Bigg] \Delta x = 0

(reaching the same equation as we would using the Gauss theorem)
(also can be seen here)

Is this the correct justification for the last step?



That depends on the accuracy order you want. At second order the mean formula can be used. At higher order the formula must be different.
FMDenaro is offline   Reply With Quote

Old   January 23, 2025, 15:14
Default
  #3
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,783
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Consider that you can partition the east and west faces into sub-partitions each with constant fluxes to approximate a non-constant flux (e.g. e = e1+e2+e3+e3...ej and w=w1+w2+w3+...wk). When you recognize this as a Riemann sum (midpoint rule, mean rule, trapezoidal rule, etc.), then it is more clear that higher order approximations exist for the Riemann integral but at the same time, there isn't a fundamental issue that breaks the whole theory.
LuckyTran is offline   Reply With Quote

Old   January 24, 2025, 05:49
Default
  #4
New Member
 
Panagiotis Iatrou
Join Date: Oct 2024
Posts: 11
Rep Power: 2
panagiat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
That depends on the accuracy order you want. At second order the mean formula can be used. At higher order the formula must be different.
What values are going to be used for the mean formula you refer to (since we are talking about one face at a time)? I think I am a bit confused. Do we split the face into subfaces as LuckyTran mentioned and work with these? If so, how do we even come up with different face fluxes since we only have 1 way to calculate the value (constant velocity within the cell)?

So, I suppose that what I wrote in my post is considered first-order? How would I search for this type of approximation? Do you have any resources?
panagiat is offline   Reply With Quote

Old   January 24, 2025, 05:55
Default
  #5
New Member
 
Panagiotis Iatrou
Join Date: Oct 2024
Posts: 11
Rep Power: 2
panagiat is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
Consider that you can partition the east and west faces into sub-partitions each with constant fluxes to approximate a non-constant flux (e.g. e = e1+e2+e3+e3...ej and w=w1+w2+w3+...wk). When you recognize this as a Riemann sum (midpoint rule, mean rule, trapezoidal rule, etc.), then it is more clear that higher order approximations exist for the Riemann integral but at the same time, there isn't a fundamental issue that breaks the whole theory.
I find the approach of thinking of it as a Riemann sum is helpful. If I am not mistaken, this is also the approach when considering the whole domain split in individual cells as when they get smaller and smaller they tend to converge to the analytical solution. So, would this mean that within each cell, we consider every quantity to be constant (whether this is the value of the variable u or the flux of each face)? Isn't this the whole idea behind FVM?
panagiat is offline   Reply With Quote

Old   January 24, 2025, 07:04
Default
  #6
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,944
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by panagiat View Post
What values are going to be used for the mean formula you refer to (since we are talking about one face at a time)? I think I am a bit confused. Do we split the face into subfaces as LuckyTran mentioned and work with these? If so, how do we even come up with different face fluxes since we only have 1 way to calculate the value (constant velocity within the cell)?

So, I suppose that what I wrote in my post is considered first-order? How would I search for this type of approximation? Do you have any resources?



Not a first order ... As you can see, your approach to discretize in a FV manner leads to the same algebric form of the second order accurate FD scheme.
That happens only for linear equations at second order when using the mean formula on stuctured grid. If you really want to see the difference between FV and FD methods, just think about what happens by using the trapezoidal rule for the integrals.
FMDenaro is offline   Reply With Quote

Old   January 24, 2025, 18:47
Default
  #7
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,783
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Quote:
Originally Posted by panagiat View Post
So, would this mean that within each cell, we consider every quantity to be constant (whether this is the value of the variable u or the flux of each face)? Isn't this the whole idea behind FVM?
No, not at all. To again use the Riemann sum example, you can discretize a function and use a particular value in an interval, but you never assume that the function is constant over the interval. Although the area of each partition is equivalent to a constant function over the interval, it is not an explicit presumption that the function is constant. If the function were constant, the integral would be trivial.

In your case, you have to now define how to calculate the fluxes on the east and west faces!

\Bigg[ \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial x}\bigg)_{w} \Bigg] \Delta y + \Bigg[ \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{e} - \bigg(\mu \dfrac{\partial u}{\partial y}\bigg)_{w} \Bigg] \Delta x = 0

You will very quickly discover that obviously u cannot (in general) be constant over the cell because then the east and west fluxes would be equal and the integral becomes the trivial 0=0, which is not useful!
LuckyTran is offline   Reply With Quote

Old   January 28, 2025, 09:03
Default
  #8
New Member
 
Panagiotis Iatrou
Join Date: Oct 2024
Posts: 11
Rep Power: 2
panagiat is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
Although the area of each partition is equivalent to a constant function over the interval, it is not an explicit presumption that the function is constant.
I am a bit confused regarding this. Don't we consider velocity u to be constant inside the cell area and equal to the representative value of the cell (the centroid)?
How is the last step on the discretization process I have in my post (solving the second integral) justified?

Quote:
Originally Posted by LuckyTran View Post
You will very quickly discover that obviously u cannot (in general) be constant over the cell because then the east and west fluxes would be equal and the integral becomes the trivial 0=0, which is not useful!
Sorry I think I have not explained my thoughts correctly. What I meant by saying that we consider every quantity to be constant is that for example throughout an individual cell face the flux is constant, not that all the faces on the cell have the same constant flux and thus the integral does not become 0=0. is this true or am I still mistaken?

Isn't this the next step in the discretization process which includes choosing a scheme? To my understanding (at least in a colocated cartesian grid), we have the unknown velocities at the center of the cell (representative values for the entirety of the cell) and then in order to calculate the fluxes on the cell faces, one must either interpolate (like central differencing) or think of another scheme.
panagiat is offline   Reply With Quote

Old   January 28, 2025, 11:31
Default
  #9
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,783
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
If it makes you feel better, you can add \lim_{\Delta y \to 0} and \lim_{\Delta x \to 0} and replace the equality sign with \approx

Quote:
Originally Posted by panagiat View Post
How is the last step on the discretization process I have in my post (solving the second integral) justified?
The intermediate value theorem guarantees that I can find a flux that will make the integral exact. So is it justifed or not? It can be. There is no mathematical meaning to asking whether or not it is justified until you complete the discretization.

Don't miss the forest for the trees.


\dfrac{\partial}{\partial x}\bigg(\mu \dfrac{\partial u}{\partial  x}\bigg) + \dfrac{\partial}{\partial y}\bigg(\mu \dfrac{\partial  u}{\partial y}\bigg) = 0

First of all, I know I can approach the discretization using the Gauss theorem. However I am interested in the alternative approach, where we evaluate each integral sequentially.
We start by integrating over an arbitrary cell

\int_{a}^{b} f(x)dx \approx f(a \leq x' \leq b)*(b-a)
f(x') is single valued but that is not an assumption that f is constant over the interval a to b. That was my point and I'm sorry that wasn't articulated well
panagiat likes this.

Last edited by LuckyTran; January 28, 2025 at 14:13.
LuckyTran is offline   Reply With Quote

Old   January 31, 2025, 14:08
Default
  #10
New Member
 
Panagiotis Iatrou
Join Date: Oct 2024
Posts: 11
Rep Power: 2
panagiat is on a distinguished road
Thank you, this makes things a lot clearer!
panagiat is offline   Reply With Quote

Old   February 17, 2025, 10:31
Default the x,y,z - component of velocity and diffusion coefficient
  #11
New Member
 
Marek Chodorski
Join Date: Aug 2013
Location: Poland
Posts: 16
Rep Power: 13
marek_ac is on a distinguished road
Hi,
there is a detailed description how to create linear equations to resolve diffusion equation in 3D dynamic with convection:
https://marek-ac.meri.pl/
Marek

Last edited by marek_ac; February 17, 2025 at 10:42. Reason: typo
marek_ac is offline   Reply With Quote

Reply

Tags
diffusion equation, discretization, mathematics

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Velocity Poisson Equation and Vector Potential Poisson Equation mykkujinu2201 Main CFD Forum 1 August 12, 2017 14:15
Discretization of mass conservation equation in a 2D staggered grid kiwiguigou Main CFD Forum 4 April 16, 2016 16:57
Diffusion Advection equation discretization scheme Farouk Main CFD Forum 0 July 2, 2013 17:10
error message cuteapathy CFX 14 March 20, 2012 07:45
Poisson equation fourier transform before discretization yohey44 Main CFD Forum 0 November 9, 2010 13:00


All times are GMT -4. The time now is 06:50.