Exact and approximate discrete vector-field operators on a Cartesian mesh

In this blog post, I attempt to introduce exact and accompanying consistent approximate discrete vector-field operators on a Cartesian mesh. These operators will act on and “produce” various styles of discretized fields. So first, the staggering of various field discretizations is introduced.

Field discretizations

Vertex point and edge-averaged (left), face-averaged (middle) and the cell-averaged discretization

We consider a cubic Cartesian mesh of size L3L^3, and origin (x0,y0,z0)(x_0, y_0, z_0) that is meshed by cubic cells of size Δ3\Delta^3. These cells have Cartesian indices [i,j,k][i,j,k]. We introduce two discretizations of a scalar field ϕ(x,y,z)\phi(x,y,z):

These scalar fields are accompanied by two discretizations for a vector field, F(x,y,z)=Fx(x,y,z)ex+Fy(x,y,z)ey+Fz(x,y,z)ez\vec F(x,y,z) = F_x(x,y,z)\vec{e}_x + F_y(x,y,z)\vec{e}_y + F_z(x,y,z)\vec{e}_z.

Exact \nabla field operators

With these discretizations we can define three exact \nabla operators.

Exact gradient (left), curl (middle) and divergence (right)

Given that these are exact operators, it is no surprise that the two possible “double \nabla” identities are satisfied: ×(ϕv)e=0f, and, (×Fe)f=0c.\nabla \times (\nabla \phi_v)_e = \vec 0_f, \ \ \ \text{ and, } \ \ \ \ \ \nabla \cdot (\nabla \times \vec F_e)_f = 0_c. Indeed, if we compute the exact (face-averaged) curl from exact (edge-averaged) gradient (computed from vertex values), we exactly get the zero vector. Further the exact (cell averaged) divergence of a (face-averaged) curl (from an edge-averaged vector field) is also exactly zero. Note that the set of three exact operators always “go up” in dimensionality, Vertex-point (0D) field ϕv Edge-averaged (1D) field×FeFace-averaged (2D) field Ff Cell-averaged (3D) field.\text{Vertex-point (0D) field } \xrightarrow{\nabla \phi_v} \text{ Edge-averaged (1D) field} \xrightarrow{\nabla \times \vec F_e} \text{Face-averaged (2D) field } \xrightarrow{\nabla \cdot \vec F_{f}} \text{ Cell-averaged (3D) field}. As such it would be nice if we could augment this set op operator definitions, with operators in the other direction. We call these, now approximate, operators “consistent” when the formulations satisfy the “double \nabla” identities exactly.

Consistent approximate \nabla operators.

We introduce three second-order accurate \nabla operators to complement the three exact operators.

It can be easily verified that these operators satisfy the aforementioned “double \nabla” identities exactly, (×Ff)e=0and×(ϕc)f=0,\nabla \cdot (\nabla \times \vec F_f)_e = 0 \ \ \ \ \ \ \text{and} \ \ \ \ \ \ \ \nabla \times (\nabla \phi_c)_f = \vec 0, and are therefore labeled “consistent”.

Applications

To finalize this blog post, and to illustrate the use of these formulations, five elementary “applications” for vector-field analysis are introduced.

Application 1: The Laplacian

We can compute the Laplacian (L=ϕL = \nabla \cdot \nabla \phi) of a scalar field “in place”, i.e. from a vertex field, as a vertex field and from a cell-averaged field as a cell-averaged field. Using the exact gradient operator, Lv=(ϕv)e,L_v = \nabla \cdot (\nabla \phi_v)_e, or using the exact divergence operator, Lc=(ϕc)f.L_c = \nabla \cdot (\nabla \phi_c)_f.

Application 2: Two Projection methods

With the Laplacian we can project a vector field onto the space of divergence free vector fields. For a face-averaged vector field (Ff\vec F_f) the steps are,

  1. Compute the exact cell-averaged divergence: Ff\nabla \cdot \vec F_f
  2. Solve the discrete Poisson problem for the cell-averaged field aca_c, (ac)f=Ff\nabla \cdot (\nabla a_c)_f = \nabla \cdot \vec F_f
  3. Reject the gradient of aca_c from FfF_f (containing the divergence) to find the desired divergence-free projected vector field, Pf\vec P_f, Pf=Ffac.\vec P_f = \vec F_f - \nabla a_c.

