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

Finite Volume Method in 2D

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 1, 2023, 13:17
Default
  #21
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
I think I am pretty comfortable with what I've done. Constructing the fluxes for the main equations will be messy, but not anything that I can't overcome.



Compute only one flux for each face, then it is sufficien to change the sign to have the fluxes for two adjacent cells.
FMDenaro is offline   Reply With Quote

Old   November 2, 2023, 05:27
Default
  #22
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
Compute only one flux for each face, then it is sufficien to change the sign to have the fluxes for two adjacent cells.
I don't understand what you mean here.
hunt_mat is offline   Reply With Quote

Old   November 2, 2023, 05:36
Default
  #23
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
I don't understand what you mean here.





you have adjacent cells sharing a face, the flux is unique, only the normal unit vector changes.

Thus, you compute for each face the flux and then us that to update the values in time just considering the correct sign.


For example, the flux at the est face of the cell i is equal to the west face of the cell i+1, just with opposite sign.
FMDenaro is offline   Reply With Quote

Old   November 3, 2023, 09:27
Default
  #24
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
you have adjacent cells sharing a face, the flux is unique, only the normal unit vector changes.

Thus, you compute for each face the flux and then us that to update the values in time just considering the correct sign.


For example, the flux at the est face of the cell i is equal to the west face of the cell i+1, just with opposite sign.
I see what you're saying. This would be one of the ways to reduce computational time right? As I don't need to use so many computations?
hunt_mat is offline   Reply With Quote

Old   November 3, 2023, 09:50
Default
  #25
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
I see what you're saying. This would be one of the ways to reduce computational time right? As I don't need to use so many computations?
Not only, this is mandatory to ensure conservation in discrete sense.
hunt_mat likes this.
FMDenaro is offline   Reply With Quote

Old   November 6, 2023, 05:39
Default
  #26
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
If I were to now discretise the equation in detail, I use the approximation:
f(x)+f(x+\delta x)\approx 2f(x+\delta x/2)
The equation then becomes:
\int_{X}^{X+\delta X}C(s,Y+\delta Y/2)ds+\int_{Y}^{Y+\delta Y}D(X+\delta X/2,s)ds\approx 0
Using the midpoint rule for integrals, the equation reduces to:
C(X+\delta X/2,Y+\delta Y/2)\delta X+D(X+\delta X/2,Y+\delta Y/2)\delta Y\approx 0
This looks reasonable to me, but that doesn't necessarily mean that it's correct.
hunt_mat is offline   Reply With Quote

Old   November 6, 2023, 06:58
Default
  #27
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
If I were to now discretise the equation in detail, I use the approximation:
f(x)+f(x+\delta x)\approx 2f(x+\delta x/2)
The equation then becomes:
\int_{X}^{X+\delta X}C(s,Y+\delta Y/2)ds+\int_{Y}^{Y+\delta Y}D(X+\delta X/2,s)ds\approx 0
Using the midpoint rule for integrals, the equation reduces to:
C(X+\delta X/2,Y+\delta Y/2)\delta X+D(X+\delta X/2,Y+\delta Y/2)\delta Y\approx 0
This looks reasonable to me, but that doesn't necessarily mean that it's correct.

I suggest thinking always to the discretization of the outer operator, in this case the integral.

In a more general second order discretization, you can use trapezoidal rule. You see a different and larger stencil.
FMDenaro is offline   Reply With Quote

Old   November 6, 2023, 07:20
Default
  #28
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
I suggest thinking always to the discretization of the outer operator, in this case the integral.

In a more general second order discretization, you can use trapezoidal rule. You see a different and larger stencil.
Which I did. If X and X+dX are very close to each other then the approximation I gave should be valid.
hunt_mat is offline   Reply With Quote

Old   November 6, 2023, 07:55
Default
  #29
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
Which I did. If X and X+dX are very close to each other then the approximation I gave should be valid.
No, the trapezoidal rule is not what you wrote. You wrote the mean value formula, is second order only on a regular grid.
The trapezoidal rule is [f(a)+f(b)]*h/2
FMDenaro is offline   Reply With Quote

Old   November 6, 2023, 10:00
Default
  #30
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
No, the trapezoidal rule is not what you wrote. You wrote the mean value formula, is second order only on a regular grid.
The trapezoidal rule is [f(a)+f(b)]*h/2
For small enough dX, and dY, then the approximations are as good as each other, and implementing makes things harder,
hunt_mat is offline   Reply With Quote

Old   November 6, 2023, 10:05
Default
  #31
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,728
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
You still need to discretize the face flux (the integral) either way. You don't know C(x+dx/2,y+dy/2)*dx

I don't understand this obsession with midpoint rule or small dx and small dy. We are in the realm of discrete math. Delta-epsilon arguments don't work here. There is (almost) always a finite error that is the neglected higher order terms (almost unless you have a TVD scheme). This is just another rabbit hole. Just write out the entire discretized integral (i.e. write down the face flux already!).




