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

periodic boundary conditions with a gradient term

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

Like Tree4Likes
  • 1 Post By andy_
  • 1 Post By andy_
  • 1 Post By michujo
  • 1 Post By andy_

Reply
 
LinkBack Thread Tools Display Modes
Old   March 6, 2013, 05:11
Default periodic boundary conditions with a gradient term
  #1
Member
 
Join Date: Jun 2010
Posts: 98
Rep Power: 7
Hooman is on a distinguished road
Hi,
I have been trying to implement periodic bc's in my 1D code, I have a gradient term in my code, which I have discretized by using central differencing, so I have
du/dx = (u_i+1 - u_i)/(x_i+1 - x_i)
so for a periodic bc at the left and right boundaries I have used
du/dx = (u_1 - u_N)/(x_1 - x_N)

where N is the final cell, but for some reason I get weird results at the boundaries.
Could someone please confirm that what I am doing it correct.
Thanks!
Hooman is offline   Reply With Quote

Old   March 6, 2013, 07:49
Default
  #2
Senior Member
 
andy
Join Date: May 2009
Posts: 129
Rep Power: 8
andy_ is on a distinguished road
Quote:
Originally Posted by Hooman View Post
Hi,
I have been trying to implement periodic bc's in my 1D code, I have a gradient term in my code, which I have discretized by using central differencing, so I have
du/dx = (u_i+1 - u_i)/(x_i+1 - x_i)
so for a periodic bc at the left and right boundaries I have used
du/dx = (u_1 - u_N)/(x_1 - x_N)

where N is the final cell, but for some reason I get weird results at the boundaries.
Could someone please confirm that what I am doing it correct.
Thanks!
You expression looks one-sided rather than central?

du/dx = (u_i+1 - u_i-1)/(x_i+1 - x_i-1) ???

For a pure upwind scheme the downstream value is not used and so can take any value. Setting it to the first solved value would look tidy but is not required. Is this what you are seeing?

Do you need to perform a line sweep to handle the unknown upstream boundary value? The code for periodic line sweeps is different to that for Dirichlet and Neumann line sweeps.
Hooman likes this.
andy_ is offline   Reply With Quote

Old   March 6, 2013, 08:07
Default
  #3
Member
 
Join Date: Jun 2010
Posts: 98
Rep Power: 7
Hooman is on a distinguished road
oooh! Thanks! Stupid of me to think I was using CDS!

I want to avoid a scheme that is based on the direction of the flow, are there such schemes that can be used just with 2 neighbouring cells involved, like in 1sr order upwind? I don't see how that would be possible but I though I'd ask just in case ...

about CDS, would the expression "du/dx = (u_i+1 - u_i-1)/(x_i+1 - x_i-1) " give du/dx across the east face or the west face of node i?
or would they both be the same. I am using collocated grid. Slightly confused by that for some reason. Would really appreciate you help.


Many Thanks!

Last edited by Hooman; March 6, 2013 at 08:33. Reason: more question
Hooman is offline   Reply With Quote

Old   March 6, 2013, 08:27
Default
  #4
Senior Member
 
andy
Join Date: May 2009
Posts: 129
Rep Power: 8
andy_ is on a distinguished road
Quote:
Originally Posted by Hooman View Post
oooh! Thanks! Stupid of me to think I was using CDS!

I want to avoid a scheme that is based on the direction of the flow, are there such schemes that can be used just with 2 neighbouring cells involved, like in 1sr order upwind? I don't see how that would be possible but I though I'd ask just in case ...

Many Thanks!
You don't say which equations you are solving. Diffusion works well with central schemes but convection does not. To make convection dominated flows behave some form of upwinding is usually used because it is physically the correct thing to do. An alternative is to use some form of energy preserving differencing but in the absence of some diffusion these often produce unreasonable solution over a long time period. There is of course loads of stuff on the topic in the literature going back to the 1960s.
Hooman likes this.
andy_ is offline   Reply With Quote

Old   March 6, 2013, 08:37
Default
  #5
Member
 
Join Date: Jun 2010
Posts: 98
Rep Power: 7
Hooman is on a distinguished road
Thanks Andy,

just added a bit to my previous question, I would appreciate you answer to that as well:
about CDS, would the expression "du/dx = (u_i+1 - u_i-1)/(x_i+1 - x_i-1) " give du/dx across the east face or the west face of node i?
or would they both be the same. I am using collocated grid.

Many Thanks
Hooman is offline   Reply With Quote

Old   March 6, 2013, 09:15
Default
  #6
Senior Member
 
andy
Join Date: May 2009
Posts: 129
Rep Power: 8
andy_ is on a distinguished road
Quote:
Originally Posted by Hooman View Post
about CDS, would the expression "du/dx = (u_i+1 - u_i-1)/(x_i+1 - x_i-1) " give du/dx across the east face or the west face of node i? or would they both be the same. I am using collocated grid.
The expression is the usual central difference approximation for the gradient of u at the location i. If you are evaluating the gradient at cell walls then this looks to be part of doing something more. Perhaps part of an upwinding scheme or the first stage of working out the second derivatives? I think you might be better off reading a book for answers to this level of question.
andy_ is offline   Reply With Quote