With this method, one can claim the cell-averaged divergence of Pf\vec P_f is exactly zero. Alternatively, one can project an edge-averaged vectorfield (Fe\vec F_e) with similar steps,

  1. Compute the approximate vertex-point divergence Fe\nabla \cdot \vec F_e
  2. Solve the Poisson problem for the vertex-point field ava_v, (ac)e=Fe\nabla \cdot (\nabla a_c)_e = \nabla \cdot \vec F_e
  3. Reject the gradient of ava_v from FeF_e (containing the divergence) to find the desired projection vector Pe\vec P_e, Pe=Feav.\vec P_e = \vec F_e - \nabla a_v.

Although the approximate divergence of Pe\vec P_e will be exactly zero, the latter method seems less favorable compared to the former, as for the latter, errors arise for both applications of the approximate divergence operator. I wonder if these two can be related.

Application 3: Vector potential

For a vector field described by a vector potential F=×A\vec F = \nabla \times \vec A, we can find the vector potential by solving either, ×(×Af)e=×Fe,\nabla \times (\nabla \times \vec A_f)_e = \nabla \times \vec F_e, or, ×(×Ae)f=×Ff,\nabla \times (\nabla \times \vec A_e)_f = \nabla \times \vec F_f, depending on the (face or edge) distretization of F\vec F.

Application 4: Consistent Helmholtz decomposition

Combining the projection (for the scalar potential) and vector potential, we can decompose any scalar field into a (rotation free) scalar gradient and (divergence free) curl field, F=a+×A.\vec F = \nabla a + \nabla \times \vec A.

There are two options:

  1. A face-averaged vector field (Ff\vec F_f) may be reconstructed by a cell-averaged scalar potential and an edge-averaged vector potential.
  2. An edge-averaged vector field (Fe\vec F_e) may be reconstructed by a vertex-point scalar potential and a face-averaged vector potential.

Application 5: The vector Laplacian

Since we have not defined a method to compute the gradient of a vector-component field, the vector Laplacian seems illusive. However, using the identity: 2F=(F)××F,\nabla^2 \vec F = \nabla (\nabla \cdot \vec F) - \nabla\times\nabla\times\vec F, we can approximate the vector Laplacian “in place” for edge-averaged vector fields, Be=2Fe=(Fe)v×(×Fe)f,\vec B_e = \nabla^2 \vec F_e = \nabla (\nabla \cdot \vec F_e)_v - \nabla \times (\nabla \times \vec F_e)_f, and face-averaged vector fields, Bf=2Ff=(Ff)c×(×Ff)e.\vec B_f = \nabla^2 \vec F_f = \nabla (\nabla \cdot \vec F_f)_c - \nabla \times (\nabla \times \vec F_f)_e.

Further applications of these “applications” will be presented later.

Vector product in DD dimensions

It is often1 said that the vector product (“×\times”, cross product) cannot be generalized to other than three dimensions. But it depends a bit on how one defines the vector product. If we forgo the requirement that is must be a binary operation (i.e. the product of two vectors) but instead require D1D - 1 vectors for the DD dimensional vector product, it generalizes quite naturally: u=×(v1,v2,...,vD1)=v1×v2×...,vD1=e1e2...eDv1,1v1,2...v1,Dv2,1v2,2...v2,DvD1,1vD1,2...vD1,D.\vec u = \times(\vec v_1, \vec v_2, ... , \vec v_{D-1}) = \vec{v}_1\times\vec v_2 \times ..., \vec v_{D-1} = \begin{vmatrix} \vec e_1 & \vec e_2 & ... & \vec e_D\\ v_{1,1} & \vec v_{1,2} & ... & v_{1,D}\\ v_{2,1} & \vec v_{2,2} & ... & v_{2,D}\\ \vdots & \vdots & \ddots & \vdots\\ v_{D-1,1} & \vec v_{D-1,2} & ... & v_{D-1,D}\end{vmatrix}. By the properties of determinants, it remains to be distributive over addition (i.e. it is a linear, product-style operator), u=0\vec u = \vec 0 if any two vectors in the product are parallel, and u\vec u is perpendicular to every argument of the product. Using this definition, we can use it for any dimension larger than one. For example, the vector product of V1=2e1+1e2\vec V_1 = 2\vec e_1 + 1\vec e_2 in 2 dimensions is U\vec U, U=×(V1)=e1e221=1e12e2.\vec U = \times(\vec V_1) = \begin{vmatrix}\vec e_1 & \vec e_2\\ 2& 1\end{vmatrix} = 1\vec{e}_1 - 2\vec{e}_2.


  1. It is not often a topic of discussion, really.↩︎

The marvelous design of this website is taken from Suckless.org