Search

Compact Finite Difference

13 min read 0 views
Compact Finite Difference

Introduction

Compact finite difference schemes are a class of numerical discretisations for partial differential equations that achieve high accuracy with relatively small stencil widths. Unlike conventional explicit finite difference approximations, which express derivatives directly in terms of neighbouring grid values, compact schemes involve implicit relations between the desired derivative and the function values at a set of grid points. This implicitness leads to a tridiagonal or cyclic tridiagonal system that must be solved at each time step or spatial step. The resulting schemes can provide spectral-like resolution while retaining the simplicity and flexibility of finite difference methods. Compact finite difference techniques are widely employed in computational fluid dynamics, acoustics, electromagnetics, and other areas where high fidelity solutions of wave-like or turbulent flows are required.

History and Background

The concept of compact finite difference was introduced in the 1970s as a means of increasing the spatial resolution of finite difference solvers without expanding the computational stencil. Early work by H. H. Lele in the late 1970s and early 1980s formalised the approach and demonstrated its superior dispersion properties in the context of compressible flow simulations. Lele's seminal papers established compact schemes as a practical alternative to Fourier spectral methods for problems with complex geometries or non-periodic boundary conditions.

Prior to Lele, implicit finite difference formulations had appeared in the context of numerical analysis for differential equations, but they were typically used for solving boundary value problems rather than for time-dependent partial differential equations. The modern compact finite difference framework capitalised on the idea that an implicit relation between the derivative and the function values could be inverted efficiently by solving a sparse linear system, especially when the system is tridiagonal. The development of fast algorithms for tridiagonal matrix inversion made such implicit schemes computationally attractive.

In the 1990s and 2000s, compact schemes were extended to non-uniform grids, higher spatial dimensions, and coupled with advanced time integration methods. The use of compact schemes in direct numerical simulation (DNS) of turbulent flows became common practice, and their combination with spectral filtering and artificial viscosity techniques provided a robust toolbox for high-order simulations.

Mathematical Foundations

Consider a uniform one-dimensional grid with spacing \(h\). Let \(u_i\) denote the numerical approximation to the exact solution \(u(x)\) at grid point \(x_i = i h\). A compact finite difference approximation for the first derivative can be written in the general form

