# periodic boundary conditions with a gradient term

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 LinkBack Thread Tools Display Modes
 March 6, 2013, 05:11 periodic boundary conditions with a gradient term #1 Member   Join Date: Jun 2010 Posts: 98 Rep Power: 7 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!

March 6, 2013, 07:49
#2
Senior Member

andy
Join Date: May 2009
Posts: 129
Rep Power: 8
Quote:
 Originally Posted by Hooman 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.

 March 6, 2013, 08:07 #3 Member   Join Date: Jun 2010 Posts: 98 Rep Power: 7 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

March 6, 2013, 08:27
#4
Senior Member

andy
Join Date: May 2009
Posts: 129
Rep Power: 8
Quote:
 Originally Posted by Hooman 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.

 March 6, 2013, 08:37 #5 Member   Join Date: Jun 2010 Posts: 98 Rep Power: 7 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

March 6, 2013, 09:15
#6
Senior Member

andy
Join Date: May 2009
Posts: 129
Rep Power: 8
Quote:
 Originally Posted by Hooman 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.

 March 6, 2013, 09:26 #7 Member   Join Date: Jun 2010 Posts: 98 Rep Power: 7 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.

 March 6, 2013, 09:37 #8 Member   Join Date: Jun 2010 Posts: 98 Rep Power: 7 This is the term I'm trying to discretize using FVM: where , is the cell surface. Versteeg upwinds in this case.

 March 6, 2013, 09:53 #9 Senior Member   Join Date: Dec 2011 Location: Madrid, Spain Posts: 133 Rep Power: 6 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 , 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.

March 6, 2013, 10:07
#10
Member

Join Date: Jun 2010
Posts: 98
Rep Power: 7
Quote:
 Originally Posted by michujo 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 , 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!

March 6, 2013, 12:46
#11
Senior Member

andy
Join Date: May 2009
Posts: 129
Rep Power: 8
Quote:
 Originally Posted by Hooman This is the term I'm trying to discretize using FVM: where , 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.

March 6, 2013, 13:05
#12
Member

Join Date: Jun 2010
Posts: 98
Rep Power: 7
Quote:
 Originally Posted by andy_ 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!

 March 6, 2013, 13:25 #13 Member   Join Date: Jun 2010 Posts: 98 Rep Power: 7 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!

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Saturn CFX 34 October 16, 2014 05:27 Ardalan Main CFD Forum 6 April 17, 2010 23:40 Pankaj CFX 9 November 23, 2009 05:05 mranji1 Main CFD Forum 4 August 24, 2009 23:45 Simon Riverin FLUENT 4 February 23, 2007 02:35

All times are GMT -4. The time now is 11:22.

 Contact Us - CFD Online - Top