2D Helmholtz decomposition on a C grid

Given a vector field (u,v) on an Arakawa C grid, solve for the potential chi and streamfunction psi in (u,v) = grad[chi] + curl[psi]
261 Downloads
Updated 15 Jun 2022

View License

Perform Helmholtz decomposition of a 2D vector field (such as a velocity) whose components are staggered on the Arakawa C grid, solving for chi and psi in
(u,v) = grad[chi] + curl[psi].
The C grid variables are laid out around a central point chi_{i,j} as follows:
psi_{i,j+1}----v_{i,j+1}------psi_{i+1,j+1}
| | |
u_{i,j}-------chi_{i,j}-------u_{i+1,j}
| | |
psi_{i,j}------v_{i,j}--------psi_{i+1,j}
The domain can be periodic or not, and need not be simply connected (it can have holes).
Internally, the function will select the largest connected component. Only one connected component is handled at a time. If you wish to work on a different connected component, simply preselect it -- look at the lines involving CC2periodic(bwconncomp(...)) for how to do that.
The image shows the streamfunction psi of the horizontal velocity field in the ocean at 300m depth (data from OCCA). See the example script to reproduce this result.

Cite As

Geoff Stanley (2025). 2D Helmholtz decomposition on a C grid (https://uk.mathworks.com/matlabcentral/fileexchange/75614-2d-helmholtz-decomposition-on-a-c-grid), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.2

Example provided

1.0.1