\[ a\,u'_i + b\,u'_{i-1} + c\,u'_{i+1} = \frac{1}{h}\left( \alpha\,u_{i+1} + \beta\,u_i + \gamma\,u_{i-1}\right), \]

where \(u'_i\) denotes the approximation to \(u_x\) at \(x_i\), and \(a, b, c, \alpha, \beta, \gamma\) are constants chosen to achieve a desired order of accuracy. The left-hand side couples the derivative at neighbouring points, rendering the scheme implicit. For a centered scheme with symmetry, one typically sets \(b = c\) and \(\alpha = \gamma\). A common choice for a sixth‑order compact approximation is

\[ \frac{1}{4} u'_{i-1} + u'_i + \frac{1}{4} u'_{i+1} = \frac{3}{8h}\left( u_{i+1} - u_{i-1}\right), \]

which yields a tridiagonal system for the derivative vector \(\mathbf{u}' = \{u'_i\}\). The right-hand side contains only function values, while the left-hand side involves neighboring derivatives. Solving the linear system gives the derivative at all interior points in a single sweep.

Standard Finite Difference vs Compact

Explicit finite difference schemes express the derivative solely in terms of function values. For example, the classical second‑order central difference for the first derivative is

\[ u'_i \approx \frac{u_{i+1} - u_{i-1}}{2h}. \]

To achieve a higher order, explicit schemes require wider stencils; a fourth‑order central difference uses points up to \(i \pm 2\). This widening increases the bandwidth of the discretisation matrix and can degrade the efficiency of linear solvers or lead to more complicated boundary treatments.

Compact schemes achieve high order with only nearest‑neighbour couplings, keeping the stencil narrow. The implicit relation results in a sparse banded system that can be solved efficiently with specialised algorithms. The reduced stencil width also simplifies the implementation of complex boundary conditions.

Derivation of Compact Schemes

The coefficients of a compact scheme are derived by matching the Taylor series expansion of both sides of the discretisation up to a desired order. For a sixth‑order compact scheme, the Taylor expansions of the terms up to \(O(h^6)\) are equated, yielding a system of equations for the unknown coefficients. Solving this system provides the coefficients that cancel all truncation errors up to the target order.

In practice, one begins by expanding \(u_{i\pm 1}\) and \(u'_{i\pm 1}\) about \(x_i\) using Taylor series:

\[ u_{i\pm 1} = u_i \pm h u'_i + \frac{h^2}{2} u''_i \pm \frac{h^3}{6} u'''_i + \frac{h^4}{24} u^{(4)}_i \pm \frac{h^5}{120} u^{(5)}_i + \frac{h^6}{720} u^{(6)}_i + O(h^7), \]

\[ u'_{i\pm 1} = u'_i \pm h u''_i + \frac{h^2}{2} u'''_i \pm \frac{h^3}{6} u^{(4)}_i + \frac{h^4}{24} u^{(5)}_i \pm \frac{h^5}{120} u^{(6)}_i + O(h^6). \]

Substituting these into the compact discretisation and collecting terms yields conditions on the coefficients that eliminate lower‑order errors. The remaining truncation error is of order \(O(h^p)\) where \(p\) is the intended order of accuracy.

Spectral-like Accuracy

One of the main advantages of compact schemes is their ability to emulate the dispersion properties of spectral methods. Spectral methods provide global information by representing the solution as a sum of orthogonal basis functions, which yields exponential convergence for smooth solutions. Compact finite difference schemes, while local, can achieve comparable resolution by virtue of their implicit coupling. The error constants associated with compact schemes decay more slowly with increasing wave number, resulting in reduced numerical dispersion for high‑frequency components.

To quantify spectral-like behaviour, one typically performs a von Neumann stability analysis or a Fourier analysis. For a given compact scheme, the modified wavenumber \(k^\ast\) is defined implicitly by the relation between the numerical derivative and the exact derivative in Fourier space:

\[ \frac{d}{dx} e^{i k x} \approx i k^\ast e^{i k x}. \]

The ratio \(k^\ast/k\) provides a measure of dispersion error. Compact schemes often maintain this ratio close to unity over a larger fraction of the Brillouin zone compared to explicit high‑order schemes.

Key Concepts

Order of Accuracy

The order of a finite difference scheme indicates how the truncation error scales with the grid spacing \(h\). A scheme of order \(p\) satisfies

\[ \left| u'_i - \frac{d u}{dx}\Big|_{x_i} \right| \le C h^p, \]

for some constant \(C\). Compact schemes can achieve high orders (fourth, sixth, eighth) while maintaining a narrow stencil, which is particularly advantageous in multi‑dimensional problems where the number of grid points per unit domain can become large.

Stability Analysis

When compact schemes are used in time‑dependent problems, the overall stability of the numerical method depends on both spatial and temporal discretisations. For linear problems with constant coefficients, a von Neumann analysis is commonly performed. The implicit spatial discretisation yields a modified wave equation where the discrete spatial operator can be expressed as a matrix \(D\). When combined with an explicit time integrator such as a Runge–Kutta scheme, the amplification factor must satisfy \(|G| \le 1\) for stability.

Because compact schemes involve implicit relations for the derivative, the spatial operator is often represented as a rational function of the differential operator, which can have a stabilising effect for high‑frequency modes. However, for strongly nonlinear problems, nonlinear stability considerations such as total variation diminishing (TVD) properties may become important, requiring additional filtering or artificial viscosity.

Dispersion and Dissipation Errors

In wave propagation problems, accurate representation of wave speed (dispersion) and energy loss (dissipation) is critical. Compact schemes reduce dispersion errors by matching higher‑order terms in the Taylor expansion, as described earlier. Dissipation errors are typically controlled by adding a small amount of artificial viscosity or by applying spectral filtering. The combination of high‑order accuracy and low numerical dissipation makes compact schemes suitable for simulating turbulence, where small‑scale energy transfer is essential.

Compact vs Explicit

Explicit schemes are straightforward to implement but require larger stencils for high order, leading to increased communication in parallel environments. Compact schemes, although requiring the solution of linear systems, maintain a small stencil and can be more efficient on modern architectures where memory bandwidth is a limiting factor. The choice between compact and explicit methods often depends on the problem geometry, boundary conditions, and available computational resources.

Applications

Computational Fluid Dynamics

Compact finite difference schemes are extensively used in DNS and high‑order Reynolds‑averaged Navier–Stokes (RANS) solvers. Their ability to resolve fine‑scale features with modest grid resolution makes them attractive for simulating turbulent channel flows, boundary layers, and jet mixing. In many CFD codes, the spatial discretisation of the convective terms employs a compact scheme while the viscous terms are discretised with a second‑order central difference, balancing accuracy and computational cost.

Aeroacoustic Simulations

In aeroacoustics, accurate prediction of sound generation and propagation requires low numerical dissipation. Compact schemes provide the necessary resolution for acoustic wave propagation in complex geometries, such as aircraft wings or turbine blades. Coupled with appropriate boundary treatments (e.g., sponge layers or absorbing boundary conditions), compact discretisations enable high‑fidelity acoustic predictions at moderate computational expense.

Wave Propagation and Seismology

Numerical modelling of seismic waves in heterogeneous media benefits from compact schemes’ low dispersion errors, which preserve wave phase over long propagation distances. In seismology, the accurate representation of high‑frequency components is essential for interpreting seismic data, and compact discretisations have been integrated into finite‑difference time‑domain (FDTD) solvers for elastic and acoustic wave equations.

Electromagnetics

The finite‑difference time‑domain (FDTD) method for Maxwell’s equations can be enhanced by compact discretisations of spatial derivatives. By reducing numerical dispersion, compact schemes improve the accuracy of electromagnetic wave propagation, antenna simulations, and photonic device modelling.

Other Scientific Computing Fields

Compact finite difference techniques have been employed in quantum mechanics for solving the Schrödinger equation, in structural dynamics for wave propagation in beams and plates, and in meteorology for high‑resolution atmospheric models. The common theme across these applications is the need for accurate, low‑dissipation discretisations over large domains.

Implementation Aspects

Boundary Treatment

Because compact schemes involve neighboring derivatives, special care is required at domain boundaries. Common strategies include

  • Using one‑sided or asymmetric compact stencils that incorporate boundary points and maintain the desired order of accuracy.
  • Employing ghost cells that hold extrapolated or mirrored values, allowing the interior stencil to remain centred.
  • Applying boundary conditions directly to the linear system by modifying the coefficient matrix rows associated with boundary points.

Periodic boundaries are the simplest case, where the linear system becomes cyclic tridiagonal. Efficient algorithms exist for solving such systems in linear time with a small constant factor.

Sparse Linear Solvers

The linear system arising from a compact discretisation is typically banded, with bandwidth equal to the stencil width plus one. For one‑dimensional problems, a tridiagonal matrix algorithm (Thomas algorithm) solves the system in \(O(N)\) operations. In multi‑dimensional problems, the system often decomposes into a sequence of one‑dimensional solves through dimensional splitting, or a sparse direct solver such as multifrontal LU factorisation can be used. Iterative solvers (GMRES, BiCGSTAB) can also be employed, but their convergence is generally slower than direct solvers for banded matrices.

Parallelisation

Compact schemes are well‑suited to distributed‑memory parallelisation because the small stencil width reduces halo exchange costs. In shared‑memory systems, the compact scheme’s narrow bandwidth leads to contiguous memory accesses, which are efficient on cache‑based architectures. For large‑scale three‑dimensional problems, a hybrid MPI‑OpenMP strategy often achieves high performance, with MPI handling inter‑process communication and OpenMP exploiting thread parallelism within each process.

Time Integration

When compact spatial discretisations are combined with explicit time integrators, the overall scheme can be formulated as a method of lines. For stability, the Courant–Friedrichs–Lewy (CFL) condition is imposed on the time step \(\Delta t\), typically requiring \(\Delta t \le \frac{C}{c_{\max}} h\) where \(c_{\max}\) is the maximum wave speed. Compact schemes’ low dispersion can allow larger CFL numbers compared to explicit high‑order schemes, improving computational efficiency.

Extensions and Variants

Adaptive Mesh Refinement (AMR)

AMR frameworks refine the mesh locally around regions of high gradients while coarsening elsewhere. Integrating compact schemes into AMR requires careful design of inter‑level interpolation operators that preserve high‑order accuracy. Several research efforts have developed compact discretisations that adapt seamlessly to non‑uniform grids, enabling efficient DNS on heterogeneous meshes.

Spectral Filtering

Even high‑order compact schemes may generate spurious high‑frequency modes due to nonlinear interactions. Spectral filtering selectively damps these modes while preserving lower‑frequency content. Typical filters include a high‑pass filter with a smooth transition or a deconvolution filter that re‑introduces resolved energy.

Hybrid Schemes

To combine the strengths of compact schemes with other discretisation techniques, hybrid schemes are often employed. For example, a compact scheme may discretise the convective terms while a staggered grid central difference discretises the viscous terms. Hybridisation can also involve coupling a compact discretisation in the interior with a low‑order method near discontinuities or shocks, employing a shock‑capturing limiter to prevent oscillations.

Higher‑Dimensional Compact Schemes

Two‑ and three‑dimensional compact discretisations can be constructed by applying the one‑dimensional compact stencil in each coordinate direction. For the Laplacian operator, a compact discretisation often involves cross‑terms between directions, leading to a system that is still sparse but with larger bandwidth. Multigrid preconditioners can accelerate the solution of such systems, especially for elliptic problems like the pressure Poisson equation in incompressible flow solvers.

Performance Considerations

On modern high‑performance computing (HPC) platforms, performance is influenced by memory bandwidth, cache utilisation, and communication latency. Compact schemes excel in situations where memory access patterns dominate, as they require fewer floating‑point operations per grid point and maintain contiguous memory layouts.

Benchmark studies comparing compact and explicit high‑order schemes show that for a given level of accuracy, the compact approach often achieves lower computational time due to reduced stencil width and improved cache behaviour. However, the need to solve linear systems introduces additional latency in parallel environments, which can be mitigated by overlapping communication and computation or by using asynchronous communication.

Limitations and Challenges

While compact finite difference schemes offer many advantages, they also present certain challenges:

  • Complex boundary implementation: Designing high‑order boundary stencils that preserve global accuracy can be nontrivial, especially for irregular geometries.
  • Nonlinear stability: In highly nonlinear problems, the implicit spatial discretisation does not guarantee monotonicity, potentially leading to oscillations near steep gradients.
  • Computational overhead: Solving the implicit linear system requires additional operations compared to fully explicit schemes, which may offset the gains from a smaller stencil in some contexts.
  • Scalability on GPUs: The need to solve linear systems may limit performance on GPU architectures, where massively parallel but fine‑granularity operations can be more efficient.

Future Directions

Research into compact finite difference schemes continues to evolve. Recent trends include

  • Developing adaptive compact schemes that adjust their coefficients based on local smoothness or error estimates.
  • Integrating machine learning techniques to predict optimal filter parameters or to design compact stencils for complex geometries.
  • Exploring hybrid discretisations that combine compact schemes for smooth regions with shock‑capturing methods near discontinuities.
  • Implementing compact schemes on emerging hardware such as tensor‑core‑enabled GPUs or FPGA accelerators.

These developments aim to extend the applicability of compact discretisations to a broader class of problems while maintaining their key advantages of high accuracy and low dissipation.

Conclusion

Compact finite difference schemes represent a powerful tool in the numerical analyst’s toolkit. By coupling neighboring derivatives implicitly, they achieve high‑order accuracy with narrow stencils, offering spectral‑like dispersion properties and low numerical dissipation. Their versatility is demonstrated across a wide spectrum of applications, from turbulent flow simulation to wave propagation in electromagnetics and seismology.

Implementation of compact schemes demands careful handling of boundary conditions and efficient linear solvers, yet the benefits often outweigh the added complexity, particularly on modern high‑performance computing platforms. As computational resources continue to grow and new application domains emerge, compact finite difference methods are likely to remain a cornerstone of high‑fidelity numerical simulations.

Was this helpful?

Share this article

See Also

Suggest a Correction

Found an error or have a suggestion? Let us know and we'll review it.

Comments (0)

Please sign in to leave a comment.

No comments yet. Be the first to comment!