normal derivatives where normal vector is ill-defined

I have to calculate the normal derivative of a function $f(i,j)$ on a domain with an irregular boundary. Let's say something like this:

x x x x
0 x 0 0
0 0 0 0

where x indicates a solid boundary.

Which is the correct way to calculate the normal derivative of $f$ at the grid point (1,2) and (3,2)?

Should I simply sum the two partial derivatives?

For example, for the grid point (1,2), would this work?

$$\frac{\partial f}{\partial \hat{n}}\bigg\rvert_{(i=1,~j=2)} = \frac{\partial f}{\partial x}\bigg\rvert_{(i=1,~j=2)} + \frac{\partial f}{\partial y}\bigg\rvert_{(i=1,~j=2)}$$

• To clarify, i is the column, j is the row, and they are both starting from zero? – Tyberius Apr 23 '18 at 14:30
• @Tyberius i is the column, j is the row, they start from 1 and from the lower left corner. The problematic points are the ones where the boundary forms corners. – shamalaia Apr 23 '18 at 15:14
• I'm just used to the opposite ordering and one of your expressions has f(1,0) – Tyberius Apr 23 '18 at 16:19
• @Tyberius I edited the question in a way to not get confused by indeces – shamalaia Apr 26 '18 at 0:55

First of all, there is a distinction between a continuous boundary having regions with ill-defined normal derivative - and its discretization having regions will ill-defined derivatives. The question describes a bit confusing discretized boundary with one point sticking out. I have a hard time imagining a boundary that could be discretized this way to solve some problem with just one point sticking out.

A classic example of a continuous boundary in 2D with such problems would be a corner, where at a corner point the direction of the normal will be undefined; thus, resulting in an ill-defined normal derivative.

So, if the normal is ill-defined -> the normal derivative is ill-defined as well.

Now, a lot depends on what you actually intend to do with your normal derivatives. For example, you might want to enforce some boundary conditions on them or use their values in some other method that requires them.

I don't think that taking the definition of a normal derivative at such bad point as a sum of two partial derivatives has any physical meaning. For a crude approximation, you might consider your corner normal to be defined either as $\hat{n}=\hat{x}$ or $\hat{n}=\hat{y}$, effectively assigning a corner to a certain part of the boundary having a well-defined normal. I have also seen averaging out the values of those derivatives (which will be 0.5 times your proposed result) being done. However, that's a decision not to handle the issue.

Some approaches would avoid having the corner point at all (having only points very close to the point with the undefined normal) or instead of a normal derivative, a reformulation with adding additional equations might be required.

The paper

features a nice overview (or references) of different techniques to handle those situations for corners, which might be useful for your needs.