0
$\begingroup$

I am solving the 1D advection problem given by:

$$\frac{\partial u}{\partial t}=-c\frac{\partial u}{\partial x}$$

where c is the wave speed, and u is the unknown field variable, and x and t are time and space. I am using central differencing to discretise in space. My initial $u$ profile which is being convected is a step profile given by

$u\left(x,t\right)=\left\{ \begin{array}{c} 1\; for\;0<x<1\\ 0\; for\;1<x<2 \end{array}\right.,$

My question is about the boundary conditions. A the moment at the boundaries, if c>0 I have set $u_L=u(1,t)$ (where u(1) is the value of u at the first node), but I end up with a lot of oscillations at the BC.

I have also tried setting $u_L=1$ and $u_R=0$ (R indicates right and L left) and that gives me oscillations too but more sensible ones. I know that with central differencing spurious oscillations are expected but I am not sure about the correct boundary conditions and I would appreciate some help. I searched online for a clear answer but was unsuccessful.

I have also solved the problem with upwinding and by setting $u_L=u(1)$ if c>0 which seems to have worked.

Thank you.

$\endgroup$
  • 1
    $\begingroup$ Central differencing should result in oscillations because the solution will be unstable. Unwinding is the proper technique for this hyperbolic solution to ensure it remains numerically stable. That's why you shouldn't be surprised the upwinded scheme appears to work. $\endgroup$ – spektr Jan 3 '16 at 1:43
  • 1
    $\begingroup$ What is the mathematical boundary condition of your problem? You have only given the initial condition. We certainly can't tell you what the correct boundary condition is -- that's part of the problem definition. Also, since $u$ is a function of two independent variables, it's unclear what $u(1)$ means. $\endgroup$ – David Ketcheson Jan 3 '16 at 3:12
  • $\begingroup$ @DavidKetcheson what do you mean by mathematical BC's? I want the step profile to pass through the boundary without being reflected back and I am not sure how to define that. As mentioned in my question, I understand how to do that for an upwind case but not for CDS. I have tried the BC's mentioned in my question. I added an explanation of what u(1) means. $\endgroup$ – Hooman Jan 3 '16 at 12:26
  • $\begingroup$ @Hooman Your domain has two boundaries. Speaking of the mathematical problem (not the numerical one), no BC needs to be prescribed at the right, but you need a BC at the left to make the problem well-posed. $\endgroup$ – David Ketcheson Jan 4 '16 at 13:17
  • $\begingroup$ @choward Central differencing is not necessarily unstable. It depends on the time discretization. $\endgroup$ – David Ketcheson Jan 4 '16 at 13:19
1
$\begingroup$

Let me briefly explain one helpful and simple approach how to better understand the boundary conditions for your wave equation with constant speed. The idea is that you can consider your problem on the infinite interval and think about an equivalent definition of boundary conditions to such situation.

So for instance if you extend your initial condition $u(x,0)$ to be valid for all real numbers then you can get the values at your boundary nodes from the exact solution $u(x,t)=u(x-c t,0)$, i.e. $u(0,t)=u(-c t, 0)$ and $u(2,t)=u(2-c t,0)$. You see that for the constant speed $c$ you should prescribe the value of solution only for one boundary node (depending on the sign of $c$), because the other boundary value is in fact defined by the initial condition (for some time)

If you want to have the constant values at boundaries, it means you prescribe $u(0,t)=u_L$ if $c>0$ or $u(2,t)=u_R$ if $c<0$. In a theory you can prescribe the both interdependently of $c$, but then in one node it is not "compatible" with your wave equation in the sense that you prescribe some different "process" than your PDE at such node (e.g. a boundary layer phenomena).

Concerning the oscillations in nuemrical solution, as you mentioned yourself and you got also correct and good advice in comments, it is due to inappropriate numerical differencing.

$\endgroup$
  • $\begingroup$ Thank you. I'm not sure I understand the last sentence in the 2nd paragraph. Do you mean that say for c>0, at the left BC, I need to set u_L to the exact solution at x=0 for all time steps but at the right BC, there is not need to define u_R at the BC? I can see that being the case for an upwind case with c>0 where only the info from the end node but not for CDS. I'm probably not understanding this correctly. I would appreciate your help gain. Thanks. $\endgroup$ – Hooman Jan 3 '16 at 12:22
  • $\begingroup$ You understand it correctly. You really have no reason to solve the wave equation with constant speed using central differencing. Not only you obtain unphysicall oscillations, but they will grow in each time step, so your numerical solution can blow up. If you for some reasons still prefer the central differencing, then in the boundary node where no boundary condition is prescribed to apply the central difference scheme you can extrapolate the missing value by e.g. a linear extrapolation. $\endgroup$ – Peter Frolkovič Jan 3 '16 at 12:30
  • $\begingroup$ Thank you. I need to compare the performance of the different method, hence I needed to understand CDS. Thanks again. $\endgroup$ – Hooman Jan 3 '16 at 13:03
  • $\begingroup$ What @PeterFrolkovič is saying is that there are no mathematically correct boundary values you can impose at the right boundary. That your method requires boundary conditions there forces you to "invent" values that you think may be appropriate. But the PDE theory isn't going to help you with that. $\endgroup$ – Wolfgang Bangerth Jan 4 '16 at 5:42
  • $\begingroup$ @WolfgangBangerth PDE theory? I think I'm more confused than before I asked this question ... looks like there's more to this ... can someone please give a clear answer on what they would have done. At the moment I have used the exact solution at the left BC and at the right BC I've extrapolated and it seems to be giving reasonable results. $\endgroup$ – Hooman Jan 5 '16 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.