0
$\begingroup$

Coding a finite difference algorithm in 1D does not require a complex mesh. In higher dimensions, you would need a mesh and its connectivity graph to compute the differential operators. Finite elements can be seen as a generalization of finite differences.

So my question is:

How is a finite difference code implemented? Are finite difference methods implemented with finite element algorithms on a Cartesian mesh using a product of P1 basis functions?

$\endgroup$
4
  • 2
    $\begingroup$ I wouldn't consider finite elements to be a generalization of finite differences, the formulation of the weak problem is quite unique and not at all how finite differences operates. High order finite volume methods might be a more apt comparison to high order finite differences. There is the K-Exact method which generalizes high order finite volume methods to arbitrary order and unstructured meshes, though it still suffers from the fundamental problem of wide stencil methods that you have to figure out what to do at the boundaries. $\endgroup$ Commented May 10 at 16:08
  • 1
    $\begingroup$ and it is possible to treat low order finite volume methods as equivalent to a piecewise constant discontinuous Galerkin method in certain situations. $\endgroup$ Commented May 10 at 16:11
  • $\begingroup$ If it is a Cartesian mesh, the basis functions are tensor products of P1 basis functions (e.g. nodal basis), and if the continuity is enforced (e.g. if it is not a DG method), then yes, FEM and FDM will give you exactly the same matrix, the same right hand side and the same solution for all linear problems $\endgroup$ Commented May 12 at 2:29
  • 1
    $\begingroup$ Implementing a FDM via FEM assembly seems a bit overkill as the primary advantage of FDM is that the operators and connectivity are known ahead of time so that the discretization can be chosen to have advantageous structure. $\endgroup$
    – whpowell96
    Commented May 12 at 17:31

1 Answer 1

5
$\begingroup$

Finite differences are implemented by fitting a (multivariate) interpolating polynomial through a set of points and taking the derivatives of said interpolating polynomial. Contrary to popular belief (mainly due to the tensor product FDM being what you find in introductory books) this works also on an unstructured set of points, it's just harder to decide which points the polynomial should choose to interpolate in a specific region (so essentially that induces something like a mesh). See the following: "The finite difference method at arbitrary irregular grids and its application in applied Mechanics" by Liszka and Orkisz. Here is also a paper using FDM on an FEM mesh "A simple finite difference approach using unstructured meshes from FEM mesh generators" by Fernandez and Kulas, or also "THE FINITE DIFFERENCE ELEMENT METHOD (FDEM) WITH EXAMPLES AND ERROR ESTIMATES" by Adolph and Schönauer.

Using (multivariate) polynomials relates to a (multivariate) Taylor expansion, but you could also use some other functions to extend your data over space (e.g. Gaussians, piecewise linear functions, splines) as long as you can define a derivative in a meaningful sense. So from that point of view you can interpret FDM, FEM, and FVM as closely related.

$\endgroup$
2
  • $\begingroup$ Ty. I read the second article you mentioned. It looks like a local surface fitting algorithm and I dont get where is the FDM part in it. Since after fitting the curve, you can have an approximation of the derivatives by differentiating the surface. $\endgroup$
    – mle
    Commented May 29 at 22:37
  • 1
    $\begingroup$ @mle Classical FDM locally fits an interpolating polynomial and takes the derivatives of it. You can prove that this is the same result as from the Taylor expansion. As far as I am aware the reason it is called finite differences is because some derivatives can be expressed as differences between the point values in the tensor product grid setting, e.g. $d_x f(x) = \frac{f(x+h)-f(x)}{h} + O(h)$. But the above is just a special case of taking the derivative of a linear function interpolating $(x,f(x))$ and $(x+h, f(x+h))$. More generally you can take higher degree polynomials and more points. $\endgroup$
    – lightxbulb
    Commented May 30 at 10:19

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