# Vector calculus in generalised orthogonal frame of reference

I want to write Navier-Stokes equations in generalised orthogonal frame of reference in Mathematica. I therefore want to expand gradient and other vector calculus operations using metric factors such that Grad[ϕ[x1, x2, x3], {x1, x2, x3}] expands as

$$\nabla \phi = \frac{1}{h_1} \frac{\partial \phi}{\partial x_1} \mathbf i_1 + \frac{1}{h_2} \frac{\partial \phi}{\partial x_2} \mathbf i_2 + \frac{1}{h_3} \frac{\partial \phi}{\partial x_3} \mathbf i_3,$$

where h1, h2 and h3 are maintained in the Mathematica's output so I can express the equations, after simplifying the expansions, in a desired reference frame. I do not really know how to make Mathematica use the metrics h.

Could you provide me with some methodology for this?

• Mathematica already supports several basis, see Grad for examples. Commented Jan 29 at 14:36
• That's true but doesn't really do the trick. I want to have a general expression such that I can define my own, body-fitted, reference frames through the metrics. Commented Jan 29 at 14:44
• Why do you not define your own Gradient, Laplacian.... E.g. grad= {1/h1 D[#,x1], 1/h2 D[#,x2],1/h3 D[#,x3]}&. Commented Jan 29 at 18:09
• Thanks Daniel, that's a fairly obvious solution that did not cross my mind. Works well! Commented Feb 5 at 8:44

patch = SymbolicTensorsScaleFactorGeometryPatch[{h1, h2, h3}, {x1, x2, x3}];

It is important to note that h1, h2, h3 will be treated as constants unless you define them as functions of coordinates. Also, you may need to specify \$Assumptions = h1 > 0 && h2 > 0 && h3 > 0 to avoid expressions like $$\sqrt{h_i^2}$$. You can compute Div and Curl the same way by substituting patch in place of chart`.