Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a PDE with mixed boundaries (Neumann and Dirichlet on some sides) in the region

$(t,x,y) \in \left( 0, T\right) \times\left\{ -L \leq x \leq L, 0 \leq y \leq h(x) \right\}$

where $h(x)$ is something like $\exp\left\{ -(x-x^*)^2\right\}$, doesn't matter. And I have Neumann boundary condition on the curve $\left(x, h(x)\right)$.

How can I provide such region to NDSolve?

share|improve this question
Perhaps you may find a mapping that transforms that into a rectangle –  belisarius Dec 25 '13 at 18:30
This related question may help. Basically, go from (t,x,y) to (t,x,u) where u=H corresponds to the boundary y=h(x). –  Timothy Wofford Dec 26 '13 at 8:29
add comment

1 Answer

NDSolve requires a rectangular domain, so you have to make a change of coordinates.

$(t,x,y) \in \left( 0, T\right) \times\left\{ a \leq x \leq b, g(x) \leq y \leq h(x) \right\}$

Since you have explicit expressions for your boundaries ($x=a$, $x=b$, $y=g(x)$, and $y=h(x)$), we can use a linear interpolation

x[u_, v_] = (1 - u)*a + u*b
y[u_, v_] = With[{x=x[u,v]},(1 - v)*g[x] + v*h[x]]
$Assumptions = {Element[{g[_], h[_]}, Reals], h[a_] > g[a_]}

In terms of these coordinates your domain becomes

$(t,u,v) \in \left( 0, T\right) \times\left\{ 0 \leq u \leq 1, 0 \leq v \leq 1 \right\}$

In my other answer I described how to transform the PDE. The general steps are

  1. write your metric
  2. find its inverse and determinant
  3. find the basis vectors and basis covectors
  4. transform components of vectors into the new coordinate bases
  5. find expressions for operations (directional derivatives, laplacians, etc.)
  6. transform PDE and IV/BVs

NDSolve should then be able to give you a solution in terms of $u$ and $v$.


You then have to map your result onto your original domain.

u[x_,y_]:= (x-a)/(b-a)
v[x_,y_]:= (y-g[x])/(h[x]-g[x])
F[t_,x_,y_]:= sol[t,u[x,y],v[x,y]]
share|improve this answer
I responded yesterday with a similar answer but deleted it when I realized that my approach did not deal correctly with the Neumann type boundary condition at the top. The problem is that your transformation does not preserve orthogonality on the top boundary thus, a Neumann condition in the (x,y) plane doesn't translate to a normal derivative in the (u,v) plane. Furthermore, NDSolve doesn't work when non-normal derivatives are are included as boundary conditions, it issues an NDSolve::bcnorm error. I could temporarily un-delete my answer, if you like. –  Mark McClure Dec 27 '13 at 18:33
@MarkMcClure, I was wondering why you deleted your answer. I would un-delete it, since it had good info. If it has a mistake, you can edit a comment, and maybe we can fix it. I agree that the equation representing the boundary condition must be changed along with PDE. The Neumann BC is n[x].grad[F[x,h[x]]==bc[x]. In the answer I linked to, I showed how to transform the directional derivative. –  Timothy Wofford Dec 27 '13 at 19:12
@MarkMcClure I see what you mean now. We need to find a better coordinate transformation. One in which not only is the coordinate constant along the boundary, but the coordinate basis vector is normal to the boundary. –  Timothy Wofford Dec 27 '13 at 23:18
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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