Let me point out what is wrong with the logic. For small enough dx and dy f(x,y)=f(x+dx,y+dy)=f(x+2dx,y+2dy) are all equally good approximations of each other. Clearly there are practical issues with this implementation.
LuckyTran is offline   Reply With Quote

Old   November 6, 2023, 11:03
Default
  #32
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
For small enough dX, and dY, then the approximations are as good as each other, and implementing makes things harder,

No, for your problem you have to write properly the equation by dividing for the measure of the volume this way




1/(dx*dy) * Integral[S] v.f ds=0



and when dx,dy->0 the equation tend to Div.f=0.


It is ok to use the midpoint rule but be aware that is only first order accurate on an irregular grid.
FMDenaro is offline   Reply With Quote

Old   November 6, 2023, 11:11
Default
  #33
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
You still need to discretize the face flux (the integral) either way. You don't know C(x+dx/2,y+dy/2)*dx

I don't understand this obsession with midpoint rule or small dx and small dy. We are in the realm of discrete math. Delta-epsilon arguments don't work here. There is (almost) always a finite error that is the neglected higher order terms (almost unless you have a TVD scheme). This is just another rabbit hole. Just write out the entire discretized integral (i.e. write down the face flux already!).




Let me point out what is wrong with the logic. For small enough dx and dy f(x,y)=f(x+dx,y+dy)=f(x+2dx,y+2dy) are all equally good approximations of each other. Clearly there are practical issues with this implementation.
The logic is fine. I like the mid-point rule because this yields the approximant as the centre of the cell, which is what I want. The fluxes have been computed as the flux F=(D,-C), has been computed, I have computed the integral using the mid-point rule. If I used the trapezium rule, I would then have to approximate the function on the cell edges. The mid-point rule gets around that.
hunt_mat is offline   Reply With Quote

Old   November 6, 2023, 11:13
Default
  #34
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
No, for your problem you have to write properly the equation by dividing for the measure of the volume this way




1/(dx*dy) * Integral[S] v.f ds=0



and when dx,dy->0 the equation tend to Div.f=0.


It is ok to use the midpoint rule but be aware that is only first order accurate on an irregular grid.
I'm using the reference configuration, so it will be a regular grid. Can you explain why what you wrote is relevant to my question? I don't understand what you're saying.
hunt_mat is offline   Reply With Quote

Old   November 6, 2023, 11:28
Default
  #35
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
I'm using the reference configuration, so it will be a regular grid. Can you explain why what you wrote is relevant to my question? I don't understand what you're saying.



if you work only on the equation Int[S] n.f dS=0, this equation would be erroneously verified for |S|->0, even for a wrong flux.


To be consistent to the limit for vanishing dx and dy you have to divide the integral.



As far as the discretization of the integral is concerned, the mid-point rule has a poor spectral representation compared to the trapezoidal rule.
FMDenaro is offline   Reply With Quote

Old   November 6, 2023, 12:16
Default
  #36
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
if you work only on the equation Int[S] n.f dS=0, this equation would be erroneously verified for |S|->0, even for a wrong flux.


To be consistent to the limit for vanishing dx and dy you have to divide the integral.



As far as the discretization of the integral is concerned, the mid-point rule has a poor spectral representation compared to the trapezoidal rule.
What are you trying to get at?
hunt_mat is offline   Reply With Quote

Old   November 6, 2023, 12:23
Default
  #37
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
What are you trying to get at?



just answered to your doubts ...
FMDenaro is offline   Reply With Quote

Old   November 6, 2023, 12:34
Default
  #38
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
just answered to your doubts ...
You've not actually answered in a way that makes sense to me. You don't seem to like the midpoint approximation for some reason, the trapezium introduces complications for obvious reasons.
hunt_mat is offline   Reply With Quote

Old   November 6, 2023, 13:00
Default
  #39
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by hunt_mat View Post
You've not actually answered in a way that makes sense to me. You don't seem to like the midpoint approximation for some reason, the trapezium introduces complications for obvious reasons.



You need to study the spectral analysis of the formulas and look at the resulting error in the wavenumber space to understand why.

But I think you are not interested in that, so use the midpoint rule that is very easy to implement.
FMDenaro is offline   Reply With Quote

Old   November 7, 2023, 05:03
Default
  #40
Senior Member
 
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 178
Rep Power: 4
hunt_mat is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
You need to study the spectral analysis of the formulas and look at the resulting error in the wavenumber space to understand why.

But I think you are not interested in that, so use the midpoint rule that is very easy to implement.
I'm not doing Fourier analysis here. It's a very nonlinear problem.
hunt_mat is offline   Reply With Quote

Reply

Tags
finite volume method


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
finite volume method and finite difference method harishkamat100 FLUENT 3 December 21, 2020 23:52
Finite element method ANSYS CFX tomd97 CFX 2 April 4, 2018 04:10
Mesh; wall function for element based finite volume method sheaker CFX 2 January 25, 2018 17:36
ALE in finite volume method littlelz Main CFD Forum 5 June 21, 2003 12:50
finite volume method for CFD analysis of 2D blunt body Aditya Vaze Main CFD Forum 1 January 19, 2000 13:55


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