Old   March 6, 2013, 09:26
Default
  #7
Member
 
Join Date: Jun 2010
Posts: 98
Rep Power: 7
Hooman is on a distinguished road
This forum was my last resort not first! I've read Versteeg, and other books, etc. I couldn't find what I wanted, perhaps because my equations are slightly different.
Thanks anyways! Your replies helped.
Hooman is offline   Reply With Quote

Old   March 6, 2013, 09:37
Default
  #8
Member
 
Join Date: Jun 2010
Posts: 98
Rep Power: 7
Hooman is on a distinguished road
This is the term I'm trying to discretize using FVM:

\intop_{\Gamma}\frac{\partial\underline{u}}{\partial x}.\underline{n}d\Gamma\overline{}

where {\Gamma} , is the cell surface.

Versteeg upwinds in this case.
Hooman is offline   Reply With Quote

Old   March 6, 2013, 09:53
Default
  #9
Senior Member
 
Join Date: Dec 2011
Location: Madrid, Spain
Posts: 133
Rep Power: 6
michujo is on a distinguished road
Hi, apart from the comments you got on the numerical schemes, I think there is a mistake in the first expression you showed for the discretization of the derivative at the boundary. You are dividing by (x1-xN) which, if I understand the notation, is about the whole length of the channel!. I think you should divide by something like 0.5\cdot\Delta x_N+0.5\cdot\Delta x_1, where [\Delta x_i] is the cell size. This expression is the length between the nodes N and 1 assuming the nodes are centered within the cells.

Maybe you could give it a try.

Cheers,
Michujo.
Hooman likes this.
michujo is offline   Reply With Quote

Old   March 6, 2013, 10:07
Default
  #10
Member
 
Join Date: Jun 2010
Posts: 98
Rep Power: 7
Hooman is on a distinguished road
Quote:
Originally Posted by michujo View Post
You are dividing by (x1-xN) which, if I understand the notation, is about the whole length of the channel!. I think you should divide by something like 0.5\cdot\Delta x_N+0.5\cdot\Delta x_1, where [\Delta x_i] is the cell size. This expression is the length between the nodes N and 1 assuming the nodes are centered within the cells.
aaa! well spotted! that improved the results a little. Many Thanks!

still looking for a central differenced scheme if anyone has any ideas ... I will keep looking myself!
Hooman is offline   Reply With Quote

Old   March 6, 2013, 12:46
Default
  #11
Senior Member
 
andy
Join Date: May 2009
Posts: 129
Rep Power: 8
andy_ is on a distinguished road
Quote:
Originally Posted by Hooman View Post
This is the term I'm trying to discretize using FVM:

\intop_{\Gamma}\frac{\partial\underline{u}}{\partial x}.\underline{n}d\Gamma\overline{}

where {\Gamma} , is the cell surface.

Versteeg upwinds in this case.
This looks like diffusion rather than convection? If so, that is a much better behaved problem and is possibly better tackled by placing the unknowns at the cell faces and not the cell centres. That is, a standard Galerkin FEM approach. But the best arrangement of grid and unknowns may well be determined by where you are going with whatever you are trying to solve.
Hooman likes this.
andy_ is offline   Reply With Quote

Old   March 6, 2013, 13:05
Default
  #12
Member
 
Join Date: Jun 2010
Posts: 98
Rep Power: 7
Hooman is on a distinguished road
Quote:
Originally Posted by andy_ View Post
This looks like diffusion rather than convection? If so, that is a much better behaved problem and is possibly better tackled by placing the unknowns at the cell faces and not the cell centres. That is, a standard Galerkin FEM approach. But the best arrangement of grid and unknowns may well be determined by where you are going with whatever you are trying to solve.
Thanks again!
I have thought about moving the nodes but was trying my best to stick with FVM with nodes in the centre, because I have convection terms as well. I will give it some serious thought now ... Thanks!
Hooman is offline   Reply With Quote

Old   March 6, 2013, 13:25
Default
  #13
Member
 
Join Date: Jun 2010
Posts: 98
Rep Power: 7
Hooman is on a distinguished road
I just took the average of the CDS obtained for the cell centres to the two sides of the faces of the current cell and it seems to work OK so far ... It involves more cells, but for now I think it's doing the job, fingers crossed!
Thanks for you guidance!
Hooman is offline   Reply With Quote

Reply

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
Wind turbine simulation Saturn CFX 34 October 16, 2014 05:27
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 6 April 17, 2010 23:40
RPM in Wind Turbine Pankaj CFX 9 November 23, 2009 05:05
periodic boundary conditions mranji1 Main CFD Forum 4 August 24, 2009 23:45
3D non-conformal periodic boundary conditions Simon Riverin FLUENT 4 February 23, 2007 02:35


All times are GMT -4. The time now is 23:07.