How to compute derivatives at cell center using adjacent cells?

84 Views Asked by At

I'm trying to compute spatial derivatives of quantity u, $\partial u \over \partial x$ and $\partial u \over \partial y$, at the center of the cells of a mesh.

I know the value u at the center of each cell, and the value at the center of each cell is considered to be the average value of u in the cell.

How do I calculate(approximate) the derivatives in a given cell if I know the value of u in the neighboring cells?

The mesh in question is very similar to the one in the picture attached.

I'm pretty sure I should be using some sort of central difference, but my confusion stems from the fact the the cell coordinates i,j do not line up with spatial coordinates x,y. Also, the mesh is structured, as shown, but is not evenly spaced. I can calculated the locations of the cell centers if needed.

Can somebody show me the exact expressions I can use to approximate the derivatives?

1

There are 1 best solutions below

0
On BEST ANSWER

Firstly, your $u$ function is defined on the space, so to make our manipulations easier, I'm gonna define $U : i, j \mapsto u(M(i, j))$, which is basically the same function but defined on the mesh instead of the space, where your mesh is doubly-parametered and defined by $M = \left \{ (x(i, j), y(i, j)), (i, j) \in [i_m, i_M]\times[j_m, j_M] \right \}$.

Basically, you want to find $\partial_x u$ and $\partial_y u$ when what you know is $U(i, j)$. Multivariate chain rule tells us that :

$$\partial_i U = \left <\nabla u \middle| \partial_i M \right >$$

In the same spirit :

$$\partial_j U = \left <\nabla u \middle| \partial_j M \right >$$

This can be rearranged into a system of two equations with two unknowns :

$$\begin{cases} \partial_iU = \partial_xu \times \partial_ix + \partial_yu \times \partial_iy \\ \partial_jU = \partial_xu \times \partial_jx + \partial_yu \times \partial_jy \end{cases}$$

There are indeed only two unknowns because we can deduct all the other derivatives with finite differences. This is always solvable as none of the derivatives are degenerate (they will never be 0).

Solving this system for $\partial_xu$ and $\partial_yu$ will yield the formula you want, and you'll just have to replace every derivative with their finite differences counterpart using the values of $u$ that you know on the mesh (through $U$). Also, you can calculate the derivatives of $x$ and $y$ using finite differences with the positions of the centers of your cells.